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 de3683db1..144446918 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())),