|
@@ -4,6 +4,10 @@ import cn.newfeifan.mall.module.product.api.sku.ProductSkuApi;
|
|
|
import cn.newfeifan.mall.module.product.api.sku.dto.ProductSkuRespDTO;
|
|
|
import cn.newfeifan.mall.module.product.api.spu.ProductSpuApi;
|
|
|
import cn.newfeifan.mall.module.product.api.spu.dto.ProductSpuRespDTO;
|
|
|
+import cn.newfeifan.mall.module.product.dal.dataobject.sku.ProductSkuDO;
|
|
|
+import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
|
|
|
+import cn.newfeifan.mall.module.product.dal.mysql.sku.ProductSkuMapper;
|
|
|
+import cn.newfeifan.mall.module.product.dal.mysql.spu.ProductSpuMapper;
|
|
|
import cn.newfeifan.mall.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
|
|
import cn.newfeifan.mall.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
|
|
import cn.newfeifan.mall.module.trade.service.price.calculator.TradeDeliveryPriceCalculator;
|
|
@@ -42,6 +46,11 @@ public class TradePriceServiceImpl implements TradePriceService {
|
|
|
@Resource
|
|
|
private List<TradePriceCalculator> priceCalculators;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ProductSkuMapper productSkuMapper;
|
|
|
+ @Resource
|
|
|
+ private ProductSpuMapper productSpuMapper;
|
|
|
+
|
|
|
/**
|
|
|
* add by Ben
|
|
|
* 计算订单含积分的各项商品价格
|
|
@@ -77,9 +86,9 @@ public class TradePriceServiceImpl implements TradePriceService {
|
|
|
// priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO));
|
|
|
//计算运费
|
|
|
TradeDeliveryPriceCalculator tradeDeliveryPriceCalculator = null;
|
|
|
- for(TradePriceCalculator tpc:priceCalculators){
|
|
|
+ for (TradePriceCalculator tpc : priceCalculators) {
|
|
|
//把计算运费对象取出来,这个对象不能new,因为自己new会缺少地址信息
|
|
|
- if(tpc.getClass().getName().equals("cn.newfeifan.mall.module.trade.service.price.calculator.TradeDeliveryPriceCalculator")){
|
|
|
+ if (tpc.getClass().getName().equals("cn.newfeifan.mall.module.trade.service.price.calculator.TradeDeliveryPriceCalculator")) {
|
|
|
tradeDeliveryPriceCalculator = (TradeDeliveryPriceCalculator) tpc;
|
|
|
break;
|
|
|
}
|
|
@@ -88,10 +97,14 @@ public class TradePriceServiceImpl implements TradePriceService {
|
|
|
tradeDeliveryPriceCalculator.calculate(calculateReqBO, calculateRespBO);
|
|
|
|
|
|
// 2.2 如果最终支付金额小于等于 0,则抛出业务异常
|
|
|
- if (calculateRespBO.getPrice().getPayPrice() <= 0) {
|
|
|
- log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]",
|
|
|
- calculateReqBO, calculateRespBO);
|
|
|
- throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL);
|
|
|
+ ProductSkuDO sku = productSkuMapper.selectById(calculateReqBO.getItems().get(0).getSkuId());
|
|
|
+ ProductSpuDO spu = productSpuMapper.selectById(sku.getSpuId());
|
|
|
+ if (!spu.getHighPrecision()) {
|
|
|
+ if (calculateRespBO.getPrice().getPayPrice() <= 0) {
|
|
|
+ log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]",
|
|
|
+ calculateReqBO, calculateRespBO);
|
|
|
+ throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL);
|
|
|
+ }
|
|
|
}
|
|
|
return calculateRespBO;
|
|
|
}
|