فهرست منبع

赠品计算付供应商

huangzhiguo 1 سال پیش
والد
کامیت
e9ae9cc5ad

+ 38 - 2
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -618,10 +618,41 @@ public class SubmitServiceImpl implements SubmitService {
                 boolean svipPriceFlag = null != svipProductPo && 1 == svipProductPo.getSvipProductFlag() && orderParamBo.getSvipUserFlag();
                 // 是否是促销赠品
                 if (productType == 2) {
+                    // 促销赠品计算商品费
+                    Double productPrice = product.getPrice();
+                    Double discountPrice = product.getPrice();
+                    // 商品税费
+                    Double productTax = 0d;
+                    Double discountTax = 0d;
+                    if (taxFlag) {
+                        productTax = MathUtil.div(MathUtil.mul(productPrice, product.getTaxRate()), 100, 2).doubleValue();
+                        discountTax = MathUtil.div(MathUtil.mul(discountPrice, product.getTaxRate()), 100, 2).doubleValue();
+                    } else if (!Integer.valueOf(1).equals(product.getIncludedTax())) {
+                        // 不含税不可开票商品和未知商品,税率置为0
+                        product.setTaxRate(0d);
+                    }
+                    log.info("促销赠品计算:productTax===" + productTax);
+                    // 商品价格
+                    if (Integer.valueOf(0).equals(product.getIncludedTax())) {
+                        if (null != product.getTaxRate() && product.getTaxRate() > 0d) {
+                            product.setPrice(MathUtil.add(productPrice, MathUtil.mul(productPrice, MathUtil.div(product.getTaxRate(), 100, 2))).doubleValue());
+                        }
+                    } else {
+                        product.setPrice(productPrice);
+                    }
+                    // 商品税后价格
+                    Double productTaxPrice = MathUtil.add(productPrice, productTax).doubleValue();
+                    // 折后税后单价
+                    Double discountTaxPrice = MathUtil.add(discountPrice, discountTax).doubleValue();
+                    // 单个商品的金额
+                    Double productAmount = MathUtil.mul(productTaxPrice, productNum).doubleValue();
+                    // 单个商品的金额
+                    product.setTotalAmount(productAmount);
+                    product.setPrice(productPrice);
+                    // 折后单价
+                    product.setDiscountPrice(discountTaxPrice);
                     // 促销赠品数+1
                     promotionalGiftsCount.incrementAndGet();
-                    product.setPrice(0d);
-                    product.setDiscountPrice(0d);
                     product.setDiscount(0d);
                     product.setTotalAmount(0d);
                     product.setTotalFee(0d);
@@ -873,6 +904,11 @@ public class SubmitServiceImpl implements SubmitService {
                     return ResponseJson.error("订单商品成本异常!", null);
                 }
                 product.setCostPrice(costPrice);
+                // 促销赠品 售价归 0
+                if (productType == 2) {
+                    product.setPrice(0d);
+                    product.setDiscountPrice(0d);
+                }
                 // 付供应商税费
                 if (null == product.getShopTaxRate() || product.getShopTaxRate() <= 0) {
                     product.setShopTaxRate(product.getTaxRate());

+ 4 - 1
src/main/resources/mapper/ReceiptMapper.xml

@@ -837,15 +837,17 @@
                         cso.orderTime,
                         cso.orderSubmitType,
                         cso.payStatus,
-                        cso.sendOutStatus,
                         cso.splitFlag,
                         cso.shopOtherFee,
                         s.name                            AS shopName,
                         ifnull(co.secondHandOrderFlag, 0) as secondHandOrderFlag,
+                        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
+                        ifnull(cso.receiptStatus, 1) as receiptStatus,
                         cso.orderType,
                         cso.organizeId,
                         cso.shopStatus as status,
                         ifnull(cso.orderStatusFlag,1) as orderStatusFlag,
+                        IFNULL(cso.refundStatus, 1) AS refundStatus,
                         (select sum(associateAmount) from cm_receipt_order_relation where shopOrderID = cso.shopOrderID) as receiptAmount,
                         (select userName from user where userID = cso.userId LIMIT 1) as userName,
                         IFNULL((SELECT SUM(refundAmount)
@@ -896,6 +898,7 @@
         cso.organizeId,
         cso.shopStatus as status,
         ifnull(cso.orderStatusFlag,1) as orderStatusFlag,
+        IFNULL(cso.refundStatus, 1) AS refundStatus,
         (select sum(associateAmount) from cm_receipt_order_relation where shopOrderID = cso.shopOrderID) as receiptAmount,
         (select userName from user where userID = cso.userId LIMIT 1) as userName,
         IFNULL((SELECT SUM(refundAmount) FROM cm_refund_shop_record WHERE shopOrderID = cso.shopOrderID AND delFlag =