Commit 68c1113ed1dad674de647a1c99a68e18f45da16e
1 parent
a6ec3fef
code review:优惠劵发放
Showing
1 changed file
with
4 additions
and
4 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
| @@ -138,9 +138,9 @@ public class CouponServiceImpl implements CouponService { | @@ -138,9 +138,9 @@ public class CouponServiceImpl implements CouponService { | ||
| 138 | public void takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takeType) { | 138 | public void takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takeType) { |
| 139 | CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId); | 139 | CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId); |
| 140 | // 1. 过滤掉达到领取限制的用户 | 140 | // 1. 过滤掉达到领取限制的用户 |
| 141 | - removeTakeLimitUserId(userIds, template); | 141 | + removeTakeLimitUser(userIds, template); |
| 142 | // 2. 校验优惠劵是否可以领取 | 142 | // 2. 校验优惠劵是否可以领取 |
| 143 | - validateCanTake(template, userIds, takeType); | 143 | + validateCouponTemplateCanTake(template, userIds, takeType); |
| 144 | 144 | ||
| 145 | // 3. 批量保存优惠劵 | 145 | // 3. 批量保存优惠劵 |
| 146 | couponMapper.insertBatch(convertList(userIds, userId -> CouponConvert.INSTANCE.convert(template, userId))); | 146 | couponMapper.insertBatch(convertList(userIds, userId -> CouponConvert.INSTANCE.convert(template, userId))); |
| @@ -156,7 +156,7 @@ public class CouponServiceImpl implements CouponService { | @@ -156,7 +156,7 @@ public class CouponServiceImpl implements CouponService { | ||
| 156 | * @param userIds 领取人列表 | 156 | * @param userIds 领取人列表 |
| 157 | * @param takeType 领取方式 | 157 | * @param takeType 领取方式 |
| 158 | */ | 158 | */ |
| 159 | - private void validateCanTake(CouponTemplateDO couponTemplate, Set<Long> userIds, CouponTakeTypeEnum takeType) { | 159 | + private void validateCouponTemplateCanTake(CouponTemplateDO couponTemplate, Set<Long> userIds, CouponTakeTypeEnum takeType) { |
| 160 | // 如果所有用户都领取过,则抛出异常 | 160 | // 如果所有用户都领取过,则抛出异常 |
| 161 | if (CollUtil.isEmpty(userIds)) { | 161 | if (CollUtil.isEmpty(userIds)) { |
| 162 | throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); | 162 | throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); |
| @@ -188,7 +188,7 @@ public class CouponServiceImpl implements CouponService { | @@ -188,7 +188,7 @@ public class CouponServiceImpl implements CouponService { | ||
| 188 | * @param userIds 用户编号数组 | 188 | * @param userIds 用户编号数组 |
| 189 | * @param couponTemplate 优惠劵模版 | 189 | * @param couponTemplate 优惠劵模版 |
| 190 | */ | 190 | */ |
| 191 | - private void removeTakeLimitUserId(Set<Long> userIds, CouponTemplateDO couponTemplate) { | 191 | + private void removeTakeLimitUser(Set<Long> userIds, CouponTemplateDO couponTemplate) { |
| 192 | if (couponTemplate.getTakeLimitCount() <= 0) { | 192 | if (couponTemplate.getTakeLimitCount() <= 0) { |
| 193 | return; | 193 | return; |
| 194 | } | 194 | } |