Commit 5f803e17ff85b56a5ae0110b46dce17e8ca2e3dd
1 parent
3a6150f5
fix(promotion):删除券时模板已被删除则跳过回退模板领取数——updateTakeCount 对已逻辑删除模板匹配 0 行会误报「剩余数量不足」致券永久删不掉
Showing
1 changed file
with
5 additions
and
1 deletions
yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
| ... | ... | @@ -115,7 +115,11 @@ public class CouponServiceImpl implements CouponService { |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // 减少优惠劵模板的领取数量 -1 |
| 118 | - couponTemplateService.updateCouponTemplateTakeCount(coupon.getTemplateId(), -1); | |
| 118 | + // 若模板已被删除则跳过:已删模板的领取计数无业务意义, | |
| 119 | + // 且 updateTakeCount 对逻辑删除的模板匹配 0 行,会误报「优惠券模板剩余数量不足」导致删券失败 | |
| 120 | + if (couponTemplateService.getCouponTemplate(coupon.getTemplateId()) != null) { | |
| 121 | + couponTemplateService.updateCouponTemplateTakeCount(coupon.getTemplateId(), -1); | |
| 122 | + } | |
| 119 | 123 | } |
| 120 | 124 | |
| 121 | 125 | @Override | ... | ... |