Price 价格服务的编写

This commit is contained in:
YunaiV
2020-08-14 19:09:17 +08:00
parent ed71f5e9c8
commit 5122b68aca
32 changed files with 858 additions and 428 deletions

View File

@@ -0,0 +1,110 @@
package cn.iocoder.mall.promotion.api.rpc.coupon.dto.card;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 优惠劵 Response DTO
*/
@Data
@Accessors(chain = true)
public class CouponCardRespDTO implements Serializable {
// ========== 基本信息 BEGIN ==========
/**
* 优惠劵编号
*/
private Integer id;
/**
* 优惠劵(码)分组编号
*/
private Integer templateId;
/**
* 优惠劵名
*/
private String title;
// /**
// * 核销码
// */
// private String verifyCode;
/**
* 优惠码状态
*
* 1-未使用
* 2-已使用
* 3-已失效
*/
private Integer status;
// ========== 基本信息 END ==========
// ========== 领取情况 BEGIN ==========
/**
* 用户编号
*/
private Integer userId;
/**
* 领取类型
*
* 1 - 用户主动领取
* 2 - 后台自动发放
*/
private Integer takeType;
// ========== 领取情况 END ==========
// ========== 使用规则 BEGIN ==========
/**
* 是否设置满多少金额可用,单位:分
*/
private Integer priceAvailable;
/**
* 生效开始时间
*/
private Date validStartTime;
/**
* 生效结束时间
*/
private Date validEndTime;
// ========== 使用规则 END ==========
// ========== 使用效果 BEGIN ==========
/**
* 优惠类型
*
* 1-代金卷
* 2-折扣卷
*/
private Integer preferentialType;
/**
* 折扣
*/
private Integer percentOff;
/**
* 优惠金额,单位:分。
*/
private Integer priceOff;
/**
* 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。
*
* 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。
*/
private Integer discountPriceLimit;
// ========== 使用效果 END ==========
// ========== 使用情况 BEGIN ==========
/**
* 使用时间
*/
private Date usedTime;
// ========== 使用情况 END ==========
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -0,0 +1,156 @@
package cn.iocoder.mall.promotion.api.rpc.coupon.dto.template;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 优惠劵(码)模板 BO
*/
@Data
@Accessors(chain = true)
public class CouponTemplateRespDTO implements Serializable {
// ========== 基本信息 BEGIN ==========
/**
* 模板编号,自增唯一。
*/
private Integer id;
/**
* 标题
*/
private String title;
/**
* 使用说明
*/
private String description;
/**
* 类型
*
* 1-优惠劵
* 2-优惠码
*/
private Integer type;
/**
* 码类型
*
* 1-一卡一码UNIQUE
* 2-通用码GENERAL
*
* 【优惠码独有】 @see CouponCodeDO
*/
private Integer codeType;
/**
* 优惠码状态
*
* 1-开启中
* 2-禁用中
* 3-已过期
*
* 当优惠劵(码)开启中,可以手动操作,设置禁用中。
*/
private Integer status;
/**
* 每人限领个数
*
* null - 则表示不限制
*/
private Integer quota;
/**
* 发放总量
*/
private Integer total;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
/**
* 是否设置满多少金额可用,单位:分
*
* 0-不限制
* 大于0-多少金额可用
*/
private Integer priceAvailable;
/**
* 可用范围的类型
*
* 10-全部ALL所有可用
* 20-部分PART部分商品可用或指定商品可用
* 21-部分PART部分商品不可用或指定商品可用
* 30-部分PART部分分类可用或指定商品可用
* 31-部分PART部分分类不可用或指定商品可用
*/
private Integer rangeType;
/**
* 指定商品 / 分类列表,使用逗号分隔商品编号
*/
private List<Integer> rangeValues;
/**
* 生效日期类型
*
* 1-固定日期
* 2-领取日期:领到券 {@link #fixedStartTerm} 日开始 N 天内有效
*/
private Integer dateType;
/**
* 固定日期-生效开始时间
*/
private Date validStartTime;
/**
* 固定日期-生效结束时间
*/
private Date validEndTime;
/**
* 领取日期-开始天数
*
* 例如0-当天1-次天
*/
private Integer fixedStartTerm;
/**
* 领取日期-结束天数
*/
private Integer fixedEndTerm;
// ========== 使用规则 END ==========
// ========== 使用效果 BEGIN ==========
/**
* 优惠类型
*
* 1-代金卷
* 2-折扣卷
*/
private Integer preferentialType;
/**
* 折扣百分比。
*
* 例如80% 为 80。
* 当 100% 为 100 ,则代表免费。
*/
private Integer percentOff;
/**
* 优惠金额,单位:分
*/
private Integer priceOff;
/**
* 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。
*
* 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。
*/
private Integer discountPriceLimit;
// ========== 使用效果 END ==========
// ========== 统计信息 BEGIN ==========
/**
* 领取优惠券的次数
*/
private Integer statFetchNum;
// ========== 统计信息 END ==========
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -1,14 +1,14 @@
package cn.iocoder.mall.promotion.api.rpc.price;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.List;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
/**
* 价格 Rpc 接口,提供价格计算的功能
*/
public class PriceRpc {
public interface PriceRpc {
CommonResult<PriceProductCalcRespDTO> calcProductPrice(PriceProductCalcReqDTO calcReqDTO);
}

View File

@@ -11,7 +11,7 @@ import java.util.List;
* 商品价格计算 Request DTO
*/
@Data
@Accessors
@Accessors(chain = true)
public class PriceProductCalcReqDTO implements Serializable {
/**

View File

@@ -1,5 +1,7 @@
package cn.iocoder.mall.promotion.api.rpc.price.dto;
import cn.iocoder.mall.promotion.api.enums.PromotionActivityTypeEnum;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -48,11 +50,14 @@ public class PriceProductCalcRespDTO implements Serializable {
@Accessors(chain = true)
public static class ItemGroup {
// /**
// * 优惠活动
// */
// // TODO 芋艿,目前会有满减送】的情况,未来有新的促销方式,可能需要改成数组
// private PromotionActivityBO activity;
/**
* 优惠活动
*
* 目前会有满减送 {@link PromotionActivityTypeEnum#FULL_PRIVILEGE} 类型的活动
*
* // TODO 芋艿,目前只会有【满减送】的情况,未来有新的促销方式,可能需要改成数组
*/
private PromotionActivityRespDTO activity;
/**
* 促销减少的金额
*
@@ -77,14 +82,28 @@ public class PriceProductCalcRespDTO implements Serializable {
@Accessors(chain = true)
public static class Item {
/**
* 商品 SPU 编号
*/
private Integer spuId;
/**
* 商品 SKU 编号
*/
private Integer skuId;
/**
* 商品 Category 编号
*/
private Integer cid;
/**
* 购买数量
*/
private Integer buyQuantity;
// /**
// * 优惠活动
// */
// private PromotionActivityBO activity;
/**
* 优惠活动
*
* 目前会有限时折扣 {@link PromotionActivityTypeEnum#TIME_LIMITED_DISCOUNT} 类型的活动
*/
private PromotionActivityRespDTO activity;
/**
* 原始单价,单位:分。
*/