Duan_xu 3 лет назад
Родитель
Сommit
c717893f11

+ 59 - 67
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -1039,64 +1039,67 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
 
         //待付供应商金额
         BigDecimal waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getPayedShopAmount());
-        if (payShopDifference.getType() == 2 && MathUtil.compare(differencePrice, waitPayShop) > 0) {
-            //多付且差价大于待付金额,会发生供应商退款操作
-            BigDecimal waitRefund = MathUtil.sub(differencePrice, waitPayShop);
-            String refundWay = payShopDifference.getRefundWay();
-            BigDecimal refundAmount = payShopDifference.getRefundAmount();
-            BigDecimal refundBalanceAmount = payShopDifference.getRefundBalanceAmount();
-            if (refundWay.equals("1")) {
-                //线下退
-                refundBalanceAmount = BigDecimal.ZERO;
-            } else if (refundWay.equals("2")) {
-                //欠款账簿
-                refundAmount = BigDecimal.ZERO;
-            } else {
-                //两种方式都有
-                refundWay = "3";
-            }
-            logger.info("待付waitRefund>>>" + waitRefund + ">>>refundAmount金额>>>" + refundAmount + ">>>refundBalanceAmount金额>>>" + refundBalanceAmount);
-            if (MathUtil.compare(waitRefund, MathUtil.add(refundAmount, refundBalanceAmount)) == 0) {
-                CmRefundShop refundShop = new CmRefundShop();
-                refundShop.setShopID(shopOrder.getShopID().toString());
-                refundShop.setOperator(currentUser.getId());
-                refundShop.setOperatTime(time);
-                refundShop.setRefundWay(refundWay);
-                refundShop.setRefundAmount(refundAmount.doubleValue());
-                refundShop.setRefundBalanceAmount(refundBalanceAmount.doubleValue());
-                refundShop.setRefundType(payShopDifference.getRefundType().toString());
-                refundShop.setRemark(payShopDifference.getRemark());
-                refundShop.setDelFlag("0");
-                cmRefundShopDao.insert(refundShop);
+       Integer payWay= newShopOrderDao.payWay(shopOrderId);
+       if(payWay==1 && shopOrder.getShopReceiptStatus()==2) {
+           if (payShopDifference.getType() == 2 && MathUtil.compare(differencePrice, waitPayShop) > 0) {
+               //多付且差价大于待付金额,会发生供应商退款操作
+               BigDecimal waitRefund = MathUtil.sub(differencePrice, waitPayShop);
+               String refundWay = payShopDifference.getRefundWay();
+               BigDecimal refundAmount = payShopDifference.getRefundAmount();
+               BigDecimal refundBalanceAmount = payShopDifference.getRefundBalanceAmount();
+               if (refundWay.equals("1")) {
+                   //线下退
+                   refundBalanceAmount = BigDecimal.ZERO;
+               } else if (refundWay.equals("2")) {
+                   //欠款账簿
+                   refundAmount = BigDecimal.ZERO;
+               } else {
+                   //两种方式都有
+                   refundWay = "3";
+               }
+               logger.info("待付waitRefund>>>" + waitRefund + ">>>refundAmount金额>>>" + refundAmount + ">>>refundBalanceAmount金额>>>" + refundBalanceAmount);
+               if (MathUtil.compare(waitRefund, MathUtil.add(refundAmount, refundBalanceAmount)) == 0) {
+                   CmRefundShop refundShop = new CmRefundShop();
+                   refundShop.setShopID(shopOrder.getShopID().toString());
+                   refundShop.setOperator(currentUser.getId());
+                   refundShop.setOperatTime(time);
+                   refundShop.setRefundWay(refundWay);
+                   refundShop.setRefundAmount(refundAmount.doubleValue());
+                   refundShop.setRefundBalanceAmount(refundBalanceAmount.doubleValue());
+                   refundShop.setRefundType(payShopDifference.getRefundType().toString());
+                   refundShop.setRemark(payShopDifference.getRemark());
+                   refundShop.setDelFlag("0");
+                   cmRefundShopDao.insert(refundShop);
 
-                CmRefundShopRecord record = new CmRefundShopRecord();
-                record.setShopID(String.valueOf(shopOrder.getShopID()));
-                record.setShopOrderID(shopOrder.getShopOrderID().toString());
-                record.setShopOrderNo(shopOrder.getShopOrderNo());
-                record.setRefundType("5");
-                record.setRefundAmount(waitRefund.doubleValue());
-                record.setRefundTime(time);
-                record.setRefundShopID(refundShop.getId());
-                record.setDelFlag("0");
-                cmRefundShopRecordDao.insert(record);
-                payShopDifference.setRefundShopId(Integer.valueOf(refundShop.getId()));
+                   CmRefundShopRecord record = new CmRefundShopRecord();
+                   record.setShopID(String.valueOf(shopOrder.getShopID()));
+                   record.setShopOrderID(shopOrder.getShopOrderID().toString());
+                   record.setShopOrderNo(shopOrder.getShopOrderNo());
+                   record.setRefundType("5");
+                   record.setRefundAmount(waitRefund.doubleValue());
+                   record.setRefundTime(time);
+                   record.setRefundShopID(refundShop.getId());
+                   record.setDelFlag("0");
+                   cmRefundShopRecordDao.insert(record);
+                   payShopDifference.setRefundShopId(Integer.valueOf(refundShop.getId()));
 
-                //修改付供应商状态
-                newShopOrderDao.updatePayStatus(shopOrder.getShopOrderID(), "3");
-                List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(shopOrder.getOrderID());
-                AtomicBoolean isPayStatus = new AtomicBoolean(true);
-                shopOrders.forEach(s -> {
-                    if (!"3".equals(s.getPayStatus())) {
-                        isPayStatus.set(false);
-                    }
-                });
-                if (isPayStatus.get()) {
-                    newOrderDao.updatePayStatus("3", shopOrder.getOrderID());
-                }
-            } else {
-                throw new Exception("退款金额异常");
-            }
-        }
+                   //修改付供应商状态
+                   newShopOrderDao.updatePayStatus(shopOrder.getShopOrderID(), "3");
+                   List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(shopOrder.getOrderID());
+                   AtomicBoolean isPayStatus = new AtomicBoolean(true);
+                   shopOrders.forEach(s -> {
+                       if (!"3".equals(s.getPayStatus())) {
+                           isPayStatus.set(false);
+                       }
+                   });
+                   if (isPayStatus.get()) {
+                       newOrderDao.updatePayStatus("3", shopOrder.getOrderID());
+                   }
+               } else {
+                   throw new Exception("退款金额异常");
+               }
+           }
+       }
         payShopDifference.setModifyUserId(Integer.parseInt(UserUtils.getUser().getId()));
         cmPayShopRecordDao.insertDifference(payShopDifference);
         if (!("3".equals(shopOrder.getPayStatus()) && 1 == payShopDifference.getType())) {
@@ -1293,17 +1296,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     newOrderDao.insertSettleRecord(settleRecord);
                     // 修改cm_split_account settlestatus
                     newOrderDao.updateSettleStatus(shopOrderId, 3);
-                    //计算供应商成本,结算金额,修改结算状态
-                    Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
-                    //计算供应商成本,结算金额,修改结算状态
-                    Double settleSum = newOrderDao.findSettleSum(shopOrderId);
-                    if (shouldPayShopAmount > settleSum) {
-                        //成本>结算金额,部分结算
-                        newOrderDao.updateShopOrderSettleStatus(shopOrderId, 2);
-                    } else {
-                        //成本=结算金额 全部结算
-                        newOrderDao.updateShopOrderSettleStatus(shopOrderId, 3);
-                    }
                 }
                 //解锁
                 redisService.remove("SDJSS");

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

