Browse Source

Merge remote-tracking branch 'origin/developerC' into developerC

Aslee 3 năm trước cách đây
mục cha
commit
d6f4e3ca98

+ 4 - 0
src/main/java/com/caimei365/order/model/po/OrderProductPo.java

@@ -16,6 +16,10 @@ import java.util.List;
 @Data
 public class OrderProductPo implements Serializable {
     private static final long serialVersionUID = 1L;
+    /**
+     * 不包含单品满减的商品金额
+     */
+    private Double realProductFee;
     /**
      * 商品Id
      */

+ 4 - 1
src/main/java/com/caimei365/order/model/po/OrderShopPo.java

@@ -13,7 +13,10 @@ import java.io.Serializable;
 @Data
 public class OrderShopPo implements Serializable {
     private static final long serialVersionUID = 1L;
-
+    /**
+     * 虚拟字段,不包含店铺满减的子订单应付
+     */
+    private Double realNeedPay;
     /**
      * 均摊优惠
      */

+ 16 - 5
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -440,6 +440,8 @@ public class SubmitServiceImpl implements SubmitService {
             AtomicDouble brokerage = new AtomicDouble(0);
             // 需要支付金额
             AtomicDouble needPayAmount = new AtomicDouble(0);
+            // 不包含店铺满减的子订单应付
+            AtomicDouble realNeedPay = new AtomicDouble(0);
             // 商品总金额
             AtomicDouble shopAmount = new AtomicDouble(0);
             // 付供应商 商品费
@@ -623,6 +625,8 @@ public class SubmitServiceImpl implements SubmitService {
                     Double productAmount = MathUtil.mul(productTaxPrice, productNum).doubleValue();
                     // 单个商品的折后金额
                     Double productFee = MathUtil.mul(discountTaxPrice, productNum).doubleValue();
+                    // 不包含单品满减的商品金额
+                    Double realProductFee = productFee;
                     // 单个商品总税费
                     Double taxFee = MathUtil.mul(discountTax, productNum).doubleValue();
                     if (hasActProductFlag && null != promotions) {
@@ -692,6 +696,7 @@ public class SubmitServiceImpl implements SubmitService {
                     // 单个商品的折后金额
                     product.setTotalFee(productFee);
                     product.setShouldPayFee(productFee);
+                    product.setRealProductFee(realProductFee);
                     // 税费
                     product.setAddedValueTax(discountTax);
                     product.setTotalAddedValueTax(taxFee);
@@ -767,6 +772,8 @@ public class SubmitServiceImpl implements SubmitService {
                 brokerage.set(MathUtil.add(brokerage.get(), product.getCmFee()).doubleValue());
                 // 需要支付金额 shouldPayFee +运费
                 needPayAmount.set(MathUtil.add(needPayAmount.get(), product.getShouldPayFee()).doubleValue());
+                // 不包含单品满减的子订单需付金额
+                realNeedPay.set(MathUtil.add(realNeedPay.get(),product.getRealProductFee()).doubleValue());
                 // 统计 总金额 包括税费
                 shopProductFee.set(MathUtil.add(shopProductFee.get(), product.getTotalFee()).doubleValue());
                 // 统计子订单内可参与店铺促销的商品总金额
@@ -847,6 +854,8 @@ public class SubmitServiceImpl implements SubmitService {
             shopOrder.setProductAmount(shopAmount.get());
             // 需要支付金额 shouldPayFee +运费
             shopOrder.setNeedPayAmount(needPayAmount.get());
+            // 设值
+            shopOrder.setRealNeedPay(realNeedPay.get());
             // 付供应商 商品费=成本价*(购买数量  + 赠品数量)
             shopOrder.setShopProductAmount(shopProductAmount.get());
             // 付给供应商税费
@@ -1092,7 +1101,6 @@ public class SubmitServiceImpl implements SubmitService {
         if (onlinePay.get()) {
             //在店铺满减算完之后重新根据商品的splitCode排shopOrderList
             List<OrderShopPo> shops = submitMapper.findShops(productIdList);
-            log.info("线上供应商splitcode----------->"+shops.toString());
             //子订单分多子订单,满减分摊到原子订单分开的子订单,无满减重算佣金/应付
             //重组订单
             shopOrderList= findSplitShopOrder(orderProductList, shopOrderList, shops, orderParamBo);
@@ -1102,7 +1110,7 @@ public class SubmitServiceImpl implements SubmitService {
             double allDiscount = MathUtil.add(couponAmount, promotionFullReduction.get()).doubleValue();
             // 分摊优惠前总佣金
             AtomicDouble oldBrokerage = new AtomicDouble(0);
-            //超级会员价/复购价/阶梯价/促销活动冲突,只能生效一个,促销活动满减计入优惠分摊,子订单售价=NeedPayAmount+promotionFullReduction
+            //超级会员价/复购价/阶梯价/促销活动冲突,只能生效一个,促销活动满减计入优惠分摊,子订单售价=realNeedPay+promotionFullReduction
             shopOrderList.forEach(orderShopPo -> {
                 orderShopPo.setOldPrice(orderShopPo.getNeedPayAmount());
                 orderShopPo.setOldBrokerage(orderShopPo.getBrokerage());
@@ -1142,7 +1150,7 @@ public class SubmitServiceImpl implements SubmitService {
             } else {
                 //无优惠金额
                 shopOrderList.forEach(so -> {
-                    double realPay = so.getNeedPayAmount();
+                    double realPay = so.getRealNeedPay();
                     so.setRealPay(realPay);
                     so.setEachDiscount(0d);
                     double charge = MathUtil.mul(realPay, 0.0065, 2).doubleValue() > 10 ? MathUtil.mul(realPay, 0.0065, 2).doubleValue() : 10;
@@ -1628,6 +1636,8 @@ public class SubmitServiceImpl implements SubmitService {
         //统计拆分的shop
         //List<OrderShopPo> collect = shops.stream().filter(s -> shops.stream().filter(so -> so.getShopId().equals(s.getShopId())).count() > 1).collect(Collectors.toList());
         //对拆分的shop重新计算子订单佣金,应付,不计入店铺满减
+        log.info("原shoporderlist--------------------》"+shopOrderList);
+        log.info("原orderproductlist--------------------》"+orderProductList);
         ArrayList<OrderShopPo> orderShopPos = new ArrayList<>();
         for (OrderShopPo shop : shops) {
             // 供应商名称
@@ -1677,9 +1687,9 @@ public class SubmitServiceImpl implements SubmitService {
                 // 佣金 = 应付采美
                 brokerage.set(MathUtil.add(brokerage.get(), product.getCmFee()).doubleValue());
                 // 需要支付金额 shouldPayFee +运费
-                needPayAmount.set(MathUtil.add(needPayAmount.get(), product.getShouldPayFee()).doubleValue());
+                needPayAmount.set(MathUtil.add(needPayAmount.get(), product.getRealProductFee()).doubleValue());
                 // 统计 总金额 包括税费
-                shopProductFee.set(MathUtil.add(shopProductFee.get(), product.getTotalFee()).doubleValue());
+                shopProductFee.set(MathUtil.add(shopProductFee.get(), product.getRealProductFee()).doubleValue());
                 // 商品总金额
                 shopAmount.set(MathUtil.add(shopAmount.get(), product.getTotalAmount()).doubleValue());
                 // 付供应商 商品费
@@ -1721,6 +1731,7 @@ public class SubmitServiceImpl implements SubmitService {
             }
             orderShopPos.add(shopOrder);
         }
+        log.info("ordershops------------------->"+orderShopPos);
         return orderShopPos;
     }