后端:促销活动增加表

This commit is contained in:
YunaiV
2019-04-15 23:33:56 +08:00
parent daf3f4c8c7
commit 974b9650de
17 changed files with 445 additions and 29 deletions

View File

@@ -0,0 +1,17 @@
package cn.iocoder.mall.promotion.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
import java.util.Collection;
import java.util.List;
public interface PromotionActivityService {
CommonResult<List<PromotionActivityBO>> getPromotionActivityListBySpuId(Integer spuId,
Collection<Integer> activityStatuses);
CommonResult<List<PromotionActivityBO>> getPromotionActivityListBySpuIds(Collection<Integer> spuIds,
Collection<Integer> activityStatuses);
}

View File

@@ -0,0 +1,134 @@
package cn.iocoder.mall.promotion.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Set;
@Data
@Accessors(chain = true)
public class PromotionActivityBO {
/**
* 活动编号
*/
private Integer id;
/**
* 活动标题
*/
private String title;
/**
* 活动类型
*
* 参见 {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityTypeEnum} 枚举
*/
private Integer type;
/**
* 活动状态
*
* 参见 {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityStatusEnum} 枚举
*/
private Integer status;
/**
* 匹配的商品 SPU 编号
*/
private Set<Integer> spuIds;
/**
* 限制折扣
*/
@Data
@Accessors(chain = true)
public static class TimeLimitedDiscount {
/**
* 商品折扣
*/
@Data
@Accessors(chain = true)
public static class Item {
/**
* 商品 SPU 编号
*/
private Integer spuId;
/**
* 优惠类型
*/
private Integer preferentialType;
/**
* 优惠值
*/
private Integer preferentialValue;
}
/**
* 每人每种限购多少
*
* 当 quota = 0 时,表示不限购
*/
private Integer quota;
/**
* 商品折扣数组
*/
private List<Item> items;
}
/**
* 满减送
*/
@Data
@Accessors(chain = true)
public static class FullPrivilege {
/**
* 优惠
*/
@Data
@Accessors(chain = true)
public static class Privilege {
/**
* 满足类型
*
* 1 - 金额
* 2 - 件数
*/
private Integer meetType;
/**
* 满足值
*/
private Integer meetValue;
/**
* 优惠类型
*/
private Integer preferentialType;
/**
* 优惠值
*/
private Integer preferentialValue;
}
/**
* 可用范围的类型
*
* 参见 {@link cn.iocoder.mall.promotion.api.constant.RangeTypeEnum} 枚举
* 暂时只用 “所有可用” + “PRODUCT_INCLUDE_PRT”
*/
private Integer rangeType;
/**
* 指定可用商品列表
*/
private List<Integer> rangeValues;
/**
* 优惠数组
*/
private List<Privilege> privileges;
}
}

View File

@@ -4,13 +4,16 @@ import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
public enum CouponTemplatePreferentialTypeEnum implements IntArrayValuable {
/**
* 优惠类型枚举
*/
public enum PreferentialTypeEnum implements IntArrayValuable {
PRICE(1, "代金卷"),
DISCOUNT(2, "折扣卷"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplatePreferentialTypeEnum::getValue).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PreferentialTypeEnum::getValue).toArray();
/**
*
@@ -21,7 +24,7 @@ public enum CouponTemplatePreferentialTypeEnum implements IntArrayValuable {
*/
private final String name;
CouponTemplatePreferentialTypeEnum(Integer value, String name) {
PreferentialTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}

View File

@@ -0,0 +1,41 @@
package cn.iocoder.mall.promotion.api.constant;
/**
* 促销活动状态枚举
*/
public enum PromotionActivityStatusEnum {
WAIT(10, "未开始"),
RUN(20, "进行中"),
END(30, "已结束"),
/**
* 1. WAIT、RUN、END 可以转换成 INVALID 状态。
* 2. INVALID 只可以转换成 DELETED 状态。
*/
INVALID(40, "已撤销"),
DELETED(50, "已删除"),
;
/**
* 状态值
*/
private final Integer value;
/**
* 状态名
*/
private final String name;
PromotionActivityStatusEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@@ -5,8 +5,8 @@ package cn.iocoder.mall.promotion.api.constant;
*/
public enum PromotionActivityTypeEnum {
LIMIT_DISCOUNT(1, "限时折扣"),
MEET_REDUCE(2, "满减送"),
TIME_LIMITED_DISCOUNT(1, "限时折扣"),
FULL_PRIVILEGE(2, "满减送"),
;
/**

View File

@@ -4,7 +4,7 @@ import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
public enum CouponTemplateRangeTypeEnum implements IntArrayValuable {
public enum RangeTypeEnum implements IntArrayValuable {
ALL(10, "所有可用"),
PRODUCT_INCLUDE_PRT(20, "部分商品可用,或指定商品可用"),
@@ -13,7 +13,7 @@ public enum CouponTemplateRangeTypeEnum implements IntArrayValuable {
CATEGORY_EXCLUDE_PRT(31, "部分分类不可用,或指定分类可用"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateRangeTypeEnum::getValue).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(RangeTypeEnum::getValue).toArray();
/**
*
@@ -24,7 +24,7 @@ public enum CouponTemplateRangeTypeEnum implements IntArrayValuable {
*/
private final String name;
CouponTemplateRangeTypeEnum(Integer value, String name) {
RangeTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}

View File

@@ -2,8 +2,8 @@ package cn.iocoder.mall.promotion.api.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplateDateTypeEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplatePreferentialTypeEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum;
import cn.iocoder.mall.promotion.api.constant.PreferentialTypeEnum;
import cn.iocoder.mall.promotion.api.constant.RangeTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
@@ -70,7 +70,7 @@ public class CouponCardTemplateAddDTO {
* 31-部分PART部分分类不可用或指定分类可用
*/
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
/**
* 指定商品 / 分类列表,使用逗号分隔商品编号
@@ -115,7 +115,7 @@ public class CouponCardTemplateAddDTO {
* 2-折扣卷
*/
@NotNull(message = "优惠类型不能为空")
@InEnum(value = CouponTemplatePreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
@InEnum(value = PreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
private Integer preferentialType;
/**
* 优惠金额,单位:分

View File

@@ -1,7 +1,7 @@
package cn.iocoder.mall.promotion.api.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum;
import cn.iocoder.mall.promotion.api.constant.RangeTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
@@ -69,7 +69,7 @@ public class CouponCardTemplateUpdateDTO {
* 31-部分PART部分分类不可用或指定分类可用
*/
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
/**
* 指定商品 / 分类列表,使用逗号分隔商品编号