Browse Source

初始付供应商成本

huangzhiguo 1 year ago
parent
commit
7a2996e0a7

+ 17 - 0
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -623,6 +623,8 @@ public class SubmitServiceImpl implements SubmitService {
                 product.setSvipReduction(0d);
                 product.setSvipReduction(0d);
                 // 组织信息
                 // 组织信息
                 product.setOrganizeId(organizeId);
                 product.setOrganizeId(organizeId);
+                // 商品原始售价
+                Double productCostPrice = null;
 
 
                 // 超级会员优惠商品详情
                 // 超级会员优惠商品详情
                 SvipProductPo svipProductPo = submitMapper.getSvipProductDetails(product.getSkuId());
                 SvipProductPo svipProductPo = submitMapper.getSvipProductDetails(product.getSkuId());
@@ -633,6 +635,7 @@ public class SubmitServiceImpl implements SubmitService {
                     // 促销赠品计算商品费
                     // 促销赠品计算商品费
                     Double productPrice = product.getPrice();
                     Double productPrice = product.getPrice();
                     Double discountPrice = product.getPrice();
                     Double discountPrice = product.getPrice();
+                    productCostPrice = product.getPrice();
                     // 商品税费
                     // 商品税费
                     Double productTax = 0d;
                     Double productTax = 0d;
                     Double discountTax = 0d;
                     Double discountTax = 0d;
@@ -676,6 +679,7 @@ public class SubmitServiceImpl implements SubmitService {
                     Double productPrice = product.getPrice();
                     Double productPrice = product.getPrice();
                     Double itemPrice = product.getPrice();
                     Double itemPrice = product.getPrice();
                     Double discountPrice = product.getPrice();
                     Double discountPrice = product.getPrice();
+                    productCostPrice = product.getPrice();
                     // 商品税费
                     // 商品税费
                     Double productTax = 0d;
                     Double productTax = 0d;
                     Double discountTax = 0d;
                     Double discountTax = 0d;
@@ -897,6 +901,8 @@ public class SubmitServiceImpl implements SubmitService {
 
 
                 // 成本价
                 // 成本价
                 Double costPrice = null;
                 Double costPrice = null;
+                // 成本价 不含税
+                Double costPriceTax = null;
                 /**
                 /**
                  * 判断是否选中固定成本价
                  * 判断是否选中固定成本价
                  * 固定成本、比例成本都需要计算税费
                  * 固定成本、比例成本都需要计算税费
@@ -908,6 +914,7 @@ public class SubmitServiceImpl implements SubmitService {
                         costTax = MathUtil.div(MathUtil.mul(product.getCostPrice(), product.getTaxRate()), 100, 2).doubleValue();
                         costTax = MathUtil.div(MathUtil.mul(product.getCostPrice(), product.getTaxRate()), 100, 2).doubleValue();
                     }
                     }
                     costPrice = MathUtil.add(product.getCostPrice(), costTax).doubleValue();
                     costPrice = MathUtil.add(product.getCostPrice(), costTax).doubleValue();
+                    costPriceTax = product.getCostPrice();
                 }
                 }
                 // 判断是否选中比例成本价
                 // 判断是否选中比例成本价
                 if (null != product.getCostProportional() && 2 == product.getCostCheckFlag() && product.getCostProportional() > 0d) {
                 if (null != product.getCostProportional() && 2 == product.getCostCheckFlag() && product.getCostProportional() > 0d) {
@@ -917,11 +924,13 @@ public class SubmitServiceImpl implements SubmitService {
                         discountTax = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getTaxRate()), 100, 2).doubleValue();
                         discountTax = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getTaxRate()), 100, 2).doubleValue();
                     }*/
                     }*/
                     costPrice = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getCostProportional()), 100, 2).doubleValue();
                     costPrice = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getCostProportional()), 100, 2).doubleValue();
+                    costPriceTax = MathUtil.div(MathUtil.mul(productCostPrice, product.getCostProportional()), 100, 2).doubleValue();
                 }
                 }
                 if (null == costPrice) {
                 if (null == costPrice) {
                     return ResponseJson.error("订单商品成本异常!", null);
                     return ResponseJson.error("订单商品成本异常!", null);
                 }
                 }
                 product.setCostPrice(costPrice);
                 product.setCostPrice(costPrice);
