暂存调整 Price 接口

pull/2/head
YunaiV 2022-10-28 22:44:12 +08:00
parent e1d5cfe8fe
commit 5c4b61f5ff
5 changed files with 61 additions and 48 deletions

View File

@ -35,34 +35,43 @@ public class PriceCalculateRespDTO {
/**
*
*
* {@link OrderItem#getTotalOriginalPrice()}
* {@link OrderItem#getOriginalPrice()}
*/
private Integer skuOriginalPrice;
private Integer originalPrice;
/**
*
*
*
* {@link OrderItem#getTotalPromotionPrice()}
* {@link OrderItem#getActivityPrice()}
*/
private Integer skuPromotionPrice;
private Integer activityPrice;
/**
*
*
*
*
* {@link OrderItem#getCouponPrice()}
*/
private Integer orderPromotionPrice;
private Integer couponPrice;
/**
*
*
* {@link OrderItem#getPointPrice()}
*/
private Integer pointPrice;
/**
*
*
* {@link OrderItem#getMemberPrice()}
*/
private Integer memberPrice;
/**
*
*/
private Integer deliveryPrice;
/**
*
*
*
* = {@link #skuOriginalPrice}
* = {@link OrderItem#getPayPrice()}
* + {@link #deliveryPrice}
* - {@link #skuPromotionPrice}
* - {@link #orderPromotionPrice}
*/
// * - {@link #couponPrice} // TODO 芋艿:靠营销表记录
private Integer payPrice;
/**
* SKU
@ -74,12 +83,6 @@ public class PriceCalculateRespDTO {
*
*/
private Long couponId;
// /**
// * 优惠劵减免金额,单位:分
// *
// * // TODO 芋艿:靠营销表记录
// */
// private Integer couponPrice;
}
@ -94,41 +97,54 @@ public class PriceCalculateRespDTO {
*/
private Integer count;
/**
*
*
* = {@link #originalUnitPrice} * {@link #getCount()}
*/
private Integer originalPrice;
/**
*
*
* ProductSkuDO price
*/
private Integer originalPrice;
private Integer originalUnitPrice;
/**
*
*
*
* = {@link #originalPrice} * {@link #getCount()}
*
*/
private Integer totalOriginalPrice;
private Integer activityPrice;
/**
*
*
*
* 8 50
* SKU {@link #payPrice}
*/
private Integer totalPromotionPrice;
private Integer couponPrice;
/**
*
*/
private Integer pointPrice;
/**
*
*/
private Integer memberPrice;
/**
*
*
* = {@link #totalOriginalPrice}
* - {@link #totalPromotionPrice}
* = {@link #originalPrice}
* - {@link #activityPrice}
* - {@link #couponPrice}
* - {@link #pointPrice}
* - {@link #memberPrice}
*/
private Integer totalPresentPrice;
private Integer payPrice;
/**
*
*
* = {@link #totalPresentPrice} / {@link #getCount()}
* = {@link #payPrice} / {@link #getCount()}
*/
private Integer presentPrice;
/**
*
*/
private Integer totalPayPrice;
private Integer payUnitPrice;
}

View File

@ -15,8 +15,8 @@ import java.util.Arrays;
@AllArgsConstructor
public enum PromotionLevelEnum implements IntArrayValuable {
ORDER(1, "订单级"),
SKU(2, "商品级"),
ORDER(1, "订单级"), // 多个商品,进行组合后优惠
SKU(2, "商品级"), // 单个商品,直接优惠
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionLevelEnum::getLevel).toArray();

View File

@ -15,8 +15,8 @@ import java.util.Arrays;
@AllArgsConstructor
public enum PromotionTypeEnum implements IntArrayValuable {
DISCOUNT(1, "限时折扣"),
REWARD(2, "满减送"),
DISCOUNT_ACTIVITY(1, "限时折扣"),
REWARD_ACTIVITY(2, "满减送"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray();

View File

@ -19,8 +19,8 @@ public interface PriceConvert {
default PriceCalculateRespDTO convert(PriceCalculateReqDTO calculateReqDTO, List<ProductSkuRespDTO> skuList) {
// 创建 PriceCalculateRespDTO 对象
PriceCalculateRespDTO priceCalculate = new PriceCalculateRespDTO();
priceCalculate.setOrder(new PriceCalculateRespDTO.Order().setSkuOriginalPrice(0).setSkuPromotionPrice(0)
.setOrderPromotionPrice(0).setDeliveryPrice(0).setPayPrice(0).setItems(new ArrayList<>())
priceCalculate.setOrder(new PriceCalculateRespDTO.Order().setOriginalPrice(0).setActivityPrice(0)
.setDeliveryPrice(0).setPayPrice(0).setItems(new ArrayList<>())
.setCouponId(calculateReqDTO.getCouponId()));
priceCalculate.setPromotions(new ArrayList<>());
// 创建它的 OrderItem 属性
@ -29,9 +29,9 @@ public interface PriceConvert {
skuList.forEach(sku -> {
Integer count = skuIdCountMap.get(sku.getId());
PriceCalculateRespDTO.OrderItem orderItem = new PriceCalculateRespDTO.OrderItem().setCount(count)
.setOriginalPrice(sku.getPrice()).setTotalOriginalPrice(sku.getPrice() * count).setTotalPromotionPrice(0);
orderItem.setTotalPresentPrice(orderItem.getTotalPresentPrice()).setPresentPrice(orderItem.getOriginalPrice())
.setTotalPayPrice(orderItem.getTotalPayPrice());
.setOriginalUnitPrice(sku.getPrice()).setOriginalPrice(sku.getPrice() * count).setActivityPrice(0);
orderItem.setPayPrice(orderItem.getPayPrice()).setPayUnitPrice(orderItem.getOriginalUnitPrice())
.setPayPrice(orderItem.getPayPrice());
priceCalculate.getOrder().getItems().add(orderItem);
});
return priceCalculate;

View File

@ -15,7 +15,6 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH;
/**
* Service
@ -54,9 +53,7 @@ public class PriceServiceImpl implements PriceService {
if (count == null) {
throw exception(SKU_NOT_EXISTS);
}
if (count > sku.getStock()) {
throw exception(SKU_STOCK_NOT_ENOUGH);
}
// 不校验库存不足,避免购物车场景,商品无货的情况
});
return skus;
}