From 2d5c0d6a1fd7d5bd06685227b79303cbd3b88aa5 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Sat, 26 Jun 2021 14:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E4=BC=98=E6=83=A0=E5=88=B8=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/CouponServiceImpl.java | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index de3683db..14444691 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -15,18 +15,12 @@ import cn.lili.common.vo.PageVO; import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.service.GoodsSkuService; -import cn.lili.modules.promotion.entity.dos.Coupon; -import cn.lili.modules.promotion.entity.dos.FullDiscount; -import cn.lili.modules.promotion.entity.dos.MemberCoupon; -import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dos.*; import cn.lili.modules.promotion.entity.enums.*; import cn.lili.modules.promotion.entity.vos.CouponSearchParams; import cn.lili.modules.promotion.entity.vos.CouponVO; import cn.lili.modules.promotion.mapper.CouponMapper; -import cn.lili.modules.promotion.service.CouponService; -import cn.lili.modules.promotion.service.FullDiscountService; -import cn.lili.modules.promotion.service.MemberCouponService; -import cn.lili.modules.promotion.service.PromotionGoodsService; +import cn.lili.modules.promotion.service.*; import cn.lili.modules.promotion.tools.PromotionTools; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -76,6 +70,9 @@ public class CouponServiceImpl extends ServiceImpl impleme //满额活动 @Autowired private FullDiscountService fullDiscountService; + //优惠券活动-优惠券关联 + @Autowired + private CouponActivityItemService couponActivityItemService; @Override public CouponVO add(CouponVO coupon) { @@ -159,15 +156,31 @@ public class CouponServiceImpl extends ServiceImpl impleme @Override public boolean deleteCoupon(String id) { CouponVO couponVO = checkStatus(id); - LambdaUpdateWrapper couponUpdateWrapper = new LambdaUpdateWrapper().eq(Coupon::getId, id).set(Coupon::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(Coupon::getDeleteFlag, true); + //更新优惠券状态为关闭,标示删除标志 + LambdaUpdateWrapper couponUpdateWrapper = new LambdaUpdateWrapper().eq(Coupon::getId, id) + .set(Coupon::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(Coupon::getDeleteFlag, true); boolean result = this.update(couponUpdateWrapper); - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(PromotionGoods::getPromotionId, id).set(PromotionGoods::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(PromotionGoods::getDeleteFlag, true); + //更新促销商品记录信息为删除 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() + .eq(PromotionGoods::getPromotionId, id) + .set(PromotionGoods::getPromotionStatus, PromotionStatusEnum.CLOSE.name()) + .set(PromotionGoods::getDeleteFlag, true); this.promotionGoodsService.update(updateWrapper); - LambdaUpdateWrapper memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper().eq(MemberCoupon::getCouponId, id).set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); + + //删除mongo优惠券信息 + LambdaUpdateWrapper memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper() + .eq(MemberCoupon::getCouponId, id) + .set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); memberCouponService.update(memberCouponLambdaUpdateWrapper); this.mongoTemplate.remove(new Query().addCriteria(Criteria.where("id").is(id)), CouponVO.class); + + //删除优惠券活动关联优惠券 + couponActivityItemService.remove(new LambdaQueryWrapper() + .eq(CouponActivityItem::getCouponId,id)); + + //删除延时任务 this.timeTrigger.delete(TimeExecuteConstant.PROMOTION_EXECUTOR, couponVO.getStartTime().getTime(), DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (PromotionTypeEnum.COUPON.name() + couponVO.getId())),