+                product.setCostPriceTax(costPriceTax);
                 // 促销赠品 售价归 0
                 // 促销赠品 售价归 0
                 if (productType == 2) {
                 if (productType == 2) {
                     product.setPrice(0d);
                     product.setPrice(0d);
@@ -2352,6 +2361,7 @@ public class SubmitServiceImpl implements SubmitService {
 
 
             // 成本价
             // 成本价
             Double costPrice = null;
             Double costPrice = null;
+            Double costPriceTax = null;
             // 判断是否选中固定成本价
             // 判断是否选中固定成本价
             if (null != product.getCostPrice() && 1 == product.getCostCheckFlag() && product.getCostPrice() >= 0d) {
             if (null != product.getCostPrice() && 1 == product.getCostCheckFlag() && product.getCostPrice() >= 0d) {
                 // 通过售价*比例得到成本价
                 // 通过售价*比例得到成本价
@@ -2360,6 +2370,7 @@ public class SubmitServiceImpl implements SubmitService {
                     costTax = MathUtil.div(MathUtil.mul(product.getCostPrice(), product.getTaxRate()), 100, 2).doubleValue();
                     costTax = MathUtil.div(MathUtil.mul(product.getCostPrice(), product.getTaxRate()), 100, 2).doubleValue();
                 }
                 }
                 costPrice = MathUtil.add(product.getCostPrice(), costTax).doubleValue();
                 costPrice = MathUtil.add(product.getCostPrice(), costTax).doubleValue();
+                costPriceTax = product.getCostPrice();
             }
             }
             // 判断是否选中比例成本价
             // 判断是否选中比例成本价
             if (null != product.getCostProportional() && 2 == product.getCostCheckFlag() && product.getCostProportional() > 0d) {
             if (null != product.getCostProportional() && 2 == product.getCostCheckFlag() && product.getCostProportional() > 0d) {
@@ -2369,11 +2380,13 @@ public class SubmitServiceImpl implements SubmitService {
                     discountTax = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getTaxRate()), 100, 2).doubleValue();
                     discountTax = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getTaxRate()), 100, 2).doubleValue();
                 }
                 }
                 costPrice = MathUtil.div(MathUtil.mul(MathUtil.add(product.getDiscountPrice(), discountTax), product.getCostProportional()), 100, 2).doubleValue();
                 costPrice = MathUtil.div(MathUtil.mul(MathUtil.add(product.getDiscountPrice(), discountTax), product.getCostProportional()), 100, 2).doubleValue();
+                costPriceTax = MathUtil.div(MathUtil.mul(orderProduct.getPrice(), product.getCostProportional()), 100, 2).doubleValue();
             }
             }
             if (null == costPrice) {
             if (null == costPrice) {
                 return ResponseJson.error("订单商品成本异常!", null);
                 return ResponseJson.error("订单商品成本异常!", null);
             }
             }
             product.setCostPrice(costPrice);
             product.setCostPrice(costPrice);
+            product.setCostPriceTax(costPriceTax);
             // 付供应商税费
             // 付供应商税费
             if (null == product.getShopTaxRate() || product.getShopTaxRate() <= 0) {
             if (null == product.getShopTaxRate() || product.getShopTaxRate() <= 0) {
                 product.setShopTaxRate(product.getTaxRate());
                 product.setShopTaxRate(product.getTaxRate());
@@ -2965,6 +2978,7 @@ public class SubmitServiceImpl implements SubmitService {
 
 
                 // 成本价
                 // 成本价
                 Double costPrice = null;
                 Double costPrice = null;
+                Double costPriceTax = null;
                 /**
                 /**
                  * 判断是否选中固定成本价
                  * 判断是否选中固定成本价
                  * 固定成本、比例成本都需要计算税费
                  * 固定成本、比例成本都需要计算税费
@@ -2976,6 +2990,7 @@ public class SubmitServiceImpl implements SubmitService {
                         costTax = MathUtil.div(MathUtil.mul(product.getCostPrice(), product.getTaxRate()), 100, 2).doubleValue();
                         costTax = MathUtil.div(MathUtil.mul(product.getCostPrice(), product.getTaxRate()), 100, 2).doubleValue();
                     }
                     }
                     costPrice = MathUtil.add(product.getCostPrice(), costTax).doubleValue();
                     costPrice = MathUtil.add(product.getCostPrice(), costTax).doubleValue();
+                    costPriceTax = product.getCostPrice();
                 }
                 }
                 // 判断是否选中比例成本价
                 // 判断是否选中比例成本价
                 if (null != product.getCostProportional() && 2 == product.getCostCheckFlag() && product.getCostProportional() > 0d) {
                 if (null != product.getCostProportional() && 2 == product.getCostCheckFlag() && product.getCostProportional() > 0d) {
@@ -2985,11 +3000,13 @@ public class SubmitServiceImpl implements SubmitService {
                         discountTax = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getTaxRate()), 100, 2).doubleValue();
                         discountTax = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getTaxRate()), 100, 2).doubleValue();
                     }*/
                     }*/
                     costPrice = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getCostProportional()), 100, 2).doubleValue();
                     costPrice = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getCostProportional()), 100, 2).doubleValue();
