暂存调整 Price 接口

This commit is contained in:
YunaiV
2022-10-28 22:44:12 +08:00
parent e1d5cfe8fe
commit 5c4b61f5ff
5 changed files with 61 additions and 48 deletions

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;
}