| | |
| | | import cn.lili.common.exception.ServiceException; |
| | | import cn.lili.modules.lmk.domain.entity.CouponVirtual; |
| | | import cn.lili.modules.lmk.domain.entity.StoreCouponSingle; |
| | | import cn.lili.modules.lmk.domain.query.StoreCouponSingleQuery; |
| | | import cn.lili.modules.lmk.enums.general.GenerateCouponStausEnum; |
| | | import cn.lili.modules.lmk.enums.general.StoreCouponStausEnum; |
| | | import cn.lili.modules.lmk.service.StoreCouponSingleService; |
| | |
| | | import cn.lili.modules.lmk.mapper.StoreCouponMapper; |
| | | import cn.lili.modules.lmk.service.StoreCouponService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.StoreCouponForm; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Result page(StoreCouponQuery query) { |
| | | IPage<StoreCouponVO> page = PageUtil.getPage(query, StoreCouponVO.class); |
| | | baseMapper.getPage(page, query); |
| | | IPage<StoreCoupon> page = PageUtil.getPage(query, StoreCoupon.class); |
| | | LambdaQueryWrapper<StoreCoupon> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(Objects.nonNull(query.getStoreId()), StoreCoupon::getStoreId, query.getStoreId()); |
| | | wrapper.eq(StringUtils.isNotBlank(query.getStatus()), StoreCoupon::getStatus, query.getStatus()); |
| | | wrapper.eq(StringUtils.isNotBlank(query.getGenerateStatus()), StoreCoupon::getGenerateStatus, query.getGenerateStatus()); |
| | | this.page(page, wrapper); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Result getPageByStoreCoupon(StoreCouponSingleQuery query){ |
| | | return storeCouponSingleService.pageByRefId(query); |
| | | } |
| | | |
| | | private static StoreCouponSingle getStoreCouponSingle(StoreCoupon storeCoupon, int i) { |
| | | StoreCouponSingle storeCouponSingle = new StoreCouponSingle(); |
| | | storeCouponSingle.setStoreCoupRef(storeCoupon.getId()); |
| | |
| | | storeCouponSingle.setCouponNo(String.format("%08d", i)); |
| | | return storeCouponSingle; |
| | | } |
| | | |
| | | @Override |
| | | public Result changeStatus(String id) { |
| | | StoreCoupon storeCoupon = this.getById(id); |
| | | if (storeCoupon == null) { |
| | | throw new ServiceException("当前店铺优惠卷不存在"); |
| | | } |
| | | String status = storeCoupon.getStatus(); |
| | | if (StoreCouponStausEnum.ENABLE.name().equals(status)) { |
| | | storeCoupon.setStatus(StoreCouponStausEnum.DISABLE.name()); |
| | | }else if (StoreCouponStausEnum.DISABLE.name().equals(status)) { |
| | | storeCoupon.setStatus(StoreCouponStausEnum.ENABLE.name()); |
| | | }else { |
| | | throw new ServiceException("当前店铺优惠卷状态异常无法修改"); |
| | | } |
| | | this.updateById(storeCoupon); |
| | | return Result.ok(); |
| | | } |
| | | } |