+                    costPriceTax = MathUtil.div(MathUtil.mul(price, product.getCostProportional()), 100, 2).doubleValue();
                 }
                 }
                 if (null == costPrice) {
                 if (null == costPrice) {
                     return ResponseJson.error("订单商品成本异常!", null);
                     return ResponseJson.error("订单商品成本异常!", null);
                 }
                 }
                 product.setCostPrice(costPrice);
                 product.setCostPrice(costPrice);
+                product.setCostPriceTax(costPriceTax);
                 // 付供应商税费
                 // 付供应商税费
                 if (null == product.getShopTaxRate() || product.getShopTaxRate() <= 0) {
                 if (null == product.getShopTaxRate() || product.getShopTaxRate() <= 0) {
                     product.setShopTaxRate(product.getTaxRate());
                     product.setShopTaxRate(product.getTaxRate());

+ 3 - 2
src/main/resources/mapper/SubmitMapper.xml

@@ -58,7 +58,7 @@
             parameterType="com.caimei365.order.model.po.OrderProductPo" useGeneratedKeys="true">
             parameterType="com.caimei365.order.model.po.OrderProductPo" useGeneratedKeys="true">
         INSERT INTO cm_order_product (orderID, orderNo, shopOrderID, shopOrderNo, organizeID, orderPromotionsId,
         INSERT INTO cm_order_product (orderID, orderNo, shopOrderID, shopOrderNo, organizeID, orderPromotionsId,
                                       productId, shopId,
                                       productId, shopId,
-                                      name, organizeCostPrice, cmCostPrice,
+                                      name, costPriceTax, organizeCostPrice, cmCostPrice,
                                       productImage, price, shopName, costPrice, normalPrice, ladderPriceFlag,
                                       productImage, price, shopName, costPrice, normalPrice, ladderPriceFlag,
                                       discountPrice, discount,
                                       discountPrice, discount,
                                       totalAmount, totalFee, shouldPayFee, productUnit, num, presentNum, discountFee,
                                       totalAmount, totalFee, shouldPayFee, productUnit, num, presentNum, discountFee,
@@ -72,7 +72,7 @@
                                       svipDiscount, svipReduction, skuID, cmPercent, organizePercent, shopPercent)
                                       svipDiscount, svipReduction, skuID, cmPercent, organizePercent, shopPercent)
         VALUES (#{orderId}, #{orderNo}, #{shopOrderId}, #{shopOrderNo}, #{organizeId}, #{orderPromotionsId},
         VALUES (#{orderId}, #{orderNo}, #{shopOrderId}, #{shopOrderNo}, #{organizeId}, #{orderPromotionsId},
                 #{productId}, #{shopId},
                 #{productId}, #{shopId},
-                #{name}, #{organizeCostPrice}, #{cmCostPrice},
+                #{name}, #{costPriceTax}, #{organizeCostPrice}, #{cmCostPrice},
                 #{image}, #{price}, #{shopName}, #{costPrice}, #{normalPrice}, #{ladderPriceFlag},
                 #{image}, #{price}, #{shopName}, #{costPrice}, #{normalPrice}, #{ladderPriceFlag},
                 #{discountPrice}, #{discount},
                 #{discountPrice}, #{discount},
                 #{totalAmount}, #{totalFee}, #{shouldPayFee}, #{productUnit}, #{num}, #{presentNum}, #{discountFee},
                 #{totalAmount}, #{totalFee}, #{shouldPayFee}, #{productUnit}, #{num}, #{presentNum}, #{discountFee},
@@ -500,6 +500,7 @@
         update cm_order_product
         update cm_order_product
         set price                   = #{price},
         set price                   = #{price},
             discountPrice           = #{price},
             discountPrice           = #{price},
+            costPriceTax            = #{costPriceTax},
             costPrice               = #{costPrice},
             costPrice               = #{costPrice},
             organizeCostPrice       = #{organizeCostPrice},
             organizeCostPrice       = #{organizeCostPrice},
             cmCostPrice             = #{cmCostPrice},
             cmCostPrice             = #{cmCostPrice},