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()); } }