From 4d110f964f994038098a980a3a6f8a2d8f39b73e Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Fri, 13 Dec 2024 09:18:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=A3=E5=86=B3=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E5=8F=AF=E4=BB=A5=E9=A2=86=E5=8F=96=E5=A4=9A=E5=BC=A0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/skyeye/coupon/entity/CouponUse.java | 3 +- .../service/impl/CouponServiceImpl.java | 13 ++-- .../service/impl/CouponUseServiceImpl.java | 64 +++++++++---------- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponUse.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponUse.java index 49de96a4..76095778 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponUse.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponUse.java @@ -18,7 +18,6 @@ import com.skyeye.coupon.enums.PromotionMaterialScope; import lombok.Data; import java.util.List; -import java.util.Map; /** * @ClassName: CouponUse @@ -43,7 +42,7 @@ public class CouponUse extends OperatorUserInfo { @TableField(exist = false) @Property(value = "优惠券信息") - private Map couponMation; + private Coupon couponMation; @TableField(value = "state") @Property(value = "状态", enumClass = CouponUseState.class) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java index 3b0dd8c2..7a6e9d07 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java @@ -68,8 +68,8 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl wrapper = new MPJLambdaWrapper() - .innerJoin(CouponMaterial.class, CouponMaterial::getCouponId, Coupon::getId) - .eq(CouponMaterial::getMaterialId, materialId) - .eq(MybatisPlusUtil.toColumns(Coupon::getEnabled), EnableEnum.ENABLE_USING.getKey()) - .isNotNull(typeKey).ne(typeKey, StrUtil.EMPTY); + .innerJoin(CouponMaterial.class, CouponMaterial::getCouponId, Coupon::getId) + .eq(CouponMaterial::getMaterialId, materialId) + .eq(MybatisPlusUtil.toColumns(Coupon::getEnabled), EnableEnum.ENABLE_USING.getKey()) + .isNotNull(typeKey).ne(typeKey, StrUtil.EMPTY); List list = skyeyeBaseMapper.selectJoinList(Coupon.class, wrapper); setDrawState(list);// 设置是否可以领取状态 outputObject.setBean(list); diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponUseServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponUseServiceImpl.java index d21b77fc..297e07dc 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponUseServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponUseServiceImpl.java @@ -101,46 +101,44 @@ public class CouponUseServiceImpl extends SkyeyeBusinessServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(MybatisPlusUtil.toColumns(CouponUse::getCouponId), couponUse.getCouponId()); - couponService.updateTakeCount(couponUse.getCouponId(), (int) count(queryWrapper)); + // 更新优惠券领取数量 + couponService.updateTakeCount(couponUse.getCouponId(), couponUse.getCouponMation().getTakeCount() + 1); + // 新增优惠券可使用的商品信息 couponUseMaterialService.createEntity(couponUse.getCouponUseMaterialList(), userId); // 定时任务 - Map couponMation = couponUse.getCouponMation(); - if (ObjectUtil.isNotEmpty(couponMation) && Objects.equals(couponMation.get("validityType"), CouponValidityType.TERM.getKey())) { - startUpTaskQuartz(couponUse.getId(), couponMation.get("name").toString(), couponUse.getValidEndTime()); + Coupon couponMation = couponUse.getCouponMation(); + if (Objects.equals(couponMation.getValidityType(), CouponValidityType.TERM.getKey())) { + startUpTaskQuartz(couponUse.getId(), couponMation.getName(), couponUse.getValidEndTime()); } }