Bladeren bron

修改虚拟商品的金额精度

Yangzw 9 maanden geleden
bovenliggende
commit
759abf9796

+ 6 - 0
feifan-module-mall/feifan-module-product-api/src/main/java/cn/newfeifan/mall/module/product/api/sku/dto/ProductSkuRespDTO.java

@@ -3,6 +3,7 @@ package cn.newfeifan.mall.module.product.api.sku.dto;
 import cn.newfeifan.mall.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -76,4 +77,9 @@ public class ProductSkuRespDTO {
      */
     private Integer secondBrokeragePrice;
 
+    /**
+     * 高精度价格
+     */
+    private BigDecimal highPrecisionPrice;
+
 }

+ 11 - 4
feifan-module-mall/feifan-module-product-api/src/main/java/cn/newfeifan/mall/module/product/api/spu/dto/ProductSpuRespDTO.java

@@ -3,6 +3,8 @@ package cn.newfeifan.mall.module.product.api.spu.dto;
 import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 // TODO @LeeYan9: ProductSpuRespDTO
 /**
  * 商品 SPU 信息 Response DTO
@@ -26,7 +28,6 @@ public class ProductSpuRespDTO {
     private String name;
     /**
      * 单位
-     *
      * 对应 product_unit 数据字典
      */
     private Integer unit;
@@ -51,7 +52,6 @@ public class ProductSpuRespDTO {
 
     /**
      * 规格类型
-     *
      * false - 单规格
      * true - 多规格
      */
@@ -77,7 +77,6 @@ public class ProductSpuRespDTO {
 
     /**
      * 物流配置模板编号
-     *
      * 对应 TradeDeliveryExpressTemplateDO 的 id 编号
      */
     private Long deliveryTemplateId;
@@ -93,10 +92,18 @@ public class ProductSpuRespDTO {
 
     /**
      * 分销类型
-     *
      * false - 默认
      * true - 自行设置
      */
     private Boolean subCommissionType;
 
+    /**
+     * 高精度
+     */
+    private Boolean highPrecision;
+    /**
+     * 高精度价格
+     */
+    private BigDecimal highPrecisionPrice;
+
 }

+ 10 - 7
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/price/calculator/TradePriceCalculatorHelper.java

@@ -4,7 +4,6 @@ import cn.hutool.core.lang.Assert;
 import cn.newfeifan.mall.framework.common.util.collection.CollectionUtils;
 import cn.newfeifan.mall.module.product.api.sku.dto.ProductSkuRespDTO;
 import cn.newfeifan.mall.module.product.api.spu.dto.ProductSpuRespDTO;
-import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO;
 import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderItemDO;
 import cn.newfeifan.mall.module.trade.enums.order.TradeOrderTypeEnum;
 import cn.newfeifan.mall.module.trade.service.price.bo.TradePriceCalculateReqBO;
@@ -20,7 +19,6 @@ import static java.util.Collections.singletonList;
 
 /**
  * {@link TradePriceCalculator} 的工具类
- *
  * 主要实现对 {@link TradePriceCalculateRespBO} 计算结果的操作
  *
  * @author 非繁源码
@@ -50,11 +48,18 @@ public class TradePriceCalculatorHelper {
             // 商品项
             TradePriceCalculateRespBO.OrderItem orderItem = new TradePriceCalculateRespBO.OrderItem();
             result.getItems().add(orderItem);
+
+            // sku 价格
+            if(!spu.getHighPrecision()){
+                orderItem.setPrice(sku.getPrice()).setPayPrice(sku.getPrice() * item.getCount())
+                        .setDiscountPrice(0).setDeliveryPrice(0).setCouponPrice(0).setPointPrice(0).setVipPrice(0);
+            }else{
+                orderItem.setPrice(sku.getHighPrecisionPrice().intValue()).setPayPrice((int)(sku.getHighPrecisionPrice().doubleValue() * item.getCount()))
+                        .setDiscountPrice(0).setDeliveryPrice(0).setCouponPrice(0).setPointPrice(0).setVipPrice(0);
+            }
+
             orderItem.setSpuId(sku.getSpuId()).setSkuId(sku.getId())
                     .setCount(item.getCount()).setCartId(item.getCartId()).setSelected(item.getSelected());
-            // sku 价格
-            orderItem.setPrice(sku.getPrice()).setPayPrice(sku.getPrice() * item.getCount())
-                    .setDiscountPrice(0).setDeliveryPrice(0).setCouponPrice(0).setPointPrice(0).setVipPrice(0);
             // sku 信息
             orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties())
                     .setWeight(sku.getWeight()).setVolume(sku.getVolume());
@@ -145,7 +150,6 @@ public class TradePriceCalculatorHelper {
 
     /**
      * 重新计算每个订单项的支付金额
-     *
      * 【目前主要是单测使用】
      *
      * @param orderItems 订单项数组
@@ -249,7 +253,6 @@ public class TradePriceCalculatorHelper {
 
     /**
      * 计算订单调价价格分摊
-     *
      * 和 {@link #dividePrice(List, Integer)} 逻辑一致,只是传入的是 TradeOrderItemDO 对象
      *
      * @param items         订单项