mall:新增价格计算的接口

pull/2/head
YunaiV 2022-08-16 08:57:18 +08:00
parent 515c0de78d
commit 5948be86a8
11 changed files with 375 additions and 58 deletions

View File

@ -21,6 +21,13 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.market.api.price;
import cn.iocoder.yudao.module.market.api.price.dto.PriceCalculateReqDTO;
import cn.iocoder.yudao.module.market.api.price.dto.PriceCalculateRespDTO;
/**
* API
*
* @author
*/
public interface PriceApi {
/**
*
*
* @param calculateReqDTO
* @return
*/
PriceCalculateRespDTO calculatePrice(PriceCalculateReqDTO calculateReqDTO);
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.market.api.price.dto;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* Request DTO
*
* @author
*/
@Data
public class PriceCalculateReqDTO {
/**
*
*
* MemberUserDO id
*/
private Long userId;
/**
*
*/
private Long couponId;
/**
* SKU
*/
@NotNull(message = "商品数组不能为空")
private List<Item> items;
/**
* SKU
*/
@Data
public static class Item {
/**
* SKU
*/
@NotNull(message = "商品 SKU 编号不能为空")
private Long skuId;
/**
* SKU
*/
@NotNull(message = "商品 SKU 数量不能为空")
@Min(value = 0L, message = "商品 SKU 数量必须大于等于 0") // 可传递 0 数量,用于购物车未选中的情况
private Integer count;
}
}

View File

@ -0,0 +1,191 @@
package cn.iocoder.yudao.module.market.api.price.dto;
import cn.iocoder.yudao.module.market.enums.common.PromotionLevelEnum;
import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum;
import lombok.Data;
import java.util.List;
/**
* Response DTO
*
* @author
*/
@Data
public class PriceCalculateRespDTO {
/**
*
*/
private Order order;
/**
* SKU
*/
private List<Item> items;
/**
*
*
* {@link #items}
*/
private List<Promotion> promotions;
/**
*
*/
@Data
public static class Order {
/**
*
*
* {@link Item#getTotalOriginalPrice()}
*/
private Integer skuOriginalPrice;
/**
*
*
* {@link Item#getTotalPromotionPrice()}
*/
private Integer skuPromotionPrice;
/**
*
*
*
*/
private Integer orderPromotionPrice;
/**
*
*/
private Integer deliveryPrice;
/**
*
*
* = {@link #skuOriginalPrice}
* + {@link #deliveryPrice}
* - {@link #skuPromotionPrice}
* - {@link #orderPromotionPrice}
* - {@link #couponPrice} // TODO 芋艿:需要再考虑一下它
*/
private Integer payPrice;
// ========== 营销基本信息 ==========
/**
*
*/
private Long couponId;
/**
*
*/
private Integer couponPrice;
}
/**
* SKU
*/
@Data
public static class Item extends PriceCalculateReqDTO.Item {
/**
*
*
* ProductSkuDO price
*/
private Integer originalPrice;
/**
*
*
* = {@link #originalPrice} * {@link #getCount()}
*/
private Integer totalOriginalPrice;
/**
*
*
* 8 50
*/
private Integer totalPromotionPrice;
/**
*
*
* = {@link #totalOriginalPrice}
* - {@link #totalPromotionPrice}
*/
private Integer totalPresentPrice;
/**
*
*
* = {@link #totalPresentPrice} / {@link #getCount()}
*/
private Integer presentPrice;
/**
*
*/
private Integer totalPayPrice;
}
/**
*
*/
@Data
public static class Promotion {
/**
*
*
*
*/
private Long id;
/**
*
*
* {@link PromotionTypeEnum}
*/
private Integer type;
/**
*
*
* {@link PromotionLevelEnum}
*/
private Integer level;
/**
* SKU
*/
private List<Item> items;
/**
*
*/
private Integer totalOriginalPrice;
/**
*
*/
private Integer totalPromotionPrice;
// TODO 芋艿是否匹配match ;不匹配的原因
// TODO 芋艿:描述
/**
* SKU
*/
@Data
public static class Item {
/**
* SKU
*/
private Long skuId;
/**
*
*/
private Integer totalOriginalPrice;
/**
*
*/
private Integer totalPromotionPrice;
}
}
}

View File

@ -1,44 +0,0 @@
package cn.iocoder.yudao.module.market.enums.activity;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import java.util.Arrays;
/**
*
*/
public enum MarketActivityTypeEnum implements IntArrayValuable {
TIME_LIMITED_DISCOUNT(1, "限时折扣"),
FULL_PRIVILEGE(2, "满减送"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MarketActivityTypeEnum::getValue).toArray();
/**
*
*/
private final Integer value;
/**
*
*/
private final String name;
MarketActivityTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.market.enums.common;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
*
*
* @author
*/
@Getter
@AllArgsConstructor
public enum PromotionLevelEnum implements IntArrayValuable {
ORDER(1, "订单级"),
SKU(2, "商品级"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionLevelEnum::getLevel).toArray();
/**
*
*/
private final Integer level;
/**
*
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.market.enums.common;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
*
*
* @author
*/
@Getter
@AllArgsConstructor
public enum PromotionTypeEnum implements IntArrayValuable {
TIME_LIMITED_DISCOUNT(1, "限时折扣"),
FULL_PRIVILEGE(2, "满减送"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray();
/**
*
*/
private final Integer type;
/**
*
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum;
import cn.iocoder.yudao.module.market.enums.activity.MarketActivityTypeEnum;
import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
@ -24,7 +24,7 @@ public class ActivityBaseVO {
@ApiModelProperty(value = "活动类型", required = true)
@NotNull(message = "活动类型不能为空")
@InEnum(MarketActivityTypeEnum.class)
@InEnum(PromotionTypeEnum.class)
private Integer activityType;
@ApiModelProperty(value = "活动状态", required = true)

View File

@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum;
import cn.iocoder.yudao.module.market.enums.activity.MarketActivityTypeEnum;
import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
@ -21,7 +21,7 @@ public class ActivityPageReqVO extends PageParam {
private String title;
@ApiModelProperty(value = "活动类型")
@InEnum(MarketActivityTypeEnum.class)
@InEnum(PromotionTypeEnum.class)
private Integer activityType;
@ApiModelProperty(value = "活动状态")

View File

@ -110,6 +110,8 @@ public class TradeOrderDO extends BaseDO {
// ========== 价格 + 支付基本信息 ==========
// 价格文档 - 淘宝https://open.taobao.com/docV3.htm?docId=108471&docType=1
// 价格文档 - 京东到家https://openo2o.jddj.com/api/getApiDetail/182/4d1494c5e7ac4679bfdaaed950c5bc7f.htm
// 价格文档 - 有赞https://doc.youzanyun.com/detail/API/0/906
// TODO promotion_details(订单优惠信息明细,商品和订单级优惠一般都在里面)
@ -118,7 +120,8 @@ public class TradeOrderDO extends BaseDO {
*
* {@link TradeOrderItemDO#getTotalOriginalPrice()}
*/
private Integer skuOriginalPrice; // niu - goods_money
// niu - goods_money
private Integer skuOriginalPrice;
/**
*
*
@ -130,11 +133,13 @@ public class TradeOrderDO extends BaseDO {
*
*
*/
private Integer orderPromotionPrice; // niu - promotion_moneytaobao - discount_fee主订单优惠
// niu - promotion_moneytaobao - discount_fee主订单优惠
private Integer orderPromotionPrice;
/**
*
*/
private Integer deliveryPrice; // niu - delivery_moneytaobao - post_fee订单邮费
// niu - delivery_moneytaobao - post_fee订单邮费
private Integer deliveryPrice;
// TODO 芋艿taobao 的trade.adjust_fee/order.adjust_fee调整金额卖家手动修改订单价格官方数据修复等等
/**
*
@ -145,7 +150,8 @@ public class TradeOrderDO extends BaseDO {
* - {@link #orderPromotionPrice}
* - {@link #couponPrice}
*/
private Integer payPrice; // niu - pay_moneytaobao - payment主订单实付金额 | trade.total_fee主订单应付金额参考使用
// niu - pay_moneytaobao - payment主订单实付金额 | trade.total_fee主订单应付金额参考使用
private Integer payPrice;
/**
*
*
@ -244,7 +250,8 @@ public class TradeOrderDO extends BaseDO {
/**
*
*/
private Integer couponPrice; // niu - coupon_money
// niu - coupon_money
private Integer couponPrice;
// /**
// * 积分抵扣的金额,单位:分
// */

View File

@ -84,19 +84,22 @@ public class TradeOrderItemDO extends BaseDO {
*
* ProductSkuDO price
*/
private Integer originalPrice; // like - original_priceniu - costPrice
// like - original_priceniu - costPrice
private Integer originalPrice;
/**
*
*
* = {@link #originalPrice} * {@link #count}
*/
private Integer totalOriginalPrice; // like - total_priceniu - 暂无
// like - total_priceniu - 暂无
private Integer totalOriginalPrice;
/**
*
*
* 8 50
*/
private Integer totalPromotionPrice; // taobao - order.discount_fee子订单商品优惠
// taobao - order.discount_fee子订单商品优惠
private Integer totalPromotionPrice;
/**
*
*
@ -109,12 +112,14 @@ public class TradeOrderItemDO extends BaseDO {
* = {@link #totalOriginalPrice}
* - {@link #totalPromotionPrice}
*/
private Integer totalPresentPrice; // like - total_pay_priceniu - goods_money; taobao - order.payment子订单实付金额不算主订单分摊金额 | order.total_fee子订单应付金额参考使用
// like - total_pay_priceniu - goods_money; taobao - order.payment子订单实付金额不算主订单分摊金额 | order.total_fee子订单应付金额参考使用
private Integer totalPresentPrice;
// TODO 芋艿part_mjz_discount(子订单分摊金额)本质上totalOriginalPrice - totalPayPrice
/**
*
*/
private Integer totalPayPrice; // taobao - divide_order_fee (分摊后子订单实付金额);
// taobao - divide_order_fee (分摊后子订单实付金额);
private Integer totalPayPrice;
// ========== 营销基本信息 ==========
// /**