mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
mall + trade:调整价格字段,更易懂
This commit is contained in:
parent
0083d12404
commit
02fa6fc5c6
@ -38,6 +38,7 @@ public class PriceCalculateRespDTO {
|
|||||||
*/
|
*/
|
||||||
private List<Promotion> promotions;
|
private List<Promotion> promotions;
|
||||||
|
|
||||||
|
// TODO @芋艿:需要改造下,主要是价格字段
|
||||||
/**
|
/**
|
||||||
* 订单
|
* 订单
|
||||||
*/
|
*/
|
||||||
@ -51,14 +52,7 @@ public class PriceCalculateRespDTO {
|
|||||||
*
|
*
|
||||||
* 对应 taobao 的 trade.total_fee 字段
|
* 对应 taobao 的 trade.total_fee 字段
|
||||||
*/
|
*/
|
||||||
private Integer originalPrice;
|
private Integer totalPrice;
|
||||||
/**
|
|
||||||
* 订单原价(总),单位:分
|
|
||||||
*
|
|
||||||
* 基于 {@link OrderItem#getPayPrice()} 求和
|
|
||||||
* 和 {@link #originalPrice} 的差异:去除商品级优惠
|
|
||||||
*/
|
|
||||||
private Integer orderPrice;
|
|
||||||
/**
|
/**
|
||||||
* 订单优惠(总),单位:分
|
* 订单优惠(总),单位:分
|
||||||
*
|
*
|
||||||
@ -207,7 +201,7 @@ public class PriceCalculateRespDTO {
|
|||||||
/**
|
/**
|
||||||
* 计算时的原价(总),单位:分
|
* 计算时的原价(总),单位:分
|
||||||
*/
|
*/
|
||||||
private Integer originalPrice;
|
private Integer totalPrice;
|
||||||
/**
|
/**
|
||||||
* 计算时的优惠(总),单位:分
|
* 计算时的优惠(总),单位:分
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@ public interface PriceConvert {
|
|||||||
// 创建 PriceCalculateRespDTO 对象
|
// 创建 PriceCalculateRespDTO 对象
|
||||||
PriceCalculateRespDTO priceCalculate = new PriceCalculateRespDTO();
|
PriceCalculateRespDTO priceCalculate = new PriceCalculateRespDTO();
|
||||||
// 创建它的 Order 属性
|
// 创建它的 Order 属性
|
||||||
PriceCalculateRespDTO.Order order = new PriceCalculateRespDTO.Order().setOriginalPrice(0).setDiscountPrice(0)
|
PriceCalculateRespDTO.Order order = new PriceCalculateRespDTO.Order().setTotalPrice(0).setDiscountPrice(0)
|
||||||
.setCouponPrice(0).setPointPrice(0).setDeliveryPrice(0).setPayPrice(0)
|
.setCouponPrice(0).setPointPrice(0).setDeliveryPrice(0).setPayPrice(0)
|
||||||
.setItems(new ArrayList<>()).setCouponId(calculateReqDTO.getCouponId());
|
.setItems(new ArrayList<>()).setCouponId(calculateReqDTO.getCouponId());
|
||||||
priceCalculate.setOrder(order).setPromotions(new ArrayList<>());
|
priceCalculate.setOrder(order).setPromotions(new ArrayList<>());
|
||||||
@ -38,8 +38,8 @@ public interface PriceConvert {
|
|||||||
orderItem.setPayPrice(orderItem.getOriginalPrice()).setOrderDividePrice(orderItem.getOriginalPrice());
|
orderItem.setPayPrice(orderItem.getOriginalPrice()).setOrderDividePrice(orderItem.getOriginalPrice());
|
||||||
priceCalculate.getOrder().getItems().add(orderItem);
|
priceCalculate.getOrder().getItems().add(orderItem);
|
||||||
// 补充价格信息到 Order 中
|
// 补充价格信息到 Order 中
|
||||||
order.setOriginalPrice(order.getOriginalPrice() + orderItem.getOriginalPrice())
|
order.setTotalPrice(order.getTotalPrice() + orderItem.getOriginalPrice())
|
||||||
.setOrderPrice(order.getOriginalPrice()).setPayPrice(order.getOriginalPrice());
|
.setPayPrice(order.getTotalPrice());
|
||||||
});
|
});
|
||||||
return priceCalculate;
|
return priceCalculate;
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ public class PriceServiceImpl implements PriceService {
|
|||||||
// 创建营销明细
|
// 创建营销明细
|
||||||
PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion()
|
PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion()
|
||||||
.setId(id).setName(name).setType(type).setLevel(level)
|
.setId(id).setName(name).setType(type).setLevel(level)
|
||||||
.setOriginalPrice(promotionItem.getOriginalPrice()).setDiscountPrice(promotionItem.getDiscountPrice())
|
.setTotalPrice(promotionItem.getOriginalPrice()).setDiscountPrice(promotionItem.getDiscountPrice())
|
||||||
.setItems(singletonList(promotionItem)).setMeet(meet).setMeetTip(meetTip);
|
.setItems(singletonList(promotionItem)).setMeet(meet).setMeetTip(meetTip);
|
||||||
priceCalculate.getPromotions().add(promotion);
|
priceCalculate.getPromotions().add(promotion);
|
||||||
}
|
}
|
||||||
@ -437,7 +437,7 @@ public class PriceServiceImpl implements PriceService {
|
|||||||
// 创建营销明细
|
// 创建营销明细
|
||||||
PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion()
|
PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion()
|
||||||
.setId(id).setName(name).setType(type).setLevel(level)
|
.setId(id).setName(name).setType(type).setLevel(level)
|
||||||
.setOriginalPrice(getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum))
|
.setTotalPrice(getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum))
|
||||||
.setDiscountPrice(getSumValue(discountPrices, value -> value, Integer::sum))
|
.setDiscountPrice(getSumValue(discountPrices, value -> value, Integer::sum))
|
||||||
.setItems(promotionItems).setMeet(meet).setMeetTip(meetTip);
|
.setItems(promotionItems).setMeet(meet).setMeetTip(meetTip);
|
||||||
priceCalculate.getPromotions().add(promotion);
|
priceCalculate.getPromotions().add(promotion);
|
||||||
@ -453,7 +453,7 @@ public class PriceServiceImpl implements PriceService {
|
|||||||
Integer originalPrice = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum);
|
Integer originalPrice = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum);
|
||||||
PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion()
|
PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion()
|
||||||
.setId(id).setName(name).setType(type).setLevel(level)
|
.setId(id).setName(name).setType(type).setLevel(level)
|
||||||
.setOriginalPrice(originalPrice).setDiscountPrice(0)
|
.setTotalPrice(originalPrice).setDiscountPrice(0)
|
||||||
.setItems(promotionItems).setMeet(false).setMeetTip(meetTip);
|
.setItems(promotionItems).setMeet(false).setMeetTip(meetTip);
|
||||||
priceCalculate.getPromotions().add(promotion);
|
priceCalculate.getPromotions().add(promotion);
|
||||||
}
|
}
|
||||||
@ -476,7 +476,6 @@ public class PriceServiceImpl implements PriceService {
|
|||||||
// 设置 Order 相关相关字段
|
// 设置 Order 相关相关字段
|
||||||
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
||||||
order.setPayPrice(order.getPayPrice() - diffPayPrice);
|
order.setPayPrice(order.getPayPrice() - diffPayPrice);
|
||||||
order.setOrderPrice(order.getOrderPrice() - diffPayPrice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,8 +70,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
||||||
// 断言 Order 部分
|
// 断言 Order 部分
|
||||||
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
||||||
assertEquals(order.getOriginalPrice(), 200);
|
assertEquals(order.getTotalPrice(), 200);
|
||||||
assertEquals(order.getOrderPrice(), 180);
|
|
||||||
assertEquals(order.getDiscountPrice(), 0);
|
assertEquals(order.getDiscountPrice(), 0);
|
||||||
assertEquals(order.getPointPrice(), 0);
|
assertEquals(order.getPointPrice(), 0);
|
||||||
assertEquals(order.getDeliveryPrice(), 0);
|
assertEquals(order.getDeliveryPrice(), 0);
|
||||||
@ -95,7 +94,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals(promotion.getName(), "会员折扣");
|
assertEquals(promotion.getName(), "会员折扣");
|
||||||
assertEquals(promotion.getType(), PromotionTypeEnum.MEMBER.getType());
|
assertEquals(promotion.getType(), PromotionTypeEnum.MEMBER.getType());
|
||||||
assertEquals(promotion.getLevel(), PromotionLevelEnum.SKU.getLevel());
|
assertEquals(promotion.getLevel(), PromotionLevelEnum.SKU.getLevel());
|
||||||
assertEquals(promotion.getOriginalPrice(), 200);
|
assertEquals(promotion.getTotalPrice(), 200);
|
||||||
assertEquals(promotion.getDiscountPrice(), 20);
|
assertEquals(promotion.getDiscountPrice(), 20);
|
||||||
assertTrue(promotion.getMeet());
|
assertTrue(promotion.getMeet());
|
||||||
assertEquals(promotion.getMeetTip(), "会员折扣:省 0.20 元");
|
assertEquals(promotion.getMeetTip(), "会员折扣:省 0.20 元");
|
||||||
@ -133,8 +132,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
||||||
// 断言 Order 部分
|
// 断言 Order 部分
|
||||||
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
||||||
assertEquals(order.getOriginalPrice(), 350);
|
assertEquals(order.getTotalPrice(), 350);
|
||||||
assertEquals(order.getOrderPrice(), 210);
|
|
||||||
assertEquals(order.getDiscountPrice(), 0);
|
assertEquals(order.getDiscountPrice(), 0);
|
||||||
assertEquals(order.getPointPrice(), 0);
|
assertEquals(order.getPointPrice(), 0);
|
||||||
assertEquals(order.getDeliveryPrice(), 0);
|
assertEquals(order.getDeliveryPrice(), 0);
|
||||||
@ -167,7 +165,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals(promotion01.getName(), "活动 1000 号");
|
assertEquals(promotion01.getName(), "活动 1000 号");
|
||||||
assertEquals(promotion01.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType());
|
assertEquals(promotion01.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType());
|
||||||
assertEquals(promotion01.getLevel(), PromotionLevelEnum.SKU.getLevel());
|
assertEquals(promotion01.getLevel(), PromotionLevelEnum.SKU.getLevel());
|
||||||
assertEquals(promotion01.getOriginalPrice(), 200);
|
assertEquals(promotion01.getTotalPrice(), 200);
|
||||||
assertEquals(promotion01.getDiscountPrice(), 80);
|
assertEquals(promotion01.getDiscountPrice(), 80);
|
||||||
assertTrue(promotion01.getMeet());
|
assertTrue(promotion01.getMeet());
|
||||||
assertEquals(promotion01.getMeetTip(), "限时折扣:省 0.80 元");
|
assertEquals(promotion01.getMeetTip(), "限时折扣:省 0.80 元");
|
||||||
@ -181,7 +179,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals(promotion02.getName(), "活动 2000 号");
|
assertEquals(promotion02.getName(), "活动 2000 号");
|
||||||
assertEquals(promotion02.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType());
|
assertEquals(promotion02.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType());
|
||||||
assertEquals(promotion02.getLevel(), PromotionLevelEnum.SKU.getLevel());
|
assertEquals(promotion02.getLevel(), PromotionLevelEnum.SKU.getLevel());
|
||||||
assertEquals(promotion02.getOriginalPrice(), 150);
|
assertEquals(promotion02.getTotalPrice(), 150);
|
||||||
assertEquals(promotion02.getDiscountPrice(), 60);
|
assertEquals(promotion02.getDiscountPrice(), 60);
|
||||||
assertTrue(promotion02.getMeet());
|
assertTrue(promotion02.getMeet());
|
||||||
assertEquals(promotion02.getMeetTip(), "限时折扣:省 0.60 元");
|
assertEquals(promotion02.getMeetTip(), "限时折扣:省 0.60 元");
|
||||||
@ -225,8 +223,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
||||||
// 断言 Order 部分
|
// 断言 Order 部分
|
||||||
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
||||||
assertEquals(order.getOriginalPrice(), 470);
|
assertEquals(order.getTotalPrice(), 470);
|
||||||
assertEquals(order.getOrderPrice(), 470);
|
|
||||||
assertEquals(order.getDiscountPrice(), 130);
|
assertEquals(order.getDiscountPrice(), 130);
|
||||||
assertEquals(order.getPointPrice(), 0);
|
assertEquals(order.getPointPrice(), 0);
|
||||||
assertEquals(order.getDeliveryPrice(), 0);
|
assertEquals(order.getDeliveryPrice(), 0);
|
||||||
@ -268,7 +265,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals(promotion01.getName(), "活动 1000 号");
|
assertEquals(promotion01.getName(), "活动 1000 号");
|
||||||
assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType());
|
assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType());
|
||||||
assertEquals(promotion01.getLevel(), PromotionLevelEnum.ORDER.getLevel());
|
assertEquals(promotion01.getLevel(), PromotionLevelEnum.ORDER.getLevel());
|
||||||
assertEquals(promotion01.getOriginalPrice(), 350);
|
assertEquals(promotion01.getTotalPrice(), 350);
|
||||||
assertEquals(promotion01.getDiscountPrice(), 70);
|
assertEquals(promotion01.getDiscountPrice(), 70);
|
||||||
assertTrue(promotion01.getMeet());
|
assertTrue(promotion01.getMeet());
|
||||||
assertEquals(promotion01.getMeetTip(), "满减送:省 0.70 元");
|
assertEquals(promotion01.getMeetTip(), "满减送:省 0.70 元");
|
||||||
@ -287,7 +284,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals(promotion02.getName(), "活动 2000 号");
|
assertEquals(promotion02.getName(), "活动 2000 号");
|
||||||
assertEquals(promotion02.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType());
|
assertEquals(promotion02.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType());
|
||||||
assertEquals(promotion02.getLevel(), PromotionLevelEnum.ORDER.getLevel());
|
assertEquals(promotion02.getLevel(), PromotionLevelEnum.ORDER.getLevel());
|
||||||
assertEquals(promotion02.getOriginalPrice(), 120);
|
assertEquals(promotion02.getTotalPrice(), 120);
|
||||||
assertEquals(promotion02.getDiscountPrice(), 60);
|
assertEquals(promotion02.getDiscountPrice(), 60);
|
||||||
assertTrue(promotion02.getMeet());
|
assertTrue(promotion02.getMeet());
|
||||||
assertEquals(promotion02.getMeetTip(), "满减送:省 0.60 元");
|
assertEquals(promotion02.getMeetTip(), "满减送:省 0.60 元");
|
||||||
@ -323,8 +320,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
||||||
// 断言 Order 部分
|
// 断言 Order 部分
|
||||||
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
||||||
assertEquals(order.getOriginalPrice(), 350);
|
assertEquals(order.getTotalPrice(), 350);
|
||||||
assertEquals(order.getOrderPrice(), 350);
|
|
||||||
assertEquals(order.getDiscountPrice(), 0);
|
assertEquals(order.getDiscountPrice(), 0);
|
||||||
assertEquals(order.getPointPrice(), 0);
|
assertEquals(order.getPointPrice(), 0);
|
||||||
assertEquals(order.getDeliveryPrice(), 0);
|
assertEquals(order.getDeliveryPrice(), 0);
|
||||||
@ -357,7 +353,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals(promotion01.getName(), "活动 1000 号");
|
assertEquals(promotion01.getName(), "活动 1000 号");
|
||||||
assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType());
|
assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType());
|
||||||
assertEquals(promotion01.getLevel(), PromotionLevelEnum.ORDER.getLevel());
|
assertEquals(promotion01.getLevel(), PromotionLevelEnum.ORDER.getLevel());
|
||||||
assertEquals(promotion01.getOriginalPrice(), 350);
|
assertEquals(promotion01.getTotalPrice(), 350);
|
||||||
assertEquals(promotion01.getDiscountPrice(), 0);
|
assertEquals(promotion01.getDiscountPrice(), 0);
|
||||||
assertFalse(promotion01.getMeet());
|
assertFalse(promotion01.getMeet());
|
||||||
assertEquals(promotion01.getMeetTip(), "TODO"); // TODO 芋艿:后面再想想
|
assertEquals(promotion01.getMeetTip(), "TODO"); // TODO 芋艿:后面再想想
|
||||||
@ -396,8 +392,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
|
||||||
// 断言 Order 部分
|
// 断言 Order 部分
|
||||||
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
PriceCalculateRespDTO.Order order = priceCalculate.getOrder();
|
||||||
assertEquals(order.getOriginalPrice(), 470);
|
assertEquals(order.getTotalPrice(), 470);
|
||||||
assertEquals(order.getOrderPrice(), 470);
|
|
||||||
assertEquals(order.getDiscountPrice(), 0);
|
assertEquals(order.getDiscountPrice(), 0);
|
||||||
assertEquals(order.getPointPrice(), 0);
|
assertEquals(order.getPointPrice(), 0);
|
||||||
assertEquals(order.getDeliveryPrice(), 0);
|
assertEquals(order.getDeliveryPrice(), 0);
|
||||||
@ -440,7 +435,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals(promotion01.getName(), "程序员节");
|
assertEquals(promotion01.getName(), "程序员节");
|
||||||
assertEquals(promotion01.getType(), PromotionTypeEnum.COUPON.getType());
|
assertEquals(promotion01.getType(), PromotionTypeEnum.COUPON.getType());
|
||||||
assertEquals(promotion01.getLevel(), PromotionLevelEnum.COUPON.getLevel());
|
assertEquals(promotion01.getLevel(), PromotionLevelEnum.COUPON.getLevel());
|
||||||
assertEquals(promotion01.getOriginalPrice(), 350);
|
assertEquals(promotion01.getTotalPrice(), 350);
|
||||||
assertEquals(promotion01.getDiscountPrice(), 70);
|
assertEquals(promotion01.getDiscountPrice(), 70);
|
||||||
assertTrue(promotion01.getMeet());
|
assertTrue(promotion01.getMeet());
|
||||||
assertEquals(promotion01.getMeetTip(), "优惠劵:省 0.70 元");
|
assertEquals(promotion01.getMeetTip(), "优惠劵:省 0.70 元");
|
||||||
|
@ -73,9 +73,6 @@ public class TradeOrderBaseVO {
|
|||||||
@Schema(description = "商品原价(总)", required = true, example = "1000")
|
@Schema(description = "商品原价(总)", required = true, example = "1000")
|
||||||
private Integer originalPrice;
|
private Integer originalPrice;
|
||||||
|
|
||||||
@Schema(description = "订单原价(总)", required = true, example = "1000")
|
|
||||||
private Integer orderPrice;
|
|
||||||
|
|
||||||
@Schema(description = "订单优惠(总)", required = true, example = "100")
|
@Schema(description = "订单优惠(总)", required = true, example = "100")
|
||||||
private Integer discountPrice;
|
private Integer discountPrice;
|
||||||
|
|
||||||
|
@ -59,10 +59,7 @@ public class AppTradeOrderDetailRespVO {
|
|||||||
private String payChannelCode;
|
private String payChannelCode;
|
||||||
|
|
||||||
@Schema(description = "商品原价(总)", required = true, example = "1000")
|
@Schema(description = "商品原价(总)", required = true, example = "1000")
|
||||||
private Integer originalPrice;
|
private Integer totalPrice;
|
||||||
|
|
||||||
@Schema(description = "订单原价(总)", required = true, example = "1000")
|
|
||||||
private Integer orderPrice;
|
|
||||||
|
|
||||||
@Schema(description = "订单优惠(总)", required = true, example = "100")
|
@Schema(description = "订单优惠(总)", required = true, example = "100")
|
||||||
private Integer discountPrice;
|
private Integer discountPrice;
|
||||||
|
@ -2,13 +2,8 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO.OrderItem;
|
|
||||||
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.order.*;
|
||||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum;
|
|
||||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderDeliveryStatusEnum;
|
|
||||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
|
|
||||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
@ -134,25 +129,15 @@ public class TradeOrderDO extends BaseDO {
|
|||||||
private String payChannelCode;
|
private String payChannelCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品原价(总),单位:分
|
* 商品原价,单位:分
|
||||||
*
|
*
|
||||||
* totalPrice = {@link TradeOrderItemDO#getPrice()} * {@link TradeOrderItemDO#getCount()} 求和
|
* totalPrice = {@link TradeOrderItemDO#getPrice()} * {@link TradeOrderItemDO#getCount()} 求和
|
||||||
*
|
*
|
||||||
* 对应 taobao 的 trade.total_fee 字段
|
* 对应 taobao 的 trade.total_fee 字段
|
||||||
*/
|
*/
|
||||||
private Integer totalPrice;
|
private Integer totalPrice;
|
||||||
// TODO 芋艿:是不是要删除这个字段?
|
|
||||||
/**
|
/**
|
||||||
* 订单原价(总),单位:分
|
* 优惠金额,单位:分
|
||||||
*
|
|
||||||
* 1. orderPrice = {@link OrderItem#getPayPrice()} 求和
|
|
||||||
* 2. orderPrice = {@link #totalPrice} - 商品级优惠
|
|
||||||
*/
|
|
||||||
private Integer orderPrice;
|
|
||||||
/**
|
|
||||||
* 订单优惠(总),单位:分
|
|
||||||
*
|
|
||||||
* 订单级优惠:对主订单的优惠,常见如:订单满 200 元减 10 元;订单满 80 包邮。
|
|
||||||
*
|
*
|
||||||
* 对应 taobao 的 order.discount_fee 字段
|
* 对应 taobao 的 order.discount_fee 字段
|
||||||
*/
|
*/
|
||||||
@ -162,7 +147,7 @@ public class TradeOrderDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer deliveryPrice;
|
private Integer deliveryPrice;
|
||||||
/**
|
/**
|
||||||
* 订单调价(总),单位:分
|
* 订单调价,单位:分
|
||||||
*
|
*
|
||||||
* 正数,加价;负数,减价
|
* 正数,加价;负数,减价
|
||||||
*/
|
*/
|
||||||
@ -170,11 +155,11 @@ public class TradeOrderDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 应付金额(总),单位:分
|
* 应付金额(总),单位:分
|
||||||
*
|
*
|
||||||
* = {@link OrderItem#getPayPrice()} 求和
|
* = {@link #totalPrice}
|
||||||
* - {@link #couponPrice}
|
* - {@link #couponPrice}
|
||||||
* - {@link #pointPrice}
|
* - {@link #pointPrice}
|
||||||
* + {@link #deliveryPrice}
|
|
||||||
* - {@link #discountPrice}
|
* - {@link #discountPrice}
|
||||||
|
* + {@link #deliveryPrice}
|
||||||
* + {@link #adjustPrice}
|
* + {@link #adjustPrice}
|
||||||
*/
|
*/
|
||||||
private Integer payPrice;
|
private Integer payPrice;
|
||||||
|
@ -102,44 +102,47 @@ public class TradeOrderItemDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer price;
|
private Integer price;
|
||||||
/**
|
/**
|
||||||
* 商品优惠(总),单位:分
|
* 优惠金额(总),单位:分
|
||||||
*
|
|
||||||
* 商品级优惠:对单个商品的,常见如:商品原价的 8 折;商品原价的减 50 元
|
|
||||||
*
|
*
|
||||||
* 对应 taobao 的 order.discount_fee 字段
|
* 对应 taobao 的 order.discount_fee 字段
|
||||||
*/
|
*/
|
||||||
private Integer discountPrice;
|
private Integer discountPrice;
|
||||||
/**
|
/**
|
||||||
* 子订单实付金额(总),不算主订单分摊金额,单位:分
|
* 运费金额(总),单位:分
|
||||||
|
*/
|
||||||
|
private Integer deliveryPrice;
|
||||||
|
/**
|
||||||
|
* 订单调价(总),单位:分
|
||||||
|
*
|
||||||
|
* 正数,加价;负数,减价
|
||||||
|
*/
|
||||||
|
private Integer adjustPrice;
|
||||||
|
/**
|
||||||
|
* 应付金额(总),单位:分
|
||||||
*
|
*
|
||||||
* = {@link #price} * {@link #count}
|
* = {@link #price} * {@link #count}
|
||||||
|
* - {@link #couponPrice}
|
||||||
|
* - {@link #pointPrice}
|
||||||
* - {@link #discountPrice}
|
* - {@link #discountPrice}
|
||||||
*
|
* + {@link #deliveryPrice}
|
||||||
* 对应 taobao 的 order.payment 字段
|
* + {@link #adjustPrice}
|
||||||
*/
|
*/
|
||||||
private Integer payPrice;
|
private Integer payPrice;
|
||||||
|
|
||||||
/**
|
|
||||||
* 子订单分摊金额(总),单位:分
|
|
||||||
* 需要分摊 {@link TradeOrderDO#getDiscountPrice()}、{@link TradeOrderDO#getCouponPrice()}、{@link TradeOrderDO#getPointPrice()}
|
|
||||||
*
|
|
||||||
* 对应 taobao 的 order.part_mjz_discount 字段
|
|
||||||
* 淘宝说明:子订单分摊优惠基础逻辑:一般正常优惠券和满减优惠按照子订单的金额进行分摊,特殊情况如果优惠券是指定商品使用的,只会分摊到对应商品子订单上不分摊。
|
|
||||||
*/
|
|
||||||
private Integer orderPartPrice;
|
|
||||||
/**
|
|
||||||
* 分摊后子订单实付金额(总),单位:分
|
|
||||||
*
|
|
||||||
* = {@link #payPrice}
|
|
||||||
* - {@link #orderPartPrice}
|
|
||||||
*
|
|
||||||
* 对应 taobao 的 divide_order_fee 字段
|
|
||||||
*/
|
|
||||||
private Integer orderDividePrice;
|
|
||||||
|
|
||||||
// ========== 营销基本信息 ==========
|
// ========== 营销基本信息 ==========
|
||||||
|
|
||||||
// TODO 芋艿:在捉摸一下
|
/**
|
||||||
|
* 优惠劵减免金额,单位:分
|
||||||
|
*
|
||||||
|
* 对应 taobao 的 trade.coupon_fee 字段
|
||||||
|
*/
|
||||||
|
private Integer couponPrice;
|
||||||
|
/**
|
||||||
|
* 积分抵扣的金额,单位:分
|
||||||
|
*
|
||||||
|
* 对应 taobao 的 trade.point_fee 字段
|
||||||
|
*/
|
||||||
|
private Integer pointPrice;
|
||||||
|
|
||||||
// ========== 售后基本信息 ==========
|
// ========== 售后基本信息 ==========
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +97,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 申请的退款金额,不能超过商品的价格
|
// 申请的退款金额,不能超过商品的价格
|
||||||
if (createReqVO.getRefundPrice() > orderItem.getOrderDividePrice()) {
|
if (createReqVO.getRefundPrice() > orderItem.getPayPrice()) {
|
||||||
throw exception(AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR);
|
throw exception(AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
|
|||||||
.setSpuId(21L).setSkuId(2L).setCount(4).setOriginalPrice(80).setOriginalUnitPrice(20)
|
.setSpuId(21L).setSkuId(2L).setCount(4).setOriginalPrice(80).setOriginalUnitPrice(20)
|
||||||
.setDiscountPrice(40).setPayPrice(40).setOrderPartPrice(15).setOrderDividePrice(25);
|
.setDiscountPrice(40).setPayPrice(40).setOrderPartPrice(15).setOrderDividePrice(25);
|
||||||
PriceCalculateRespDTO.Order priceOrder = new PriceCalculateRespDTO.Order()
|
PriceCalculateRespDTO.Order priceOrder = new PriceCalculateRespDTO.Order()
|
||||||
.setOriginalPrice(230).setOrderPrice(100).setDiscountPrice(0).setCouponPrice(30)
|
.setTotalPrice(230).setDiscountPrice(0).setCouponPrice(30)
|
||||||
.setPointPrice(10).setDeliveryPrice(20).setPayPrice(80).setCouponId(101L).setCouponPrice(30)
|
.setPointPrice(10).setDeliveryPrice(20).setPayPrice(80).setCouponId(101L).setCouponPrice(30)
|
||||||
.setItems(Arrays.asList(priceOrderItem01, priceOrderItem02));
|
.setItems(Arrays.asList(priceOrderItem01, priceOrderItem02));
|
||||||
when(priceApi.calculatePrice(argThat(priceCalculateReqDTO -> {
|
when(priceApi.calculatePrice(argThat(priceCalculateReqDTO -> {
|
||||||
@ -170,7 +170,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
|
|||||||
assertFalse(tradeOrderDO.getPayed());
|
assertFalse(tradeOrderDO.getPayed());
|
||||||
assertNull(tradeOrderDO.getPayTime());
|
assertNull(tradeOrderDO.getPayTime());
|
||||||
assertEquals(tradeOrderDO.getTotalPrice(), 230);
|
assertEquals(tradeOrderDO.getTotalPrice(), 230);
|
||||||
assertEquals(tradeOrderDO.getOrderPrice(), 100);
|
|
||||||
assertEquals(tradeOrderDO.getDiscountPrice(), 0);
|
assertEquals(tradeOrderDO.getDiscountPrice(), 0);
|
||||||
assertEquals(tradeOrderDO.getAdjustPrice(), 0);
|
assertEquals(tradeOrderDO.getAdjustPrice(), 0);
|
||||||
assertEquals(tradeOrderDO.getPayPrice(), 80);
|
assertEquals(tradeOrderDO.getPayPrice(), 80);
|
||||||
@ -208,8 +207,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
|
|||||||
assertEquals(tradeOrderItemDO01.getPrice(), 50);
|
assertEquals(tradeOrderItemDO01.getPrice(), 50);
|
||||||
assertEquals(tradeOrderItemDO01.getDiscountPrice(), 20);
|
assertEquals(tradeOrderItemDO01.getDiscountPrice(), 20);
|
||||||
assertEquals(tradeOrderItemDO01.getPayPrice(), 130);
|
assertEquals(tradeOrderItemDO01.getPayPrice(), 130);
|
||||||
assertEquals(tradeOrderItemDO01.getOrderPartPrice(), 7);
|
|
||||||
assertEquals(tradeOrderItemDO01.getOrderDividePrice(), 35);
|
|
||||||
assertEquals(tradeOrderItemDO01.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
assertEquals(tradeOrderItemDO01.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||||
// 断言 TradeOrderItemDO 订单(第 2 个)
|
// 断言 TradeOrderItemDO 订单(第 2 个)
|
||||||
TradeOrderItemDO tradeOrderItemDO02 = tradeOrderItemDOs.get(1);
|
TradeOrderItemDO tradeOrderItemDO02 = tradeOrderItemDOs.get(1);
|
||||||
@ -228,8 +225,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
|
|||||||
assertEquals(tradeOrderItemDO02.getPrice(), 20);
|
assertEquals(tradeOrderItemDO02.getPrice(), 20);
|
||||||
assertEquals(tradeOrderItemDO02.getDiscountPrice(), 40);
|
assertEquals(tradeOrderItemDO02.getDiscountPrice(), 40);
|
||||||
assertEquals(tradeOrderItemDO02.getPayPrice(), 40);
|
assertEquals(tradeOrderItemDO02.getPayPrice(), 40);
|
||||||
assertEquals(tradeOrderItemDO02.getOrderPartPrice(), 15);
|
|
||||||
assertEquals(tradeOrderItemDO02.getOrderDividePrice(), 25);
|
|
||||||
assertEquals(tradeOrderItemDO02.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
assertEquals(tradeOrderItemDO02.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||||
// 校验调用
|
// 校验调用
|
||||||
verify(productSkuApi).updateSkuStock(argThat(updateStockReqDTO -> {
|
verify(productSkuApi).updateSkuStock(argThat(updateStockReqDTO -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user