【代码优化】商城: 满减送活动 CRUD 部分

This commit is contained in:
puhui999
2024-08-27 16:46:04 +08:00
parent 1e4cc953d3
commit 710f29d911
11 changed files with 220 additions and 175 deletions

View File

@ -1,8 +1,12 @@
package cn.iocoder.yudao.module.promotion.api.reward.dto;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -21,28 +25,50 @@ public class RewardActivityMatchRespDTO {
* 活动标题
*/
private String name;
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
/**
* 开始时间
*/
private LocalDateTime startTime;
/**
* 结束时间
*/
private LocalDateTime endTime;
/**
* 备注
*/
private String remark;
/**
* 条件类型
*
* 枚举 {@link PromotionConditionTypeEnum}
*/
private Integer conditionType;
/**
* 商品范围
*
* 枚举 {@link PromotionProductScopeEnum}
*/
private Integer productScope;
/**
* 商品 SPU 编号的数组
*/
private List<Long> productScopeValues;
/**
* 优惠规则的数组
*/
private List<Rule> rules;
/**
* 商品 SPU 编号的数组
*/
private List<Long> spuIds;
// TODO 芋艿:后面 RewardActivityRespDTO 有了之后Rule 可以放过去
/**
* 优惠规则
*/
@Data
public static class Rule {
public static class Rule implements Serializable {
/**
* 优惠门槛
@ -59,10 +85,18 @@ public class RewardActivityMatchRespDTO {
* 是否包邮
*/
private Boolean freeDelivery;
/**
* 是否赠送积分
*/
private Boolean givePoint;
/**
* 赠送的积分
*/
private Integer point;
/**
* 是否赠送优惠券
*/
private Boolean giveCoupon;
/**
* 赠送的优惠劵编号的数组
*/

View File

@ -44,7 +44,8 @@ public interface ErrorCodeConstants {
ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_002, "满减送活动已关闭,不能修改");
ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_006_003, "满减送活动未关闭,不能删除");
ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭");
ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1_013_006_005, "满减送活动已结束,不能关闭");
ErrorCode REWARD_ACTIVITY_SCOPE_ALL_EXISTS = new ErrorCode(1_013_006_005, "已存在商品范围为全场的满减送活动");
ErrorCode REWARD_ACTIVITY_SCOPE_CATEGORY_EXISTS = new ErrorCode(1_013_006_006, "存在商品类型参加了其它满减送活动");
// ========== TODO 空着 1-013-007-000 ============

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.enums.common;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -35,4 +36,16 @@ public enum PromotionProductScopeEnum implements IntArrayValuable {
return ARRAYS;
}
public static boolean isAll(Integer scope) {
return ObjUtil.equal(scope, ALL.scope);
}
public static boolean isSpu(Integer scope) {
return ObjUtil.equal(scope, SPU.scope);
}
public static boolean isCategory(Integer scope) {
return ObjUtil.equal(scope, CATEGORY.scope);
}
}