Browse Source

fix 优惠券领取数量限制

skyline 1 year ago
parent
commit
9066dff7b6

+ 2 - 2
service/src/main/java/com/kym/service/miniapp/impl/UserCouponServiceImpl.java

@@ -106,7 +106,7 @@ public class UserCouponServiceImpl extends MPJBaseServiceImpl<UserCouponMapper,
             throw new BusinessException("优惠券不存在或已失效!");
         }
 
-        if (coupon.getClaimedQuantity() >= coupon.getQuantity()) {
+        if (coupon.getClaimedQuantity() >= coupon.getQuantity() && coupon.getQuantity() > 0) {
             DynamicDataSourceContextHolder.poll();
             throw new BusinessException("优惠券已领完!");
         }
@@ -126,7 +126,7 @@ public class UserCouponServiceImpl extends MPJBaseServiceImpl<UserCouponMapper,
         coupon.setClaimedQuantity(coupon.getClaimedQuantity() + 1);
 
         // 校验优惠券数量是否已领完
-        if (coupon.getClaimedQuantity() >= coupon.getQuantity()) {
+        if (coupon.getClaimedQuantity() >= coupon.getQuantity() && coupon.getQuantity() > 0) {
             coupon.setStatus(Coupon.STATUS_已结束);
         }
         couponService.updateById(coupon);