@@ -592,9 +592,12 @@
                 <a id="applyShopOtherFee" href="${ctx}/order/cmPayShop/shopOtherFeeForm?shopOrderId=${s.shopOrderID}">付第三方申请</a>
                 <c:if test="${s.paying ne '1' and s.payStatus eq '1' and !s.modifyPayable}">
                     <shiro:hasPermission name="order:cmPayShop:modifyPay">
-                        <a onclick="applypayWay(${s.shopReceiptStatus},${s.payWay});"  href="${ctx}/shopOrder/toChangePayShopAmount?shopOrderID=${s.shopOrderID}">修改成本</a>
+                        <a onclick="applypayWay(${s.shopReceiptStatus},${s.payWay})"  href="${ctx}/shopOrder/toChangePayShopAmount?shopOrderID=${s.shopOrderID}">修改成本</a>
                     </shiro:hasPermission>
                 </c:if>
+                <c:if test="${s.shopReceiptStatus eq 2 || s.payWay eq 1}">
+                    <a href="${ctx}/order/cmPayShop/differencePriceForm?shopOrderId=${s.shopOrderID}">供应商差价</a>
+                </c:if>
                 <c:if test="${(s.modifyPayable and s.paying ne '1') || s.payStatus eq '2'}">
                     <a href="${ctx}/order/cmPayShop/differencePriceForm?shopOrderId=${s.shopOrderID}">供应商差价</a>
                 </c:if>
@@ -693,7 +696,6 @@
 <div class="pagination">${page}</div>
 
 <script>
-
     //线上支付的子订单不能直接修改成本
     function applypayWay(shopReceiptStatus,payWay) {
         console.log(payWay);
@@ -705,7 +707,6 @@
         }
     }
 
-
     (function () {
         var payTableEle = $('.pay-table'),
             payProductEle = $('.pay-product-item');
@@ -914,7 +915,6 @@
 
 
 
-
             $('#applyShopOtherFee').on('click', function () {
             if (checked.length > 1) {
                 alertx('每次只能选择一个子订单进行付第三方申请');