zhijiezhao před 1 rokem
rodič
revize
4a06cb35b4

+ 43 - 10
src/main/webapp/WEB-INF/views/modules/order/cmPayShopChange.jsp

@@ -304,7 +304,7 @@
                 <tr>
                     <td style="padding-top: 10px;">
                         <b>付供应商:</b><font color="red"><span
-                            id="div-supplier-fee">${newShopOrder.shouldPayShopAmount-newShopOrder.shopOtherFee}</span></font>
+                            id="div-supplier-fee">${newShopOrder.shouldPayShopAmount - newShopOrder.shopOtherFee}</span></font>
                     </td>
                     <input style="display: none" id="hidePayShop" value="${newShopOrder.shouldPayShopAmount}">
                         <%--<td style="padding-top: 10px;">
@@ -471,15 +471,46 @@
             obj.value = 0;
         }
         var of = $("#shopOtherFee").val();
-        console.log(of);
+        console.log("of----------------" + of);
         if (of > 0) {
-            // // 使用getElementById获取span元素
-            // var spanElement = document.getElementById("div-supplier-fee");
-            // var text = spanElement.innerText;
-            var text = $("#hidePayShop").val();
-            console.log("text----------" + text);
-            var pay = text - of;
-            $("#div-supplier-fee").text(pay);
+            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();// 单个供应商是税费
+
+                console.log(num + " " + presentNum + " " + " " + costPrice + " " + supplierTaxRate + " " + singleShouldPayTotalTax)
+
+                // 校验参数
+                if (null == num) num = 0;
+                if (null == presentNum) presentNum = 0;
+                if (null == costPrice) costPrice = 0;
+                if (null == supplierTaxRate) supplierTaxRate = 0;
+                if (null == singleShouldPayTotalTax) singleShouldPayTotalTax = 0;
+                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)));
+                console.log("totalAmount--------------" + totalAmount);
+            });
+            var shopPostFee = $("#shopPostFee").val();
+            console.log("shopPostFee----------" + shopPostFee);
+            console.log("shopPostFee----------" + shopPostFee);
+            totalAmount += Number(shopPostFee);
+            totalAmount -= Number(of);
+            $("#div-supplier-fee").text(totalAmount);
         }
     }
 
@@ -552,7 +583,9 @@
             //计算应付供应商
             totalAmount += ((Number(productNum) * Number(costPrice)) + (Number(productNum) * Number(singleShouldPayTotalTax))); /* + (Number(productNum) * Number(singleShouldPayTotalTax))*/
         });
-        totalAmount -= Number(shopPostFee);
+        var of = $("#shopOtherFee").val();
+        totalAmount += Number(shopPostFee);
+        totalAmount -= Number(of);
         // 四舍五入
         var s = totalAmount.toFixed(2);
         $("#div-supplier-fee").text(s);