Commit 073ffb5c71de157c0e0b2397b2b7853e487f1ff8
1 parent
887594ec
fix: 【coupon】更新发放数量校验逻辑,确保用户领取时剩余数量充足
Showing
1 changed file
with
3 additions
and
2 deletions
yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
| ... | ... | @@ -282,10 +282,11 @@ public class CouponServiceImpl implements CouponService { |
| 282 | 282 | if (ObjUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) { |
| 283 | 283 | throw exception(COUPON_TEMPLATE_CANNOT_TAKE); |
| 284 | 284 | } |
| 285 | - // 校验发放数量不能过小(仅在 CouponTakeTypeEnum.USER 用户领取时) | |
| 285 | + // 校验剩余发放数量是否充足(仅在 CouponTakeTypeEnum.USER 用户领取时) | |
| 286 | + // 关联案例:https://t.zsxq.com/mElGQ、https://t.zsxq.com/6pLzr | |
| 286 | 287 | if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType()) |
| 287 | 288 | && ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TAKE_LIMIT_COUNT_MAX) // 校验不限制领取数 |
| 288 | - && ObjUtil.notEqual(couponTemplate.getTotalCount(), CouponTemplateDO.TOTAL_COUNT_MAX)) { // 校验不限制发放数量 | |
| 289 | + && couponTemplate.getTakeCount() > couponTemplate.getTotalCount()) { // 已领取数量 >= 总发放数量 | |
| 289 | 290 | throw exception(COUPON_TEMPLATE_NOT_ENOUGH); |
| 290 | 291 | } |
| 291 | 292 | // 校验"固定日期"的有效期类型是否过期 | ... | ... |