Commit 8d4cc35cde8fd7174bb0eaa60d5af56c150224d8

Authored by YunaiV
1 parent b1ad2f81

【缺陷修复】商城:优惠劵在不限制时,无法发送的问题

yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java
... ... @@ -30,6 +30,11 @@ import java.util.List;
30 30 @EqualsAndHashCode(callSuper = true)
31 31 public class CouponTemplateDO extends BaseDO {
32 32  
  33 + /**
  34 + * 不限制领取数量
  35 + */
  36 + public static final Integer TIME_LIMIT_COUNT_MAX = -1;
  37 +
33 38 // ========== 基本信息 BEGIN ==========
34 39 /**
35 40 * 模板编号,自增唯一
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
... ... @@ -269,7 +269,8 @@ public class CouponServiceImpl implements CouponService {
269 269 throw exception(COUPON_TEMPLATE_NOT_EXISTS);
270 270 }
271 271 // 校验剩余数量
272   - if (couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
  272 + if (ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
  273 + && couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
273 274 throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
274 275 }
275 276 // 校验"固定日期"的有效期类型是否过期
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java
1 1 package cn.iocoder.yudao.module.promotion.service.coupon;
2 2  
  3 +import cn.hutool.core.util.ObjUtil;
3 4 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi;
... ... @@ -59,7 +60,7 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
59 60 CouponTemplateDO couponTemplate = validateCouponTemplateExists(updateReqVO.getId());
60 61 // 校验发放数量不能过小(仅在 CouponTakeTypeEnum.USER 用户领取时)
61 62 if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType())
62   - && updateReqVO.getTotalCount() > 0 // 大于 0 的原因,是因为 -1 不限制
  63 + && ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
63 64 && updateReqVO.getTotalCount() < couponTemplate.getTakeCount()) {
64 65 throw exception(COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL, couponTemplate.getTakeCount());
65 66 }
... ...