fix: 【coupon】更新发放数量校验逻辑,确保用户领取时剩余数量充足

This commit is contained in:
YunaiV 2025-11-22 18:09:50 +08:00
parent 887594ec2e
commit 073ffb5c71

View File

@ -282,10 +282,11 @@ public class CouponServiceImpl implements CouponService {
if (ObjUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) {
throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
}
// 校验发放数量不能过小仅在 CouponTakeTypeEnum.USER 用户领取时
// 校验剩余发放数量是否充足仅在 CouponTakeTypeEnum.USER 用户领取时
// 关联案例https://t.zsxq.com/mElGQhttps://t.zsxq.com/6pLzr
if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType())
&& ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TAKE_LIMIT_COUNT_MAX) // 校验不限制领取数
&& ObjUtil.notEqual(couponTemplate.getTotalCount(), CouponTemplateDO.TOTAL_COUNT_MAX)) { // 校验不限制发放数量
&& couponTemplate.getTakeCount() > couponTemplate.getTotalCount()) { // 已领取数量 >= 发放数量
throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
}
// 校验"固定日期"的有效期类型是否过期