zhijiezhao 1 anno fa
parent
commit
557b0186e1

+ 3 - 39
src/main/java/com/caimei/modules/order/web/CmPayShopController.java

@@ -340,17 +340,10 @@ public class CmPayShopController extends BaseController {
                 }
                 // product.setSingleShouldPayTotalTax(MathUtil.div(MathUtil.mul(MathUtil.div(product.getCostPrice(), MathUtil.div(MathUtil.add(product.getTaxRate(), 100),100)), product.getSupplierTaxRate()), 100).doubleValue());
                 Double singleShouldPayTotalTax = product.getSingleShouldPayTotalTax() == null ? 0d : product.getSingleShouldPayTotalTax();
-                Double supplierTaxRate = product.getTaxRate() == null ? 0d : product.getTaxRate();
+                Double supplierTaxRate = product.getSupplierTaxRate() == null ? 0d : product.getSupplierTaxRate();
                 // 获取已被退款的商品数量
                 Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(Integer.parseInt(shopOrderID), orderProductID);
                 returnNum = returnNum == null ? 0 : returnNum;
-//                List<CmReturnedPurchaseProduct> o = rL.stream().
-//                        filter(r -> r.getOrderProductID().equals(orderProductID));
-//                CmReturnedPurchaseProduct b = o.isPresent() ? o.get() : null;
-//                int returnNum = 0;
-//                if (b != null)
-//                    returnNum = (b.getActualReturnedNum() == null ? 0 : b.getActualReturnedNum())
-//                            + (b.getActualCancelNum() == null ? 0 : b.getActualCancelNum());
                 NewOrderProduct orderProduct = newOrderProductService.get(String.valueOf(orderProductID));
                 // 修改前
                 if (StringUtils.isEmpty(dbcostType)) {
@@ -492,10 +485,8 @@ public class CmPayShopController extends BaseController {
         //当子订单0成本时,若主订单中其他子订单(除了运费子订单)都为0成本,设主订单为已付款,否则设为部分付款
         NewOrder newOrder = newOrderService.get(shopOrder.getOrderID().toString());
         if (soZeroCostFlag) {
-
             AtomicReference<Boolean> zeroCostFlag = new AtomicReference<>(true);
             AtomicReference<Boolean> freightFlag = new AtomicReference<>(false);
-
             newOrder.getNewShopOrders().forEach(item -> {
                 if (item.getShopID().equals(998)) {
                     freightFlag.set(true);
@@ -524,8 +515,6 @@ public class CmPayShopController extends BaseController {
             }
             newOrderService.updatePayStatus(newOrder);
         }
-
-
         shopOrder.setShopPostFee(freight); //运费
         shopOrder.setShopOtherFee(thirdPartyFee); //付第三方
         shopOrder.setCostType(costType);
@@ -533,37 +522,12 @@ public class CmPayShopController extends BaseController {
         shopOrder.setModifyShouldPayUserID(UserUtils.getUser().getId());  //修改人的用户id
         shopOrder.setModifyShouldPayDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));  //修改时间
         double shouldPayShopAmount = shopOrder.getShopProductAmount() + shopOrder.getShopPostFee(); // + shopOrder.getShopTaxFee();
-        if (shopOrder.getPayedShopAmount() != null && shouldPayShopAmount == shopOrder.getPayedShopAmount())
+        if (shopOrder.getPayedShopAmount() != null && shouldPayShopAmount == shopOrder.getPayedShopAmount()) {
             shopOrder.setPayStatus("3");
+        }
         // 付供应商 - 优惠券 - 促销满减优惠
         shopOrder.setShouldPayShopAmount(MathUtil.sub(shouldPayShopAmount , MathUtil.add(shopOrder.getCouponAmount(), shopOrder.getPromotionFullReduction())).doubleValue());
         newShopOrderService.modifyPayShopAmount(shopOrder, orderProducts);
-
-        /*if(shopOrder.getShopReceiptStatus()==1){
-            System.out.println(shopOrder.getShopReceiptStatus());
-            logger.info("未付款子订单进了成本修改"+shopOrder.getShouldPayShopAmount()+"-----"+shopOrder.getShopOtherFee());
-            double mum= newShopOrder.getProductAmount();
-            mum-= shopOrder.getShopOtherFee()+shopOrder.getShouldPayShopAmount();
-            //因为成本上升,子订单佣金下降。当成本上升到子订单佣金不大于线上支付最大手续费时不能进行线上支付所以减了第三方
-            System.out.println(">>>>>>>>子订单佣金"+mum+"----"+shopOrder.getBrokerage());
-            double fee=0.0;
-            if(shopOrder.getShopOtherFee()>=1000.01){
-                //手续费 =子订单金额*默认代理费率
-                 fee=shopOrder.getProductAmount()*0.0065;
-                if(mum<fee){
-                    newOrderDao.updateOnlinePayFlag(1,shopOrder.getOrderID());
-                }
-            }else if(shopOrder.getShopOtherFee()<=1000.01){
-                 fee=shopOrder.getProductAmount()*0.0025;
-                if(mum<fee){
-                    newOrderDao.updateOnlinePayFlag(1,shopOrder.getOrderID());
-                }
-            }
-            if(mum>fee){
-                newOrderDao.updateOnlinePayFlag(0,shopOrder.getOrderID());
-            }
-        }*/
-
         return "redirect:" + Global.getAdminPath() + "/shopOrder/payOrderList";
     }
 

+ 49 - 4
src/main/webapp/WEB-INF/views/modules/order/cmPayShopChange.jsp

@@ -211,7 +211,8 @@
                 <input id="orderID" type="hidden" name="orderID" value="${newShopOrder.orderID}">
                 <input id="productAmount" type="hidden" name="productAmount" value="${newShopOrder.productAmount}">
                 <input id="couponAmount" type="hidden" name="couponAmount" value="${newShopOrder.couponAmount}">
-                <input id="promotionFullReduction" type="hidden" name="promotionFullReduction" value="${newShopOrder.promotionFullReduction}">
+                <input id="promotionFullReduction" type="hidden" name="promotionFullReduction"
+                       value="${newShopOrder.promotionFullReduction}">
                 <label style="color:red">注意:计算成本时请注意,含税商品的成本包括税费,无需另外计算税费</label>
                 <table class="table table-striped table-bordered table-condensed" style="width: 70%">
                     <tr>
@@ -261,8 +262,8 @@
                                     </c:when>
                                     <c:otherwise>
                                         <input style="width: 120px;float: left" maxlength="5" id="supplierTaxRate"
-                                               name="newOrderProducts[${index.index}].taxRate"
-                                               value="${empty product.taxRate?0.0:product.taxRate}"
+                                               name="newOrderProducts[${index.index}].supplierTaxRate"
+                                               value="${empty product.supplierTaxRate?0.0:product.supplierTaxRate}"
                                                onchange="changeShouldPay(this)"/>%
                                     </c:otherwise>
                                 </c:choose>
@@ -460,6 +461,50 @@
                 })
             }, 500);
         });
