Commit 09aa6b25675e03dddb70afa2730d275ba07ad967

Authored by puhui999
1 parent 40b6e5a3

【缺陷修复】商城:优惠券在领取类型为指定发放和新人券时无法发送的问题

yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
@@ -263,13 +263,17 @@ public class CouponServiceImpl implements CouponService { @@ -263,13 +263,17 @@ public class CouponServiceImpl implements CouponService {
263 if (CollUtil.isEmpty(userIds)) { 263 if (CollUtil.isEmpty(userIds)) {
264 throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); 264 throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE);
265 } 265 }
266 -  
267 // 校验模板 266 // 校验模板
268 if (couponTemplate == null) { 267 if (couponTemplate == null) {
269 throw exception(COUPON_TEMPLATE_NOT_EXISTS); 268 throw exception(COUPON_TEMPLATE_NOT_EXISTS);
270 } 269 }
  270 + // 校验领取方式
  271 + if (ObjUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) {
  272 + throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
  273 + }
271 // 校验剩余数量 274 // 校验剩余数量
272 - if (ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制 275 + if (ObjUtil.equal(CouponTakeTypeEnum.USER.getType(), couponTemplate.getTakeType()) // 直接领取
  276 + && ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
273 && couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) { 277 && couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
274 throw exception(COUPON_TEMPLATE_NOT_ENOUGH); 278 throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
275 } 279 }
@@ -279,10 +283,7 @@ public class CouponServiceImpl implements CouponService { @@ -279,10 +283,7 @@ public class CouponServiceImpl implements CouponService {
279 throw exception(COUPON_TEMPLATE_EXPIRED); 283 throw exception(COUPON_TEMPLATE_EXPIRED);
280 } 284 }
281 } 285 }
282 - // 校验领取方式  
283 - if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) {  
284 - throw exception(COUPON_TEMPLATE_CANNOT_TAKE);  
285 - } 286 +
286 } 287 }
287 288
288 /** 289 /**