mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	【代码评审】商城:满减送活动的实现
This commit is contained in:
		@@ -60,13 +60,6 @@ public class RewardActivityBaseVO {
 | 
				
			|||||||
    @Valid // 校验下子对象
 | 
					    @Valid // 校验下子对象
 | 
				
			||||||
    private List<Rule> rules;
 | 
					    private List<Rule> rules;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @AssertTrue(message = "商品范围编号的数组不能为空")
 | 
					 | 
				
			||||||
    @JsonIgnore
 | 
					 | 
				
			||||||
    public boolean isProductScopeValuesValid() {
 | 
					 | 
				
			||||||
        return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
 | 
					 | 
				
			||||||
                || CollUtil.isNotEmpty(productScopeValues);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Schema(description = "优惠规则")
 | 
					    @Schema(description = "优惠规则")
 | 
				
			||||||
    @Data
 | 
					    @Data
 | 
				
			||||||
    public static class Rule {
 | 
					    public static class Rule {
 | 
				
			||||||
@@ -114,4 +107,11 @@ public class RewardActivityBaseVO {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @AssertTrue(message = "商品范围编号的数组不能为空")
 | 
				
			||||||
 | 
					    @JsonIgnore
 | 
				
			||||||
 | 
					    public boolean isProductScopeValuesValid() {
 | 
				
			||||||
 | 
					        return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
 | 
				
			||||||
 | 
					                || CollUtil.isNotEmpty(productScopeValues);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,6 +99,7 @@ public class RewardActivityDO extends BaseDO {
 | 
				
			|||||||
         * 是否包邮
 | 
					         * 是否包邮
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        private Boolean freeDelivery;
 | 
					        private Boolean freeDelivery;
 | 
				
			||||||
 | 
					        // TODO @puhui999:是不是大于零,就认为赠送积分哈;简洁一点;
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
         * 是否赠送积分
 | 
					         * 是否赠送积分
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
@@ -107,6 +108,7 @@ public class RewardActivityDO extends BaseDO {
 | 
				
			|||||||
         * 赠送的积分
 | 
					         * 赠送的积分
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        private Integer point;
 | 
					        private Integer point;
 | 
				
			||||||
 | 
					        // TODO @puhui999:非空,就认为赠送优惠劵
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
         * 是否赠送优惠券
 | 
					         * 是否赠送优惠券
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -82,6 +82,7 @@ public class RewardActivityServiceImpl implements RewardActivityService {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void closeRewardActivity(Long id) {
 | 
					    public void closeRewardActivity(Long id) {
 | 
				
			||||||
        // 校验存在
 | 
					        // 校验存在
 | 
				
			||||||
 | 
					        // TODO @puhui999:去掉 PromotionActivityStatusEnum,使用 CommonStatus 作为状态哈。开启,关闭
 | 
				
			||||||
        RewardActivityDO dbRewardActivity = validateRewardActivityExists(id);
 | 
					        RewardActivityDO dbRewardActivity = validateRewardActivityExists(id);
 | 
				
			||||||
        if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢
 | 
					        if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢
 | 
				
			||||||
            throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED);
 | 
					            throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -190,6 +190,7 @@ public class RewardActivityServiceImplTest extends BaseDbUnitTest {
 | 
				
			|||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void testGetRewardActivities_product() {
 | 
					    public void testGetRewardActivities_product() {
 | 
				
			||||||
        // mock 数据
 | 
					        // mock 数据
 | 
				
			||||||
 | 
					       // TODO @puhui999:有单测的问题,也一起瞅瞅
 | 
				
			||||||
        RewardActivityDO productActivity01 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus())
 | 
					        RewardActivityDO productActivity01 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus())
 | 
				
			||||||
                .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L)));
 | 
					                .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L)));
 | 
				
			||||||
        rewardActivityMapper.insert(productActivity01);
 | 
					        rewardActivityMapper.insert(productActivity01);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user