Commit 03e510adfde31b3040f184ac2007f0b4ff3aa1c7

Authored by YunaiV
1 parent f6acc9de

fix:【MALL】修复了一些问题 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1315

yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
... ... @@ -181,7 +181,7 @@ public class CouponServiceImpl implements CouponService {
181 181 * @param couponId 模版编号
182 182 * @param userId 用户编号
183 183 */
184   - @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) // 每次调用开启一个新的事务
  184 + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) // 每次调用开启一个新的事务,避免在一个大的事务里面
185 185 public void invalidateCoupon(Long couponId, Long userId) {
186 186 if (couponId == null || couponId <= 0) {
187 187 return;
... ... @@ -279,8 +279,8 @@ public class CouponServiceImpl implements CouponService {
279 279 if (ObjUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) {
280 280 throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
281 281 }
282   - // 校验剩余数量
283   - if (ObjUtil.equal(CouponTakeTypeEnum.USER.getType(), couponTemplate.getTakeType()) // 直接领取
  282 + // 校验发放数量不能过小(仅在 CouponTakeTypeEnum.USER 用户领取时)
  283 + if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType())
284 284 && ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
285 285 && couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
286 286 throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
... ... @@ -291,7 +291,6 @@ public class CouponServiceImpl implements CouponService {
291 291 throw exception(COUPON_TEMPLATE_EXPIRED);
292 292 }
293 293 }
294   -
295 294 }
296 295  
297 296 /**
... ...