Commit f5706972a09c1f1aa47952144734ed3c63677740
1 parent
4c2ed461
【代码评审】商城:满减送活动的实现
Showing
4 changed files
with
11 additions
and
7 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java
| @@ -60,13 +60,6 @@ public class RewardActivityBaseVO { | @@ -60,13 +60,6 @@ public class RewardActivityBaseVO { | ||
| 60 | @Valid // 校验下子对象 | 60 | @Valid // 校验下子对象 |
| 61 | private List<Rule> rules; | 61 | private List<Rule> rules; |
| 62 | 62 | ||
| 63 | - @AssertTrue(message = "商品范围编号的数组不能为空") | ||
| 64 | - @JsonIgnore | ||
| 65 | - public boolean isProductScopeValuesValid() { | ||
| 66 | - return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空 | ||
| 67 | - || CollUtil.isNotEmpty(productScopeValues); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | @Schema(description = "优惠规则") | 63 | @Schema(description = "优惠规则") |
| 71 | @Data | 64 | @Data |
| 72 | public static class Rule { | 65 | public static class Rule { |
| @@ -114,4 +107,11 @@ public class RewardActivityBaseVO { | @@ -114,4 +107,11 @@ public class RewardActivityBaseVO { | ||
| 114 | 107 | ||
| 115 | } | 108 | } |
| 116 | 109 | ||
| 110 | + @AssertTrue(message = "商品范围编号的数组不能为空") | ||
| 111 | + @JsonIgnore | ||
| 112 | + public boolean isProductScopeValuesValid() { | ||
| 113 | + return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空 | ||
| 114 | + || CollUtil.isNotEmpty(productScopeValues); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | } | 117 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java
| @@ -99,6 +99,7 @@ public class RewardActivityDO extends BaseDO { | @@ -99,6 +99,7 @@ public class RewardActivityDO extends BaseDO { | ||
| 99 | * 是否包邮 | 99 | * 是否包邮 |
| 100 | */ | 100 | */ |
| 101 | private Boolean freeDelivery; | 101 | private Boolean freeDelivery; |
| 102 | + // TODO @puhui999:是不是大于零,就认为赠送积分哈;简洁一点; | ||
| 102 | /** | 103 | /** |
| 103 | * 是否赠送积分 | 104 | * 是否赠送积分 |
| 104 | */ | 105 | */ |
| @@ -107,6 +108,7 @@ public class RewardActivityDO extends BaseDO { | @@ -107,6 +108,7 @@ public class RewardActivityDO extends BaseDO { | ||
| 107 | * 赠送的积分 | 108 | * 赠送的积分 |
| 108 | */ | 109 | */ |
| 109 | private Integer point; | 110 | private Integer point; |
| 111 | + // TODO @puhui999:非空,就认为赠送优惠劵 | ||
| 110 | /** | 112 | /** |
| 111 | * 是否赠送优惠券 | 113 | * 是否赠送优惠券 |
| 112 | */ | 114 | */ |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java
| @@ -82,6 +82,7 @@ public class RewardActivityServiceImpl implements RewardActivityService { | @@ -82,6 +82,7 @@ public class RewardActivityServiceImpl implements RewardActivityService { | ||
| 82 | @Override | 82 | @Override |
| 83 | public void closeRewardActivity(Long id) { | 83 | public void closeRewardActivity(Long id) { |
| 84 | // 校验存在 | 84 | // 校验存在 |
| 85 | + // TODO @puhui999:去掉 PromotionActivityStatusEnum,使用 CommonStatus 作为状态哈。开启,关闭 | ||
| 85 | RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); | 86 | RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); |
| 86 | if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 | 87 | if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 |
| 87 | throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); | 88 | throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImplTest.java
| @@ -190,6 +190,7 @@ public class RewardActivityServiceImplTest extends BaseDbUnitTest { | @@ -190,6 +190,7 @@ public class RewardActivityServiceImplTest extends BaseDbUnitTest { | ||
| 190 | @Test | 190 | @Test |
| 191 | public void testGetRewardActivities_product() { | 191 | public void testGetRewardActivities_product() { |
| 192 | // mock 数据 | 192 | // mock 数据 |
| 193 | + // TODO @puhui999:有单测的问题,也一起瞅瞅 | ||
| 193 | RewardActivityDO productActivity01 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) | 194 | RewardActivityDO productActivity01 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) |
| 194 | .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))); | 195 | .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))); |
| 195 | rewardActivityMapper.insert(productActivity01); | 196 | rewardActivityMapper.insert(productActivity01); |