+        var totalAmount = 0;
+        $(".orderProducts").each(function (i, ele) {
+            // 商品层信息
+            var num = $(ele).find('input[id=num]').val();
+            var presentNum = $(ele).find('input[id=presentNum]').val();
+            var costPrice = $(ele).find('input[id=costPrice]').val();
+            var supplierTaxRate = $(ele).find('input[id=supplierTaxRate]').val();
+            var singleShouldPayTotalTax = $(ele).find('label[id=singleShouldPayTotalTaxLabel]').text();// 单个供应商是税费
+
+            // 校验参数
+            if (null == num) num = 0;
+            if (null == presentNum) presentNum = 0;
+            if (null == costPrice) costPrice = 0;
+            if (null == supplierTaxRate || supplierTaxRate === undefined || supplierTaxRate.includes("-")) supplierTaxRate = 0;
+            if (null == singleShouldPayTotalTax || singleShouldPayTotalTax === undefined || singleShouldPayTotalTax.includes("-")) singleShouldPayTotalTax = 0;
+            console.log(num + " " + presentNum + " " + " " + costPrice + " " + supplierTaxRate + " " + singleShouldPayTotalTax)
+
+            var productNum = Number(num) + Number(presentNum);
+
+            if (singleShouldPayTotalTax == '-----') {
+                singleShouldPayTotalTax = 0;
+                $(ele).find('input[id=singleShouldPayTotalTax]').val(0);
+            } else {
+                //计算供应商税费(单)
+                singleShouldPayTotalTax = (costPrice * supplierTaxRate * 0.01).toFixed(2);
+                $(ele).find('label[id=singleShouldPayTotalTaxLabel]').text(singleShouldPayTotalTax);
+                $(ele).find('input[id=singleShouldPayTotalTax]').val(singleShouldPayTotalTax);
+            }
+            //计算应付供应商
+            totalAmount += ((Number(productNum) * Number(costPrice)) + (Number(productNum) * Number(singleShouldPayTotalTax)));
+        });
+        //获取供应商层信息
+        var shopPostFee = $("#shopPostFee").val();
+        var couponAmount = $("#couponAmount").val();
+        var promotionFullReduction = $("#promotionFullReduction").val();
+        if (null == shopPostFee) shopPostFee = 0;
+        var of = $("#shopOtherFee").val();
+        totalAmount += Number(shopPostFee);
+        totalAmount -= Number(of);
+        totalAmount -= Number(couponAmount);
+        totalAmount -= Number(promotionFullReduction);
+        // 四舍五入
+        var s = totalAmount.toFixed(2);
+        $("#div-supplier-fee").text(s);
     });
 
     // 输入框验证
@@ -589,7 +634,7 @@
                 $(ele).find('input[id=singleShouldPayTotalTax]').val(singleShouldPayTotalTax);
             }
             //计算应付供应商
-            totalAmount += ((Number(productNum) * Number(costPrice)) + (Number(productNum) * Number(singleShouldPayTotalTax))); /* + (Number(productNum) * Number(singleShouldPayTotalTax))*/
+            totalAmount += ((Number(productNum) * Number(costPrice)) + (Number(productNum) * Number(singleShouldPayTotalTax)));
         });
         var of = $("#shopOtherFee").val();
         totalAmount += Number(shopPostFee);