瀏覽代碼

Merge remote-tracking branch 'origin/developer' into developer

Aslee 2 年之前
父節點
當前提交
177052592b
共有 53 個文件被更改,包括 6553 次插入493 次删除
  1. 97 28
      src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java
  2. 21 0
      src/main/java/com/caimei/modules/order/dao/CmReturnedPurchaseDao.java
  3. 20 0
      src/main/java/com/caimei/modules/order/dao/NewOrderDao.java
  4. 2 0
      src/main/java/com/caimei/modules/order/dao/NewOrderProductDao.java
  5. 10 0
      src/main/java/com/caimei/modules/order/dao/NewShopOrderDao.java
  6. 16 0
      src/main/java/com/caimei/modules/order/entity/ChangePayShopDifference.java
  7. 9 0
      src/main/java/com/caimei/modules/order/entity/CmReceiptOrderRelation.java
  8. 36 0
      src/main/java/com/caimei/modules/order/entity/CmRefundRecord.java
  9. 34 0
      src/main/java/com/caimei/modules/order/entity/CmRefundTransfer.java
  10. 27 1
      src/main/java/com/caimei/modules/order/entity/CmReturnedPurchase.java
  11. 62 14
      src/main/java/com/caimei/modules/order/entity/Constant.java
  12. 36 1
      src/main/java/com/caimei/modules/order/entity/NewOrder.java
  13. 19 0
      src/main/java/com/caimei/modules/order/entity/NewShopOrder.java
  14. 59 0
      src/main/java/com/caimei/modules/order/entity/SettleRecord.java
  15. 81 0
      src/main/java/com/caimei/modules/order/entity/SettleResult.java
  16. 219 5
      src/main/java/com/caimei/modules/order/service/CmPayShopService.java
  17. 225 85
      src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java
  18. 35 29
      src/main/java/com/caimei/modules/order/service/NewOrderService.java
  19. 28 0
      src/main/java/com/caimei/modules/order/service/NewShopOrderService.java
  20. 1 1
      src/main/java/com/caimei/modules/order/service/SplitAccountService.java
  21. 404 0
      src/main/java/com/caimei/modules/order/utils/RSA.java
  22. 69 0
      src/main/java/com/caimei/modules/order/utils/SettlePostFormUtil.java
  23. 75 2
      src/main/java/com/caimei/modules/order/web/CmPayShopController.java
  24. 22 0
      src/main/java/com/caimei/modules/order/web/CmShopOrderController.java
  25. 1 0
      src/main/java/com/caimei/modules/product/web/CmSecondHandDetailController.java
  26. 20 13
      src/main/resources/mappings/modules/order/CmReceiptOrderRelationMapper.xml
  27. 66 5
      src/main/resources/mappings/modules/order/CmReturnedPurchaseMapper.xml
  28. 62 1
      src/main/resources/mappings/modules/order/OrderMapper.xml
  29. 165 1
      src/main/resources/mappings/modules/order/ShopOrderMapper.xml
  30. 269 34
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/applyRefoundForm.jsp
  31. 5 2
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp
  32. 230 133
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReturnRecord.jsp
  33. 2 2
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReviewReturnRecord.jsp
  34. 119 36
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/refundRecord.jsp
  35. 331 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/settlementRecord.jsp
  36. 40 11
      src/main/webapp/WEB-INF/views/modules/order/checkPaymentOrder.jsp
  37. 1 0
      src/main/webapp/WEB-INF/views/modules/order/cmPayFormList.jsp
  38. 1 1
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopDetail.jsp
  39. 3 1
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopForm.jsp
  40. 22 7
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopList.jsp
  41. 834 0
      src/main/webapp/WEB-INF/views/modules/order/cmSettlementForm.jsp
  42. 1129 0
      src/main/webapp/WEB-INF/views/modules/order/cmSettlementList.jsp
  43. 1 0
      src/main/webapp/WEB-INF/views/modules/order/cmSplitAccountList.jsp
  44. 6 2
      src/main/webapp/WEB-INF/views/modules/order/differencePriceForm.jsp
  45. 9 9
      src/main/webapp/WEB-INF/views/modules/order/newOrderList.jsp
  46. 48 20
      src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp
  47. 1 0
      src/main/webapp/WEB-INF/views/modules/order/paidShopOrderList.jsp
  48. 3 3
      src/main/webapp/WEB-INF/views/modules/order/refundRecord.jsp
  49. 285 0
      src/main/webapp/WEB-INF/views/modules/order/settleRecordList.jsp
  50. 1247 0
      src/main/webapp/WEB-INF/views/modules/product/cmSecondDetailForm.jsp
  51. 14 14
      src/main/webapp/WEB-INF/views/modules/userNew/cmAgencyRemarksList.jsp
  52. 14 14
      src/main/webapp/WEB-INF/views/modules/userNew/cmRegistRemarksList.jsp
  53. 18 18
      src/main/webapp/WEB-INF/views/modules/userNew/cmUnRegistRemarksList.jsp

+ 97 - 28
src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java

@@ -10,10 +10,7 @@ import com.caimei.modules.order.dao.CmDiscernReceiptDao;
 import com.caimei.modules.order.dao.CmReturnedPurchaseDao;
 import com.caimei.modules.order.dao.NewOrderProductDao;
 import com.caimei.modules.order.entity.*;
-import com.caimei.modules.order.service.CmReceiptOrderRelationService;
-import com.caimei.modules.order.service.CmReturnedPurchaseService;
-import com.caimei.modules.order.service.NewOrderProductService;
-import com.caimei.modules.order.service.NewOrderService;
+import com.caimei.modules.order.service.*;
 import com.caimei.modules.product.dao.CmPromotionDao;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.modules.user.dao.CmUserDao;
@@ -29,6 +26,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.util.Assert;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,9 +38,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 退款信息列表Controller
@@ -61,6 +58,8 @@ public class CmRefundsProductController extends BaseController {
     @Resource
     private CmReturnedPurchaseDao cmReturnedPurchaseDao;
     @Resource
+    private NewShopOrderService newShopOrderService;
+    @Resource
     private NewOrderService newOrderService;
     @Resource
     private CmReturnedPurchaseService cmReturnedPurchaseService;
@@ -160,6 +159,9 @@ public class CmRefundsProductController extends BaseController {
             if (StringUtils.isNotEmpty(cmReturnedPurchase.getId())) {
                 cmReturnedPurchase = cmReturnedPurchaseDao.get(cmReturnedPurchase.getId());//编辑重置数据
             }
+            if (2 == cmReturnedPurchase.getRefundType()) {
+                cmReturnedPurchase.setFreeRefundFee(cmReturnedPurchase.getRefundFee());
+            }
             NewOrder newOrder = newOrderService.getNewOrder(cmReturnedPurchase);
 
             //统计订单已支付金额
@@ -272,19 +274,18 @@ public class CmRefundsProductController extends BaseController {
 
             //是否可以线上退回
             boolean returnOnline = false;
-            if (cmDiscernReceipt != null && "1".equals(cmDiscernReceipt.getPayWay())) {
-                /*Date splitTime = cmDiscernReceiptDao.findSplitTime(newOrder.getOrderID());
-                if (splitTime != null) {
-                    Calendar calendar = Calendar.getInstance();
-                    calendar.setTime(splitTime);
-                    calendar.set(Calendar.HOUR_OF_DAY, 23);
-                    calendar.set(Calendar.MINUTE, 20);
-                    if (calendar.getTime().compareTo(new Date()) > 0) {
-                        returnOnline = true;
-                    }
-                } else {
-                    returnOnline = true;
-                }*/
+            String status = "";
+            if (null != cmReturnedPurchase.getOnlineShopOrderId()) {
+                //1未结算2部分结算3已结算
+                status = cmReturnedPurchaseDao.findShopOrderSettleStatus(cmReturnedPurchase.getOnlineShopOrderId());
+                cmReturnedPurchase.setRefundFee(newOrder.getNewShopOrders().get(0).getReceiptAmount());
+                cmReturnedPurchase.setRefundOnlineFee(cmReturnedPurchase.getFreeRefundFee());
+            }
+            Integer count = cmReturnedPurchaseDao.findRefundType(cmReturnedPurchase.getOrderID());
+            if (count > 0) {
+                cmReturnedPurchase.setRefundType(3);
+            }
+            if (cmDiscernReceipt != null && "1".equals(cmDiscernReceipt.getPayWay()) && "1".equals(status)) {
                 returnOnline = true;
             }
             Integer lastReceiptDetailId = cmDiscernReceiptDao.findOrderLastReceiptDetailId(newOrder.getOrderID().toString());
@@ -321,6 +322,16 @@ public class CmRefundsProductController extends BaseController {
             if (!StringUtils.equals("1", receiptStatus)) {//代收款状态不需要支付方式0元
                 //判断退款方式(1有支付有退款(退款方式可多选具体参考以上金额)、4未支付无退款(未支付发起退款))
                 String returnedWay = cmReturnedPurchase.getReturnedWay();//1:账户余额/2:线上退回/3:线下转账
+                if (null != cmReturnedPurchase.getRefundBalanceFee() && cmReturnedPurchase.getRefundBalanceFee() > 0) {
+                    returnedWay = "1";
+                }
+                if (null != cmReturnedPurchase.getRefundOfflineFee() && cmReturnedPurchase.getRefundOfflineFee() > 0) {
+                    returnedWay = "3";
+                }
+                if (null != cmReturnedPurchase.getRefundBalanceFee() && null != cmReturnedPurchase.getRefundOfflineFee() && cmReturnedPurchase.getRefundBalanceFee() > 0 && cmReturnedPurchase.getRefundOfflineFee() > 0) {
+                    returnedWay = "1,3";
+                }
+                cmReturnedPurchase.setReturnedWay(returnedWay);
                 if (StringUtils.isNotEmpty(returnedWay)) {
                     boolean contains = returnedWay.contains(",");
                     if (!returnedWay.contains("1")) {
@@ -357,8 +368,10 @@ public class CmRefundsProductController extends BaseController {
             Integer freightNum = 0;
             //是否是订金充值订单
             boolean rechargeGoods = false;
+            Integer shopOrderId = 0;
             if (cmReturnedPurchase.getCmReturnedPurchaseProductList() != null && cmReturnedPurchase.getCmReturnedPurchaseProductList().size() > 0) {
                 for (List<CmReturnedPurchaseProduct> item : cmReturnedPurchase.getCmReturnedPurchaseProductList()) {
+                    shopOrderId = item.get(0).getShopOrderID();
                     if (item != null && item.size() > 0) {
                         for (CmReturnedPurchaseProduct bean : item) {
                             if (bean.getProductID().equals(999)) {
@@ -415,11 +428,23 @@ public class CmRefundsProductController extends BaseController {
             if (cmReturnedPurchase.getRefundOfflineFee() == null) {
                 cmReturnedPurchase.setRefundOfflineFee(0d);
             }
+
             //线上退款
             if ("2".equals(cmReturnedPurchase.getReturnedWay())) {
-                double refundOnlineFee = refundFee - newOrder.getBalancePayFee();
-                cmReturnedPurchase.setRefundOnlineFee(refundOnlineFee);
-                cmReturnedPurchase.setRefundBalanceFee(newOrder.getBalancePayFee());
+                Double paid = cmReturnedPurchaseDao.findShopOrderPaid(shopOrderId);
+                cmReturnedPurchase.setRefundFee(paid);
+                cmReturnedPurchase.setRefundOnlineFee(paid);
+                if (2 == cmReturnedPurchase.getRefundType()) {
+                    //查找线上订单已支付金额,申请退款金额不能大于此金额
+                    Double onlinePay = null == cmReturnedPurchaseDao.findOnlinePay(shopOrderId) ? 0d : cmReturnedPurchaseDao.findOnlinePay(shopOrderId);
+                    cmReturnedPurchase.setRefundFee(cmReturnedPurchase.getFreeRefundFee());
+                    cmReturnedPurchase.setRefundOnlineFee(cmReturnedPurchase.getFreeRefundFee());
+                    if (cmReturnedPurchase.getFreeRefundFee() > onlinePay) {
+                        model.addAttribute("errorMsg", "退款金额不能大于已付金额");
+                        cmReturnedPurchase.setOnlineShopOrderId(shopOrderId);
+                        return applyRefound(cmReturnedPurchase, request, response, model);
+                    }
+                }
             } else if ("1".equals(cmReturnedPurchase.getReturnedWay()) && cmReturnedPurchase.getRefundBalanceFee() == 0d) {
                 //线上支付,全部退余额
                 cmReturnedPurchase.setRefundBalanceFee(refundFee);
@@ -435,13 +460,25 @@ public class CmRefundsProductController extends BaseController {
             }
 
             //判断退款金额和打款金额是否一致
-            double v = totalRefundFee - refundFee;
-            if (v > 0.1 || v < -0.1) {
-                model.addAttribute("errorMsg", "各退款方式的金额之和不等于退款总金额,请重新计算后再提交申请");
-                return applyRefound(cmReturnedPurchase, request, response, model);
+            if (1 == cmReturnedPurchase.getRefundType() && !"2".equals(cmReturnedPurchase.getReturnedWay())) {
+                double v = totalRefundFee - refundFee;
+                if (v > 0.1 || v < -0.1) {
+                    model.addAttribute("errorMsg", "各退款方式的金额之和不等于退款总金额,请重新计算后再提交申请");
+                    return applyRefound(cmReturnedPurchase, request, response, model);
+                }
+            } else if (2 == cmReturnedPurchase.getRefundType()) {
+                if (!(cmReturnedPurchase.getReturnedWay()).contains("2")) {
+                    double v = totalRefundFee - cmReturnedPurchase.getFreeRefundFee();
+                    if (v > 0.1 || v < -0.1) {
+                        model.addAttribute("errorMsg", "各退款方式的金额之和不等于退款总金额,请重新计算后再提交申请");
+                        return applyRefound(cmReturnedPurchase, request, response, model);
+                    }
+                }
             }
 
-            cmReturnedPurchase.setRefundFee(refundFee);
+            if (!"2".equals(cmReturnedPurchase.getReturnedWay())) {
+                cmReturnedPurchase.setRefundFee(refundFee);
+            }
             String saveInfo = cmReturnedPurchaseService.save(cmReturnedPurchase, freightNum, request, response, model);
             if (StringUtils.isNotEmpty(saveInfo)) {
                 model.addAttribute("errorMsg", saveInfo);
@@ -715,6 +752,13 @@ public class CmRefundsProductController extends BaseController {
                     refundFee += bean.getRefundFee();
                 }
             }
+            List<Integer> shopOrderIDs = newShopOrderService.findIDsByOrderID(cmReturnedPurchase.getOrderID());
+            List<CmPayShopRecord> pr = new ArrayList<>();
+            for (Integer shopOrderID : shopOrderIDs) {
+                List<CmPayShopRecord> payShopRecordList = newShopOrderService.getPayedRecords(shopOrderID.toString());
+                pr.addAll(payShopRecordList);
+            }
+            model.addAttribute("pr", pr);
             model.addAttribute("cmReturnedPurchaseList", dataList);
             model.addAttribute("order", newOrder);
             model.addAttribute("receipt", listRelation);
@@ -727,6 +771,31 @@ public class CmRefundsProductController extends BaseController {
         return "modules/bulkpurchase/refundRecord";
     }
 
+    @RequestMapping(value = "toSettleRecord")
+    public String toSettleRecord(CmReturnedPurchase cmReturnedPurchase, String from, HttpServletRequest request, HttpServletResponse response, Model model) {
+        try {
+            NewOrder newOrder = newOrderService.get(cmReturnedPurchase.getOrderID().toString());
+            List<CmReceiptOrderRelation> listRelation = cmReceiptOrderRelationService.findByOrderID(newOrder.getOrderID().toString());
+            List<CmReturnedPurchase> dataList = cmReturnedPurchaseService.getReturnedPurchaseList(cmReturnedPurchase);
+            Double refundFee = 0D;  //退款总额
+            for (CmReturnedPurchase bean : dataList) {
+                if (!bean.getStatus().equals("3")) {
+                    refundFee += bean.getRefundFee();
+                }
+            }
+            List<SettleRecord> settleRecord = newOrderService.findSettleRecord(cmReturnedPurchase.getOrderID());
+            model.addAttribute("settleRecord", settleRecord);
+            model.addAttribute("order", newOrder);
+            model.addAttribute("receipt", listRelation);
+            model.addAttribute("refundFee", refundFee);
+            model.addAttribute("from", from);
+            model.addAttribute("orderID", cmReturnedPurchase.getOrderID().toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "modules/bulkpurchase/settlementRecord";
+    }
+
     /**
      * @return
      * @Author ye.qin

+ 21 - 0
src/main/java/com/caimei/modules/order/dao/CmReturnedPurchaseDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.order.dao;
 
+import com.caimei.modules.order.entity.CmRefundRecord;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.order.entity.CmReturnedPurchase;
@@ -30,4 +31,24 @@ public interface CmReturnedPurchaseDao extends CrudDao<CmReturnedPurchase> {
     List<Integer> findReturnedShopOrder(Integer orderID);
 
     String findSplitCode(Integer shopOrderId);
+
+    List<Integer> getReturnShopOrder(String id);
+
+    void insertCmRefundRecord(CmRefundRecord cmRefundRecord);
+
+    Double findBrokerage(String orderRequestNo);
+
+    Double findRefundTransfer(String orderRequestNo);
+
+    Double findRefundCharge(String orderRequestNo);
+
+    Double findPayAmount(String orderRequestNo);
+
+    Double findOnlinePay(Integer shopOrderId);
+
+    String findShopOrderSettleStatus(Integer onlineShopOrderId);
+
+    Integer findRefundType(Integer orderID);
+
+    Double findShopOrderPaid(Integer shopOrderID);
 }

+ 20 - 0
src/main/java/com/caimei/modules/order/dao/NewOrderDao.java

@@ -221,6 +221,8 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
 
     void updateOnlinePayFlag(@Param("onlinePayFlag") Integer onlinePayFlag,@Param("orderId") Integer orderId);
 
+    void updateBrokerage(@Param("shopOrderID")Integer shopOrderID ,@Param("brokerage")Double brokerage);
+
     Integer findSupport(Integer shopOrderId);
 
     List<OrderProductVo> getOrderProductByShopOrderId(Integer shopOrderId);
@@ -240,4 +242,22 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
     void updateBySplitStatus(String mbOrderId);
 
     Integer findOnlinePay(Integer orderID);
+
+    String findSplitCode(String shopOrderId);
+
+    Double findPayAmount(String shopOrderId);
+
+    Double findShouldPayShopAmount(String shopOrderId);
+
+    void updateSettleStatus(@Param("shopOrderId")String shopOrderId,@Param("productType") Integer productType);
+
+    void updateShopOrderSettleStatus(@Param("shopOrderId")String shopOrderId, @Param("settleStatus")Integer settleStatus);
+
+    void insertSettleRecord(SettleRecord settleRecord);
+
+    Double findSettleSum(String shopOrderId);
+
+    List<SettleRecord> findSettleRecord(Integer orderID);
+
+    Double findSettleAmount(Integer orderID);
 }

+ 2 - 0
src/main/java/com/caimei/modules/order/dao/NewOrderProductDao.java

@@ -103,4 +103,6 @@ public interface NewOrderProductDao extends CrudDao<NewOrderProduct> {
      * @param shopOrderID
      */
     Integer countReturnedFreightProduct(Integer shopOrderID);
+
+
 }

+ 10 - 0
src/main/java/com/caimei/modules/order/dao/NewShopOrderDao.java

@@ -2,6 +2,7 @@ package com.caimei.modules.order.dao;
 
 import com.caimei.modules.order.entity.CmPayShop;
 import com.caimei.modules.order.entity.NewShopOrder;
+import com.caimei.modules.order.entity.SettleRecord;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import org.apache.ibatis.annotations.Param;
@@ -82,4 +83,13 @@ public interface NewShopOrderDao extends CrudDao<NewShopOrder> {
     Double findIncome(Integer orderID);
 
     List<NewShopOrder> findSplitList(NewShopOrder shopOrder);
+
+    List<NewShopOrder> findSettlementList(NewShopOrder shopOrder);
+
+    List<SettleRecord> findSettleRecord(String shopOrderID);
+
+    List<NewShopOrder> findListByShopOrderId(Integer onlineShopOrderId);
+
+    //查询子订单是 线上 还是 线上
+    Integer payWay(Integer shopOrderID);
 }

+ 16 - 0
src/main/java/com/caimei/modules/order/entity/ChangePayShopDifference.java

@@ -144,6 +144,14 @@ public class ChangePayShopDifference implements Serializable {
      */
     private CmRefundShop refundShop;
 
+    /**
+     * 子订单收款状态  1待收款、2部分收款、3已收款
+     * @return
+     */
+    private  Integer shopReceiptStatus;
+
+
+
     public Integer getId() {
         return id;
     }
@@ -367,4 +375,12 @@ public class ChangePayShopDifference implements Serializable {
     public void setPayStatus(String payStatus) {
         this.payStatus = payStatus;
     }
+
+    public Integer getShopReceiptStatus() {
+        return shopReceiptStatus;
+    }
+
+    public void setShopReceiptStatus(Integer shopReceiptStatus) {
+        this.shopReceiptStatus = shopReceiptStatus;
+    }
 }

+ 9 - 0
src/main/java/com/caimei/modules/order/entity/CmReceiptOrderRelation.java

@@ -23,6 +23,7 @@ public class CmReceiptOrderRelation extends DataEntity<CmReceiptOrderRelation> {
     private String receiptDate;    //收款时间
     private String confirmType;        //确认订单类型
 
+    private Integer splitStatus;   //分账状态:0待分账,1已分账(只针对线上支付)
     /**
      * 抹平备注(目前适用后台直接抹平账户操作)
      */
@@ -47,6 +48,14 @@ public class CmReceiptOrderRelation extends DataEntity<CmReceiptOrderRelation> {
      */
     private String payWay;
 
+    public Integer getSplitStatus() {
+        return splitStatus;
+    }
+
+    public void setSplitStatus(Integer splitStatus) {
+        this.splitStatus = splitStatus;
+    }
+
     public String getPayWay() {
         return payWay;
     }

+ 36 - 0
src/main/java/com/caimei/modules/order/entity/CmRefundRecord.java

@@ -0,0 +1,36 @@
+package com.caimei.modules.order.entity;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+public class CmRefundRecord extends DataEntity<CmRefundRecord> {
+
+    private static final long serialVersionUID = 1L;
+
+    private Double refundAmount;
+    private String orderRequestNo;
+    private Integer shopOrderId;
+
+    public Double getRefundAmount() {
+        return refundAmount;
+    }
+
+    public void setRefundAmount(Double refundAmount) {
+        this.refundAmount = refundAmount;
+    }
+
+    public String getOrderRequestNo() {
+        return orderRequestNo;
+    }
+
+    public void setOrderRequestNo(String orderRequestNo) {
+        this.orderRequestNo = orderRequestNo;
+    }
+
+    public Integer getShopOrderId() {
+        return shopOrderId;
+    }
+
+    public void setShopOrderId(Integer shopOrderId) {
+        this.shopOrderId = shopOrderId;
+    }
+}

+ 34 - 0
src/main/java/com/caimei/modules/order/entity/CmRefundTransfer.java

@@ -0,0 +1,34 @@
+package com.caimei.modules.order.entity;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+public class CmRefundTransfer extends DataEntity<CmRefundTransfer> {
+    private static final long serialVersionUID = 1L;
+    private Integer transferType;//转账类型,1网银手续费2佣金
+    private Double transferAmount;//转账金额
+    private String orderRequestNo;
+
+    public Integer getTransferType() {
+        return transferType;
+    }
+
+    public void setTransferType(Integer transferType) {
+        this.transferType = transferType;
+    }
+
+    public Double getTransferAmount() {
+        return transferAmount;
+    }
+
+    public void setTransferAmount(Double transferAmount) {
+        this.transferAmount = transferAmount;
+    }
+
+    public String getOrderRequestNo() {
+        return orderRequestNo;
+    }
+
+    public void setOrderRequestNo(String orderRequestNo) {
+        this.orderRequestNo = orderRequestNo;
+    }
+}

+ 27 - 1
src/main/java/com/caimei/modules/order/entity/CmReturnedPurchase.java

@@ -30,6 +30,7 @@ public class CmReturnedPurchase extends DataEntity<CmReturnedPurchase> {
     private String operatingOrderStatus;    //发起该操作时订单状态快照:0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
     private Double returnedPurchaseFee;        // 退款(退货)总金额
     private Double refundFee;        // 退款总额(给买家)
+    private Double freeRefundFee;   //自定义退款总额
     private String image1;        // 凭证图片1
     private String image2;        // 凭证图片2
     private String image3;        // 凭证图片3
@@ -69,9 +70,26 @@ public class CmReturnedPurchase extends DataEntity<CmReturnedPurchase> {
     private String reviewUserName;//审核人
     private String name; //机构名
     private Integer orderType; //订单类型 0协销订单、 1普通订单、 2呵呵订单
-
+    private Integer refundType;  //退款模式 1按商品金额退款  2 自定义金额退款
     private String beginTime;     //时间开始 查询条件 申请时间
     private String endTime;        //时间结束  查询条件 申请时间
+    private Integer onlineShopOrderId; //子订单id
+
+    public Integer getOnlineShopOrderId() {
+        return onlineShopOrderId;
+    }
+
+    public void setOnlineShopOrderId(Integer onlineShopOrderId) {
+        this.onlineShopOrderId = onlineShopOrderId;
+    }
+
+    public Double getFreeRefundFee() {
+        return freeRefundFee;
+    }
+
+    public void setFreeRefundFee(Double freeRefundFee) {
+        this.freeRefundFee = freeRefundFee;
+    }
 
     public String getName() {
         return name;
@@ -123,6 +141,14 @@ public class CmReturnedPurchase extends DataEntity<CmReturnedPurchase> {
 //		this.shopOrderID = shopOrderID;
 //	}
 
+    public Integer getRefundType() {
+        return refundType;
+    }
+
+    public void setRefundType(Integer refundType) {
+        this.refundType = refundType;
+    }
+
     public Integer getUserID() {
         return userID;
     }

+ 62 - 14
src/main/java/com/caimei/modules/order/entity/Constant.java

@@ -12,17 +12,26 @@ public class Constant {
 
     public static final String betaSplit = "https://core-b.caimei365.com/order/pay/delay/split/callback";
 
-    //专票 信息 测试佣金暂入信息  308785626@qq.com vip/二手暂入信息
+    /**
+     * 专票 信息 测试佣金暂入信息  308785626@qq.com vip/二手暂入信息
+     */
     public static final String CUSTOMERNUM = "E1807059160";
-    //信息的邮箱
+    /**
+     * 信息的邮箱
+     */
     public static final String XX_MAIL = "308785626@qq.com";
 
-    //收款商编 网络   xun.zhang@caimei365.com
+    /**
+     * 收款商编 网络   xun.zhang@caimei365.com
+     */
     public static final String CUSTOMERNUM2 = "E1807062884";
-    //网络的邮箱
+    /**
+     * 网络的邮箱
+     */
     public static final String WL_MAIL = "xun.zhang@caimei365.com";
-
-    //普票 奥泰 测试私账暂进奥泰   caimei365@yeah.net
+    /**
+     * 普票 奥泰 测试私账暂进奥泰   caimei365@yeah.net
+     */
     public static final String CUSTOMERNUM3 = "E1807085606";
 
     public static final String AT_MAIL = "caimei365@yeah.net";
@@ -30,24 +39,63 @@ public class Constant {
     public static final String SPLIT = "&";
 
     public static final String DOMAIN_NAME = "http://pay.trx.helipay.com/";
-    //网银地址http://pay.trx.helipay.com/trx/online/interface.action
+    /**
+     * 网银地址http://pay.trx.helipay.com/trx/online/interface.action
+     */
     public static final String YL = "http://pay.trx.helipay.com/trx/online/interface.action";
-    //分账地址
+    /**
+     * 分账地址
+     */
     public static final String FZ = "http://pay.trx.helipay.com/trx/accountPay/interface.action";
+    /**
+     * 结算地址
+     */
+    public static final String JS = "http://transfer.trx.helipay.com/trx/transfer/interface.action";
 
-    //微信/支付宝扫码/小程序公众号支付
+    /**
+     * 微信/支付宝扫码/小程序公众号支付
+     */
     public static final String SAOMA = "1iHnZaalUNAVcfcbKdh6n86Z0yUHtM6f";
-    //网银
+    /**
+     * 网银
+     */
     public static final String WANGYIN = "CZiCbGrgFYQMldVkQnzbFQeQkn6mp25w";
-    //虚拟账户支付
+    /**
+     * 虚拟账户支付
+     */
     public static final String XUNI = "8VmdRSXMIOfUo7aEq1iYs2XEWgGZpBQc";
-    //分账
+    /**
+     * 分账
+     */
     public static final String FENZHANG = "2hATS0A4IoxdudGxNkGRNOt6aFSdOd8Q";
-    //公共产品
+    /**
+     * 公共产品
+     */
     public static final String GONG="wrED4jYgKLQVsEwtgZ2eQmXrRgo7VHy4";
+    /**
+     * 结算
+     */
+    public static final String JIESUAN="fiweQU8igfuhBTcXLLDAQ3DScwIPEy2s";
+
     /**
      * 扫码接口地址
      */
     public static final String REQUEST_URL = DOMAIN_NAME + "trx/app/interface.action";
-
+    /**
+     *     结算私钥
+     */
+    public static final String signKey_setttlement = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAK8T2luDwK3jKwLp\n" +
+            "AVNRr8+1qHGUkCIe6ZicK6Oc33xB4vA+2Hyz9I9343DgcYbuq6/t7lxzb5+fRvjd\n" +
+            "B63YM4bFDh0nyDeoNwoKCWUlHV1iuqJC5rHr/C96IR+l0Aiu619lZI+mmkFgX8xd\n" +
+            "g2gX4Up1sqZlwy0qv25mm9skyK01AgMBAAECgYEAn75YjQmhA8fzlbsuF2zAIqAY\n" +
+            "alHoVQmpkDJmaumWzJR9UUG2W8oCiekU4AgZ7cjVZDePNlGpdpZotmdOO2O6VmkF\n" +
+            "x9mOcgcM87t9PmkkRcVjpvkSixFyNFRpcYECm+YXOE/d/1rS5zvOubU3L8XzvP9O\n" +
+            "SQQhQ8xtVl9SFoAMB70CQQDkQv7mtsoMrwqxwC4/tXzSoOclEOSWXqtNEAxMlq5D\n" +
+            "ZAPeOSfImwTlb7s5lX1MkrbdOvf2EWoW5cNaLyIdo3jDAkEAxFpZUvUu0oS4EOtX\n" +
+            "kXZaJicuRaovY9TzGjEr9pTgRGlOcK3pUS4nNEKqT8cBfgNJ1veBsk25g8fHMKQq\n" +
+            "GMkipwJBAMl0+6XCM+cn4gdpNyhRVD5NdlO3ahfwq71S6Zf68QhXUDakOSGK97JL\n" +
+            "f3FeJ30ai7wLXGdXjUtyM4z3xmNkMKMCQFC5ECXx1JkJpR6Xkj2kGXW7/+L2D1uM\n" +
+            "jZEEDB3ooLafUHc0mEoenlF24su/ddaXhYDR6kkieRU7SaGuq/vanNsCQQC8fuH0\n" +
+            "APa0grLrsMdNTLlHNCnf/s+mjeMt3rV3SbPZ5pbnEPWILYvxN8NnOVZmxQw6E7+R\n" +
+            "CBcHmGCo7zF53o4t";
 }

+ 36 - 1
src/main/java/com/caimei/modules/order/entity/NewOrder.java

@@ -84,6 +84,7 @@ public class NewOrder extends DataEntity<NewOrder> {
     // -----------------  v5.0.0 end
 
     //-------------        虚拟字段   ----------------------------
+    private Integer settleRecordNum;   //佣金结算数量
     private String shopName;            //供应商
     private String receiver;//收货人
     private String buyer;//买家
@@ -108,6 +109,8 @@ public class NewOrder extends DataEntity<NewOrder> {
     private String applyReturnedPurchaseFlag;//0不可以申请,1可以申请(此标记只用于是否存在审核中或者审核不通过记录,存在记录则不可以申请)
     private String spName;
     private Integer serviceProviderId;  //协销Id
+    private Integer settleStatus;    //结算状态   1未结算2部分结算3已结算
+    private Double settleAmount;   // 已结算金额
 
     private String productName;     //商品名称(根据商品名称筛选订单)
     private List<NewOrderProduct> orderProduct;// 订单内的商品集合
@@ -148,7 +151,7 @@ public class NewOrder extends DataEntity<NewOrder> {
     private Integer collageStatus;  // 拼团状态:1拼团中,2已拼成
     private Double reductionAmount;    //分享减免金额
     private Double reductionTouchPrice; //分享减免条件
-
+    private Integer onlinfePayFlag;  //线上支付标记
 
     /**
      * 呵呵商城优惠券
@@ -156,6 +159,30 @@ public class NewOrder extends DataEntity<NewOrder> {
     private Integer receiveCouponId;
     private CmHeheCouponOrderRecord heheCouponRecord;   //优惠券信息
 
+    public Double getSettleAmount() {
+        return settleAmount;
+    }
+
+    public void setSettleAmount(Double settleAmount) {
+        this.settleAmount = settleAmount;
+    }
+
+    public Integer getSettleRecordNum() {
+        return settleRecordNum;
+    }
+
+    public void setSettleRecordNum(Integer settleRecordNum) {
+        this.settleRecordNum = settleRecordNum;
+    }
+
+    public Integer getOnlinfePayFlag() {
+        return onlinfePayFlag;
+    }
+
+    public void setOnlinfePayFlag(Integer onlinfePayFlag) {
+        this.onlinfePayFlag = onlinfePayFlag;
+    }
+
     public Integer getOrderSeen() {
         return orderSeen;
     }
@@ -180,6 +207,14 @@ public class NewOrder extends DataEntity<NewOrder> {
         this.promotions = promotions;
     }
 
+    public Integer getSettleStatus() {
+        return settleStatus;
+    }
+
+    public void setSettleStatus(Integer settleStatus) {
+        this.settleStatus = settleStatus;
+    }
+
     public Double getPromotionFullReduction() {
         return promotionFullReduction;
     }

+ 19 - 0
src/main/java/com/caimei/modules/order/entity/NewShopOrder.java

@@ -95,6 +95,8 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private BigDecimal differencePrice;  //补差价金额
     private Integer userBeans; //订单采美豆数量
     private Double svipShopReduction;   //超级会员优惠
+    private Integer settleStatus;    //结算状态   1未结算2部分结算3已结算
+    private Integer payWay; //线上支付状态 1线上 2线下 3余额抵扣
     //-------------        虚拟字段   ----------------------------
     private Double income;       //主订单总佣金
     private List<String> shopOrderNos;      //主订单下所有子订单
@@ -152,6 +154,23 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
 
     private boolean payShopOtherFee = true; //是否可以付第三方申请
 
+    public Integer getSettleStatus() {
+        return settleStatus;
+    }
+
+    public void setSettleStatus(Integer settleStatus) {
+        this.settleStatus = settleStatus;
+    }
+
+
+    public Integer getPayWay() {
+        return payWay;
+    }
+
+    public void setPayWay(Integer payWay) {
+        this.payWay = payWay;
+    }
+
     public Double getIncome() {
         return income;
     }

+ 59 - 0
src/main/java/com/caimei/modules/order/entity/SettleRecord.java

@@ -0,0 +1,59 @@
+package com.caimei.modules.order.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class SettleRecord implements Serializable {
+
+    private Double settleAmount;
+    /**
+     * 结算类型 1供应商成本,2佣金
+     */
+    private Integer settleType;
+    private String shopOrderId;
+    private String splitCode;
+    private Date settleTime;
+
+    public Double getSettleAmount() {
+        return settleAmount;
+    }
+
+    public void setSettleAmount(Double settleAmount) {
+        this.settleAmount = settleAmount;
+    }
+
+    public Integer getSettleType() {
+        return settleType;
+    }
+
+    public void setSettleType(Integer settleType) {
+        this.settleType = settleType;
+    }
+
+    public String getShopOrderId() {
+        return shopOrderId;
+    }
+
+    public void setShopOrderId(String shopOrderId) {
+        this.shopOrderId = shopOrderId;
+    }
+
+    public String getSplitCode() {
+        return splitCode;
+    }
+
+    public void setSplitCode(String splitCode) {
+        this.splitCode = splitCode;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date getSettleTime() {
+        return settleTime;
+    }
+
+    public void setSettleTime(Date settleTime) {
+        this.settleTime = settleTime;
+    }
+}

+ 81 - 0
src/main/java/com/caimei/modules/order/entity/SettleResult.java

@@ -0,0 +1,81 @@
+package com.caimei.modules.order.entity;
+
+import com.google.common.collect.ImmutableSet;
+
+import java.io.Serializable;
+import java.util.Set;
+
+public class SettleResult implements Serializable{
+    private String rt1_bizType;
+    private String rt2_retCode;
+    private String rt3_retMsg;
+    private String rt4_customerNumber;
+    private String rt5_orderId;
+    private String sign;
+
+    /**
+     * 需要加签的属性参数
+     * 看接口文档
+     */
+    public static final Set<String> NEED_SIGN_PARAMS = ImmutableSet.of("rt1_bizType", "rt2_retCode", "rt4_customerNumber", "rt5_orderId");
+
+    public String getRt1_bizType() {
+        return rt1_bizType;
+    }
+
+    public void setRt1_bizType(String rt1_bizType) {
+        this.rt1_bizType = rt1_bizType;
+    }
+
+    public String getRt2_retCode() {
+        return rt2_retCode;
+    }
+
+    public void setRt2_retCode(String rt2_retCode) {
+        this.rt2_retCode = rt2_retCode;
+    }
+
+    public String getRt3_retMsg() {
+        return rt3_retMsg;
+    }
+
+    public void setRt3_retMsg(String rt3_retMsg) {
+        this.rt3_retMsg = rt3_retMsg;
+    }
+
+    public String getRt4_customerNumber() {
+        return rt4_customerNumber;
+    }
+
+    public void setRt4_customerNumber(String rt4_customerNumber) {
+        this.rt4_customerNumber = rt4_customerNumber;
+    }
+
+    public String getRt5_orderId() {
+        return rt5_orderId;
+    }
+
+    public void setRt5_orderId(String rt5_orderId) {
+        this.rt5_orderId = rt5_orderId;
+    }
+
+    public String getSign() {
+        return sign;
+    }
+
+    public void setSign(String sign) {
+        this.sign = sign;
+    }
+
+    @Override
+    public String toString() {
+        return "SettleResult{" +
+                "rt1_bizType='" + rt1_bizType + '\'' +
+                ", rt2_retCode='" + rt2_retCode + '\'' +
+                ", rt3_retMsg='" + rt3_retMsg + '\'' +
+                ", rt4_customerNumber='" + rt4_customerNumber + '\'' +
+                ", rt5_orderId='" + rt5_orderId + '\'' +
+                ", sign='" + sign + '\'' +
+                '}';
+    }
+}

+ 219 - 5
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -1,16 +1,23 @@
 package com.caimei.modules.order.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.caimei.dfs.image.beens.ImageUploadInfo;
 import com.caimei.modules.common.utils.UploadUtils;
 import com.caimei.modules.hehe.dao.HeHeNewOrderDao;
 import com.caimei.modules.miniprogram.utils.UploadPicUtils;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
+import com.caimei.modules.order.utils.Disguiser;
+import com.caimei.modules.order.utils.MyBeanUtils;
+import com.caimei.modules.order.utils.RSA;
+import com.caimei.modules.order.utils.SettlePostFormUtil;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.user.dao.NewCmShopDao;
 import com.caimei.modules.user.entity.NewCmShop;
+import com.caimei.redis.RedisService;
 import com.caimei.utils.MathUtil;
 import com.caimei.utils.StringUtil;
+import com.opensymphony.module.sitemesh.html.CustomTag;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
@@ -23,10 +30,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.beans.IntrospectionException;
+import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
@@ -63,6 +71,8 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
     private HeHeNewOrderDao heHeNewOrderDao;
     @Resource
     private CmRefundShopDao cmRefundShopDao;
+    @Resource
+    private RedisService redisService;
 
 
     public List<CmPayShop> exports(Page<CmPayShop> cmPayShopPage, CmPayShop cmPayShop) {
@@ -252,7 +262,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 so.setDiscountTotalFee(newOrder.getDiscountFee());
                 //机构运费
                 so.setFreight(newOrder.getFreight());
-                if("0".equals(newOrder.getFreePostFlag())||"-1".equals(newOrder.getFreePostFlag())||"-2".equals(newOrder.getFreePostFlag())){
+                if ("0".equals(newOrder.getFreePostFlag()) || "-1".equals(newOrder.getFreePostFlag()) || "-2".equals(newOrder.getFreePostFlag())) {
                     so.setFreight(Double.valueOf(newOrder.getFreePostFlag()));
                 }
                 //机构运费是否已退
@@ -265,6 +275,21 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 //主订单总佣金
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
                 so.setIncome(income);
+               //若成本下降太多导致部分收款的钱,已经大于成本重新计算佣金
+                if("0".equals(newOrder.getOnlinePayFlag()) && so.getShopReceiptStatus()==2){
+                    double mum= so.getProductAmount();
+                    System.out.println(so.getReceiptTotalFee());
+                    System.out.println(so.getShouldPayShopAmount());
+                    BigDecimal getShouldPayShopAmount = MathUtil.sub(so.getShouldPayShopAmount(), so.getDifferencePrice());
+                    if(so.getReceiptTotalFee()>Double.valueOf(getShouldPayShopAmount.toString())){
+                        //子订单佣金
+
+                        mum-= so.getShopOtherFee()+Double.valueOf(getShouldPayShopAmount.toString());
+                        so.setBrokerage(mum);
+                    }else { so.setBrokerage(null);}
+                }else { so.setBrokerage(null);}
+                //要是不大于成本默认显示
+
             }
             cmPayShop.setTotalAmount(totalAmount);
             cmPayShop.setBalancePayFee(0D);
@@ -338,7 +363,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 so.setDiscountTotalFee(newOrder.getDiscountFee());
                 //机构运费
                 so.setFreight(newOrder.getFreight());
-                if("0".equals(newOrder.getFreePostFlag())||"-1".equals(newOrder.getFreePostFlag())||"-2".equals(newOrder.getFreePostFlag())){
+                if ("0".equals(newOrder.getFreePostFlag()) || "-1".equals(newOrder.getFreePostFlag()) || "-2".equals(newOrder.getFreePostFlag())) {
                     so.setFreight(Double.valueOf(newOrder.getFreePostFlag()));
                 }
                 //机构运费是否已退
@@ -352,6 +377,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
                 so.setIncome(income);
             }
+
             cmPayShop.setShopOrders(csos);
         }
     }
@@ -929,6 +955,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
             payShopDifference.setRebateAmount(BigDecimal.valueOf(rebateAmount));
             payShopDifference.setType(shopOrder.getDifferenceType());
             payShopDifference.setDifferencePrice(shopOrder.getDifferencePrice());
+            payShopDifference.setShopReceiptStatus( shopOrder.getShopReceiptStatus());
         }
         payShopDifference.setWaitPayShop(waitPayShop);
         return payShopDifference;
@@ -1075,6 +1102,9 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         if (!("3".equals(shopOrder.getPayStatus()) && 1 == payShopDifference.getType())) {
             newShopOrderDao.updateByDifferencePrice(payShopDifference.getType(), differencePrice, shopOrderId);
         }
+
+
+
     }
 
     public ChangePayShopOther shopOtherApplyEdit(Integer payShopId) {
@@ -1096,4 +1126,188 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         payShopOther.setPayShopId(payShopId);
         return payShopOther;
     }
+
+    public void settleEdit(CmPayShop cmPayShop, String[] shopOrderIDs) {
+        if (shopOrderIDs != null && shopOrderIDs.length >= 1) {  //新建
+            List<NewShopOrder> payOrderList = newShopOrderDao.findPayOrderListByIDs(shopOrderIDs);
+            List<Integer> shopIDs = payOrderList.stream().map(NewShopOrder::getShopID).distinct().collect(Collectors.toList());
+            Integer shopID = shopIDs.get(0);
+            NewCmShop shop = newCmShopDao.get(shopID + "");
+            cmPayShop.setShopID(shop.getShopID().toString());
+            cmPayShop.setShopName(shop.getName());
+            cmPayShop.setBankAccount(shop.getBankAccount());
+            cmPayShop.setBankAccountName(shop.getBankAccountName());
+            cmPayShop.setBankName(shop.getBankName());
+            cmPayShop.setAbleRebateAmount(shop.getAbleRebateAmount() == null ? 0D : shop.getAbleRebateAmount());
+            cmPayShop.setRebateAmount(shop.getRebateAmount() == null ? 0D : shop.getRebateAmount());
+            //付款单待付供应商总金额
+            double totalAmount = 0D;
+            for (NewShopOrder so : payOrderList) {
+                totalAmount += ((so.getShouldPayShopAmount() == null ? 0D : so.getShouldPayShopAmount()) -
+                        (so.getPayedShopAmount() == null ? 0D : so.getPayedShopAmount()));
+                if (so.getDifferenceType() != null && so.getDifferenceType() == 1) {
+                    totalAmount = MathUtil.add(totalAmount, so.getDifferencePrice()).doubleValue();
+                } else if (so.getDifferenceType() != null && so.getDifferenceType() == 2) {
+                    totalAmount = MathUtil.sub(totalAmount, so.getDifferencePrice()).doubleValue();
+                }
+                List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
+                /*
+                 1. 若发生退货,数量要减去已退货和已取消的数量
+                 2. 有赠品的商品只能全退
+                 */
+                for (NewOrderProduct p : orderProductList) {
+                    Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
+                    returnNum = returnNum == null ? 0 : returnNum;
+                    p.setReturnedNum(returnNum);
+                }
+                so.setNewOrderProducts(orderProductList);
+                so.setWaitPayShop((so.getShouldPayShopAmount() == null ? 0D : so.getShouldPayShopAmount()) - (so.getPayedShopAmount() == null ? 0D : so.getPayedShopAmount()));
+                if (so.getDifferenceType() != null && so.getDifferenceType() == 1) {
+                    BigDecimal waitPayShop = MathUtil.add(so.getWaitPayShop(), so.getDifferencePrice());
+                    so.setWaitPayShop(waitPayShop.doubleValue());
+                } else if (so.getDifferenceType() != null && so.getDifferenceType() == 2) {
+                    BigDecimal waitPayShop = MathUtil.sub(so.getWaitPayShop(), so.getDifferencePrice());
+                    so.setWaitPayShop(waitPayShop.doubleValue());
+                }
+                // 设置线上单的已付为已经结算的金额
+                so.setPayedShopAmount(newOrderDao.findSettleSum(so.getShopOrderID().toString()));
+                //统计该子订单的主的收款金额和收款状态
+                NewOrder newOrder = newOrderDao.get(so.getOrderID().toString());
+                if (null != newOrder) {
+                    so.setReceiptStatus(newOrder.getReceiptStatus());
+                    if ("2".equals(newOrder.getOrderType())) {
+                        //呵呵商城订单
+                        so.setOrderType(2);
+                        String name = heHeNewOrderDao.findHeUser(newOrder.getUserID());
+                        so.setClubName(name);
+                    }
+                } else {
+                    so.setReceiptStatus("1");
+                }
+                Double receiptTotalFee = cmReceiptOrderRelationDao.findPayFeeByOrderID(so.getOrderID().toString());
+                so.setReceiptTotalFee(receiptTotalFee);
+                //主订单退款(退货)总金额
+                so.setReturnedPurchaseTotalFee(newShopOrderService.getOrderReturnedPurchaseFee(so));
+                //经理折扣
+                so.setDiscountTotalFee(newOrder.getDiscountFee());
+                //机构运费
+                so.setFreight(newOrder.getFreight());
+                if ("0".equals(newOrder.getFreePostFlag()) || "-1".equals(newOrder.getFreePostFlag()) || "-2".equals(newOrder.getFreePostFlag())) {
+                    so.setFreight(Double.valueOf(newOrder.getFreePostFlag()));
+                }
+                //机构运费是否已退
+                Integer returnedFreightNum = newOrderProductDao.countReturnedFreightProduct(so.getOrderID());
+                Boolean returnedFreightFlag = returnedFreightNum == null ? false : returnedFreightNum > 0 ? true : false;
+                so.setReturnedFreightFlag(returnedFreightFlag);
+                //所有子订单号
+                List<String> strings = newShopOrderDao.findShopOrderNos(so.getOrderID());
+                so.setShopOrderNos(strings);
+                //主订单总佣金
+                Double income = newShopOrderDao.findIncome(so.getOrderID());
+                so.setIncome(income);
+            }
+            cmPayShop.setTotalAmount(totalAmount);
+            cmPayShop.setBalancePayFee(0D);
+            cmPayShop.setTransferPayFee(totalAmount);
+            User currentUser = UserUtils.getUser();
+            cmPayShop.setApplicant(currentUser.getId());
+            cmPayShop.setApplicantName(currentUser.getName());
+            cmPayShop.setStatus("0");
+            cmPayShop.setShopOrders(payOrderList);
+        } else {
+            applyDetail(cmPayShop);
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public void settlement(String shopOrderId, Double settleAmount) throws Exception {
+        // 结算付供应商
+        String format = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
+        String substring = format.substring(20);
+        String P3_customerNumber = newOrderDao.findSplitCode(shopOrderId);
+        redisService.set("SDJSS", 1, 120L);
+        settleOrder("JSCB" + shopOrderId + substring, settleAmount, P3_customerNumber, shopOrderId, 1);
+        // 结算佣金 佣金目前分到网络
+        Double payAmount = newOrderDao.findPayAmount(shopOrderId);
+        if (null != payAmount && payAmount > 0) {
+            settleOrder("JSYJ" + shopOrderId + substring, payAmount, Constant.CUSTOMERNUM2, shopOrderId, 2);
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public void settleOrder(String P2_orderId, Double settleAmount, String P3_customerNumber, String shopOrderId, Integer settleFlag) throws Exception {
+        //子订单id,结算金额
+        Map<String, String> sPara = new HashMap<String, String>();
+        sPara.put("P1_bizType", "MerchantSettlement");
+        sPara.put("P2_orderId", P2_orderId);
+        sPara.put("P3_customerNumber", P3_customerNumber);
+        sPara.put("P4_amount", settleAmount.toString());
+        sPara.put("P5_summary", "订单结算");
+        sPara.put("signType", "RSA");
+        StringBuffer sb = new StringBuffer();
+        sb.append(Constant.SPLIT).append("MerchantSettlement").append(Constant.SPLIT).append(P2_orderId).append(Constant.SPLIT)
+                .append(P3_customerNumber).append(Constant.SPLIT).append(settleAmount).append(Constant.SPLIT).append("订单结算")
+                .append(Constant.SPLIT).append("RSA");
+        String sign = RSA.sign(sb.toString(), RSA.getPrivateKey(Constant.signKey_setttlement));
+        sPara.put("sign", sign);
+        SettleResult settleResult = SettlePostFormUtil.postForm(sPara, Constant.JS, sign, SettleResult.class);
+        if (!"0000".equals(settleResult.getRt2_retCode())) {
+            logger.info("settleResult----------------->" + settleResult.toString());
+            throw new Exception("结算失败!");
+        } else {
+            String assemblyRespOriSign = "";
+            assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(settleResult, SettleResult.NEED_SIGN_PARAMS);
+            assemblyRespOriSign += Constant.JIESUAN;
+            String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
+            if (!checkSign.equals(settleResult.getSign())) {
+                logger.info("settleResult----------------->" + settleResult.toString());
+                throw new Exception("结算验签失败!");
+            } else {
+                SettleRecord settleRecord = new SettleRecord();
+                //存结算表,改子订单结算状态
+                if (1 == settleFlag) {
+                    //成本结算
+                    settleRecord.setSettleType(settleFlag);
+                    settleRecord.setSettleAmount(settleAmount);
+                    settleRecord.setSplitCode(P3_customerNumber);
+                    settleRecord.setShopOrderId(shopOrderId);
+                    newOrderDao.insertSettleRecord(settleRecord);
+                    // 修改cm_split_account settlestatus
+                    newOrderDao.updateSettleStatus(shopOrderId, 1);
+                    //计算供应商成本,结算金额,修改结算状态
+                    Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
+                    Double settleSum = newOrderDao.findSettleSum(shopOrderId);
+                    if (shouldPayShopAmount > settleSum) {
+                        //成本>结算金额,部分结算
+                        newOrderDao.updateShopOrderSettleStatus(shopOrderId, 2);
+                    } else {
+                        //成本=结算金额 全部结算
+                        newOrderDao.updateShopOrderSettleStatus(shopOrderId, 3);
+                    }
+                } else {
+                    //佣金结算
+                    settleRecord.setSettleType(settleFlag);
+                    settleRecord.setSettleAmount(settleAmount);
+                    settleRecord.setSplitCode(P3_customerNumber);
+                    settleRecord.setShopOrderId(shopOrderId);
+                    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");
+            }
+        }
+    }
 }

+ 225 - 85
src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java

@@ -44,6 +44,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -125,6 +126,10 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
             model.addAttribute("errorMsg", "待确认,待收待发订单 不能申请退款");
             return "待确认,待收待发订单 不能申请退款";
         }
+        Integer changeFlag = 0;
+        if ("2".equals(cmReturnedPurchase.getReturnedWay())) {
+            changeFlag = 1;
+        }
         cmReturnedPurchase.setReturnedWay("1");
         if (NewOrderStatus.isNotPay(newOrder.getStatus())) {
             //未支付订单无退款
@@ -229,30 +234,32 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                 }
             }
         }
-        if (newOrder.getPromotionFullReduction() != null) {
-            //减去促销满减金额
-            returnedPurchaseFee = returnedPurchaseFee - newOrder.getPromotionFullReduction();
-        }
-        if (newOrder.getCouponAmount() > 0) {
-            //减去优惠券金额
-            returnedPurchaseFee = MathUtil.sub(returnedPurchaseFee, newOrder.getCouponAmount()).doubleValue();
-        }
-        cmReturnedPurchase.setReturnedPurchaseFee(returnedPurchaseFee);
-        refundFee += getRefundFee(newOrder, cmReturnedPurchase, freightNum);
-        //充值或缴纳订金订单
-        if (rechargeGoods) {
-            CmUser user = cmUserDao.get(newOrder.getUserID().toString());
-            if (user != null && user.getAbleUserMoney() != null && user.getAbleUserMoney() < refundFee) {
-                refundFee = user.getAbleUserMoney();
+        if (1 == cmReturnedPurchase.getRefundType() && 0 == changeFlag) {
+            if (newOrder.getPromotionFullReduction() != null) {
+                //减去促销满减金额
+                returnedPurchaseFee = returnedPurchaseFee - newOrder.getPromotionFullReduction();
             }
-            cmReturnedPurchase.setReturnedPurchaseFee(refundFee);
-            if (user != null) {
-                //冻结余额
-                user.setAbleUserMoney(user.getAbleUserMoney() - refundFee);
-                cmUserDao.updateMoney(user);
+            if (newOrder.getCouponAmount() > 0) {
+                //减去优惠券金额
+                returnedPurchaseFee = MathUtil.sub(returnedPurchaseFee, newOrder.getCouponAmount()).doubleValue();
+            }
+            cmReturnedPurchase.setReturnedPurchaseFee(returnedPurchaseFee);
+            refundFee += getRefundFee(newOrder, cmReturnedPurchase, freightNum);
+            //充值或缴纳订金订单
+            if (rechargeGoods) {
+                CmUser user = cmUserDao.get(newOrder.getUserID().toString());
+                if (user != null && user.getAbleUserMoney() != null && user.getAbleUserMoney() < refundFee) {
+                    refundFee = user.getAbleUserMoney();
+                }
+                cmReturnedPurchase.setReturnedPurchaseFee(refundFee);
+                if (user != null) {
+                    //冻结余额
+                    user.setAbleUserMoney(user.getAbleUserMoney() - refundFee);
+                    cmUserDao.updateMoney(user);
+                }
             }
+            cmReturnedPurchase.setRefundFee(refundFee);
         }
-        cmReturnedPurchase.setRefundFee(refundFee);
         cmReturnedPurchaseDao.update(cmReturnedPurchase);
         return null;
     }
@@ -563,7 +570,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
             }
             newOrderService.update(newOrder);
             //判断是否选择退回余额
-            if ((returnedPurchase.getReturnedWay().equals("1") && returnedPurchase.getRefundBalanceFee() > 0d) || newOrder.getRechargeGoods() != null) {
+            if ((StringUtils.isNotBlank(returnedPurchase.getReturnedWay())&&"1".equals(returnedPurchase.getReturnedWay()) && returnedPurchase.getRefundBalanceFee() > 0d) || (null!=newOrder.getRechargeGoods()&&(1 == newOrder.getRechargeGoods() || 2 == newOrder.getRechargeGoods()))) {
                 Double userMoney = user.getUserMoney();
                 Double ableUserMoney = user.getAbleUserMoney();
                 Double refundBalanceFee = returnedPurchase.getRefundBalanceFee();
@@ -572,7 +579,6 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                 if (ableUserMoney == null) ableUserMoney = 0d;
                 if (refundBalanceFee == null) refundBalanceFee = 0d;
                 user.setUserID(newOrder.getUserID());
-
                 //添加余额收支记录
                 CmUserBalanceRecord cmUserBalanceRecord = new CmUserBalanceRecord();
                 cmUserBalanceRecord.setUserId(newOrder.getUserID());
@@ -585,7 +591,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                 cmUserBalanceRecord.setReturnedId(Integer.parseInt(returnedPurchase.getId()));
                 cmUserBalanceRecord.setDelFlag("0");
 
-                if (newOrder.getRechargeGoods() != null) {
+                if (null != newOrder.getRechargeGoods() && (1 == newOrder.getRechargeGoods() || 2 == newOrder.getRechargeGoods())) {
                     user.setUserMoney(userMoney - refundFee);
                     cmUserBalanceRecord.setAmount(String.valueOf(refundFee));
                     cmUserBalanceRecord.setType("2");
@@ -605,12 +611,13 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
             updateShopOrderAmount(newOrder.getOrderID());
 
             //判断是否有线上退款
-            if (returnedPurchase.getReturnedWay().equals("1") && returnedPurchase.getRefundOnlineFee() > 0) {
-                List<Integer> shopOrderIds = cmReturnedPurchaseDao.findReturnedShopOrder(returnedPurchase.getOrderID());
+            if ("1".equals(returnedPurchase.getReturnedWay()) && returnedPurchase.getRefundOnlineFee() > 0) {
+                List<Integer> shopOrderIds = cmReturnedPurchaseDao.getReturnShopOrder(returnedPurchase.getId());
                 if (null == shopOrderIds || 0 == shopOrderIds.size()) {
                     throw new Exception("退款子订单信息错误!");
                 }
-                theOnlineRefund(shopOrderIds);
+                Double refundOnlineFee = returnedPurchase.getRefundOnlineFee();
+                theOnlineRefund(shopOrderIds, refundOnlineFee);
             }
 
             //二手订单交易全退,标记未售
@@ -752,28 +759,158 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
      *
      * @param shopOrderIds
      */
-    public void theOnlineRefund(List<Integer> shopOrderIds) {
+    public void theOnlineRefund(List<Integer> shopOrderIds, Double refundOnlineFee) throws Exception {
         List<CmReceiptOrderRelation> relationList = cmReceiptOrderRelationDao.findByShopOrderIds(shopOrderIds);
-//        AtomicDouble allRefund = new AtomicDouble(0);
-//        relationList.forEach(r -> allRefund.getAndSet(Double.parseDouble(r.getAssociateAmount())));
         if (null != relationList && relationList.size() > 0) {
             for (CmReceiptOrderRelation orderRelation : relationList) {
                 //cdr表payway为1纯线上收款
                 if ("1".equals(orderRelation.getPayWay())) {
+                    String value = "";
+                    double chargeFee = MathUtil.sub(refundOnlineFee, Double.parseDouble(orderRelation.getAssociateAmount())).doubleValue();
+                    if (chargeFee > 0) {
+                        //要退的钱大于本次交易金额
+                        value = orderRelation.getAssociateAmount();
+                    } else {
+                        value = refundOnlineFee.toString();
+                    }
                     //不同产品区分
                     if ("12".equals(orderRelation.getPayType()) || "17".equals(orderRelation.getPayType())) {
+                        if (1 == orderRelation.getSplitStatus()) {
+                            //已分帐应该先转回佣金
+                            //如果已转回则不再转。
+                            Double refundTransfer = cmReturnedPurchaseDao.findRefundTransfer(orderRelation.getOrderRequestNo());
+                            if (0 == refundTransfer) {
+                                Double brokerage = cmReturnedPurchaseDao.findBrokerage(orderRelation.getOrderRequestNo());
+                                if (brokerage > 0) {
+                                    //0.1%手续费,转回金额*99.9%=brokerage
+                                    Double v = MathUtil.div(brokerage, 0.999, 2).doubleValue();
+                                    transferMoney(v, orderRelation.getShopOrderId(), orderRelation.getOrderRequestNo(), 2);
+                                }
+                            }
+                        }
+                        //手续费转给供应商
+                        Double refundTransfer = cmReturnedPurchaseDao.findRefundCharge(orderRelation.getOrderRequestNo());
+                        if (0 == refundTransfer) {
+                            //计算手续费
+                            Double payAmount = cmReturnedPurchaseDao.findPayAmount(orderRelation.getOrderRequestNo());
+                            Double charge = 0d;
+                            //个人0.2%企业10
+                            if ("12".equals(orderRelation.getPayType())) {
+                                charge = MathUtil.mul(payAmount, 0.002, 2).doubleValue();
+                            } else {
+                                charge = 10d;
+                            }
+                            //0.1%手续费,转回金额*99.9%=payAmount
+                            Double v = MathUtil.div(charge, 0.999, 2).doubleValue();
+                            transferMoney(v, orderRelation.getShopOrderId(), orderRelation.getOrderRequestNo(), 1);
+                        }
                         //网银
-                        unionRefund(orderRelation.getOrderRequestNo(), orderRelation.getAssociateAmount(), orderRelation.getShopOrderId());
+                        unionRefund(orderRelation.getOrderRequestNo(), value, orderRelation.getShopOrderId());
                     } else {
+                        // 已分帐应该先转回佣金
+                        if (1 == orderRelation.getSplitStatus()) {
+                            //已分帐应该先转回佣金
+                            //如果已转回则不再转。
+                            Double refundTransfer = cmReturnedPurchaseDao.findRefundTransfer(orderRelation.getOrderRequestNo());
+                            if (0 == refundTransfer) {
+                                Double brokerage = cmReturnedPurchaseDao.findBrokerage(orderRelation.getOrderRequestNo());
+                                if (brokerage > 0) {
+                                    //0.1%手续费,转回金额*99.9%=brokerage
+                                    Double v = MathUtil.div(brokerage, 0.999, 2).doubleValue();
+                                    transferMoney(v, orderRelation.getShopOrderId(), orderRelation.getOrderRequestNo(), 2);
+                                }
+                            }
+                        }
                         //扫码
-                        onlinePay(orderRelation.getOrderRequestNo(), orderRelation.getAssociateAmount(), orderRelation.getShopOrderId());
+                        onlinePay(orderRelation.getOrderRequestNo(), value, orderRelation.getShopOrderId());
+                    }
+
+                    if (0 == refundOnlineFee) {
+                        break;
                     }
                 }
             }
         }
     }
 
-    public void onlinePay(String orderRequestNo, String money, Integer shopOrderId) {
+    public void transferMoney(Double v, Integer shopOrderId, String orderRequestNo, Integer flag) {
+        try {
+            AccountPayOrder accountPayOrder = new AccountPayOrder();
+            accountPayOrder.setP1_bizType("AccountPaySub");
+            accountPayOrder.setP2_signType("MD5");
+            String format1 = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
+            accountPayOrder.setP3_timestamp(format1);
+            String substring = format1.substring(20);
+            // fz+当前微秒时间+原唯一订单号
+            accountPayOrder.setP4_orderId("FZ" + substring + orderRequestNo);
+            //付款账户子订单绑定商户号(这里从佣金转出)
+            accountPayOrder.setP5_customerNumber(Constant.CUSTOMERNUM2);
+            AccountPayOrder.AccountPayOrderExt accountPayOrderExt = new AccountPayOrder.AccountPayOrderExt();
+            //收款账户商编  填写splitBillRules时候不填写MerchantNo,Amount并且即使填写这两个参数不生效!!
+            accountPayOrderExt.setInMerchantNo(cmReturnedPurchaseDao.findSplitCode(shopOrderId));
+            accountPayOrderExt.setOrderType(AccountPayOrderType.TRANSFER);
+            accountPayOrderExt.setAmount(BigDecimal.valueOf(v));
+            accountPayOrderExt.setServerCallbackUrl("");
+            accountPayOrderExt.setGoodsName("退款转账");
+            String ext = JSON.toJSONString(accountPayOrderExt);
+            logger.info("退款转账分账规则串json串:" + ext);
+            accountPayOrder.setP6_ext(ext);
+            // 生成签名
+            StringBuilder builder = new StringBuilder();
+            builder.append(Constant.SPLIT)
+                    .append(accountPayOrder.getP1_bizType()).append(Constant.SPLIT)
+                    .append(accountPayOrder.getP2_signType()).append(Constant.SPLIT)
+                    .append(accountPayOrder.getP3_timestamp()).append(Constant.SPLIT)
+                    .append(accountPayOrder.getP4_orderId()).append(Constant.SPLIT)
+                    .append(accountPayOrder.getP5_customerNumber()).append(Constant.SPLIT)
+                    .append(accountPayOrder.getP6_ext()).append(Constant.SPLIT)
+                    .append(Constant.XUNI);
+            String sign = Disguiser.disguiseMD5(builder.toString().trim());
+            Map<String, String> bean = convertBean(accountPayOrder);
+            logger.info("--------------------> 发送退款转账参数:  " + bean);
+            Map<String, String> map = postForm(bean, Constant.FZ, sign, Map.class);
+            logger.info("----------------退款转账数据: " + map.toString());
+            if (map != null) {
+                String code = map.get("rt5_retCode");
+                if (!"0000".equals(code)) {
+                    String msg = map.get("rt6_retMsg");
+                    logger.info("【退款转账】>>>>>>>>>>退款转账失败>>>>>>>msg:" + msg);
+                } else {
+                    CmRefundTransfer cmRefundTransfer = new CmRefundTransfer();
+                    cmRefundTransfer.setTransferType(flag);
+                    cmRefundTransfer.setTransferAmount(v);
+                    cmRefundTransfer.setOrderRequestNo(orderRequestNo);
+                }
+            }
+        } catch (Exception e) {
+            logger.error("【退款转账】>>>>>>>>>>错误信息", e);
+        }
+    }
+
+    public Map<String, String> convertBean(Object bean) {
+        Class clazz = bean.getClass();
+        Field[] fields = clazz.getDeclaredFields();
+        for (Field f : fields) {
+            f.setAccessible(true);
+        }
+        try {
+            Map<String, String> retMap = new LinkedHashMap<>();
+            for (Field f : fields) {
+                String key = f.toString().substring(f.toString().lastIndexOf(".") + 1);
+                Object value = f.get(bean);
+                if (value == null) {
+                    value = "";
+                }
+                retMap.put(key, (String) value);
+            }
+            return retMap;
+        } catch (Exception e) {
+            logger.info("分账", e);
+            throw new IllegalStateException("分账异常", e);
+        }
+    }
+
+    public void onlinePay(String orderRequestNo, String money, Integer shopOrderId) throws Exception {
         AppPayRefundOrderVo orderVo = new AppPayRefundOrderVo();
         orderVo.setP1_bizType("AppPayRefund");
         String splitCode = cmReturnedPurchaseDao.findSplitCode(shopOrderId);
@@ -785,42 +922,43 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
         orderVo.setP4_refundOrderId("TK" + tk + orderRequestNo);
         //退款金额
         orderVo.setP5_amount(money);
-        try {
-            Map<String, String> map = MyBeanUtils.convertBean(orderVo, new LinkedHashMap());
-            String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppPayRefundOrderVo.NEED_SIGN_PARAMS);
-            oriMessage += Constant.SAOMA;
-            String sign = Disguiser.disguiseMD5(oriMessage.trim());
-            logger.info("签名串:" + sign);
-            map.put("sign", sign);
-            logger.info("发送参数:" + map);
-            Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
-            logger.info("响应结果:" + resultMap);
-            if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
-                String resultMsg = (String) resultMap.get("response");
-                AppPayRefundOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppPayRefundOrderResponseVo.class);
-                String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppPayRefundOrderResponseVo.NEED_SIGN_PARAMS);
-                assemblyRespOriSign += Constant.SAOMA;
-                logger.info("组装返回结果签名串:" + assemblyRespOriSign);
-                String responseSign = orderResponseVo.getSign();
-                logger.info("响应签名:" + responseSign);
-                String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
-                if (checkSign.equals(responseSign)) {
-                    if ("0001".equals(orderResponseVo.getRt2_retCode())) {
-                        logger.info("第三方退款成功>>>>>>>shopOrderId>>>" + shopOrderId);
-                    } else {
-                        logger.error("退款失败========================" + orderResponseVo.getRt5_orderId() + "-" + orderResponseVo.getRt3_retMsg());
-                        throw new Exception("第三方退款失败!");
-                    }
+        Map<String, String> map = MyBeanUtils.convertBean(orderVo, new LinkedHashMap());
+        String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppPayRefundOrderVo.NEED_SIGN_PARAMS);
+        oriMessage += Constant.SAOMA;
+        String sign = Disguiser.disguiseMD5(oriMessage.trim());
+        logger.info("签名串:" + sign);
+        map.put("sign", sign);
+        logger.info("发送参数:" + map);
+        Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
+        logger.info("响应结果:" + resultMap);
+        if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
+            String resultMsg = (String) resultMap.get("response");
+            AppPayRefundOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppPayRefundOrderResponseVo.class);
+            String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppPayRefundOrderResponseVo.NEED_SIGN_PARAMS);
+            assemblyRespOriSign += Constant.SAOMA;
+            logger.info("组装返回结果签名串:" + assemblyRespOriSign);
+            String responseSign = orderResponseVo.getSign();
+            logger.info("响应签名:" + responseSign);
+            String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
+            if (checkSign.equals(responseSign)) {
+                if ("0001".equals(orderResponseVo.getRt2_retCode())) {
+                    CmRefundRecord cmRefundRecord = new CmRefundRecord();
+                    cmRefundRecord.setRefundAmount(Double.parseDouble(money));
+                    cmRefundRecord.setOrderRequestNo(orderRequestNo);
+                    cmRefundRecord.setShopOrderId(shopOrderId);
+                    cmReturnedPurchaseDao.insertCmRefundRecord(cmRefundRecord);
+                    logger.info("第三方退款成功>>>>>>>shopOrderId>>>" + shopOrderId);
                 } else {
-                    logger.error("退款验签失败");
-                    throw new Exception("第三方退款验签失败!");
+                    logger.error("退款失败========================" + orderResponseVo.getRt5_orderId() + "-" + orderResponseVo.getRt3_retMsg());
+                    throw new Exception("第三方退款失败!");
                 }
             } else {
-                logger.error("退款请求失败");
-                throw new Exception("第三方退款请求失败!");
+                logger.error("退款验签失败");
+                throw new Exception("第三方退款验签失败!");
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+        } else {
+            logger.error("退款请求失败");
+            throw new Exception("第三方退款请求失败!");
         }
     }
 
@@ -828,7 +966,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
     //1.本方法内转账手续费等待到账再发起退款请求
     //2.异步
     //3.回调
-    void unionRefund(String orderRequestNo, String money, Integer shopOrderId) {
+    void unionRefund(String orderRequestNo, String money, Integer shopOrderId) throws Exception {
         Map<String, String> sPara = new HashMap<String, String>();
         sPara.put("P1_bizType", "OnlineRefund");
         sPara.put("P2_orderId", orderRequestNo);
@@ -843,30 +981,32 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                 append(money).append("&").append("TK" + orderRequestNo).append("&").append("无").append("&").append("&").append(Constant.WANGYIN);
         String sign = Disguiser.disguiseMD5(sb.toString());
         sPara.put("sign", sign);
-        try {
-            OnlineRefundData on = postForm(sPara, Constant.YL, sign, OnlineRefundData.class);
-            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(on), JSONObject.class);
-            if (!"0000".equals(on.getRt2_retCode())) {
-                logger.info("退款失败:" + on.toString());
-                throw new Exception("退款失败");
+        OnlineRefundData on = postForm(sPara, Constant.YL, sign, OnlineRefundData.class);
+        JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(on), JSONObject.class);
+        if (!"0000".equals(on.getRt2_retCode())) {
+            logger.info("退款失败:" + on.toString());
+            throw new Exception("退款失败");
+        } else {
+            String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(on, OnlineRefundData.NEED_SIGN_PARAMS);
+            logger.info("组装返回结果签名串:" + assemblyRespOriSign);
+            assemblyRespOriSign += Constant.SPLIT + Constant.WANGYIN;
+            String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
+            if (!checkSign.equals(on.getSign())) {
+                logger.error("验签失败========================" + on.getRt3_retMsg());
+                throw new Exception("第三方退款失败!");
             } else {
-                String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(on, OnlineRefundData.NEED_SIGN_PARAMS);
-                logger.info("组装返回结果签名串:" + assemblyRespOriSign);
-                assemblyRespOriSign += Constant.SPLIT + Constant.WANGYIN;
-                String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
-                if (!checkSign.equals(on.getSign())) {
-                    logger.error("验签失败========================" + on.getRt3_retMsg());
-                    throw new Exception("第三方退款失败!");
-                } else {
-                    logger.info("第三方退款成功");
-                }
+                CmRefundRecord cmRefundRecord = new CmRefundRecord();
+                cmRefundRecord.setRefundAmount(Double.parseDouble(money));
+                cmRefundRecord.setOrderRequestNo(orderRequestNo);
+                cmRefundRecord.setShopOrderId(shopOrderId);
+                cmReturnedPurchaseDao.insertCmRefundRecord(cmRefundRecord);
+                logger.info("第三方退款成功");
             }
-        } catch (Exception e) {
-            e.printStackTrace();
         }
     }
 
-    public  <T> T postForm(Map<String, String> params, String url, String sign, Class<T> clazz) {
+
+    public <T> T postForm(Map<String, String> params, String url, String sign, Class<T> clazz) {
         FormBody.Builder builder = new FormBody.Builder();
         for (Map.Entry<String, String> entry : params.entrySet()) {
             builder.add(entry.getKey(), entry.getValue());

+ 35 - 29
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -1368,7 +1368,9 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 }
             }
             List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(cmReturnedPurchase.getOrderID());
-            logger.info("shopOrders》》》》》" + shopOrders.toString());
+            if(null!=cmReturnedPurchase.getOnlineShopOrderId()&&0<cmReturnedPurchase.getOnlineShopOrderId()){
+                 shopOrders = newShopOrderDao.findListByShopOrderId(cmReturnedPurchase.getOnlineShopOrderId());
+            }
             if (CollectionUtils.isNotEmpty(shopOrders)) {
                 for (NewShopOrder shopOrder : shopOrders) {
                     //获取退货退款记录
@@ -1827,34 +1829,34 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
             }
         }
 
-        if (count == 1) {
-            try {
-                //发货短信推送(取消推送)
-                CmUser user = cmUserDao.get(order.getUserID().toString());
-                if (user != null && StringUtils.isNotBlank(user.getBindMobile()) && "0".equals(order.getRebateFlag())) {
-                    String wwwServer = Global.getConfig("wwwServer");
-                    boolean sendSms = false;
-                    if ("2".equals(order.getSendOutStatus()) && "1".equals(sendOutStatus)) {
-                        //部分发货
-                        String shortLink = getShortLink(8, 7, wwwServer + "user/order/detail.html?orderId=" + order.getOrderID());
-                        String content = "您的订单(订单编号:" + order.getOrderNo() + ")已部分发货。您可关注采美公众号或者访问采美微信小程序和网站查看订单。平台公众号:微信搜索“采美365网”; " +
-                                "微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
-                        sendSms = getSendSms(7, user.getBindMobile(), content);
-                    } else if ("3".equals(order.getSendOutStatus())) {
-                        //已发货
-                        String shortLink = getShortLink(8, 8, wwwServer + "user/order/detail.html?orderId=" + order.getOrderID());
-                        String content = "您的订单(订单编号:" + order.getOrderNo() + ")已发货完毕。您可关注采美公众号或者访问采美微信小程序和网站查看订单。平台公众号:微信搜索“采美365网”; " +
-                                "微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
-                        sendSms = getSendSms(8, user.getBindMobile(), content);
-                    }
-                    if (!sendSms) {
-                        logger.info("发货短信推送失败,订单id>>>>" + order.getOrderID());
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
+//        if (count == 1) {
+//            try {
+//                //发货短信推送(取消推送)
+//                CmUser user = cmUserDao.get(order.getUserID().toString());
+//                if (user != null && StringUtils.isNotBlank(user.getBindMobile()) && "0".equals(order.getRebateFlag())) {
+//                    String wwwServer = Global.getConfig("wwwServer");
+//                    boolean sendSms = false;
+//                    if ("2".equals(order.getSendOutStatus()) && "1".equals(sendOutStatus)) {
+//                        //部分发货
+//                        String shortLink = getShortLink(8, 7, wwwServer + "user/order/detail.html?orderId=" + order.getOrderID());
+//                        String content = "您的订单(订单编号:" + order.getOrderNo() + ")已部分发货。您可关注采美公众号或者访问采美微信小程序和网站查看订单。平台公众号:微信搜索“采美365网”; " +
+//                                "微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
+//                        sendSms = getSendSms(7, user.getBindMobile(), content);
+//                    } else if ("3".equals(order.getSendOutStatus())) {
+//                        //已发货
+//                        String shortLink = getShortLink(8, 8, wwwServer + "user/order/detail.html?orderId=" + order.getOrderID());
+//                        String content = "您的订单(订单编号:" + order.getOrderNo() + ")已发货完毕。您可关注采美公众号或者访问采美微信小程序和网站查看订单。平台公众号:微信搜索“采美365网”; " +
+//                                "微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
+//                        sendSms = getSendSms(8, user.getBindMobile(), content);
+//                    }
+//                    if (!sendSms) {
+//                        logger.info("发货短信推送失败,订单id>>>>" + order.getOrderID());
+//                    }
+//                }
+//            } catch (Exception e) {
+//                e.printStackTrace();
+//            }
+//        }
         return lb.getId();
     }
 
@@ -2600,4 +2602,8 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         newOrderDao.updatePayAndReceipt(orderId);
         newOrderDao.updatePayStatusSon(orderId);
     }
+
+    public List<SettleRecord> findSettleRecord(Integer orderID) {
+        return newOrderDao.findSettleRecord(orderID);
+    }
 }

+ 28 - 0
src/main/java/com/caimei/modules/order/service/NewShopOrderService.java

@@ -433,6 +433,9 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
 
     public Page<NewOrder> findPaymentOrderList(Page<NewOrder> page, NewOrder newOrder) {
         newOrder.setPage(page);
+        List<SettleRecord> settleRecord = newOrderDao.findSettleRecord(newOrder.getOrderID());
+        Integer num=null==settleRecord?0:settleRecord.size();
+        newOrder.setSettleRecordNum(num);
         if (newOrder.getPayStatus() != null && newOrder.getPayStatus() != "") {
             String[] split = newOrder.getPayStatus().split(",");
             newOrder.setPs(split);
@@ -447,6 +450,9 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
             orderIds = cmDiscernReceiptDao.findRebateOrderID(orderList.stream().map(NewOrder::getOrderID).collect(Collectors.toList()));
         }
         for (NewOrder order : orderList) {
+            if("0".equals(order.getOnlinePayFlag())){
+                order.setSettleAmount(newOrderDao.findSettleAmount(order.getOrderID()));
+            }
             if (orderIds != null && orderIds.contains(order.getOrderID())) {
                 order.setRebateOrder("1");
                 order.setReceiptStatus("4");
@@ -668,4 +674,26 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         page.setList(payOrderList);
         return page;
     }
+
+    @Transactional(readOnly = false)
+    public Page<NewShopOrder> findSettlementList(Page<NewShopOrder> page, NewShopOrder shopOrder) {
+        shopOrder.setPage(page);
+        if (StringUtils.isNotBlank(shopOrder.getPayStatus())) {
+            String[] split = shopOrder.getPayStatus().split(",");
+            shopOrder.setPs(split);
+        }
+        // 已分帐,子订单未结算/部分结算,有未结算付款
+        List<NewShopOrder> payOrderList = newShopOrderDao.findSettlementList(shopOrder);
+        setValue(payOrderList);
+        page.setList(payOrderList);
+        return page;
+    }
+
+    public List<SettleRecord> getSettleRecord(String shopOrderID) {
+        return newShopOrderDao.findSettleRecord(shopOrderID);
+    }
+
+    public Integer payWay(Integer shoprderID){
+        return newShopOrderDao.payWay(shoprderID);
+    }
 }

+ 1 - 1
src/main/java/com/caimei/modules/order/service/SplitAccountService.java

@@ -221,7 +221,7 @@ public class SplitAccountService extends BaseService {
                             } else {
                                 for (SplitAccountPo splitAccount : splitBillDetail) {
                                     splitAccount.setMbOrderId(orderRelation.getMbOrderId());
-                                    splitAccount.setOrderRequestNo(substring + orderRelation.getOrderRequestNo());
+                                    splitAccount.setOrderRequestNo(orderRelation.getOrderRequestNo());
                                     splitAccount.setPayStatus(1);
                                     // 保存分账详情
                                     newOrderDao.insertSplitAccount(splitAccount);

+ 404 - 0
src/main/java/com/caimei/modules/order/utils/RSA.java

@@ -0,0 +1,404 @@
+package com.caimei.modules.order.utils;
+
+import org.apache.commons.lang.ArrayUtils;
+import sun.misc.BASE64Encoder;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.KeyPair;
+import java.security.*;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Arrays;
+import java.util.Enumeration;
+
+/**
+ * 私钥签名,私钥签名(只有私钥能签),公钥验证签名,确认发起人是私钥持有人
+ * 公钥加密,公钥加密只有私钥能解密
+ * @author datou
+ *
+ */
+public class RSA {
+	
+	 /** 
+     * String to hold name of the encryption padding. 
+     */  
+    public static final String NOPADDING = "RSA/NONE/NoPadding";
+    
+    public static final String RSANONEPKCS1PADDING = "RSA/NONE/PKCS1Padding";
+    
+    public static final String RSAECBPKCS1PADDING = "RSA/ECB/PKCS1Padding";
+	
+	public static final String PROVIDER = "BC";
+	
+	static{
+		Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
+	}
+	
+	/**
+	 * 验证签名
+	 * 
+	 * @param data
+	 *            数据
+	 * @param sign
+	 *            签名
+	 * @param pubicKey
+	 *            公钥
+	 * @return
+	 */
+	public static boolean verifySign(byte[] data, byte[] sign,
+			PublicKey publicKey) {
+		try {
+			Signature signature = Signature
+					.getInstance("MD5withRSA");
+			signature.initVerify(publicKey);
+			signature.update(data);
+			boolean result = signature.verify(sign);
+			return result;
+		} catch (Exception e) {
+
+			throw new RuntimeException("verifySign fail!", e);
+		}
+	}
+
+	/**
+	 * 验证签名
+	 * 
+	 * @param data
+	 *            数据
+	 * @param sign
+	 *            签名
+	 * @param pubicKey
+	 *            公钥
+	 * @return
+	 */
+	public static boolean verifySign(String data, String sign,
+			PublicKey pubicKey) {
+		try {
+			byte[] dataByte = data
+					.getBytes("UTF-8");
+			byte[] signByte = Base64.decode(sign
+					.getBytes("UTF-8"));
+			return verifySign(dataByte, signByte, pubicKey);
+		} catch (UnsupportedEncodingException e) {
+
+			throw new RuntimeException("verifySign fail! data["+data+"] sign["+sign+"]", e);
+		}
+	}
+
+	/**
+	 * 签名
+	 * 
+	 * @param data
+	 * @param key
+	 * @return
+	 */
+	public static byte[] sign(byte[] data, PrivateKey key) {
+		try {
+			Signature signature = Signature
+					.getInstance("MD5withRSA");
+			signature.initSign(key);
+			signature.update(data);
+			return signature.sign();
+		} catch (Exception e) {
+			throw new RuntimeException("sign fail!", e);
+		}
+	}
+
+	/**
+	 * 签名
+	 * 
+	 * @param data
+	 * @param key
+	 * @return
+	 */
+	public static String sign(String data, PrivateKey key) {
+		System.out.println("原文:" + data);
+		try {
+			byte[] dataByte = data.getBytes("UTF-8");
+			return new String(Base64.encode(sign(dataByte, key)));
+		} catch (UnsupportedEncodingException e) {
+			throw new RuntimeException("sign fail!", e);
+		}
+	}
+
+	/**
+	 * 加密
+	 * 
+	 * @param data
+	 * @param key
+	 * @return
+	 */
+	public static byte[] encrypt(byte[] data, Key key,String padding) {
+		try {
+            final Cipher cipher = Cipher.getInstance(padding, PROVIDER);
+			cipher.init(Cipher.ENCRYPT_MODE, key);
+			return cipher.doFinal(data);
+		} catch (Exception e) {
+
+			throw new RuntimeException("encrypt fail!", e);
+		}
+	}
+	
+	/**
+	 * 加密
+	 * 
+	 * @param data
+	 * @param key
+	 * @return
+	 */
+	public static String encryptToBase64(String data, Key key,String padding) {
+		try {
+			return new String(Base64.encode(encrypt(
+					data.getBytes("UTF-8"),
+					key,padding)));
+		} catch (Exception e) {
+			throw new RuntimeException("encrypt fail!", e);
+		}
+	}
+
+	/**
+	 * 解密
+	 * 
+	 * @param data
+	 * @param key
+	 * @return
+	 */
+	public static byte[] decrypt(byte[] data, Key key,String padding) {
+		try {
+            final Cipher cipher = Cipher.getInstance(padding, PROVIDER); 
+			cipher.init(Cipher.DECRYPT_MODE, key);
+			return cipher.doFinal(data);
+		} catch (Exception e) {
+			throw new RuntimeException("encrypt fail!", e);
+		}
+	}
+
+	/**
+	 * 解密
+	 * 
+	 * @param data
+	 * @param key
+	 * @return
+	 */
+	public static String decryptFromBase64(String data, Key key,String padding) {
+		try {
+			return new String(decrypt(Base64.decode(data.getBytes()), key,padding),
+					"UTF-8");
+		} catch (Exception e) {
+			throw new RuntimeException("encrypt fail!", e);
+		}
+	}
+	
+	public static void createKeyPairs(int size) throws Exception {  
+	    // create the keys  
+	    KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", PROVIDER);  
+	    generator.initialize(size, new SecureRandom());  
+	    KeyPair pair = generator.generateKeyPair();  
+	    PublicKey pubKey = pair.getPublic();  
+	    PrivateKey privKey = pair.getPrivate();  
+	    byte[] pk = pubKey.getEncoded();  
+	    byte[] privk = privKey.getEncoded();  
+	    String strpk = new String(Base64.encodeBase64(pk));  
+	    String strprivk = new String(Base64.encodeBase64(privk));  
+	    System.out.println("公钥:" + Arrays.toString(pk));  
+	    System.out.println("私钥:" + Arrays.toString(privk));  
+	    System.out.println("公钥Base64编码:" + strpk);  
+	    System.out.println("私钥Base64编码:" + strprivk);  
+	  }
+	
+	public static PublicKey getPublicKey(String base64EncodePublicKey) throws Exception{
+		 KeyFactory keyf = KeyFactory.getInstance("RSA", PROVIDER);  
+		 X509EncodedKeySpec pubX509 = new X509EncodedKeySpec(Base64.decodeBase64(base64EncodePublicKey.getBytes()));
+		 PublicKey pubkey = keyf.generatePublic(pubX509);  
+		 return pubkey;
+	}
+	
+	public static PrivateKey getPrivateKey(String base64EncodePrivateKey)throws Exception{
+		KeyFactory keyf = KeyFactory.getInstance("RSA", PROVIDER);  
+		 PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(Base64.decodeBase64(base64EncodePrivateKey.getBytes()));
+		 PrivateKey privkey = keyf.generatePrivate(priPKCS8);
+		 return privkey;
+	}
+	
+	
+	 public static byte[] encode(String encodeString, Key key,String padding) throws Exception {
+		 final Cipher cipher = Cipher.getInstance(padding, PROVIDER);
+		  cipher.init(Cipher.ENCRYPT_MODE, key);
+		  byte[] bytes = encodeString.getBytes("UTF-8");
+		  byte[] encodedByteArray = new byte[] {};
+		  for (int i = 0; i < bytes.length; i += 117) {
+		   byte[] subarray = ArrayUtils.subarray(bytes, i, i + 117);
+		   byte[] doFinal = cipher.doFinal(subarray);
+		   encodedByteArray = ArrayUtils.addAll(encodedByteArray, doFinal);
+		  }
+		  return encodedByteArray;
+	}
+	 
+	 /**
+		 * 加密
+		 * 
+		 * @param data
+		 * @param key
+		 * @return
+		 */
+		public static String encodeToBase64(String data, Key key,String padding) {
+			try {
+				return new String(Base64.encode(encode(	data,
+						key,padding)));
+			} catch (Exception e) {
+				throw new RuntimeException("encrypt fail!", e);
+			}
+		}
+	 
+	 public static String decode(byte[] decodeByteArray, Key key,String padding) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException, NoSuchProviderException {
+		 final Cipher cipher = Cipher.getInstance(padding, PROVIDER);
+		  cipher.init(Cipher.DECRYPT_MODE, key);
+		  StringBuilder sb = new StringBuilder();
+		  for (int i = 0; i < decodeByteArray.length; i += 128) {
+		   byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(decodeByteArray, i, i + 128));
+		   sb.append(new String(doFinal));
+		  }
+		  return sb.toString();
+		 }
+	 
+	 /**
+		 * 解密
+		 * 
+		 * @param data
+		 * @param key
+		 * @return
+		 */
+		public static String decodeFromBase64(String data, Key key,String padding) {
+			try {
+				return new String(decode(Base64.decode(data.getBytes()), key,padding).getBytes(),
+						"UTF-8");
+			} catch (Exception e) {
+				throw new RuntimeException("encrypt fail!", e);
+			}
+		}
+		
+		/**
+		 * 得到密钥字符串(经过base64编码)
+		 * 
+		 * @return
+		 */
+		public static String getKeyString(Key key) throws Exception {
+			byte[] keyBytes = key.getEncoded();
+			String s = (new BASE64Encoder()).encode(keyBytes);
+			return s;
+		}
+		
+		public static String getKeyStringByCer(String path) throws Exception{
+			CertificateFactory cff = CertificateFactory.getInstance("X.509");
+			FileInputStream fis1 = new FileInputStream(path);
+			Certificate cf = cff.generateCertificate(fis1);
+			PublicKey pk1 = cf.getPublicKey();
+			String key = getKeyString(pk1);
+			System.out.println("public:\n" + key);
+			return key;
+		}
+		
+		public static String getKeyStringByPfx(String strPfx, String strPassword){  
+	        try {  
+	            KeyStore ks = KeyStore.getInstance("PKCS12");  
+	            FileInputStream fis = new FileInputStream(strPfx);  
+	            // If the keystore password is empty(""), then we have to set  
+	            // to null, otherwise it won't work!!!  
+	            char[] nPassword = null;  
+	            if ((strPassword == null) || strPassword.trim().equals("")){  
+	                nPassword = null;  
+	            }  
+	            else  
+	            {  
+	                nPassword = strPassword.toCharArray();  
+	            }  
+	            ks.load(fis, nPassword);  
+	            fis.close();  
+	            System.out.println("keystore type=" + ks.getType());  
+	            // Now we loop all the aliases, we need the alias to get keys.  
+	            // It seems that this value is the "Friendly name" field in the  
+	            // detals tab <-- Certificate window <-- view <-- Certificate  
+	            // Button <-- Content tab <-- Internet Options <-- Tools menu   
+	            // In MS IE 6.  
+	            Enumeration enumas = ks.aliases();  
+	            String keyAlias = null;  
+	            if (enumas.hasMoreElements())// we are readin just one certificate.  
+	            {  
+	                keyAlias = (String)enumas.nextElement();   
+	                System.out.println("alias=[" + keyAlias + "]");  
+	            }  
+	            // Now once we know the alias, we could get the keys.  
+	            System.out.println("is key entry=" + ks.isKeyEntry(keyAlias));  
+	            PrivateKey prikey = (PrivateKey) ks.getKey(keyAlias, nPassword);  
+	            Certificate cert = ks.getCertificate(keyAlias);  
+	            PublicKey pubkey = cert.getPublicKey();  
+	            
+	            String basePrikey = RSA.getKeyString(prikey);
+	            System.out.println("cert class = " + cert.getClass().getName());  
+	            System.out.println("cert = " + cert);  
+	            System.out.println("public key = " + pubkey);  
+	            System.out.println("private key = " + prikey); 
+	            System.out.println("pubkey key = " + RSA.getKeyString(pubkey));
+	            System.out.println("prikey key = " + RSA.getKeyString(prikey));
+	            System.out.println("pubkey key length = " + RSA.getKeyString(pubkey).length());
+	            System.out.println("prikey key length = " + RSA.getKeyString(prikey).length());
+	            return basePrikey;  
+	        }  
+	        catch (Exception e)  
+	        {  
+	            e.printStackTrace();  
+	        }  
+	        return null;  
+	    } 
+
+	/**
+	 * 512位PKCS#8
+	 * @param args
+	 * @throws Exception
+	 */
+	public static void main(String[] args) throws Exception {
+		//getKeyStringByCer("/usr/local/cjpayProductServerCertExpiryDate20170509.cer");
+		//String privatekey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDYNb+tFTFM+V4kzeeubf5iUPgKl50kxXuEJ57qrFJ0iC0eHpOlw3axqD+zjnWQ+/R1yWUl77SOqgvowmtbKz1qLgXyB57G2lAveL48tp0yyd+tfQMQkW1duT27lGp1bAj/lhwVulvUSzJPqlc4mBt0F+/jEGQ4VZRmR0NxhMbutj7pu61rawZDqS/FSrcnt872uHaUsF+b7c2JcOl7qyB3ySLcMjkJ6rAonYohMCfy0ZT9KruRJQMXtVAbuDLxS+BASDYeE1aOqbg+KPQRfCPdM6t0FX4Y0o6y6cwhd6GQ2OcM6o4lUoKIV6ggeZWG/CHwm85mQ5dbhb7JhMj80CMzAgMBAAECggEBANRC0E7IQ4JiPr67NvzUF63F9/3OIwR6rGxtyWJykvC80C6FrkZKwzhfCUrqTRltge4xLhA0aHq3DsIQPP1gUgbv7/5Q5NwscBRq4bkRPvshnWrhFCUr4MbmmWiSqIFm8t6ZLDFYp9afjGERxldVXX54EZZF/V4hBnPy+o9z3ylyC8skTpX91xTlx523UCGRPWG9cLID5OHrhnWfRybeO7ekGzTFSD7pMIZvQ24mrC6eTJZK6QmAMTB6UxEfyQ+scETO5RhwKOl1KngfQ7rjNSr8tfPcj7u5jdu9VbWYgrg/SKzQTkZCzoLeubwVmTdhMvKmN0KZx771sqVfCa21maECgYEA8+nUHAhJpP/iDJUyh0zksBRBlakI4/UR4/LoVzKQ2eQybXmKDFPSGRXse/YQUvFNirtWHYtxruRWmKxUOlbI8ByWo2sSEZZkQ/5/RLLa7GeH46B7iw19fE8kVv6m9uXHSP+DZqPZ+oyMGI1h9CFO9hnGuzR6ZMBtWBuPwAIX/z0CgYEA4ux8wKGMkPPUxmMLSb7nTjy1q9g8K2YdBWNDTed82H9wwTkVdkWRcDmS64PQEglaK3BCBdI5nN4xQ4p/xEaVVicKChl+1kFpErrHIRO0PEHj/X2+UVurGr19ayEimSBbkqP9s8Ilm867zVjgUbBPb5eEGwF2ZWvBzHp62x+90y8CgYB6gmakEdGTi2ZpdYKkjI2Mlw/98KHjhVMQEBB8w4wXtNNTQymAWZV8PhPCi2vVjReqZ7+wJTrbYhrQojXH+5D/cQyEViIELWp88FXSFpd5B+MsBI4o4IS3rDSPcWZBOlYnJxdDtWalvnQbXN/nM9eqKnYzzv7unewNxgIkqaiN7QKBgA3H5tub8/lplWZm5WyZF1r8/NtuylioXuLQ4Gl+wWo0cxiI6vC/0NFL7cw3uQ8fWkaBDsFjvvPz2nILmy7ESpVs0YNDgRxp5IOqrCUqGSv/pGTkmgY+1ulM0K0M2hkKigUhyGp+Q+Jub6FM4HKVjn1sai1prVMDdEWCuqtMBi8pAoGBAMAZp5m+dUkgG9nUk4Hek+zGhBTUe56NdgTRRX1m8LofW4G4wIG34nLNxEvGmklQjmgGfg1s/XhBQ+BrNUhD4fP+d5Q78qdNqQGzBamXHgjw3fGwUZJJqnatdTeQlf2hSwOSps6cwECezdB0jdxN8oiWCYFc22wP076jHOiMgU+J";
+		String publickey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDonLTXehZeFwmsg+zs8AHrsgGPkGXLS7Lhf2RMOHmAHC/MsvnrfHfu0GD0FcX7NuXKBJK7KsA0MWlEkHezuoRkZS2xZ79qQzImSVE3POO4g1ZVTsW2Bl9LNN2mkTAsum6ik/vodYzftbS0tT73SvgHk54mAm8cWdiQOEVmdX0yhQIDAQAB";
+//		System.err.println("-----------"+getKeyStringByCer("/usr/local/businessgate.cer"));
+//		String padding = RSAECBPKCS1PADDING;
+		//createKeyPairs(1024);
+//		String publickey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCN7fVkqM5hzcPg+xTKEOCsMQ2WQyqgaVbMd3atYN9zngW/biNqkt9vo5EWvoZ/WEByXPvanZRKWMPRFU39fxmtAxdl5TBoh+f4utd8TqdQ2c/uMRUzOecNXlvEZZNXN3Pgu/LLr1ss/H2ma+Lwkoq1WBkWzpY5BJqqhBKpQfWPRwIDAQAB";
+//		System.out.println(publickey.length());
+//		String privatekey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAI3t9WSozmHNw+D7FMoQ4KwxDZZDKqBpVsx3dq1g33OeBb9uI2qS32+jkRa+hn9YQHJc+9qdlEpYw9EVTf1/Ga0DF2XlMGiH5/i613xOp1DZz+4xFTM55w1eW8Rlk1c3c+C78suvWyz8faZr4vCSirVYGRbOljkEmqqEEqlB9Y9HAgMBAAECgYBREHDwpVn7ksMmZUJih3FL6FiSUpquNHxXHIS0UnhOWRt/UzD3Vhw4b3wXOYsogQeOSn2vSAHC1SBC86AwAcBvqXmKrmuCPoZX0MQkO4tVqfONgE4sq1jbuWHobwP14iZTGqdY69a13Vx6C4PFaOElOkzJbyDA4YkjTBvuR5IvAQJBAPCzgT4uhA73WMsntlI/YhKL7NteA/epUPJbL2UnY6Tf3vqSsvskU9ulgmJLUt1GBG7NFNYXQ6a6I/3GqOPdz7ECQQCW81Iv6Rpns5Ovz1zwpU/bZDwR2Mx+ARDv/DFPH3wJ4J+KJ1XLzEGn9+DLujAkSjrfb1OTNUK2723QOAPYX0R3AkAZwrxkUUok5+gC5h8nMk1mur8Aw1EdYmudZJDv/IU3khYlLyokosCu00nfBzy5HdM/oIdIWnkNEQLlGCvfJ1AhAkBcW2+zxKnVPThlXzh8PIkJsOBYAw/LIJfeXa1FvfvEh1zVyI9j7AtX2//8ZmTCL3Cp+JFoBjRVfVTxCvS/VDqtAkBSU/x90zjwVYDTYPUxyyLz9jYLVu3vHavaTRUTmMn4D4qHSmq3WahYOrrOpI80+Cwrf+bc08hKB+DgNBHpnE0E";
+//		System.err.println(publickey.length());
+//		System.err.println(privatekey.length());
+		PublicKey publicKey = RSA.getPublicKey(publickey);
+		//PrivateKey privateKey = RSA.getPrivateKey(privatekey);
+		System.out.println("1");
+//		String sign = sign("1234",privateKey);
+//		System.out.println(sign);
+		System.out.println(verifySign("#TransferSingle#M800029658#20161108105547054321#20161108105547054321#10#ICBC#6212261001064813709#test#B2C#PAYER#true", "RSRECZmnN4f1giR8EnUSaUY9dRf0RAVLWFAoL+IDenMd0QXU9YckvfrS5Xg/EhBPt8W11ee5cqmcIsjAshsV18gF4RcuHint4woMOBiA32tKCE7e4rkjD5/R2x4MRTUv+2eLSyjzOh4nNvFY184WcN7tJdo4tj0o6QVkUJRFqfo=", publicKey));
+//		String tmp = "104AE7ACA503EF4347DEA3EEFB5DB979747815526A0DD54168BB4B7197F776064CD6724542AFBFDA7B4B6F849B6130407E3709C280AF736CAF324D1D52010BD852BBCC1F5B9C668C1533BB747C1258761B80CA74AB0F2BA7E518A8A4BC7F407B531E7B8EFC877385503D4BE888DF5A113B1C6DC27EB94EFA16E112F23046B4ECE87B30EA62463A9CB0D94805A36D6239B9E587F95FF3E8F540132FE5FA590F52FEC9EC4FBB35C2108CA06F1F51AD6680199B51F85641EBDE5A7DC6127ED12237A86B5E025E0648217B7B8426F23348AF47DEA3EEFB5DB979AE85F4D79480DA150EE81C08064A010DBB900498D56FD7B432046000D768C2297CC3DD0AD15040DFD4EFC9FFCD7728984A4FADD66C8023FC0CF3780EA41D4080A8BC59E35FACBC20598B60BD0DE0C5414F0F380AECE38A98707A545C29D0D88E49A080904EF26202871D4BC06A49F1CEA977C5BC4DBB02786892E78AC3851EA233EE8D325757D64204EB1F637D5A609BC38E3BA2442BEFDE4DB0FD720BBC2F44BE9E0451A4425007C3706E9BF85A1F3F498DC6FFDD3EC2126C7F0EC61787ECF427A085AC5E3AD59E7E3C204BE6B0E89B31131043C210BC0947B51CE07CB37714048DDE18516F7D293969D714523D1F8096E59114409341897AB95064FA860C1E97A316D3D6CCADC2B8FA844541C58F457BCFEAFA022DA453BBB3142AF113CDCD125D1DF096E77244B47C150F3EE5BCDE5931C58C38D9C53C2222C08B0EA5C136EA1A4F2E512FF283430901D4F4212E3EA86B5E025E064821D4A1AE4629EEDDAD6000CD2CBAAE5B630712D23618975E838F620A31B788672896CEAF520A39CAEF37986D3F3CB1352DFDB75D2AAEF197D9F0142CF0FDE71082048F6024013895F461EB07B8A4C4897F7C32F38140BC42309D4E41D2F8F8DA277540506387A01118914B7C6D87ED185BC23CCC73C83B58C477579A1ADB3832678F2611BC14D24876";
+//		String s3 = RSA.decodeFromBase64(tmp, publicKey, padding);
+//		System.out.println(s3+"=====s3=====");
+//		System.out.println(s3.length()+"=====s3=====");
+//		String plain = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567";
+//		System.out.println(plain.getBytes().length);
+//		byte[] encryptByte = RSA.encode(plain, privateKey,padding);
+//		System.err.println(encryptByte.length+"=====encryptByte=====");
+//		byte[] sign = RSA.sign(encryptByte, privateKey);
+//		System.out.println(RSA.verifySign(encryptByte,sign,publicKey));
+//		String s2 = RSA.decode(encryptByte, publicKey,padding);
+//		System.out.println(s2+"=====s2=====");
+//		System.out.println(s2.length()+"=====s2=====");
+//		String encryptString = RSA.encodeToBase64(plain, privateKey, padding);
+//		System.err.println(encryptString.length()+"=====encryptString====="+encryptString);
+		
+		
+	}
+}

+ 69 - 0
src/main/java/com/caimei/modules/order/utils/SettlePostFormUtil.java

@@ -0,0 +1,69 @@
+package com.caimei.modules.order.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import okhttp3.FormBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author zzj
+ */
+
+
+public class SettlePostFormUtil {
+
+    public static OkHttpClient client = new OkHttpClient.Builder()
+            .connectTimeout(3, TimeUnit.SECONDS)
+            .readTimeout(20, TimeUnit.SECONDS)
+            .build();
+
+    public static <T> T postForm(Map<String, String> params, String url, String sign, Class<T> clazz) {
+        FormBody.Builder builder = new FormBody.Builder();
+        for (Map.Entry<String, String> entry : params.entrySet()) {
+            builder.add(entry.getKey(), entry.getValue());
+        }
+        builder.add("sign", sign);
+
+        Request request = new Request.Builder() // okHttp post
+                .url(url)
+                .post(builder.build())
+                .build();
+
+        Response response = null;
+        try {
+            response = client.newCall(request).execute();
+        } catch (IOException e) {
+            throw new IllegalStateException("请求出错", e);
+        }
+        if (!response.isSuccessful()) {
+            try {
+                System.out.println(response.body().string());
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            throw new RuntimeException("请求失败了: http response code: " + response.code());
+        }
+
+        okhttp3.ResponseBody body = response.body();
+        String content = null;
+        try {
+            content = body.string();
+        } catch (IOException e) {
+            throw new IllegalStateException("IO异常", e);
+        }
+        JSONObject res = JSON.parseObject(content);
+        //结算response
+        if (!"接收成功".equals(res.getString("rt3_retMsg"))) {
+            System.out.println("结算失败响应------->"+res.toString());
+        }
+        /** rt4_success 为 true,需验签  **/
+        return res.toJavaObject(clazz);
+    }
+
+}

+ 75 - 2
src/main/java/com/caimei/modules/order/web/CmPayShopController.java

@@ -4,6 +4,7 @@ import com.caimei.dfs.image.beens.ImageUploadInfo;
 import com.caimei.modules.common.utils.ExcelUtil;
 import com.caimei.modules.common.utils.UploadUtils;
 import com.caimei.modules.order.dao.CmPayShopRecordDao;
+import com.caimei.modules.order.dao.NewOrderDao;
 import com.caimei.modules.order.dao.NewOrderProductDao;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.*;
@@ -11,6 +12,7 @@ import com.caimei.modules.order.utils.OrderUtil;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.user.entity.CmUserOrganize;
 import com.caimei.modules.user.service.CmUserOrganizeService;
+import com.caimei.redis.RedisService;
 import com.caimei.utils.MathUtil;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
@@ -47,6 +49,9 @@ import java.util.concurrent.atomic.AtomicReference;
 @RequestMapping(value = "${adminPath}/order/cmPayShop")
 public class CmPayShopController extends BaseController {
 
+
+    @Resource
+    private RedisService redisService;
     @Autowired
     private CmPayShopService cmPayShopService;
     @Resource
@@ -67,6 +72,8 @@ public class CmPayShopController extends BaseController {
     private CmPayShopRecordDao cmPayShopRecordDao;
     @Resource
     private NewOrderProductDao newOrderProductDao;
+    @Resource
+    private NewOrderDao newOrderDao;
 
     @ModelAttribute
     public CmPayShop get(@RequestParam(required = false) String id) {
@@ -385,8 +392,9 @@ public class CmPayShopController extends BaseController {
         shopOrder.setPayStatus(soZeroCostFlag ? "3" : "1");
         shopOrder.setZeroCostFlag(soZeroCostFlag ? 1 : 0);
         //当子订单0成本时,若主订单中其他子订单(除了运费子订单)都为0成本,设主订单为已付款,否则设为部分付款
+         NewOrder newOrder = newOrderService.get(shopOrder.getOrderID().toString());
         if (soZeroCostFlag) {
-            NewOrder newOrder = newOrderService.get(shopOrder.getOrderID().toString());
+
             AtomicReference<Boolean> zeroCostFlag = new AtomicReference<>(true);
             AtomicReference<Boolean> freightFlag = new AtomicReference<>(false);
 
@@ -418,19 +426,45 @@ public class CmPayShopController extends BaseController {
             }
             newOrderService.updatePayStatus(newOrder);
         }
+
+
+
         shopOrder.setShopPostFee(freight); //运费
         shopOrder.setShopOtherFee(thirdPartyFee); //付第三方
         shopOrder.setCostType(costType);
         shopOrder.setModifyShouldPayNote(modifyShouldPayNote);  //备注
         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())
             shopOrder.setPayStatus("3");
         shopOrder.setShouldPayShopAmount(shouldPayShopAmount);
         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";
     }
 
@@ -595,6 +629,21 @@ public class CmPayShopController extends BaseController {
         return "modules/order/cmPayShopForm";
     }
 
+    /**
+     * 发起结算申请  去结算单页面
+     *
+     * @param cmPayShop
+     * @param shopOrderIDs
+     * @param model
+     * @return
+     */
+    @RequestMapping("settleEdit")
+    public String settleEdit(CmPayShop cmPayShop, String[] shopOrderIDs, Model model) {
+        cmPayShopService.settleEdit(cmPayShop, shopOrderIDs);
+        model.addAttribute("cmPayShop", cmPayShop);
+        return "modules/order/cmSettlementForm";
+    }
+
     /**
      * 去编辑页面 信息回显
      */
@@ -720,6 +769,30 @@ public class CmPayShopController extends BaseController {
         return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/applyDetail?id=" + cmPayShop.getId();
     }
 
+    /**
+     * 付款单 发起结算申请
+     *
+     * @return
+     */
+    @RequestMapping("settlement")
+    public String settlement(Double settleAmount, String shopOrderId,RedirectAttributes redirectAttributes) throws Exception {
+        Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
+        Double settleSum = newOrderDao.findSettleSum(shopOrderId);
+        if(settleSum>=shouldPayShopAmount){
+            addMessage(redirectAttributes, "此订单已结算完毕!");
+            return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
+        }
+        if(settleSum>=shouldPayShopAmount){}
+        Integer SDJSS = (Integer) redisService.get("SDJSS");
+        //验锁
+        if (null != SDJSS && SDJSS > 0) {
+            addMessage(redirectAttributes, "请勿短时间内重复结算,等待支付公司返回结算结果!");
+            return "redirect:" + Global.getAdminPath() + "/shopOrder/splitList/?repage";
+        }
+        cmPayShopService.settlement(shopOrderId, settleAmount);
+        return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
+    }
+
 
     ////applyPayWipe
     @RequiresPermissions("order:cmPayShop:edit")

+ 22 - 0
src/main/java/com/caimei/modules/order/web/CmShopOrderController.java

@@ -7,6 +7,7 @@ import com.caimei.modules.order.service.CmChangePayShopRecondService;
 import com.caimei.modules.order.service.NewShopOrderService;
 import com.caimei.modules.user.entity.CmUserOrganize;
 import com.caimei.modules.user.service.CmUserOrganizeService;
+import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.thinkgem.jeesite.common.web.BaseController;
@@ -72,11 +73,13 @@ public class CmShopOrderController extends BaseController {
             newShopOrder.setEndTime(newShopOrder.getEndTime().trim() + " 23:59:59");
         }
         Page<NewShopOrder> page = newShopOrderService.findPayOrderList(new Page<>(request, response), newShopOrder);
+
         //获取组织列表
         List<CmUserOrganize> cmUserOrganizeList = cmUserOrganizeService.findOrganize();
         model.addAttribute("cmUserOrganizeList", cmUserOrganizeList);
         model.addAttribute("page", page);
         model.addAttribute("operatingMode", newShopOrder.getOperatingMode());
+
         if ("3".equals(newShopOrder.getOperatingMode())) {
             //已付款子订单页面
             return "modules/order/paidShopOrderList";
@@ -109,11 +112,21 @@ public class CmShopOrderController extends BaseController {
     public String SplitAccount(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model){
         //1. 展示付款状态为待付款和部分付款状态的线上支付的子订单;
         //2. 子订单按下单时间降序排列
+        //3. 手动分账页面需要只控制显示已收款的子订单
         Page<NewShopOrder> page = newShopOrderService.findSplitList(new Page<>(request, response),newShopOrder);
         model.addAttribute("page", page);
         return "modules/order/cmSplitAccountList";
     }
 
+    @RequestMapping("settlement")
+    public String Settlement(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model){
+        //1. 展示已分帐的线上子订单
+        //2. 子订单按下单时间降序排列
+        Page<NewShopOrder> page = newShopOrderService.findSettlementList(new Page<>(request, response),newShopOrder);
+        model.addAttribute("page", page);
+        return "modules/order/cmSettlementList";
+    }
+
     @RequestMapping("payShopRemark")
     public String payShopRemark(CmChangePayShopRecond cmChangePayShopRecond, HttpServletRequest request, HttpServletResponse response, Model model) {
         Integer shopOrderId = cmChangePayShopRecond.getShopOrderId();
@@ -185,6 +198,15 @@ public class CmShopOrderController extends BaseController {
         return "modules/order/payedAndRefundRecordList";
     }
 
+    @RequestMapping("settleRecord")
+    public String settleRecord(String shopOrderID, HttpServletRequest request, HttpServletResponse response, Model model) {
+        List<SettleRecord> pr = newShopOrderService.getSettleRecord(shopOrderID);
+        NewShopOrder shopOrder = newShopOrderService.getShopOrderInfo(shopOrderID);
+        model.addAttribute("pr", pr);
+        model.addAttribute("s", shopOrder);
+        return "modules/order/settleRecordList";
+    }
+
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping("checkPaymentOrder")
     public String checkPaymentOrder(NewOrder newOrder, HttpServletRequest request, HttpServletResponse response, Model model) {

+ 1 - 0
src/main/java/com/caimei/modules/product/web/CmSecondHandDetailController.java

@@ -193,6 +193,7 @@ public class CmSecondHandDetailController extends BaseController {
         model.addAttribute("cmSecondHandDetail", cmSecondHandDetail);
         return "modules/product/cmSecondHandDetailForm";
     }
+//   http://192.168.2.101/api/2022%E5%B9%B4/2022%E5%B9%B4%E5%B0%8F%E9%9C%80%E6%B1%82
 
     @RequiresPermissions("product:cmSecondHandDetail:edit")
     @RequestMapping(value = "save")

+ 20 - 13
src/main/resources/mappings/modules/order/CmReceiptOrderRelationMapper.xml

@@ -216,23 +216,30 @@
 		select userId from cm_order where orderId=#{orderId}
 	</select>
 	<select id="findByShopOrderIds" resultType="com.caimei.modules.order.entity.CmReceiptOrderRelation">
-		select
-			a.*,
-			b.payType as "payType",
-			b.receiptDate as "receiptDate",
-			b.confirmType as "confirmType",
-			b.balanceAccountsRemark as "balanceAccountsRemark",
-			b.payWay as "payWay"
-		from  cm_receipt_order_relation a
-		left join cm_discern_receipt b on a.receiptID = b.id
-		where a.shopOrderId in
-		<foreach collection="shopOrderIds" open="(" close=")" item="shopOrderId" separator=",">
-			#{shopOrderId}
+		SELECT
+			a.relationType,
+			a.receiptID,
+			a.shopOrderId,
+			a.orderID,
+			a.mbOrderId,
+			a.orderRequestNo,
+			a.splitStatus,
+			a.associateAmount-IFNULL((SELECT SUM(refundAmount) FROM cm_refundmoney_record WHERE orderRequestNo=a.orderRequestNo),0) AS associateAmount,
+			b.payType AS "payType",
+			b.receiptDate AS "receiptDate",
+			b.confirmType AS "confirmType",
+			b.balanceAccountsRemark AS "balanceAccountsRemark",
+			b.payWay AS "payWay"
+		FROM  cm_receipt_order_relation a
+		LEFT JOIN cm_discern_receipt b ON a.receiptID = b.id
+		WHERE a.shopOrderId IN
+		<foreach collection="shopOrderIds" separator="," item="shopOrderID" open="(" close=")">
+			#{shopOrderID}
 		</foreach>
 		  AND b.receiptType = '1'
 		  AND b.receiptStatus = '3'
 		  AND a.delFlag = '0'
 		  AND b.delFlag = '0'
-		order by b.receiptDate desc
+		ORDER BY a.associateAmount DESC
 	</select>
 </mapper>

+ 66 - 5
src/main/resources/mappings/modules/order/CmReturnedPurchaseMapper.xml

@@ -11,7 +11,7 @@
 		a.returnedWay AS "returnedWay",
 		a.payType AS "payType",
 		a.operatingOrderStatus AS "operatingOrderStatus",
-		a.returnedPurchaseFee AS "returnedPurchaseFee",
+		ifnull(a.returnedPurchaseFee,0) AS "returnedPurchaseFee",
 		a.refundFee AS "refundFee",
 		a.image1 AS "image1",
 		a.image2 AS "image2",
@@ -28,7 +28,7 @@
 		a.returnTime AS "returnTime",
 		a.applicationUserID AS "applicationUserID",
 		a.reviewUserID AS "reviewUserID",
-		a.refundBalanceFee AS "refundBalanceFee",
+		ifnull(a.refundBalanceFee,0) AS "refundBalanceFee",
 		a.refundOnlineFee AS "refundOnlineFee",
 		a.refundOfflineFee AS "refundOfflineFee",
 		a.bankAccountName AS "bankAccountName",
@@ -40,7 +40,8 @@
 		b.orderType as "orderType",
 		c.userName as "userName",
 		c.name as "name",
-		c.userOrganizeID as "userOrganizeId"
+		c.userOrganizeID as "userOrganizeId",
+		ifnull(a.refundType,1) as "refundType"
 	</sql>
 
 	<sql id="cmReturnedPurchaseJoins">
@@ -211,7 +212,8 @@
 			applicationUserID,
 			returnTime,
 			reviewUserID,
-			confirmReturnTime
+			confirmReturnTime,
+            refundType
 		) VALUES (
 			#{returnedNo},
 			#{orderID},
@@ -239,9 +241,15 @@
 			#{applicationUserID},
 			#{returnTime},
 			#{reviewUserID},
-			#{confirmReturnTime}
+			#{confirmReturnTime},
+		    #{refundType}
 		)
 	</insert>
+	<insert id="insertCmRefundRecord">
+		insert into cm_refundmoney_record
+		(refundAmount,orderRequestNo,shopOrderId)
+		values(#{refundAmount},#{orderRequestNo},#{shopOrderId})
+	</insert>
 
 	<update id="updateRevokeApply">
 		UPDATE cm_returned_purchase
@@ -363,6 +371,9 @@
 			<if test="delFlag != null and delFlag != ''" >
 				delFlag = #{delFlag},
 			</if>
+		    <if test="refundType != null">
+				refundType = #{refundType},
+			</if>
         </set>
 
 		WHERE id = #{id}
@@ -406,4 +417,54 @@
     <select id="findSplitCode" resultType="java.lang.String">
 		select splitCode from cm_shop_order where shopOrderID = #{shopOrderId}
 	</select>
+	<select id="getReturnShopOrder" resultType="java.lang.Integer">
+		SELECT shopOrderId FROM cm_returned_purchase_product crpp
+		LEFT JOIN cm_returned_purchase crp ON crp.id=crpp.returnedID
+		WHERE crp.id=#{id}
+		  AND crp.status=2
+		  AND crp.returnedWay =1
+		  AND crp.delflag=0
+	</select>
+	<select id="findBrokerage" resultType="java.lang.Double">
+		SELECT SUM(splitAccount)
+		FROM cm_split_account
+		WHERE productType = 3
+		  AND TYPE=5
+		  AND orderRequestNo= #{orderRequestNo}
+	</select>
+	<select id="findRefundTransfer" resultType="java.lang.Double">
+		SELECT SUM(transferAmount) FROM cm_refund_transfer
+		WHERE transferType=2
+		  AND orderRequestNo=#{orderRequestNo}
+	</select>
+	<select id="findRefundCharge" resultType="java.lang.Double">
+		SELECT SUM(transferAmount) FROM cm_refund_transfer
+		WHERE transferType=1
+		  AND orderRequestNo=#{orderRequestNo}
+	</select>
+	<select id="findPayAmount" resultType="java.lang.Double">
+		select associateAmount from cm_receipt_order_relation
+		where orderRequestNo = #{orderRequestNo}
+	</select>
+	<select id="findOnlinePay" resultType="java.lang.Double">
+		SELECT SUM(receiptAmount) FROM
+		cm_discern_receipt cdr
+		LEFT JOIN cm_receipt_order_relation cror ON cror.receiptID=cdr.Id
+		WHERE shopOrderId=#{shopOrderId}
+	</select>
+	<select id="findShopOrderSettleStatus" resultType="java.lang.String">
+		select settleStatus from cm_shop_order where shopOrderID = #{onlineShopOrderId}
+	</select>
+	<select id="findRefundType" resultType="java.lang.Integer">
+		SELECT COUNT(*) FROM cm_returned_purchase
+		WHERE orderId=#{orderID}
+		  AND delflag = 0
+		  AND refundtype=2
+	</select>
+	<select id="findShopOrderPaid" resultType="java.lang.Double">
+		SELECT SUM(associateAmount)
+		FROM cm_receipt_order_relation
+		WHERE shopOrderId=#{shopOrderID}
+		AND delflag=0
+	</select>
 </mapper>

+ 62 - 1
src/main/resources/mappings/modules/order/OrderMapper.xml

@@ -39,7 +39,7 @@
 		a.freight AS freight,
 		a.userBeans AS userBeans,
 		a.delFlag AS delFlag,
-		a.onlinePayFlag AS onlinePayFlag,
+		ifnull(a.onlinePayFlag,1) AS onlinePayFlag,
 		a.payTime AS payTime,
 		a.splitFlag AS splitFlag,
 		(select sum(cop.totalAddedValueTax) from cm_order_product cop where cop.orderID = a.orderID) AS totalAddedValueTax,
@@ -134,11 +134,15 @@
         LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID and sp.status = 90
         LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
         LEFT JOIN product p ON cop.productID = p.productID
+        left join cm_shop_order cso on co.orderid=cso.orderID
         <where>
             co.orderType != 2
             <if test="orderID != null and orderID != ''">
                 AND co.orderID = #{orderID}
             </if>
+            <if test="settleStatus != null">
+                AND cso.settleStatus = #{settleStatus}
+            </if>
             <if test="orderNo != null and orderNo != ''">
                 AND co.orderNo = #{orderNo}
             </if>
@@ -974,6 +978,16 @@
     <update id="updateBySplitStatus">
         UPDATE cm_receipt_order_relation SET splitStatus = 1 WHERE mbOrderId = #{mbOrderId}
     </update>
+    <update id="updateSettleStatus">
+        update cm_split_account
+        set settleStatus = 1
+        where shopOrderId = #{shopOrderId}
+        and productType = #{productType}
+    </update>
+    <update id="updateShopOrderSettleStatus">
+        update cm_shop_order set settleStatus = #{settleStatus}
+        where shopOrderId = #{shopOrderId}
+    </update>
     <delete id="deleteCouponOrderRecord">
         DELETE
         FROM cm_coupon_order_record
@@ -996,6 +1010,7 @@
         LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
         LEFT JOIN cm_order co ON cror.orderID = co.orderID
         WHERE cror.relationType = 2
+          AND a.receiptStatus=3
           AND cror.delFlag = 0
           AND cror.mbOrderId IS NOT NULL
           AND cror.splitStatus = 0
@@ -1325,6 +1340,41 @@
           AND co.orderType != 2
           AND cror.orderID=#{orderID}
     </select>
+    <select id="findSplitCode" resultType="java.lang.String">
+        select splitCode from cm_shop_order where shopOrderID = #{shopOrderId}
+    </select>
+    <select id="findPayAmount" resultType="java.lang.Double">
+        SELECT SUM(splitAccount) FROM cm_split_account csa
+        LEFT JOIN cm_receipt_order_relation cror ON csa.shopOrderId=cror.shopOrderId
+        WHERE csa.shopOrderId = #{shopOrderId}
+          AND csa.type=5
+          AND csa.settleStatus = 0
+          AND csa.productType = 3
+          AND cror.splitStatus =1
+          AND cror.delflag=0
+    </select>
+    <select id="findShouldPayShopAmount" resultType="java.lang.Double">
+        select shouldPayShopAmount from cm_shop_order where shopOrderID = #{shopOrderId}
+    </select>
+    <select id="findSettleSum" resultType="java.lang.Double">
+        SELECT IFNULL(SUM(settleAmount),0) FROM cm_settle_record
+        WHERE settleType = 1
+          AND shopOrderId = 24665
+    </select>
+    <select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
+        select distinct
+        csr.settleAmount,csr.shopOrderId,csr.settleTime from cm_settle_record csr
+        left join cm_shop_order cso on csr.shopOrderId = cso.shopOrderID
+        where cso.orderID=#{orderID}
+        and settleType = 2
+    </select>
+    <select id="findSettleAmount" resultType="java.lang.Double">
+        SELECT ifnull(SUM(settleAmount),0)
+        FROM cm_settle_record csr
+        LEFT JOIN cm_shop_order cso ON csr.shopOrderId = cso.shopOrderId
+        WHERE settleType=1
+          AND cso.orderId=#{orderID}
+    </select>
     <insert id="insertSplitAccount">
         INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId, vipRecordId,
                                       authVipRecordId, type, subUserNo, splitAccount,
@@ -1345,4 +1395,15 @@
         INSERT INTO cm_pay_shop_record (shopID, shopOrderID, shopOrderNo, payAmount, wipePayment, payType, payTime, payShopID, status, delFlag)
         VALUES (#{shopId}, #{shopOrderId}, #{shopOrderNo}, #{payAmount}, #{wipePayment}, #{payType}, #{payTime}, #{payShopId}, #{status}, #{delFlag})
     </insert>
+    <insert id="insertSettleRecord">
+        INSERT INTO cm_settle_record(settleamount, settletype, shoporderid, splitcode, settletime)
+        VALUES (#{settleAmount},#{settleType},#{shopOrderId},#{splitCode},now())
+    </insert>
+
+    <update id="updateBrokerage">
+        UPDATE cm_shop_order SET
+            brokerage = #{brokerage}
+        WHERE shopOrderID = #{shopOrderID}
+    </update>
+
 </mapper>

+ 165 - 1
src/main/resources/mappings/modules/order/ShopOrderMapper.xml

@@ -71,6 +71,7 @@
     		a.shopOtherFee AS shopOtherFee,
     		a.paying AS paying,
     		a.costType AS costType,
+            a.settleStatus AS settleStatus,
     		a.modifyShouldPayNote AS modifyShouldPayNote,
     		a.orderPromotionsId AS orderPromotionsId,
     		a.differenceType AS differenceType,
@@ -765,11 +766,14 @@
         co.status AS status,
         bou.name AS buyer,
         s.name AS shopName,
-        c.name AS clubName
+        c.name AS clubName,
+        cdr.payWay AS payWay
         from cm_shop_order a
         left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
         left join bp_order_userinfo bou on bou.orderId = a.orderID
         left join cm_order co on co.orderID = a.orderID
+        LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
+        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
         left join shop s on s.shopID = a.shopID
         LEFT JOIN club c ON c.userID = a.userID
         <where>
@@ -1133,6 +1137,7 @@
           AND cror.delFlag = 0
           AND cror.mbOrderId IS NOT NULL
           AND cror.splitStatus = 0
+          AND a.receiptStatus=3
           AND co.orderID NOT IN (
             SELECT orderID
             FROM cm_order_product
@@ -1158,4 +1163,163 @@
         WHERE orderID = #{orderid}
     </select>
 
+    <select id="payWay" resultType="java.lang.Integer">
+        SELECT  cdr.payWay
+        FROM cm_shop_order a
+                 LEFT JOIN cm_order co ON co.orderID = a.orderID
+                 LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
+                 LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        WHERE a.shopOrderID =  #{shopOrderID}
+    </select>
+
+
+    <select id="findSettlementList" resultType="com.caimei.modules.order.entity.NewShopOrder">
+        SELECT co.couponAmount            AS couponAmount,
+               co.userBeans               AS userBeans,
+               a.shopOrderID              AS shopOrderID,
+               a.orderID                  AS orderID,
+               a.organizeID               AS organizeID,
+               a.shopOrderNo              AS shopOrderNo,
+               a.orderNo                  AS orderNo,
+               a.userID                   AS userID,
+               a.shopID                   AS shopID,
+               a.itemCount                AS itemCount,
+               a.townID                   AS townID,
+               a.productAmount            AS productAmount,
+               a.discountAmount           AS discountAmount,
+               a.accountAmount            AS accountAmount,
+               a.totalAmount              AS totalAmount,
+               a.payFlag                  AS payFlag,
+               a.payTime                  AS payTime,
+               a.finishTime               AS finishTime,
+               a.refundStatus             AS refundStatus,
+               a.needPayAmount            AS needPayAmount,
+               a.canRefundAmount          AS canRefundAmount,
+               a.refundAmount             AS refundAmount,
+               a.clubID                   AS clubID,
+               a.spID                     AS spID,
+               a.mainSpID                 AS mainSpID,
+               a.orderBeanAmount          AS orderBeanAmount,
+               a.useBeanAmount            AS useBeanAmount,
+               a.useBeanFlag              AS useBeanFlag,
+               a.canRefundFlag            AS canRefundFlag,
+               a.useBalanceFlag           AS useBalanceFlag,
+               a.canRefundBeans           AS canRefundBeans,
+               a.freePostageFee           AS freePostageFee,
+               a.freePostageTicketID      AS freePostageTicketID,
+               a.brokerage                AS brokerage,
+               a.delFlag                  AS delFlag,
+               a.refundsAmount            AS refundsAmount,
+               a.orderStatusFlag          AS orderStatusFlag,
+               a.buyStatus                AS buyStatus,
+               a.orderSubmitType          AS orderSubmitType,
+               a.orderType                AS orderType,
+               a.orderTime                AS orderTime,
+               a.deliveryTimeMills        AS deliveryTimeMills,
+               a.presentNum               AS presentNum,
+               a.preferential             AS preferential,
+               a.outStoreNum              AS outStoreNum,
+               IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
+               a.splitFlag                AS splitFlag,
+               a.autoReceiveTimeMills     AS autoReceiveTimeMills,
+               a.autoOverTimeMills        AS autoOverTimeMills,
+               a.receiveGoodsTime         AS receiveGoodsTime,
+               a.totalAddedValueTax       AS totalAddedValueTax,
+               a.note                     AS note,
+               a.payStatus                AS payStatus,
+               a.sendOutStatus            AS sendOutStatus,
+               a.shopProductAmount        AS shopProductAmount,
+               a.shopPostFee              AS shopPostFee,
+               a.shopTaxFee               AS shopTaxFee,
+               a.shouldPayShopAmount      AS shouldPayShopAmount,
+               a.payedShopAmount          AS payedShopAmount,
+               a.shopOtherFee             AS shopOtherFee,
+               a.paying                   AS paying,
+               a.costType                 AS costType,
+               a.modifyShouldPayNote      AS modifyShouldPayNote,
+               a.orderPromotionsId        AS orderPromotionsId,
+               a.differenceType           AS differenceType,
+               a.differencePrice          AS differencePrice,
+               a.proportional             AS proportional,
+               a.promotionFullReduction   AS promotionFullReduction,
+               a.zeroCostFlag             AS zeroCostFlag,
+               a.settleStatus             AS settleStatus,
+               co.payTotalFee             AS payTotalFee,
+               co.status                  AS STATUS,
+               bou.name                   AS buyer,
+               s.name                     AS shopName,
+               c.name                     AS clubName
+        FROM cm_shop_order a
+        LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
+        LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
+        LEFT JOIN cm_order co ON co.orderID = a.orderID
+        LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
+        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        LEFT JOIN cm_split_account csa on csa.shopOrderId = a.shopOrderID
+        LEFT JOIN shop s ON s.shopID = a.shopID
+        LEFT JOIN club c ON c.userID = a.userID
+        WHERE co.organizeID = 0
+          AND co.refundType != 2
+          AND co.delFlag = 0
+          AND co.orderType != 2
+          AND co.receiptStatus = 3
+          AND a.delFlag = 0
+          AND a.shopID != 998
+          AND cdr.payWay = 1
+          AND cror.relationType = 2
+          AND a.settleStatus in (1,2)
+          AND csa.settleStatus = 0
+          AND cror.delFlag = 0
+          AND cror.mbOrderId IS NOT NULL
+          AND cror.splitStatus = 1
+        <if test="startTime != null and startTime != ''">
+            AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
+        </if>
+        <if test="endTime != null and endTime != ''">
+            AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
+        </if>
+        <if test="orderID != null and orderID != ''">
+            AND a.orderID = #{orderID}
+        </if>
+        <if test="orderNo != null and orderNo != ''">
+            AND a.orderNo like concat('%', #{orderNo} ,'%')
+        </if>
+        <if test="ps != null and ps.length>0 ">
+            AND a.settleStatus in
+            <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="shopName != null and shopName != ''">
+            AND s.name like concat('%', #{shopName} ,'%')
+        </if>
+        <if test="clubName != null and clubName != ''">
+            AND c.name like concat('%', #{clubName} ,'%')
+        </if>
+        <if test="shopOrderID != null and shopOrderID != ''">
+            AND a.shopOrderID = #{shopOrderID}
+        </if>
+        <if test="shopOrderNo != null and shopOrderNo != ''">
+            AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
+        </if>
+        GROUP BY a.shopOrderID
+        ORDER BY a.shopOrderID DESC
+    </select>
+    <select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
+        select settleAmount,settleType,settleTime
+        from cm_settle_record
+        where shopOrderId = #{shopOrderID}
+    </select>
+    <select id="findListByShopOrderId" resultType="com.caimei.modules.order.entity.NewShopOrder">
+        SELECT<include refid="shopOrderColumns"/>,
+        b.name as shopName,
+        oa.id as orderArchiveId,
+        co.receiptStatus
+        FROM cm_shop_order a
+        left join shop b on a.shopID = b.shopID
+        left join cm_order_archive oa on a.shopOrderID = oa.shopOrderId
+        left join cm_order co on co.orderID = a.orderID
+        WHERE a.shopOrderId = #{onlineShopOrderId}
+        ORDER BY a.shopOrderNo DESC
+    </select>
 </mapper>

+ 269 - 34
src/main/webapp/WEB-INF/views/modules/bulkpurchase/applyRefoundForm.jsp

@@ -36,7 +36,7 @@
                     //线下转账
                     if (${!returnOnline}){
                         //判断退款金额是否和填写金额总和一致
-                        var obj = document.getElementsByName("returnedWay");
+                        var obj = document.getElementsByClassName("check-item-review");
                         var checked0 = obj[0].checked;
                         var checked1 = obj[1].checked;
                         if(!checked1 && !checked0){
@@ -69,7 +69,6 @@
                                 return;
                             }
                         }
-
                         if(checked1){
                             var refundBalanceFee = $('#refundBalanceFee').val();
                             if( refundBalanceFee == null || refundBalanceFee == ""){
@@ -85,10 +84,22 @@
                             refundFee = 0;
                         }
                         refundFee = parseFloat(refundFee);
-                        var  number = refundFee - totalFee;
-                        if(number > 0.1 || number < -0.1){
-                            alertx("各退款方式的金额之和不等于退款总金额,请重新计算后再提交申请");
-                            return;
+                        var refundType = $("#refundType").val();
+                        console.log("refundType------------>"+refundType);
+                        if(1==refundType){
+                            var  number = refundFee - totalFee;
+                            if(number > 0.1 || number < -0.1){
+                                alertx("各退款方式的金额之和不等于退款总金额,请重新计算后再提交申请");
+                                return;
+                            }
+                        }else{
+                            var refundFee = $("#freeRefundFee").val();
+                            console.log("自定义退款金额------------》"+refundFee);
+                            if(refundFee == "" || refundFee == null){
+                                refundFee = 0;
+                                alertx("请填写自定义退款金额!");
+                                return;
+                            }
                         }
 
                         if (${cmDiscernReceipt.payWay eq 1}) {
@@ -107,10 +118,10 @@
                             }
                         }
                     }else if (${returnOnline}){
-                        var obj = document.getElementsByName("returnedWay");
+                        var obj = document.getElementsByClassName("check-item-review");
                         var checked0 = obj[0].checked;
-                        var checked1 = obj[1].checked;
-                        if(!checked1 && !checked0){
+                        // var checked1 = obj[1].checked;
+                        if(!checked0){
                             alertx("请选择退款方式");
                             return;
                         }
@@ -163,7 +174,7 @@
 
         function showBankInfo() {
                 if (${!returnOnline}){
-                var obj = document.getElementsByName("returnedWay"),
+                var obj = document.getElementsByClassName("refundOfflineFee"),
                     blockEle = $('.refund-details-block');
                 if(obj){
                     if(obj[0].checked){
@@ -257,12 +268,40 @@
             <td><b>退款编号:</b>
                 ${empty returnedNo?'':(returnedNo)}
             </td>
+            <c:if test="${cmReturnedPurchase.refundType eq 1 or cmReturnedPurchase.refundType eq 2}">
+            <td><b>退款模式:</b>
+                <form:select path="refundType" class="input-medium" id="refundType" onchange="changeType()">
+                    <form:option value="1">按商品金额退款</form:option>
+                    <form:option value="2">自定义金额退款</form:option>
+                </form:select>
+            </td>
+            </c:if>
+            <c:if test="${cmReturnedPurchase.refundType eq 3}">
+                <td><b>退款模式:</b>
+                    <form:select path="refundType" class="input-medium" id="refundType" onchange="changeType()">
+                        <form:option value="2">自定义金额退款</form:option>
+                    </form:select>
+                </td>
+            </c:if>
             <td><b>申请时间:</b>
                     ${returnTime}
             </td>
-            <td><b>申请金额:</b>
+            <c:if test="${cmReturnedPurchase.refundType eq 1}">
+            <td id="spt"><b>申请金额:</b>
                 <span class="refundFee"><fmt:formatNumber value="${empty cmReturnedPurchase.refundFee?'0.00':(cmReturnedPurchase.refundFee)}" pattern="#0.00"/></span>元
             </td>
+            <td id="zdy" hidden><b>申请金额:</b>
+                <from:input id="freeRefundFee" path="freeRefundFee" onkeyup="num(this)"   placeholder="¥0.00" value="${empty cmReturnedPurchase.freeRefundFee?'':(cmReturnedPurchase.freeRefundFee)}"></from:input>
+            </td>
+            </c:if>
+            <c:if test="${cmReturnedPurchase.refundType eq 2 or cmReturnedPurchase.refundType eq 3}">
+                <td id="spt" hidden><b>申请金额:</b>
+                    <span class="refundFee"><fmt:formatNumber value="${empty cmReturnedPurchase.refundFee?'0.00':(cmReturnedPurchase.refundFee)}" pattern="#0.00"/></span>元
+                </td>
+                <td id="zdy"><b>申请金额:</b>
+                    <from:input id="freeRefundFee" path="freeRefundFee" onkeyup="num(this)"   placeholder="¥0.00" value="${empty cmReturnedPurchase.freeRefundFee?'':(cmReturnedPurchase.freeRefundFee)}"></from:input>
+                </td>
+            </c:if>
             <td><b>退款状态:</b>
                 <c:if test="${empty status}">
                     待申请
@@ -290,11 +329,21 @@
                         线上退回
                     </c:if>
                     <c:if test="${!returnOnline}">
-                        <input class="check-item-review refundOfflineFee" type="checkbox"   name="returnedWay" value='3' onclick="showBankInfo()"/>
+                        <c:if test="${cmReturnedPurchase.refundOfflineFee>0}">
+                            <input class="check-item-review refundOfflineFee" checked type="checkbox" onclick="showBankInfo()"/>
+                        </c:if>
+                        <c:if test="${empty cmReturnedPurchase.refundOfflineFee or cmReturnedPurchase.refundOfflineFee eq 0}">
+                            <input class="check-item-review refundOfflineFee" type="checkbox" onclick="showBankInfo()"/>
+                        </c:if>
                         线下转账
                         <from:input path="refundOfflineFee" onkeyup="num(this)"   placeholder="¥0.00" value="${empty cmReturnedPurchase.refundOfflineFee?'':(cmReturnedPurchase.refundOfflineFee)}"></from:input>
-                        <c:if test="${empty order.rechargeGoods}">
-                            <input class="check-item-review refundBalanceFee" type="checkbox"  name="returnedWay" value='1'/>
+                        <c:if test="${order.rechargeGoods ne 1 && order.rechargeGoods ne 2}">
+                            <c:if test="${cmReturnedPurchase.refundBalanceFee>0}">
+                            <input class="check-item-review refundBalanceFee" checked type="checkbox"/>
+                            </c:if>
+                        <c:if test="${empty cmReturnedPurchase.refundBalanceFee or cmReturnedPurchase.refundBalanceFee eq 0}">
+                            <input class="check-item-review refundBalanceFee" type="checkbox"/>
+                        </c:if>
                             账户余额
                             <from:input path="refundBalanceFee" onkeyup="num(this)" placeholder="¥0.00" value="${empty cmReturnedPurchase.refundBalanceFee?'':(cmReturnedPurchase.refundBalanceFee)}"></from:input>
                         </c:if>
@@ -457,10 +506,10 @@
                     <font>无退款</font>
                 </c:if>
                 <c:if test="${order.refundType == 1}">
-                    <font color="#ff8c00">部分退款</font>
+                    <font>部分退款</font>
                 </c:if>
                 <c:if test="${order.refundType == 2}">
-                    <font color="green">已退款</font>
+                    <font>已退款</font>
                 </c:if></td>
             </td>
         </tr>
@@ -646,7 +695,7 @@
                                     <tr>
                                         <td><font color="red">待发货:<span id="toBeShipped${status.index}${productStatus.index}">${newOrderProduct.notOutStore - newOrderProduct.cancelProductNum}</span></font></td>
                                         <td><font color="red">已取消:<span id="toBeShipped${status.index}${productStatus.index}">${newOrderProduct.cancelProductNum}</span></font></td>
-                                        <td colspan="4"><font color="red"><span>本次取消:<input ${newOrderProduct.presentNum>0 or (order.onlinePayFlag eq 0 and shopOrder.shopID eq 998)?"readonly":""} id="applicationCancelNum${status.index}${productStatus.index}" class="cancelGoodsInput shopOrderInput" name="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].applicationCancelNum" value="${(order.onlinePayFlag eq 0 and shopOrder.shopID eq 998)?0:(newOrderProduct.notOutStore - newOrderProduct.cancelProductNum)}" oninput="this.value=this.value.replace(/\D/g,'').replace(/^0+(?=\d)/,1)" class="input cancel" type="text" onchange="setApplicationCancelNum(${status.index},${productStatus.index})"></span></font></td>
+                                        <td colspan="4"><font color="red"><span>本次取消:<input ${newOrderProduct.presentNum>0 or (order.onlinfePayFlag eq 0 and shopOrder.shopID eq 998)?"readonly":""} id="applicationCancelNum${status.index}${productStatus.index}" class="cancelGoodsInput shopOrderInput" name="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].applicationCancelNum" value="${(order.onlinePayFlag eq 0 and shopOrder.shopID eq 998)?0:(newOrderProduct.notOutStore - newOrderProduct.cancelProductNum)}" oninput="this.value=this.value.replace(/\D/g,'').replace(/^0+(?=\d)/,1)" class="input cancel" type="text" onchange="setApplicationCancelNum(${status.index},${productStatus.index})"></span></font></td>
                                         <form:hidden path="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].shopOrderID" value="${newOrderProduct.shopOrderID}"/>
                                         <form:hidden path="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].productID" value="${newOrderProduct.productID}"/>
                                         <form:hidden path="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].orderProductID" value="${newOrderProduct.orderProductID}"/>
@@ -658,7 +707,129 @@
                     </c:forEach>
                 </table>
             </c:if>
-        </c:forEach>
+            </table>
+        <%--默认状态代码--%>
+        <c:if test="${shopOrder.defaultStatus}">
+            <table id="shopOrderTable${status.index}"
+                   class="table shopOrderTable table-striped table-bordered table-condensed">
+                <thead></thead>
+                <tr>
+                    <td style="width: 300px;">
+                        子订单号(ID):${shopOrder.shopOrderNo}(${shopOrder.shopOrderID})
+                    </td>
+                    <td style="width: 275px;">
+                        子订单金额:¥<fmt:formatNumber type="number" value="${shopOrder.totalAmount}" pattern="0.00"
+                                                 maxFractionDigits="2"/>
+                    </td>
+                    <td>
+                        发货状态:${fns:getDictLabel(shopOrder.sendOutStatus,'sendOutStatus' ,'' )}
+                    </td>
+                    <td>
+                        付款状态:${fns:getDictLabel(shopOrder.payStatus,'payStatus' ,'' )}
+                    </td>
+                    <td>
+                        供应商:${shopOrder.shopName}
+                    </td>
+                </tr>
+                <c:forEach items="${shopOrder.newOrderProducts}" var="newOrderProduct" varStatus="productStatus">
+                    <tr>
+                        <td colspan="5">
+                            <table id="newOrderProductTable" class="table table-striped table-bordered table-condensed">
+                                <tr>
+                                    <td rowspan="4" style="width: 295px;height: 125px">
+                                        <img style="width: 100px;height: 100px" src="${newOrderProduct.image}">
+                                        <font title="${newOrderProduct.name}">${fns:abbr(newOrderProduct.name,30)}</font>
+                                    </td>
+                                    <td style="width: 275px;">
+                                        单价:¥<fmt:formatNumber type="number" value="${newOrderProduct.price}"
+                                                              pattern="0.00" maxFractionDigits="2"/>
+                                    </td>
+                                    <td>
+                                        折扣 :${newOrderProduct.discount}%
+                                    </td>
+                                    <td>
+                                        折后单价 :¥<span class="discountPrice"><fmt:formatNumber type="number"
+                                                                                             value="${newOrderProduct.discountPrice}"
+                                                                                             pattern="0.00"
+                                                                                             maxFractionDigits="2"/></span>
+                                    </td>
+                                    <td>
+                                        数量(赠品):${newOrderProduct.num}(${newOrderProduct.presentNum})
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td style="width: 275px;">
+                                        税率:${newOrderProduct.taxRate}%
+                                    </td>
+                                    <td>
+                                        税费:¥<span class="addedValueTax"><fmt:formatNumber type="number"
+                                                                                          value="${newOrderProduct.addedValueTax}"
+                                                                                          pattern="0.00"
+                                                                                          maxFractionDigits="2"/></span>
+                                    </td>
+                                    <td colspan="2">
+                                        总额:¥<fmt:formatNumber type="number" value="${newOrderProduct.shouldPayFee}"
+                                                              pattern="0.00" maxFractionDigits="2"/>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td><font color="red">已发货:<span
+                                            id="shipped${status.index}${productStatus.index}">${newOrderProduct.num + newOrderProduct.presentNum - newOrderProduct.notOutStore}</span></font>
+                                    </td>
+                                    <input type="hidden" id="returning${status.index}${productStatus.index}"
+                                           value="${newOrderProduct.returningPurchaseProductNum}"/>
+                                    <td><font color="red"><span>已退货:<span
+                                            id="returned${status.index}${productStatus.index}">${newOrderProduct.returnedPurchaseProductNum}</span></span></font>
+                                    </td>
+                                    <td colspan="4"><font
+                                            color="red"><span>本次退货:<input ${newOrderProduct.presentNum>0 or (order.onlinePayFlag eq 0 and shopOrder.shopID eq 998)?"readonly":""}
+                                            presentNum="${newOrderProduct.presentNum}"
+                                            id="applicationReturnedNum${status.index}${productStatus.index}"
+                                            class="refundGoodsInput1 shopOrderInput1 refundGoodsInput shopOrderInput"
+                                            name="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].applicationReturnedNum"
+                                            value="${(order.onlinePayFlag eq 0 and shopOrder.shopID eq 998)?0:(newOrderProduct.num + newOrderProduct.presentNum - newOrderProduct.notOutStore - newOrderProduct.returnedPurchaseProductNum)}"
+                                            oninput="this.value=this.value.replace(/\D/g,'').replace(/^0+(?=\d)/,1)"
+                                            class="input tuihuo" type="text"
+                                            onchange="setApplicationReturnedNum(${status.index},${productStatus.index})"></span></font>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td><font color="red">待发货:<span
+                                            id="toBeShipped${status.index}${productStatus.index}">${newOrderProduct.notOutStore - newOrderProduct.cancelProductNum}</span></font>
+                                    </td>
+                                    <td><font color="red">已取消:<span
+                                            id="toBeShipped${status.index}${productStatus.index}">${newOrderProduct.cancelProductNum}</span></font>
+                                    </td>
+                                    <td colspan="4"><font
+                                            color="red"><span>本次取消:<input ${newOrderProduct.presentNum>0 or (order.onlinePayFlag eq 0 and shopOrder.shopID eq 998)?"readonly":""}
+                                            id="applicationCancelNum${status.index}${productStatus.index}"
+                                            class="cancelGoodsInput shopOrderInput"
+                                            name="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].applicationCancelNum"
+                                            value="${(order.onlinePayFlag eq 0 and shopOrder.shopID eq 998)?0:(newOrderProduct.notOutStore - newOrderProduct.cancelProductNum)}"
+                                            oninput="this.value=this.value.replace(/\D/g,'').replace(/^0+(?=\d)/,1)"
+                                            class="input cancel" type="text"
+                                            onchange="setApplicationCancelNum(${status.index},${productStatus.index})"></span></font>
+                                    </td>
+                                    <form:hidden
+                                            path="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].shopOrderID"
+                                            value="${newOrderProduct.shopOrderID}"/>
+                                    <form:hidden
+                                            path="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].productID"
+                                            value="${newOrderProduct.productID}"/>
+                                    <form:hidden
+                                            path="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].orderProductID"
+                                            value="${newOrderProduct.orderProductID}"/>
+                                    <form:hidden
+                                            path="cmReturnedPurchaseProductList[${status.index}][${productStatus.index}].shopID"
+                                            value="${newOrderProduct.shopID}"/>
+                                </tr>
+                            </table>
+                        </td>
+                    </tr>
+                </c:forEach>
+            </table>
+        </c:if>
+    </c:forEach>
     <div class="form-actions">
                 <input id="btnSubmit" class="btn btn-primary" type="submit" value="申 请"/>&nbsp;
 
@@ -670,10 +841,65 @@
 <script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/orderForm.js"></script>
 <script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/stages.js"></script>
 <script>
+
+    function changeType(){
+        var refundType =  $("#refundType").val();
+        if(1==refundType){
+            var orderStatus = $("#orderStatus").val();
+            var isBuFenFaHuo = $("#isBuFenFaHuo").val();
+            if(isBuFenFaHuo == "true"){
+                $(".shopOrderInput").attr("readonly",true);
+                /*$(".shopOrderInput1").attr("readonly",false);*///设置邮费的可修改
+            };
+
+            //有促销商品订单不可修改
+            if (${isPromotions}){
+                $(".shopOrderInput").attr("readonly",true);
+            }
+
+            //线上全部付款订单不可修改
+            if (${order.receiptStatus == 3 && cmDiscernReceipt.payWay eq 1}){
+                $(".shopOrderInput").attr("readonly",true);
+            }
+
+            // 有优惠不可修改,只能全退
+            if (${order.discountAmount > 0 and order.onlinePayFlag eq 0}){
+                $(".shopOrderInput").attr("readonly",true);
+            }
+
+            //充值订单不可修改
+            if (${order.rechargeGoods != null && (order.rechargeGoods eq 1 || order.rechargeGoods eq 2)}){
+                $(".shopOrderInput").attr("readonly",true);
+            }
+            $("#zdy").hide();
+            $("#spt").show();
+        }
+        if(2==refundType || 3==refundType) {
+            $("input[readonly='readonly']").removeProp("readonly");
+            $("#spt").hide();
+            $("#zdy").show();
+        }
+    }
+
+    function showBankInfo() {
+        if (${!returnOnline}){
+            var obj = document.getElementsByClassName("refundOfflineFee"),
+                blockEle = $('.refund-details-block');
+            if(obj){
+                if(obj[0].checked){
+                    //显示银行信息
+                    blockEle.show();
+                } else {
+                    blockEle.hide();
+                }
+            }
+        }
+    }
+
     $(function () {
         var orderStatus = $("#orderStatus").val();
         var isBuFenFaHuo = $("#isBuFenFaHuo").val();
-        debugger
+        var refundType =  $("#refundType").val();
         if(isBuFenFaHuo == "true"){
             $(".shopOrderInput").attr("readonly",true);
             /*$(".shopOrderInput1").attr("readonly",false);*///设置邮费的可修改
@@ -704,6 +930,10 @@
             $(".shopOrderInput").attr("readonly",true);
         }
 
+        if(2==refundType || 3==refundType){
+            $("input[readonly='readonly']").removeProp("readonly");
+        }
+
         if (${order.rechargeGoods != null && order.rechargeGoods eq 1 && ableUserMoney eq 0}){
             alertx("本订单为缴纳订金订单,机构的余额为¥0.00,不能进行退款", function(){
                 window.location.href = "${ctx}/order/orderList";
@@ -915,28 +1145,33 @@
     }
 
     function setApplicationReturnedNum(a,b){
+        var refundType =  $("#refundType").val();
         var num = $("#applicationReturnedNum"+a+b).val();
         var max = Number($("#shipped"+a+b).html()  - $("#returning"+a+b).html() - $("#returned"+a+b).html());
-        if(num > max){
-            alertx("退货数量不能大于已发货数量(之前已退不算)!");
-            $("#applicationReturnedNum"+a+b).val(0)
-        }
-        if (num !== max && ${returnOnline}){
-            alertx("退货数量只能等于已发货数量(之前已退不算)!");
-            $("#applicationReturnedNum"+a+b).val(0)
+        if(1==refundType){
+            if(num > max){
+                alertx("退货数量不能大于已发货数量(之前已退不算)!");
+                $("#applicationReturnedNum"+a+b).val(0)
+            }
+            if (num !== max && ${returnOnline}){
+                alertx("退货数量只能等于已发货数量(之前已退不算)!");
+                $("#applicationReturnedNum"+a+b).val(0)
+            }
         }
-
     };
     function setApplicationCancelNum(a,b){
+        var refundType =  $("#refundType").val();
         var num = $("#applicationCancelNum"+a+b).val();
         var max = Number($("#toBeShipped"+a+b).html());
-        if(num > max){
-            alertx("取消数量不能大于待发数量,请重新填写!");
-            $("#applicationCancelNum"+a+b).val(0)
-        }
-        if (num !== max && ${returnOnline}){
-            alertx("取消数量只能等于待发数量,请重新填写!");
-            $("#applicationCancelNum"+a+b).val(0)
+        if(1==refundType){
+            if(num > max){
+                alertx("取消数量不能大于待发数量,请重新填写!");
+                $("#applicationCancelNum"+a+b).val(0)
+            }
+            if (num !== max && ${returnOnline}){
+                alertx("取消数量只能等于待发数量,请重新填写!");
+                $("#applicationCancelNum"+a+b).val(0)
+            }
         }
     };
 </script>

+ 5 - 2
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp

@@ -140,6 +140,9 @@
             <td><b>退款编号:</b>
                     ${empty cmReturnedPurchase.returnedNo?'':(cmReturnedPurchase.returnedNo)}
             </td>
+            <td><b>退款模式:</b>
+                    ${cmReturnedPurchase.refundType eq 1?'按商品退回':'自定义金额退款'}
+            </td>
             <td><b>申请时间:</b>
                     ${cmReturnedPurchase.returnTime}
             </td>
@@ -353,10 +356,10 @@
                 <font>无退款</font>
             </c:if>
             <c:if test="${order.refundType == 1}">
-                <font color="#ff8c00">部分退款</font>
+                <font>部分退款</font>
             </c:if>
             <c:if test="${order.refundType == 2}">
-                <font color="green">已退款</font>
+                <font>已退款</font>
             </c:if></td>
         </td>
     </tr>

+ 230 - 133
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReturnRecord.jsp

@@ -7,7 +7,10 @@
     <title>退款退货记录</title>
     <meta name="decorator" content="default"/>
     <style media="print">
-        @page { size: landscape; }
+        @page {
+            size: landscape;
+        }
+
         .refund-btn-top, .nav {
             display: none;
         }
@@ -43,47 +46,64 @@
             text-align: center;
             white-space: nowrap;
         }
-        .controls{
+
+        .controls {
             font-size: 0;
         }
-        .controls .conList{
+
+        .controls .conList {
             display: inline-block;
             margin-right: 15px;
         }
-        .conList .btn:nth-of-type(1){
+
+        .conList .btn:nth-of-type(1) {
             margin-left: 25px;
         }
+
         .refund-btn-top {
             float: right;
             margin-top: -18px;
             margin-right: 10px;
             height: 40px;
         }
+
         #enlarge-box {
             position: fixed;
             /*width: 325px;*/
             top: 50%;
             left: 50%;
-            transform: translate(-50%,-50%);
+            transform: translate(-50%, -50%);
             border: 2px solid #eee;
             background: #fff;
             display: none;
         }
-        .zeroCost .message{
-            display:none;
-            position:absolute;
-            background:#FFF;
-            white-space:nowrap;
-            border:1px solid black;
+
+        .zeroCost .message {
+            display: none;
+            position: absolute;
+            background: #FFF;
+            white-space: nowrap;
+            border: 1px solid black;
 
         }
-        .zeroCost:hover .message{
+
+        .zeroCost:hover .message {
             display: inline-block;
             color: black;
             padding: 5px;
             margin-left: 10px;
         }
-        .weishaIcon {background:darkorange;color:white;margin:0 0px;padding:0 3px;font-style:normal;font-size: 12px; display:inline-block;border-radius:2px}
+
+        .weishaIcon {
+            background: darkorange;
+            color: white;
+            margin: 0 0px;
+            padding: 0 3px;
+            font-style: normal;
+            font-size: 12px;
+            display: inline-block;
+            border-radius: 2px
+        }
     </style>
     <script type="text/javascript">
         $(document).ready(function () {
@@ -107,18 +127,16 @@
         });
 
 
-
-
         function openClauseInfo(index) {
-            var content=$("#clauseContent"+index).val();
+            var content = $("#clauseContent" + index).val();
             if (content == '') {
                 return false;
             }
             $.jBox(content, {
-                title: $("#clauseName"+index).val(),
+                title: $("#clauseName" + index).val(),
                 width: $(top.document).width() - 440,
-                height: $(top.document).height()-240,
-                buttons: { '关闭': true }
+                height: $(top.document).height() - 240,
+                buttons: {'关闭': true}
             });
         }
     </script>
@@ -130,19 +148,24 @@
     <c:if test="${from eq '3'}">
         <li><a href="${ctx}/shopOrder/checkPaymentOrder">订单财务信息</a></li>
     </c:if>
-    <li class="active"><a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID.rpc?orderID=${order.orderID}">退款退货详情</a></li>
+    <li class="active"><a
+            href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID.rpc?orderID=${order.orderID}">退款退货详情</a>
+    </li>
 </ul>
 <br/>
 <div class="refund-btn-top">
     <c:if test="${from ne '3'}">
-    <input type="button" class="btn btn-primary" onclick="window.location.href='${ctx}${cmReturnedPurchase.orderType eq 2?'/hehe/new/order/orderList':'/order/orderList'}'"  value="返回">
+        <input type="button" class="btn btn-primary"
+               onclick="window.location.href='${ctx}${cmReturnedPurchase.orderType eq 2?'/hehe/new/order/orderList':'/order/orderList'}'"
+               value="返回">
     </c:if>
 </div>
 <c:forEach items="${cmReturnedPurchaseList}" var="cmReturnedPurchase" varStatus="cmReturnedPurchaseStatus">
-    <form:form id="inputForm${cmReturnedPurchaseStatus.index}" modelAttribute="cmReturnedPurchase" action="${ctx}/bulkpurchase/cmRefundsProduct/saveRefound" method="post"
+    <form:form id="inputForm${cmReturnedPurchaseStatus.index}" modelAttribute="cmReturnedPurchase"
+               action="${ctx}/bulkpurchase/cmRefundsProduct/saveRefound" method="post"
                class="form-horizontal">
         <c:if test="${cmReturnedPurchaseStatus.index ne 0}">
-            <hr style="height:5px;border:none;border-top:5px ridge green;" />
+            <hr style="height:5px;border:none;border-top:5px ridge green;"/>
         </c:if>
         <%--审核模块--%>
         <c:if test="${not empty cmReturnedPurchase.confirmReturnTime}">
@@ -168,19 +191,24 @@
                         <c:if test="${not empty cmReturnedPurchase.reviewImage1 || not empty cmReturnedPurchase.reviewImage2  || not empty cmReturnedPurchase.reviewImage3  || not empty cmReturnedPurchase.reviewImage4  || not empty cmReturnedPurchase.reviewImage5}">
                             审核凭证:
                             <c:if test="${not empty cmReturnedPurchase.reviewImage1}">
-                                <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.reviewImage1}">
+                                <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                     src="${cmReturnedPurchase.reviewImage1}">
                             </c:if>
                             <c:if test="${not empty cmReturnedPurchase.reviewImage2}">
-                                <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.reviewImage2}">
+                                <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                     src="${cmReturnedPurchase.reviewImage2}">
                             </c:if>
                             <c:if test="${not empty cmReturnedPurchase.reviewImage3}">
-                                <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.reviewImage3}">
+                                <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                     src="${cmReturnedPurchase.reviewImage3}">
                             </c:if>
                             <c:if test="${not empty cmReturnedPurchase.reviewImage4}">
-                                <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.reviewImage4}">
+                                <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                     src="${cmReturnedPurchase.reviewImage4}">
                             </c:if>
                             <c:if test="${not empty cmReturnedPurchase.reviewImage5}">
-                                <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.reviewImage5}">
+                                <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                     src="${cmReturnedPurchase.reviewImage5}">
                             </c:if>
                         </c:if>
                     </td>
@@ -211,22 +239,28 @@
                     <c:if test="${not empty cmReturnedPurchase.image1 || not empty cmReturnedPurchase.image2 || not empty cmReturnedPurchase.image3 || not empty cmReturnedPurchase.image4 || not empty cmReturnedPurchase.image5}">
                         申请凭证:
                         <c:if test="${not empty cmReturnedPurchase.image1}">
-                            <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.image1}">
+                            <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                 src="${cmReturnedPurchase.image1}">
                         </c:if>
                         <c:if test="${not empty cmReturnedPurchase.image2}">
-                            <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.image2}">
+                            <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                 src="${cmReturnedPurchase.image2}">
                         </c:if>
                         <c:if test="${empty cmReturnedPurchase.image3}">
-                            <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.image3}">
+                            <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                 src="${cmReturnedPurchase.image3}">
                         </c:if>
                         <c:if test="${not empty cmReturnedPurchase.image3}">
-                            <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.image3}">
+                            <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                 src="${cmReturnedPurchase.image3}">
                         </c:if>
                         <c:if test="${not empty cmReturnedPurchase.image4}">
-                            <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.image4}">
+                            <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                 src="${cmReturnedPurchase.image4}">
                         </c:if>
                         <c:if test="${not empty cmReturnedPurchase.image5}">
-                            <img class="enlarge-pic" style="height: 70px;width: 65px" src="${cmReturnedPurchase.image5}">
+                            <img class="enlarge-pic" style="height: 70px;width: 65px"
+                                 src="${cmReturnedPurchase.image5}">
                         </c:if>
                     </c:if>
                 </td>
@@ -246,7 +280,9 @@
                         ${cmReturnedPurchase.returnTime}
                 </td>
                 <td><b>申请金额:</b>
-                    <span class="refundFee"><fmt:formatNumber value="${empty cmReturnedPurchase.refundFee?'0.00':(cmReturnedPurchase.refundFee)}" pattern="#0.00"/></span>元&nbsp;&nbsp;&nbsp;(账户余额抵扣:${order.balancePayFee})
+                    <span class="refundFee"><fmt:formatNumber
+                            value="${empty cmReturnedPurchase.refundFee?'0.00':(cmReturnedPurchase.refundFee)}"
+                            pattern="#0.00"/></span>元&nbsp;&nbsp;&nbsp;(账户余额抵扣:${order.balancePayFee})
                 </td>
                 <td><b>退款审核状态:</b>
                     <c:if test="${empty cmReturnedPurchase.status}">
@@ -266,7 +302,7 @@
                 </td>
             </tr>
             <tr>
-                <td  colspan="4" >
+                <td colspan="4">
                     <b>退款方式:</b>
                     <c:if test="${cmReturnedPurchase.returnedWay eq 4}">
                         未支付无退款
@@ -274,20 +310,20 @@
                     <c:if test="${cmReturnedPurchase.returnedWay eq 1}">
                         <c:if test="${not empty cmReturnedPurchase.refundBalanceFee && cmReturnedPurchase.refundBalanceFee ne 0 }">
                             余额账户:<fmt:formatNumber type="number" pattern="#,##0.00"
-                                                   value="${cmReturnedPurchase.refundBalanceFee}" />元&nbsp;&nbsp;&nbsp;&nbsp;
+                                                   value="${cmReturnedPurchase.refundBalanceFee}"/>元&nbsp;&nbsp;&nbsp;&nbsp;
                         </c:if>
                         <c:if test="${not empty cmReturnedPurchase.refundOnlineFee && cmReturnedPurchase.refundOnlineFee ne 0 }">
                             线上退回:<fmt:formatNumber type="number" pattern="#,##0.00"
-                                                   value="${cmReturnedPurchase.refundOnlineFee}" />元&nbsp;&nbsp;&nbsp;&nbsp;
+                                                   value="${cmReturnedPurchase.refundOnlineFee}"/>元&nbsp;&nbsp;&nbsp;&nbsp;
                         </c:if>
                         <br>
                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                         <c:if test="${not empty cmReturnedPurchase.refundOfflineFee && cmReturnedPurchase.refundOfflineFee ne 0 }">
                             线下转账:<fmt:formatNumber type="number" pattern="#,##0.00"
-                                                   value="${cmReturnedPurchase.refundOfflineFee}" />元&nbsp;&nbsp;&nbsp;&nbsp;
+                                                   value="${cmReturnedPurchase.refundOfflineFee}"/>元&nbsp;&nbsp;&nbsp;&nbsp;
                             采美退款银行:
                             <c:if test="${cmReturnedPurchase.payType == '1'}">
-                               建设银行7297
+                                建设银行7297
                             </c:if>
                             <c:if test="${cmReturnedPurchase.payType == '2'}">
                                 中信银行0897
@@ -359,7 +395,8 @@
             </tr>
             <tr>
                 <td>
-                    订单金额:¥<fmt:formatNumber type="number" value="${order.payTotalFee}" pattern="0.00" maxFractionDigits="2" />
+                    订单金额:¥<fmt:formatNumber type="number" value="${order.payTotalFee}" pattern="0.00"
+                                            maxFractionDigits="2"/>
                     <c:if test="${not empty order.couponOrderRecord}">
                         <c:if test="${order.couponOrderRecord.couponType eq 0}">
                             <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(活动券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
@@ -389,11 +426,14 @@
                     </c:if>
                 </td>
                 <td>
-                    应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2" />(账户余额抵扣:${order.balancePayFee})
-                    <a href="${ctx}/order/cmDiscernReceipt/detail?id=${lastReceiptDetailId}" style="text-decoration: underline;margin-left: 20px">查看订单收款情况</a>
+                    应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00"
+                                            maxFractionDigits="2"/>(账户余额抵扣:${order.balancePayFee})
+                    <a href="${ctx}/order/cmDiscernReceipt/detail?id=${lastReceiptDetailId}"
+                       style="text-decoration: underline;margin-left: 20px">查看订单收款情况</a>
                 </td>
                 <td>
-                    经理折扣:¥<fmt:formatNumber type="number" value="${order.discountFee}" pattern="0.00" maxFractionDigits="2" />
+                    经理折扣:¥<fmt:formatNumber type="number" value="${order.discountFee}" pattern="0.00"
+                                            maxFractionDigits="2"/>
                 </td>
                 <td>
                     机构运费:
@@ -466,7 +506,8 @@
                     <c:if test="${order.payStatus == 3}">
                         <font color="green">已付款</font>
                         <c:if test="${order.zeroCostFlag eq 1}">
-                            <a href="javascript:;" class="zeroCost"><span><img src="/static/images/info.jpg" style="width: 15px;margin-bottom: 4px"></span>
+                            <a href="javascript:;" class="zeroCost"><span><img src="/static/images/info.jpg"
+                                                                               style="width: 15px;margin-bottom: 4px"></span>
                                 <div class="message">
                                     <span>商品成本为0,直接置为已付款,无需付款供应商</span>
                                 </div>
@@ -480,21 +521,22 @@
                         <font>无退款</font>
                     </c:if>
                     <c:if test="${order.refundType == 1}">
-                        <font color="#ff8c00">部分退款</font>
+                        <font>部分退款</font>
                     </c:if>
                     <c:if test="${order.refundType == 2}">
-                        <font color="green">已退款</font>
+                        <font>已退款</font>
                     </c:if></td>
                 </td>
             </tr>
             <tr>
                 <td>
-                    机构:${order.buyer}<c:if test="${order.organizeID == 3}"></c:if>
+                    机构:${order.buyer}
+                    <c:if test="${order.organizeID == 3}"></c:if>
                 </td>
                 <td>
                     收货人:${order.bpOrderUserinfo.shouHuoRen}(${order.bpOrderUserinfo.mobile})
                 </td>
-                <td  colspan="2">
+                <td colspan="2">
                     地址:${order.bpOrderUserinfo.province}${order.bpOrderUserinfo.city}${order.bpOrderUserinfo.town}${order.bpOrderUserinfo.address}
                 </td>
             </tr>
@@ -503,88 +545,140 @@
         <%--单次退款商品信息汇总--%>
 
         <table id="cmReturnedPurchaseTable" class="table table-striped table-bordered table-condensed">
-                <c:forEach items="${cmReturnedPurchase.shopOrderReturnedList}" var="shopOrderReturneds" varStatus="shopOrderReturnedStatus">
-                    <tr>
-                        <td colspan="7">
-                            <table id="shopOrderReturnedTable${shopOrderReturnedStatus.index}" class="table table-striped table-bordered table-condensed">
+            <c:forEach items="${cmReturnedPurchase.shopOrderReturnedList}" var="shopOrderReturneds"
+                       varStatus="shopOrderReturnedStatus">
+                <tr>
+                    <td colspan="7">
+                        <table id="shopOrderReturnedTable${shopOrderReturnedStatus.index}"
+                               class="table table-striped table-bordered table-condensed">
+                            <tr>
+                                <td style="width: 300px;">
+                                    子订单编号(ID):${shopOrderReturneds.shopOrderNo}(${shopOrderReturneds.shopOrderID})
+                                </td>
+                                <td style="width: 250px;">子订单金额:${shopOrderReturneds.productAmount}</td>
+                                <td>
+                                        <%--                                        收款状态:${fns:getDictLabel(shopOrderReturneds.shopReceiptStatus,'receiptStatus' ,'' )}--%>
+                                    <c:if test="${shopOrderReturneds.shopReceiptStatus == 1}">
+                                        <font color="red">待收款</font>
+                                    </c:if>
+                                    <c:if test="${shopOrderReturneds.shopReceiptStatus == 2}">
+                                        <font color="#ff8c00">部分收款</font>
+                                    </c:if>
+                                    <c:if test="${shopOrderReturneds.shopReceiptStatus == 3}">
+                                        <font color="green">已收款</font>
+                                    </c:if>
+                                </td>
+                                <td>发货状态:
+                                        <%--                                            ${fns:getDictLabel(shopOrderReturneds.sendOutStatus,'sendOutStatus' ,'' )}--%>
+                                    <c:if test="${shopOrderReturneds.sendOutStatus == 1}">
+                                        <font color="red">待发货</font>
+                                    </c:if>
+                                    <c:if test="${shopOrderReturneds.sendOutStatus == 2}">
+                                        <font color="#ff8c00">部分发货</font>
+                                    </c:if>
+                                    <c:if test="${shopOrderReturneds.sendOutStatus == 3}">
+                                        <font color="green">已发货</font>
+                                    </c:if>
+                                </td>
+                                <td>付款状态:
+                                        <%--                                            ${fns:getDictLabel(shopOrderReturneds.payStatus,'payStatus' ,'' )}--%>
+                                    <c:if test="${shopOrderReturneds.payStatus == 1}">
+                                        <font color="red">待付款</font>
+                                    </c:if>
+                                    <c:if test="${shopOrderReturneds.payStatus == 2}">
+                                        <font color="#ff8c00">部分付款</font>
+                                    </c:if>
+                                    <c:if test="${shopOrderReturneds.payStatus == 3}">
+                                        <font color="green">已付款</font>
+                                    </c:if>
+                                </td>
+                                <td>供应商:${shopOrderReturneds.shopName}</td>
+                            </tr>
+                            <c:if test="${order.onlinePayFlag eq 0}">
                                 <tr>
-                                    <td style="width: 300px;">子订单编号(ID):${shopOrderReturneds.shopOrderNo}(${shopOrderReturneds.shopOrderID})</td>
-                                    <td  style="width: 250px;">子订单金额:${shopOrderReturneds.productAmount}</td>
                                     <td>
-                                        收款状态:${fns:getDictLabel(shopOrderReturneds.shopReceiptStatus,'receiptStatus' ,'' )}
+                                        商品总额:¥<fmt:formatNumber type="number"
+                                                                value="${shopOrderReturneds.needPayAmount}"
+                                                                pattern="0.00" maxFractionDigits="2"/>
+                                    </td>
+                                    <td>
+                                        优惠:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.eachDiscount}"
+                                                              pattern="0.00" maxFractionDigits="2"/>
                                     </td>
-                                    <td>发货状态:
-                                            ${fns:getDictLabel(shopOrderReturneds.sendOutStatus,'sendOutStatus' ,'' )}
+                                    <td>
+                                        应付金额:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.realPay}"
+                                                                pattern="0.00" maxFractionDigits="2"/>
                                     </td>
-                                    <td>付款状态:
-                                            ${fns:getDictLabel(shopOrderReturneds.payStatus,'payStatus' ,'' )}
+                                    <td>
+                                        已付金额:¥<fmt:formatNumber type="number"
+                                                                value="${shopOrderReturneds.receiptAmount}"
+                                                                pattern="0.00" maxFractionDigits="2"/>
                                     </td>
-                                    <td>供应商:${shopOrderReturneds.shopName}</td>
+                                    <td>
+                                        待付金额:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.restAmount}"
+                                                                pattern="0.00" maxFractionDigits="2"/>
+                                    </td>
+                                </tr>
+                            </c:if>
+                            <c:forEach items="${shopOrderReturneds.cmReturnedPurchaseProductList}"
+                                       var="cmReturnedPurchaseProduct" varStatus="cmReturnedPurchaseProductStatus">
+                                <tr>
+                                    <td rowspan="4" style="width: 295px;height: 125px">
+                                        <img style="width: 100px;height: 100px"
+                                             src="${cmReturnedPurchaseProduct.mainImage}">
+                                        <font title="${cmReturnedPurchaseProduct.name}">${fns:abbr(cmReturnedPurchaseProduct.name,30)}</font>
+                                    </td>
+                                    <td>单价:¥${cmReturnedPurchaseProduct.price}<c:if
+                                            test="${order.collageFlag eq 1}"><font color="red">(拼团价)</font></c:if></td>
+                                    <c:if test="${order.collageFlag eq 1}"><font color="red">(拼团价)</font></c:if>
+                                    <td>折扣:${cmReturnedPurchaseProduct.discount}</td>
+                                    <td>折后单价:¥${cmReturnedPurchaseProduct.discountPrice}</td>
+                                    <td>
+                                        购买数量(赠品数)X${cmReturnedPurchaseProduct.num}(${cmReturnedPurchaseProduct.presentNum})
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td>税率:${cmReturnedPurchaseProduct.taxRate}</td>
+                                    <td>税费:¥${cmReturnedPurchaseProduct.totalAddedValueTax}</td>
+                                    <td colspan="2">总额:¥${cmReturnedPurchaseProduct.totalFee}</td>
                                 </tr>
-                                <c:if test="${order.onlinePayFlag eq 0}">
-                                    <tr>
-                                        <td>
-                                            商品总额:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.needPayAmount}" pattern="0.00" maxFractionDigits="2" />
-                                        </td>
-                                        <td>
-                                            优惠:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.eachDiscount}" pattern="0.00" maxFractionDigits="2" />
-                                        </td>
-                                        <td>
-                                            应付金额:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.realPay}" pattern="0.00" maxFractionDigits="2" />
-                                        </td>
-                                        <td>
-                                            已付金额:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.receiptAmount}" pattern="0.00" maxFractionDigits="2" />
-                                        </td>
-                                        <td>
-                                            待付金额:¥<fmt:formatNumber type="number" value="${shopOrderReturneds.restAmount}" pattern="0.00" maxFractionDigits="2" />
-                                        </td>
-                                    </tr>
-                                </c:if>
-                                <c:forEach items="${shopOrderReturneds.cmReturnedPurchaseProductList}" var="cmReturnedPurchaseProduct" varStatus="cmReturnedPurchaseProductStatus">
-                                    <tr>
-                                        <td  rowspan="4" style="width: 295px;height: 125px">
-                                            <img style="width: 100px;height: 100px"  src="${cmReturnedPurchaseProduct.mainImage}">
-                                            <font title="${cmReturnedPurchaseProduct.name}">${fns:abbr(cmReturnedPurchaseProduct.name,30)}</font>
-                                        </td>
-                                        <td>单价:¥${cmReturnedPurchaseProduct.price}<c:if test="${order.collageFlag eq 1}"><font color="red">(拼团价)</font></c:if></td>                                            <c:if test="${order.collageFlag eq 1}"><font color="red">(拼团价)</font></c:if>
-                                        <td>折扣:${cmReturnedPurchaseProduct.discount}</td>
-                                        <td>折后单价:¥${cmReturnedPurchaseProduct.discountPrice}</td>
-                                        <td>购买数量(赠品数)X${cmReturnedPurchaseProduct.num}(${cmReturnedPurchaseProduct.presentNum})</td>
-                                    </tr>
-                                    <tr>
-                                        <td>税率:${cmReturnedPurchaseProduct.taxRate}</td>
-                                        <td>税费:¥${cmReturnedPurchaseProduct.totalAddedValueTax}</td>
-                                        <td colspan="2">总额:¥${cmReturnedPurchaseProduct.totalFee}</td>
-                                    </tr>
-                                    <tr>
-                                        <td><font color="red">已发货:${cmReturnedPurchaseProduct.num+cmReturnedPurchaseProduct.presentNum - cmReturnedPurchaseProduct.notOutStore}</font></td>
-                                        <td><font color="red">已退货:<span id="applicationReturnedNum${shopOrderReturnedStatus.index}${cmReturnedPurchaseProductStatus.index}">${cmReturnedPurchaseProduct.returnedPurchaseProductNum}</span></font></td>
-                                        <td colspan="2"><font color="red">本次退货:
-                                                ${empty cmReturnedPurchaseProduct.actualReturnedNum ? 0 : cmReturnedPurchaseProduct.actualReturnedNum}
-                                        </font>
-                                        </td>
-                                    </tr>
-                                    <tr>
-                                        <td><font color="red">待发货:${cmReturnedPurchaseProduct.notOutStore - cmReturnedPurchaseProduct.cancelProductNum}</font></td>
-                                        <td><font color="red">已取消:<span id="applicationCancelNum${shopOrderReturnedStatus.index}${cmReturnedPurchaseProductStatus.index}">${cmReturnedPurchaseProduct.cancelProductNum}</span></font></td>
-                                        <td colspan="2"><font color="red">本次取消:
-                                                ${empty cmReturnedPurchaseProduct.actualCancelNum ? 0 : cmReturnedPurchaseProduct.actualCancelNum}
-                                        </font>
-                                        </td>
-                                    </tr>
-                                    <%--<form:hidden path="cmReturnedPurchaseProductList[${shopOrderReturnedStatus.index}][${cmReturnedPurchaseProductStatus.index}].returnedReceiver" value="${cmReturnedPurchaseProduct.returnedReceiver}"/>--%>
-                                </c:forEach>
-                            </table>
-                        </td>
-                    </tr>
-                </c:forEach>
+                                <tr>
+                                    <td><font
+                                            color="red">已发货:${cmReturnedPurchaseProduct.num+cmReturnedPurchaseProduct.presentNum - cmReturnedPurchaseProduct.notOutStore}</font>
+                                    </td>
+                                    <td><font color="red">已退货:<span
+                                            id="applicationReturnedNum${shopOrderReturnedStatus.index}${cmReturnedPurchaseProductStatus.index}">${cmReturnedPurchaseProduct.returnedPurchaseProductNum}</span></font>
+                                    </td>
+                                    <td colspan="2"><font color="red">本次退货:
+                                            ${empty cmReturnedPurchaseProduct.actualReturnedNum ? 0 : cmReturnedPurchaseProduct.actualReturnedNum}
+                                    </font>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td><font
+                                            color="red">待发货:${cmReturnedPurchaseProduct.notOutStore - cmReturnedPurchaseProduct.cancelProductNum}</font>
+                                    </td>
+                                    <td><font color="red">已取消:<span
+                                            id="applicationCancelNum${shopOrderReturnedStatus.index}${cmReturnedPurchaseProductStatus.index}">${cmReturnedPurchaseProduct.cancelProductNum}</span></font>
+                                    </td>
+                                    <td colspan="2"><font color="red">本次取消:
+                                            ${empty cmReturnedPurchaseProduct.actualCancelNum ? 0 : cmReturnedPurchaseProduct.actualCancelNum}
+                                    </font>
+                                    </td>
+                                </tr>
+                                <%--<form:hidden path="cmReturnedPurchaseProductList[${shopOrderReturnedStatus.index}][${cmReturnedPurchaseProductStatus.index}].returnedReceiver" value="${cmReturnedPurchaseProduct.returnedReceiver}"/>--%>
+                            </c:forEach>
+                        </table>
+                    </td>
+                </tr>
+            </c:forEach>
 
         </table>
     </form:form>
 </c:forEach>
 
 <c:if test="${empty cmReturnedPurchaseList}">
-    <p style="text-align: center;"><font  color="#1e90ff">暂无退货退款详情记录.....</font></p>
+    <p style="text-align: center;"><font color="#1e90ff">暂无退货退款详情记录.....</font></p>
 </c:if>
 <c:if test="${not empty cmReturnedPurchaseList}">
     <table id="orderTable" class="table table-striped table-bordered table-condensed">
@@ -592,11 +686,14 @@
             <td>
                 <div class="order-rows">
                     <label>发票信息:</label>
-                    <input id="invoice1" class="invoice1" name="invoice" type="radio" ${order.orderInvoice.type == 0 ? 'checked="checked"':''} disabled="disabled">
+                    <input id="invoice1" class="invoice1" name="invoice"
+                           type="radio" ${order.orderInvoice.type == 0 ? 'checked="checked"':''} disabled="disabled">
                     <label for="invoice1">不需要发票</label>
-                    <input id="invoice2" name="invoice" type="radio" ${order.orderInvoice.type == 1 ? 'checked="checked"':''} disabled="disabled">
+                    <input id="invoice2" name="invoice"
+                           type="radio" ${order.orderInvoice.type == 1 ? 'checked="checked"':''} disabled="disabled">
                     <label for="invoice2">普通发票</label>
-                    <input id="invoice3" name="invoice" type="radio" ${order.orderInvoice.type == 2 ? 'checked="checked"':''} disabled="disabled">
+                    <input id="invoice3" name="invoice"
+                           type="radio" ${order.orderInvoice.type == 2 ? 'checked="checked"':''} disabled="disabled">
                     <label for="invoice3">增值税发票</label>
                     <c:if test="${order.orderInvoice.type == 1}">
                         <br>
@@ -669,28 +766,28 @@
 <script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/stages.js"></script>
 <script>
     $(function () {
-        $('.print-now').on('click',function() {
+        $('.print-now').on('click', function () {
             window.print();
         })
     });
 
-    (function(){
-        $('body').click(function(e) {
+    (function () {
+        $('body').click(function (e) {
             var target = $(e.target),
                 $block = $('.operation-block');
-            if(target.is('.operation-btn')) {
-                if($block.css('display') === 'none') {
+            if (target.is('.operation-btn')) {
+                if ($block.css('display') === 'none') {
                     $block.show();
                 } else {
                     $block.hide();
                 }
             }
-            if(!target.is('.operation-block') && !target.is('.operation-btn')) {
+            if (!target.is('.operation-block') && !target.is('.operation-btn')) {
                 $block.hide();
             }
         });
 
-        $('.clauseId').each(function() {
+        $('.clauseId').each(function () {
             var self = $(this);
             if (!self.prop("checked")) {
                 self.parent().hide();
@@ -709,16 +806,16 @@
             }
         })
 
-        $('body').on('mouseover', '.enlarge-pic', function() {
+        $('body').on('mouseover', '.enlarge-pic', function () {
             var thisSrc = $(this).attr('src'),
                 enlargeBox = $('#enlarge-box');
-            if(thisSrc) {
+            if (thisSrc) {
                 enlargeBox.show(50);
-                $('#enlarge-box').find('img').attr('src',thisSrc);
+                $('#enlarge-box').find('img').attr('src', thisSrc);
             }
         })
 
-        $('body').on('mouseout', '.enlarge-pic', function() {
+        $('body').on('mouseout', '.enlarge-pic', function () {
             var enlargeBox = $('#enlarge-box');
             enlargeBox.hide();
         })

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReviewReturnRecord.jsp

@@ -419,10 +419,10 @@
                 <font>无退款</font>
             </c:if>
             <c:if test="${order.refundType == 1}">
-                <font color="#ff8c00">部分退款</font>
+                <font>部分退款</font>
             </c:if>
             <c:if test="${order.refundType == 2}">
-                <font color="green">已退款</font>
+                <font>已退款</font>
             </c:if></td>
         </td>
     </tr>

+ 119 - 36
src/main/webapp/WEB-INF/views/modules/bulkpurchase/refundRecord.jsp

@@ -144,7 +144,16 @@
             </c:if>
         </td>
         <td>
-            收款状态:${fns:getDictLabel(order.receiptStatus,'receiptStatus' ,'' )}
+            收款状态:<%--${fns:getDictLabel(order.receiptStatus,'receiptStatus' ,'' )}--%>
+            <c:if test="${order.receiptStatus == 1}">
+                <font color="red">待收款</font>
+            </c:if>
+            <c:if test="${order.receiptStatus == 2}">
+                <font color="#ff8c00">部分收款</font>
+            </c:if>
+            <c:if test="${order.receiptStatus == 3}">
+                <font color="green">已收款</font>
+            </c:if>
         </td>
         <c:if test="${order.orderType eq 2}">
             <td>
@@ -162,7 +171,17 @@
             </td>
         </c:if>
         <td>
-            付款状态:${fns:getDictLabel(order.payStatus,'payStatus' ,'' )}
+            付款状态:<%--${fns:getDictLabel(order.payStatus,'payStatus' ,'' )}--%>
+            <c:if test="${order.payStatus == 1}">
+                <font color="red">待付款</font>
+            </c:if>
+            <c:if test="${order.payStatus == 2}">
+                <font color="#ff8c00">部分付款</font>
+            </c:if>
+            <c:if test="${order.payStatus == 3}">
+                <font color="green">已付款</font>
+            </c:if>
+
             <c:if test="${order.zeroCostFlag eq 1}">
                 <a href="javascript:;" class="zeroCost"><span><img src="/static/images/info.jpg" style="width: 15px;margin-bottom: 4px"></span>
                     <div class="message">
@@ -171,8 +190,31 @@
                 </a>
             </c:if>
         </td>
+        <c:if test="${order.onlinePayFlag == 0}">
         <td>
-            退款(退货)状态:${fns:getDictLabel(order.refundType,'refundType' ,'' )}
+            结算状态:
+            <c:if test="${order.settleStatus == 1}">
+                <font color="red">待结算</font>
+            </c:if>
+            <c:if test="${order.settleStatus == 2}">
+                <font color="#ff8c00">部分结算</font>
+            </c:if>
+            <c:if test="${order.settleStatus == 3}">
+                <font color="green">已结算</font>
+            </c:if>
+        </td>
+        </c:if>
+        <td>
+<%--            退款(退货)状态:${fns:getDictLabel(order.refundType,'refundType' ,'' )}--%>
+    <c:if test="${order.refundType == 1}">
+        <font color="red">待发货</font>
+    </c:if>
+    <c:if test="${order.refundType == 2}">
+        <font color="#ff8c00">部分发货</font>
+    </c:if>
+    <c:if test="${order.refundType == 3}">
+        <font color="green">已发货</font>
+    </c:if>
         </td>
     </tr>
     <tr>
@@ -281,50 +323,91 @@
         </c:if>
     </c:forEach>
 </c:if>
-<c:if test="${empty receipt}">
-    <div class="record-title">收款记录: 无</div>
+<%--<c:if test="${empty receipt}">--%>
+<%--    <div class="record-title">收款记录: 无</div>--%>
+<%--</c:if>--%>
+<%--<br><br>--%>
+<%--<c:if test="${not empty cmReturnedPurchaseList}">--%>
+<%--    <div class="record-title">退款记录:</div>--%>
+<%--    <table id="cmReturnedPurchaseTable" class="table table-striped table-bordered table-condensed">--%>
+<%--        <tr>--%>
+<%--            <th class="table-order">序号</th>--%>
+<%--            <th class="table-id">退款编号</th>--%>
+<%--            <th class="table-cell3">退款金额</th>--%>
+<%--            <th class="table-cell4">申请时间</th>--%>
+<%--            <th class="table-cell5">退款状态</th>--%>
+<%--        </tr>--%>
+<%--        <c:forEach items="${cmReturnedPurchaseList}" var="cmReturnedPurchase" varStatus="cmReturnedPurchaseStatus">--%>
+<%--            <tr>--%>
+<%--                <td>--%>
+<%--                        ${cmReturnedPurchaseStatus.index + 1}--%>
+<%--                </td>--%>
+<%--                <td>--%>
+<%--                    <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecord.rpc?id=${cmReturnedPurchase.id}&orderID=${cmReturnedPurchase.orderID}"--%>
+<%--                       style="cursor: pointer">--%>
+<%--                            ${cmReturnedPurchase.returnedNo}</a>--%>
+<%--                </td>--%>
+<%--                <td><fmt:formatNumber value="${cmReturnedPurchase.refundFee}" type="currency"/></td>--%>
+<%--                <td>${cmReturnedPurchase.returnTime}</td>--%>
+<%--                <td><c:if test="${cmReturnedPurchase.status eq 1}">--%>
+<%--                    待审核--%>
+<%--                </c:if>--%>
+<%--                    <c:if test="${cmReturnedPurchase.status eq 2}">--%>
+<%--                        审核通过--%>
+<%--                    </c:if>--%>
+<%--                    <c:if test="${cmReturnedPurchase.status eq 3}">--%>
+<%--                        审核不通过--%>
+<%--                    </c:if>--%>
+<%--                </td>--%>
+<%--            </tr>--%>
+<%--        </c:forEach>--%>
+<%--    </table>--%>
+<%--</c:if>--%>
+<c:if test="${empty pr}">
+    <div class="record-title">付款记录:无</div>
 </c:if>
-<br><br>
-<c:if test="${not empty cmReturnedPurchaseList}">
-    <div class="record-title">退款记录:</div>
-    <table id="cmReturnedPurchaseTable" class="table table-striped table-bordered table-condensed">
+<c:if test="${not empty pr}">
+    <div class="record-title">付款记录:</div>
+    <table id="contentTable" class="table table-striped table-bordered table-condensed" width="70%" border="1">
+        <thead>
         <tr>
-            <th class="table-order">序号</th>
-            <th class="table-id">退款编号</th>
-            <th class="table-cell3">退款金额</th>
-            <th class="table-cell4">申请时间</th>
-            <th class="table-cell5">退款状态</th>
+            <th>序号</th>
+            <th>付款单ID</th>
+            <th>付款时间</th>
+            <th>付款方式</th>
+            <th>付款金额</th>
         </tr>
-        <c:forEach items="${cmReturnedPurchaseList}" var="cmReturnedPurchase" varStatus="cmReturnedPurchaseStatus">
+        </thead>
+        <tbody>
+        <c:forEach items="${pr}" var="p" varStatus="pp">
             <tr>
-                <td>
-                        ${cmReturnedPurchaseStatus.index + 1}
-                </td>
-                <td>
-                    <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecord.rpc?id=${cmReturnedPurchase.id}&orderID=${cmReturnedPurchase.orderID}"
-                       style="cursor: pointer">
-                            ${cmReturnedPurchase.returnedNo}</a>
-                </td>
-                <td><fmt:formatNumber value="${cmReturnedPurchase.refundFee}" type="currency"/></td>
-                <td>${cmReturnedPurchase.returnTime}</td>
-                <td><c:if test="${cmReturnedPurchase.status eq 1}">
-                    待审核
-                </c:if>
-                    <c:if test="${cmReturnedPurchase.status eq 2}">
-                        审核通过
+                <td>${pp.index + 1}</td>
+                <td><a href="${ctx}/order/cmPayShop/applyDetail?id=${p.payShopID}">${p.payShopID}</a></td>
+                <td>${p.payTime}</td>
+                <td><c:if test="${p.payType == '1'}">
+                        建设银行7297
+                    </c:if>
+                    <c:if test="${p.payType == '2'}">
+                        中信银行0897
+                    </c:if>
+                    <c:if test="${p.payType == '3'}">
+                        中信银行7172
                     </c:if>
-                    <c:if test="${cmReturnedPurchase.status eq 3}">
-                        审核不通过
+                    <c:if test="${p.payType == '4'}">
+                        广发银行0115
+                    </c:if>
+                    <c:if test="${p.payType == '5'}">
+                        广发银行5461
                     </c:if>
                 </td>
+                <td>${p.payAmount}</td>
             </tr>
         </c:forEach>
+        </tbody>
     </table>
 </c:if>
-<c:if test="${empty cmReturnedPurchaseList}">
-    <div class="record-title">退款记录:无</div>
     <br>
-</c:if>
+
 
 
 <script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/loadAddress.js"></script>
@@ -337,4 +420,4 @@
 
 </script>
 </body>
-</html>
+</html>

+ 331 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/settlementRecord.jsp

@@ -0,0 +1,331 @@
+<%@ taglib prefix="from" uri="http://www.springframework.org/tags/form" %>
+<%@ taglib prefix="input" uri="/struts-tags" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>收退款记录</title>
+    <meta name="decorator" content="default"/>
+    <style>
+        .form-horizontal .controls {
+            margin-left: 0;
+        }
+
+        .dateInput input {
+            width: 150px;
+        }
+
+        .clause span {
+            margin-left: 30px;
+        }
+
+        #productTable th {
+            text-align: center;
+            white-space: nowrap;
+        }
+
+        #productTable td {
+            text-align: center;
+            white-space: nowrap;
+        }
+
+        .controls {
+            font-size: 0;
+        }
+
+        .controls .conList {
+            display: inline-block;
+            margin-right: 15px;
+        }
+
+        .conList .btn:nth-of-type(1) {
+            margin-left: 25px;
+        }
+
+        #refundTable th, #cmReturnedPurchaseTable th {
+            width: 20%;
+        }
+
+        .record-title {
+            height: 30px;
+            line-height: 30px;
+            padding-left: 8px;
+        }
+        .zeroCost .message{
+            display:none;
+            position:absolute;
+            background:#FFF;
+            white-space:nowrap;
+            border:1px solid black;
+
+        }
+        .zeroCost:hover .message{
+            display: inline-block;
+            color: black;
+            padding: 5px;
+            margin-left: 10px;
+        }
+        .weishaIcon {background:darkorange;color:white;margin:0 0px;padding:0 3px;font-style:normal;font-size: 12px; display:inline-block;border-radius:2px}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+
+        });
+
+
+    </script>
+</head>
+<body>
+<input type="hidden" id="product_index" value="${fn:length(order.orderProduct)}">
+<input type="hidden" id="ctx" value="${ctx}">
+<ul class="nav nav-tabs">
+    <c:if test="${from eq '1' or from eq '2'}">
+        <c:if test="${orderType eq 2}">
+            <li><a href="${ctx}/hehe/new/order/orderList">订单列表</a></li>
+        </c:if>
+        <c:if test="${orderType ne 2}">
+            <li><a href="${ctx}/order/orderList">订单列表</a></li>
+        </c:if>
+    </c:if>
+    <c:if test="${from eq '2'}">
+        <li><a href="${ctx}/order/detail?id=${orderID}">订单详情</a></li>
+    </c:if>
+    <c:if test="${from eq '3'}">
+        <li><a href="${ctx}/shopOrder/checkPaymentOrder">订单财务信息</a></li>
+    </c:if>
+    <li class="active"><a href="#">收退款记录</a></li>
+</ul>
+<br/>
+<table id="orderTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    </thead>
+    <tr>
+        <td>
+            下单时间:${order.orderTime}
+        </td>
+        <td>
+            订单号(ID):${order.orderNo}(${order.orderID})
+        </td>
+        <td>
+            <c:if test="${order.organizeID != 1}">
+                订单类型:${fns:getDictLabel(order.orderType,'order_type' ,'' )}
+                <c:if test="${order.orderType eq 2}">
+                    ${order.collageFlag eq 1?'拼团订单':'独立订单'}
+                </c:if>
+            </c:if>
+        </td>
+        <td>
+            <c:if test="${order.organizeID != 1}">
+                订单来源:${fns:getDictLabel(order.orderSource,'bp_orderSource' ,'' )}
+            </c:if>
+        </td>
+    </tr>
+    <tr>
+        <td>
+            订单状态:
+            <c:if test="${ not empty order.status}">
+                ${fns:getNewOrderStatus(order.status)}
+            </c:if>
+        </td>
+        <td>
+            收款状态:<%--${fns:getDictLabel(order.receiptStatus,'receiptStatus' ,'' )}--%>
+            <c:if test="${order.receiptStatus == 1}">
+                <font color="red">待收款</font>
+            </c:if>
+            <c:if test="${order.receiptStatus == 2}">
+                <font color="#ff8c00">部分收款</font>
+            </c:if>
+            <c:if test="${order.receiptStatus == 3}">
+                <font color="green">已收款</font>
+            </c:if>
+        </td>
+        <c:if test="${order.orderType eq 2}">
+            <td>
+                拼团状态:
+                <c:choose>
+                    <c:when test="${order.collageFlag eq 1 && (order.status eq 31 || order.status eq 32 || order.status eq 33)}">
+                        <font color="${order.collageStatus eq 1?'#00CC66':(order.collageStatus eq 2?'red':'')}">
+                                ${order.collageStatus eq 1?'拼团中':(order.collageStatus eq 2?'已拼成':'-')}
+                        </font>
+                    </c:when>
+                    <c:otherwise>
+                        -
+                    </c:otherwise>
+                </c:choose>
+            </td>
+        </c:if>
+        <td>
+            付款状态:<%--${fns:getDictLabel(order.payStatus,'payStatus' ,'' )}--%>
+            <c:if test="${order.payStatus == 1}">
+                <font color="red">待付款</font>
+            </c:if>
+            <c:if test="${order.payStatus == 2}">
+                <font color="#ff8c00">部分付款</font>
+            </c:if>
+            <c:if test="${order.payStatus == 3}">
+                <font color="green">已付款</font>
+            </c:if>
+
+            <c:if test="${order.zeroCostFlag eq 1}">
+                <a href="javascript:;" class="zeroCost"><span><img src="/static/images/info.jpg" style="width: 15px;margin-bottom: 4px"></span>
+                    <div class="message">
+                        <span>商品成本为0,直接置为已付款,无需付款供应商</span>
+                    </div>
+                </a>
+            </c:if>
+        </td>
+        <c:if test="${order.onlinePayFlag == 0}">
+        <td>
+            结算状态:
+            <c:if test="${order.settleStatus == 1}">
+                <font color="red">待结算</font>
+            </c:if>
+            <c:if test="${order.settleStatus == 2}">
+                <font color="#ff8c00">部分结算</font>
+            </c:if>
+            <c:if test="${order.settleStatus == 3}">
+                <font color="green">已结算</font>
+            </c:if>
+        </td>
+        </c:if>
+        <td>
+<%--            退款(退货)状态:${fns:getDictLabel(order.refundType,'refundType' ,'' )}--%>
+    <c:if test="${order.refundType == 1}">
+        <font color="red">待发货</font>
+    </c:if>
+    <c:if test="${order.refundType == 2}">
+        <font color="#ff8c00">部分发货</font>
+    </c:if>
+    <c:if test="${order.refundType == 3}">
+        <font color="green">已发货</font>
+    </c:if>
+        </td>
+    </tr>
+    <tr>
+        <td>
+            机构:${order.bpOrderUserinfo.name}<c:if test="${order.organizeID == 3}"></c:if>
+        </td>
+        <td>
+            收货人:${order.bpOrderUserinfo.shouHuoRen}
+        </td>
+        <td>
+            手机:${order.bpOrderUserinfo.mobile}
+        </td>
+        <td>
+            地址:${order.bpOrderUserinfo.province}${order.bpOrderUserinfo.city}${order.bpOrderUserinfo.town}${order.bpOrderUserinfo.address}
+        </td>
+    </tr>
+    <tr>
+        <td>
+            订单金额:¥${order.payTotalFee}
+            <c:if test="${not empty order.couponOrderRecord}">
+                <c:if test="${order.couponOrderRecord.couponType eq 0}">
+                    <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(活动券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
+                </c:if>
+                <c:if test="${order.couponOrderRecord.couponType eq 1}">
+                    <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(品类券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
+                </c:if>
+                <c:if test="${order.couponOrderRecord.couponType eq 2}">
+                    <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(用户专享券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
+                </c:if>
+                <c:if test="${order.couponOrderRecord.couponType eq 3}">
+                    <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(店铺券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
+                </c:if>
+                <c:if test="${order.couponOrderRecord.couponType eq 4}">
+                    <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(新用户券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
+                </c:if>
+            </c:if>
+            <c:if test="${not empty order.heheCouponRecord}">
+                <a href="${ctx}/hehe/cmHeheCoupon/receiveDetails?userId=${order.userID}">
+                    <font color="red">
+                        (${order.heheCouponRecord.couponType eq 1 ? '活动':order.heheCouponRecord.couponType eq 2?'专享':order.heheCouponRecord.couponType eq 3?'新人':order.heheCouponRecord.couponType eq 4?'好友分享':order.heheCouponRecord.couponType eq 5?'好友消费':'消费分享'}券抵扣¥${order.heheCouponRecord.couponAmount},满${order.heheCouponRecord.touchPrice}减${order.heheCouponRecord.couponAmount})
+                    </font>
+                </a>
+            </c:if>
+            <c:if test="${order.reductionAmount > 0}">
+                (分享减免¥${order.reductionAmount},满${order.reductionTouchPrice}减${order.reductionAmount})
+            </c:if>
+        </td>
+        <td>
+            应收总额:¥${order.payableAmount}
+        </td>
+        <td>
+            经理折扣:¥${order.discountFee}
+        </td>
+        <td>
+            运费:
+            <c:if test="${order.freePostFlag == 0}">
+                包邮
+            </c:if>
+            <c:if test="${order.freePostFlag == -1}">
+                到付
+            </c:if>
+            <c:if test="${order.freePostFlag == -2}">
+                仪器到付-产品包邮
+            </c:if>
+            <c:if test="${order.freePostFlag != -1 && order.freePostFlag != 0 && order.freePostFlag != -2}">
+                ¥<fmt:formatNumber value="${order.freight}" pattern="0.00"/>
+            </c:if>
+            <c:if test="${order.userBeans > 0}">
+                <font color="red">(采美豆抵用:${order.userBeans})</font>
+            </c:if>
+        </td>
+    </tr>
+    <tr>
+        <td>优惠券:${order.couponAmount}</td>
+        <td>退款总额:¥${refundFee}</td>
+        <td COLSPAN="3">
+
+        </td>
+    </tr>
+</table>
+<c:if test="${not empty settleRecord}">
+    <div class="record-title">佣金结算记录:</div>
+    <table id="refundTable" class="table table-striped table-bordered table-condensed">
+        <tr>
+            <th class="table-order">序号</th>
+            <th class="table-id">子订单ID</th>
+            <th class="table-cell3">结算时间</th>
+            <th class="table-cell4">结算金额</th>
+        </tr>
+        <c:forEach items="${settleRecord}" var="settle" varStatus="s">
+            <tr>
+                <td>${s.index + 1}</td>
+                <td>${settle.shopOrderId}</td>
+                <td><fmt:formatDate value="${settle.settleTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
+                <td><fmt:formatNumber value="${settle.settleAmount}" type="currency"/></td>
+            </tr>
+        </c:forEach>
+    </table>
+</c:if>
+<c:if test="${empty settleRecord}">
+    <div class="record-title">佣金结算记录: 无</div>
+</c:if>
+
+<script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/loadAddress.js"></script>
+<script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/orderForm.js"></script>
+<script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/stages.js"></script>
+<script>
+    $(function () {
+
+    });
+
+</script>
+</body>
+</html>

+ 40 - 11
src/main/webapp/WEB-INF/views/modules/order/checkPaymentOrder.jsp

@@ -391,6 +391,13 @@
                     <form:option value="${organize.id}" label="${organize.organizeName}"/>
                 </c:forEach>
             </form:select>
+            <label>结算状态:</label>
+            <form:select path="settleStatus" class="select-ele input-medium required">
+                <form:option value="" label="请选择"/>
+                <form:option value="1" label="未结算"/>
+                <form:option value="2" label="部分结算"/>
+                <form:option value="3" label="已结算"/>
+            </form:select>
             <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
         </div>
         <div class="clearfix"></div>
@@ -413,9 +420,12 @@
                     <th>付款状态</th>
                     <th>应付金额</th>
                     <th>已付金额</th>
+                    <th>结算状态</th>
+                    <th>应结金额</th>
+                    <th>已结金额</th>
                     <th>退款状态</th>
                     <th>退款金额</th>
-                    <th colspan="2">机构</th>
+                    <th>机构</th>
                     <th>优惠券</th>
                     <th>经理折扣</th>
                     <th>机构运费</th>
@@ -488,19 +498,35 @@
                             <fmt:formatNumber value="${s.paid}" type="number" pattern="#,##0.00"/>
                         </c:if>
                     </td>
+                    <td>
+                        <c:if test="${s.onlinePayFlag eq 0}">
+                            <c:if test="${s.settleAmount < s.shouldPayShopAmount && s.settleAmount > 0}"><font color="#ff8c00">部分结算</font></c:if>
+                            <c:if test="${s.settleAmount eq s.shouldPayShopAmount && s.settleAmount > 0}"><font color="green">已结算</font></c:if>
+                            <c:if test="${s.settleAmount eq 0}"><font color="red">未结算</font></c:if>
+                        </c:if>
+                        <c:if test="${s.onlinePayFlag eq 1}">---</c:if>
+                    </td>
+                    <td>
+                        <c:if test="${s.onlinePayFlag eq 0}"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></c:if>
+                        <c:if test="${s.onlinePayFlag eq 1}">---</c:if>
+                    </td>
+                    <td>
+                        <c:if test="${s.onlinePayFlag eq 0}"><fmt:formatNumber value="${s.settleAmount}" type="number" pattern="#,##0.00"/></c:if>
+                        <c:if test="${s.onlinePayFlag eq 1}">---</c:if>
+                    </td>
                     <td>
                         <c:if test="${s.refundType == 1}">
-                            部分退款
+                            <font>部分退款</font>
                         </c:if>
                         <c:if test="${s.refundType == 2}">
-                            已退款
+                            <font>已退款</font>
                         </c:if>
                         <c:if test="${s.refundType != 1 && s.refundType != 2}">
-                            无退款
+                            <font>无退款</font>
                         </c:if>
                     </td>
                     <td><fmt:formatNumber value="${s.returnValue}" type="number" pattern="#,##0.00"/></td>
-                    <td colspan="2">
+                    <td>
                         <c:if test="${s.organizeID == '1'}">
                             <span class="org-note">星范</span>
                         </c:if>
@@ -546,8 +572,8 @@
                         <th colspan="2">应付供应商</th>
                         <th colspan="3">应付税费</th>
                         <th>供应商运费</th>
-                        <th>付第三方</th>
-                        <th>成本类型</th>
+                        <th colspan="2">付第三方</th>
+                        <th colspan="2">成本类型</th>
                     </tr>
                     <tr class="t2">
                         <td colspan="3">${so.shopOrderNo}(${so.shopOrderID})</td>
@@ -579,8 +605,8 @@
                                                           pattern="#,##0.00"/></td>
                         <td class="product-freight"><fmt:formatNumber value="${so.shopPostFee}" type="number"
                                                                       pattern="#,##0.00"/></td>
-                        <td><fmt:formatNumber value="${so.shopOtherFee}" type="number" pattern="#,##0.00"/></td>
-                        <td><c:if test="${empty so.costType || so.costType == '1'}">固定成本</c:if><c:if
+                        <td colspan="2"><fmt:formatNumber value="${so.shopOtherFee}" type="number" pattern="#,##0.00"/></td>
+                        <td colspan="2"><c:if test="${empty so.costType || so.costType == '1'}">固定成本</c:if><c:if
                                 test="${so.costType == '2'}">比例成本</c:if></td>
                     </tr>
                     <tr>
@@ -593,7 +619,7 @@
                         <th colspan="2">总价</th>
                         <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                         <th>成本(单)</th>
-                        <th colspan="2">成本(总)</th>
+                        <th colspan="4">成本(总)</th>
                     </tr>
                     <c:forEach items="${so.newOrderProducts}" var="p" varStatus="pIndex">
                         <tr class="pay-product-item">
@@ -644,7 +670,7 @@
                                 </c:otherwise>
                             </c:choose></td>
                             <td><fmt:formatNumber value="${p.costPrice}" type="number" pattern="#,##0.00"/></td>
-                            <td colspan="2"><fmt:formatNumber
+                            <td colspan="4"><fmt:formatNumber
                                     value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}" type="number"
                                     pattern="#,##0.00"/></td>
                         </tr>
@@ -652,6 +678,9 @@
                 </c:forEach>
             </table>
             <div style="float:right">
+                <c:if test="${s.settleRecordNum>0}">
+                <a href="${ctx}/bulkpurchase/cmRefundsProduct/toSettleRecord?orderID=${s.orderID}">佣金结算记录</a>
+                </c:if>
                 <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord?orderID=${s.orderID}&from=3">收付款记录</a>&nbsp;&nbsp;&nbsp;
                 <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID?orderID=${s.orderID}&from=3">用户退款/货记录</a>&nbsp;&nbsp;&nbsp;
                 <a href="${ctx}/shopOrder/refundRecord?orderID=${s.orderID}">供应商退/付款记录</a>

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/order/cmPayFormList.jsp

@@ -46,6 +46,7 @@
 		<shiro:hasPermission name="order:cmPayShop:split">
 			<li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
 		</shiro:hasPermission>
+		<li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
 	</ul>
 	<form:form id="searchForm" modelAttribute="cmPayShop" action="${ctx}/order/cmPayShop/" method="post" class="breadcrumb form-search">
 		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/order/cmPayShopDetail.jsp

@@ -460,7 +460,7 @@
 					resVal = '';
 				totalComissionEle = thisEle.find('.payCm'),
 				comissionEle = thisEle.find('.payCm-t'),
-				thirdPartyVal = thisEle.find('.third-party-fee').text().replace(',',''),
+				thirdPartyVal = thisEle.find('.third-party-fee').text().replace(',',''),//付第三方
 				freightVal = thisEle.find('.freight').text().replace(',',''),
 				clubFreight = Number(thisEle.find('.clubFreight').text().replace(',','')),
 				discountFee = Number(thisEle.find('.discountFee').text().replace(',','')),

+ 3 - 1
src/main/webapp/WEB-INF/views/modules/order/cmPayShopForm.jsp

@@ -528,7 +528,9 @@
                     <tr>
                         <td>${s.shopOrderNo}(${s.shopOrderID})</td>
                         <td colspan="3">${s.shopName}</td>
-                        <td colspan="3" class="payCm-t"></td> <%-- 子订单佣金=商品总佣金+机构运费-付第三方-供应商运费-分摊优惠--%>
+                        <c:if test="${empty s.brokerage}"><td colspan="3" class="payCm-t"></td></c:if>
+                        <c:if test="${not empty s.brokerage}"><td colspan="3" class="">${s.brokerage}</td></c:if>
+                         <%-- 子订单佣金=商品总佣金+机构运费-付第三方-供应商运费-分摊优惠--%>
                         <td colspan="3" class="product-fee">${s.shopProductAmount}</td>
 
                         <td class="taxes">

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

@@ -304,10 +304,12 @@
     <shiro:hasPermission name="order:cmPayShop:split">
         <li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
     </shiro:hasPermission>
+        <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
 </ul>
 <form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newShopOrder"
            action="${ctx}/shopOrder/payOrderList?operatingMode=${operatingMode
 }" method="post" class="breadcrumb form-search">
+
     <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
     <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
     <div class="ul-form">
@@ -357,12 +359,14 @@
     <button id="select-all" style="color:white;background-color:#2F6FAB">全选</button>
     <c:if test="${operatingMode == '1'}">
         <button id="apply" class="t-btn" style="color:white;background-color:#2F6FAB">付款申请</button>
-        <button id="applyShopOtherFee" class="t-btn" style="color:white;background-color:#2F6FAB">付第三方申请</button>
+<%--        <button id="applyShopOtherFee" class="t-btn" style="color:white;background-color:#2F6FAB">付第三方申请</button>--%>
     </c:if>
     <c:if test="${operatingMode == '2'}">
         <button id="refund" class="t-btn">已付退款</button>
     </c:if>
     <c:forEach items="${page.list}" var="s" varStatus="sIndex">
+        <input id="shopReceiptStatus" type="hidden" value="${s.shopReceiptStatus}">
+        <input id="payWay" type="hidden" value="${s.payWay}">
         <div class="pay-list-item">
             <table class="table table-striped table-bordered table-condensed pay-table">
                 <tr>
@@ -585,9 +589,10 @@
                 </c:forEach>
             </table>
             <div class="pay-more-func">
+                <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 href="${ctx}/shopOrder/toChangePayShopAmount?shopOrderID=${s.shopOrderID}">修改成本</a>
+                        <a id="applypayWay"  href="${ctx}/shopOrder/toChangePayShopAmount?shopOrderID=${s.shopOrderID}">修改成本</a>
                     </shiro:hasPermission>
                 </c:if>
                 <c:if test="${(s.modifyPayable and s.paying ne '1') || s.payStatus eq '2'}">
@@ -895,12 +900,22 @@
         });
 
         //付第三方
-        $('#applyShopOtherFee').on('click', function () {
-            var checked = $('.pay-wrapper input[type=checkbox]:checked');
-            if (checked.length < 1) {
-                alertx('请选择一个子订单');
+
+        $('#applypayWay').on('click', function () {
+
+            var shopReceiptStatus=$('#shopReceiptStatus').val();
+            var payWay=$('#payWay').val();
+            console.log(payWay)
+            debugger
+            console.log(shopReceiptStatus)
+
+             if (payWay == 1 && shopReceiptStatus==2) {
+                alertx('线上支付的子订单不能直接修改成本!');
                 return false;
-            }
+             }
+            });
+
+            $('#applyShopOtherFee').on('click', function () {
             if (checked.length > 1) {
                 alertx('每次只能选择一个子订单进行付第三方申请');
                 return false;

+ 834 - 0
src/main/webapp/WEB-INF/views/modules/order/cmSettlementForm.jsp

@@ -0,0 +1,834 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>付款单表管理</title>
+    <meta name="decorator" content="default"/>
+    <style>
+        .red {
+            color: red;
+            font-style: normal;
+        }
+
+        .nowrap {
+            white-space: nowrap;
+        }
+
+        .table th {
+            text-align: center
+        }
+
+        .table td {
+            text-align: center
+        }
+
+        .payment-form h4 {
+            width: 96%;
+            margin-left: 2%;
+            padding-bottom: 20px;
+            text-align: center;
+            border-bottom: 1px solid #eee
+        }
+
+        .required {
+            color: red
+        }
+
+        .payment-form label {
+            width: 100px;
+            text-align: right;
+            vertical-align: middle;
+            font-weight: 600
+        }
+
+        .payment-form-top {
+            padding: 10px 0
+        }
+
+        .payment-form-top > div, .payment-form-bottom > div {
+            width: 94%;
+            margin-left: 3%;
+            height: 50px;
+            line-height: 50px;
+            border-bottom: 1px solid #eee;
+            white-space: nowrap
+        }
+
+        .payment-form-top input {
+            vertical-align: baseline
+        }
+
+        .payment-form-top > div:last-child span {
+            margin-left: 15px
+        }
+
+        .payment-form-top > div:last-child span:nth-of-type(1) {
+            margin-left: 0
+        }
+
+        .pay-list-item {
+            margin-bottom: 30px
+        }
+
+        .pay-table {
+            width: 96%;
+            margin-left: 2%;
+            margin-bottom: 10px
+        }
+
+        .pay-table th {
+            background: #f9f9f9
+        }
+
+        .pay-table tr:first-child th {
+            background: #eee !important
+        }
+
+        .pay-table td {
+            background: #fff !important
+        }
+
+        .need-to-pay {
+            width: 90px
+        }
+
+        .payment-form-bottom label {
+            width: 140px
+        }
+
+        .used-amount {
+            width: 80px;
+            margin-top: 6px
+        }
+
+        .process-details span {
+            width: 140px;
+            margin-left: 50px;
+            font-weight: 600
+        }
+
+        .process-for-label {
+            margin-left: 0 !important
+        }
+
+        .process-details div {
+            display: inline-block
+        }
+
+        .payment-btn {
+            width: 96%;
+            margin-left: 2%;
+            text-align: center;
+            height: 60px;
+            line-height: 60px;
+            margin-top: 30px
+        }
+
+        .payment-btn button {
+            width: 100px;
+            height: 35px;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            border: none;
+            border: 1px solid #ddd
+        }
+
+        .apply-btn {
+            background: #3daae9;
+            color: #fff
+        }
+
+        .cfm-btn:active, .return-btn:active {
+            background: #ddd;
+            color: #fff
+        }
+
+        .mask {
+            width: 100%;
+            height: 100%;
+            position: fixed;
+            top: 0;
+            background: rgba(0, 0, 0, 0.7);
+            display: none
+        }
+
+        .tips-popup-content {
+            width: 40%;
+            height: auto;
+            padding-bottom: 30px;
+            background: #fff;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            position: absolute;
+            top: 50%;
+            left: 50%;
+            transform: translate(-50%, -50%)
+        }
+
+        .tips-popup-content div {
+            width: 100%;
+            text-align: center
+        }
+
+        .tips-popup-content {
+            width: 30%
+        }
+
+        .tips-popup-content p {
+            text-align: center;
+            padding: 80px;
+            font-size: 20px
+        }
+
+        .tips-popup-content h4 {
+            padding-left: 10px;
+            height: 40px;
+            line-height: 40px;
+            border-bottom: 1px solid #eee;
+            margin-bottom: 20px
+        }
+
+        .tips-cfm-btn, .tips-cancel-btn {
+            width: 100px;
+            height: 40px;
+            margin: auto;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            background: #3daae9;
+            color: #fff;
+            border: none
+        }
+
+        .return-btn, .tips-cancel-btn {
+            background: #fff;
+            color: #555;
+            margin-left: 50px
+        }
+
+        .tips-cancel-btn {
+            border: 1px solid #ddd;
+            margin-left: 20px;
+            display: none
+        }
+
+        #close-btn1 {
+            top: 8px;
+            right: 10px;
+            width: 18px;
+            position: absolute;
+            cursor: pointer
+        }
+
+        td.supplier-fee {
+            text-align: left;
+        }
+
+        td.supplier-fee .wipeBtn {
+            width: auto;
+            white-space: nowrap;
+            height: 30px;
+            line-height: 30px;
+            display: none;
+        }
+
+        .inputForm { /*max-width:1200px;*/
+            width: 100%;
+        }
+
+        .inputForm table {
+            width: 100%;
+            line-height: 18px;
+            margin-bottom: 50px;
+        }
+
+        .inputForm th, .inputForm td {
+            font-weight: normal;
+            text-align: left;
+            padding: 8px 5px;
+            border-bottom: 1px solid rgb(238, 238, 238);
+        }
+
+        .inputForm th {
+            width: 15%;
+            text-align: right;
+            white-space: nowrap;
+            font-weight: bold;
+        }
+
+        .inputForm td input[type="text"] {
+            width: 320px;
+            height: 16px;
+            line-height: 16px;
+        }
+
+        .inputForm td input.short {
+            width: 110px;
+        }
+
+        .inputForm td b.line {
+            margin: 0 15px 0 20px;
+            font-weight: normal
+        }
+
+        .wipeVisible {
+            display: none;
+        }
+
+        .wipeRemarks {
+            margin: 0;
+        }
+
+        .controls {
+            font-size: 0
+        }
+
+        .select2-choice {
+            width: 100px
+        }
+
+        .upload-content {
+            position: relative;
+        }
+
+        .upload-content * {
+            margin: 0;
+            padding: 0;
+        }
+
+        .upload-content .conList {
+            display: inline-block;
+            margin-right: 5px;
+            width: 90px;
+            height: 90px;
+            background: #e6e6e6;
+            border-radius: 5px;
+            position: relative;
+            overflow: hidden
+        }
+
+        .upload-content .conList li {
+            position: relative;
+            padding: 18px 0
+        }
+
+        .upload-content .conList li img {
+            width: 100%;
+            margin: 0 !important;
+            padding: 0 !important
+        }
+
+        .upload-content img.cancel-upload {
+            position: absolute;
+            top: 0;
+            right: 0;
+            cursor: pointer;
+            z-index: 100
+        }
+
+        .upload-content .conList .btn {
+            position: absolute;
+            width: 100%;
+            height: 100%;
+            top: 0;
+            left: 0;
+            background: #e6e6e6
+        }
+
+        .upload-content .conList .btn div {
+            padding-top: 20px
+        }
+
+        .upload-content .conList .btn div span {
+            font-size: 35px
+        }
+
+        .hide-pic {
+            display: none !important
+        }
+
+        .upload-tips {
+            margin: 10px 0
+        }
+
+        .mask {
+            z-index: 9999;
+        }
+
+        .weishaIcon {
+            background: darkorange;
+            color: white;
+            margin: 0 0px;
+            padding: 0 3px;
+            font-style: normal;
+            font-size: 12px;
+            display: inline-block;
+            border-radius: 2px
+        }
+
+        .clubFreight {
+            display: none
+        }
+
+        .discountFee {
+            display: none
+        }
+    </style>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
+    <li class="active"><a>申请结算</a></li>
+</ul>
+<br/>
+<form action="${ctx}/order/cmPayShop/apply" id="form" method="post">
+    <div class="payment-form">
+        <h4>付款单</h4>
+        <div class="payment-form-content">
+            <c:forEach items="${cmPayShop.shopOrders}" var="s">
+                <table class="table table-striped table-bordered table-condensed pay-table">
+                    <tr>
+                        <th>订单编号(ID)</th>
+                        <th colspan="3">客户</th>
+                        <th colspan="2">下单时间</th>
+                        <th>订单金额</th>
+                        <th colspan="3">所有子订单</th>
+                        <th>订单总佣金</th>
+                        <th>机构运费</th>
+                        <th>收款状态</th>
+                        <th colspan="3">收款金额</th>
+                        <th>经理折扣</th>
+                        <th>优惠券</th>
+                    <tr/>
+                    <tr>
+                        <td> ${s.orderNo}(${s.orderID})</td>
+                        <td colspan="3"> ${s.buyer}</td>
+                        <td colspan="2"> ${s.orderTime}</td>
+                        <td>${s.payTotalFee}</td>
+                        <td colspan="3">
+                            <c:forEach items="${s.shopOrderNos}" var="cs">
+                                ${cs}<br/>
+                            </c:forEach>
+                        </td>
+                        <td>${s.income}</td>
+                        <td>
+                            <label class="clubFreight" style="display: none">
+                                <c:choose>
+                                    <c:when test="${s.freight != -1 && s.freight != 0 && s.freight != -2 && s.returnedFreightFlag ne true}">
+                                        <fmt:formatNumber value="${s.freight}"/>
+                                    </c:when>
+                                    <c:otherwise>
+                                        <fmt:formatNumber value="0"/>
+                                    </c:otherwise>
+                                </c:choose>
+                            </label>
+                            <c:if test="${s.freight == 0}">
+                                包邮
+                            </c:if>
+                            <c:if test="${s.freight == -1}">
+                                到付
+                            </c:if>
+                            <c:if test="${s.freight == -2}">
+                                仪器到付-产品包邮
+                            </c:if>
+                            <c:if test="${s.freight != -1 && s.freight != 0 && s.freight != -2}">
+                                <fmt:formatNumber value="${s.freight}" type="currency"/>
+                                <c:if test="${s.returnedFreightFlag eq true}"><font color="red">(已退)</font></c:if>
+                            </c:if>
+                            <c:if test="${s.userBeans gt 0}">
+                                (采美豆抵用${s.userBeans})
+                            </c:if>
+                        </td>
+                        <td>
+                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
+                               style="text-decoration: underline">
+                                <c:if test="${s.receiptStatus == 1}"><font color="red">待收款</font></c:if>
+                                <c:if test="${s.receiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                                <c:if test="${s.receiptStatus == 3}"><font color="green">已收款</font></c:if></a>
+                        </td>
+                        <td colspan="3">
+                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
+                               style="text-decoration: underline">${s.receiptTotalFee}</a>
+                        </td>
+                        <td>
+                            <label class="discountFee">
+                                <c:choose>
+                                    <c:when test="${s.discountTotalFee gt 0 && s.discountTotalFee gt s.returnedPurchaseTotalFee}">
+                                        <fmt:formatNumber value="${s.discountTotalFee - s.returnedPurchaseTotalFee}"/>
+                                    </c:when>
+                                    <c:otherwise>
+                                        0
+                                    </c:otherwise>
+                                </c:choose>
+                            </label>
+                            <c:if test="${s.discountTotalFee gt 0}">
+                                <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
+                                    <fmt:formatNumber value="${s.discountTotalFee - s.returnedPurchaseTotalFee}"
+                                                      type="currency"/>
+                                </c:if>
+                                <c:if test="${s.discountTotalFee le s.returnedPurchaseTotalFee}">
+                                    ¥0.00
+                                </c:if>
+                                <c:if test="${s.returnedPurchaseTotalFee gt 0}">
+                                <span style="color: red">
+                                    (原<fmt:formatNumber value="${s.discountTotalFee}" type="currency"/>,因退货折扣取消
+                                    <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
+                                        <fmt:formatNumber value="${s.returnedPurchaseTotalFee}" type="currency"/>
+                                    </c:if>
+                                    <c:if test="${s.discountTotalFee le s.returnedPurchaseTotalFee}">
+                                        <fmt:formatNumber value="${s.discountTotalFee}" type="currency"/>
+                                    </c:if>)
+                                </span>
+                                </c:if>
+                            </c:if>
+                            <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
+                        </td>
+                        <td class="couponAmount">${s.couponAmount} </td>
+                        <td class="eachDiscount" style="display: none">${s.eachDiscount}</td>
+                    <tr/>
+                    <tr>
+                        <th>子订单编号(ID)</th>
+                        <th colspan="3"> 供应商</th>
+                        <th colspan="3">子订单佣金</th>
+                        <th colspan="3">商品费</th>
+                        <th>应付税费</th>
+                        <th>供应商运费</th>
+                        <th>结算状态</th>
+                        <th colspan="3">付供应商</th>
+                        <th>付第三方</th>
+                        <th>成本类型</th>
+                    </tr>
+                    <tr>
+                        <td>${s.shopOrderNo}(${s.shopOrderID})<input type="hidden" id="shopOrderId-hidden" name="shopOrderId"
+                                                                     value="${s.shopOrderID}"></td>
+                        <td colspan="3">${s.shopName}</td>
+                        <td colspan="3" class="payCm-t"></td>
+                            <%-- 子订单佣金=商品总佣金+机构运费-付第三方-供应商运费-分摊优惠--%>
+                        <td colspan="3" class="product-fee">${s.shopProductAmount}</td>
+
+                        <td class="taxes">
+                            <fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/>
+                        </td>
+
+                        <td class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
+                                                              pattern="#,##0.00"/></td>
+
+                        <td>
+                            <c:if test="${s.settleStatus == 1}"><font
+                                    color="red">待结算</font></c:if>
+                            <c:if test="${s.settleStatus == 2}"><font color="#ff8c00">部分结算</font></c:if>
+                            <c:if test="${s.settleStatus == 3 || empty s.settleStatus}"><font color="green">已结算</font></c:if>
+                        </td>
+
+                        <td colspan="3" class="supplier-fee">
+                            <div><span class="nowrap">
+                            <c:if test="${s.differenceType ne 1 && s.differenceType ne 2}">
+                                应付:<fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/>
+                            </c:if>
+							<c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
+                                <font color="black">${s.shouldPayShopAmount+s.differencePrice}</font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                            </c:if>
+							<c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
+                                <font color="black">${s.shouldPayShopAmount-s.differencePrice}</font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            </c:if>
+							,</span>
+                                <span class="nowrap">已付:${s.payedShopAmount},</span></div>
+                            <div><span class="nowrap">待付:<input type="number"
+                                                                value="<fmt:formatNumber value="${s.waitPayShop}" pattern="0.00"/>"
+                                                                class="need-to-pay" data-type="${s.differenceType}"
+                                                                data-difference="${s.differencePrice}"
+                                                                data-pay="${s.shouldPayShopAmount}"
+                                                                data-payed="${s.payedShopAmount}"></span></div>
+                            <input type="hidden" name="payInfo" class="payInfo" data-shoporderid="${s.shopOrderID}"
+                                   value="${s.shopOrderID}_${s.waitPayShop}_0">
+                        </td>
+
+                        <td class="third-party-fee">${s.shopOtherFee}</td>
+
+                        <td>
+                            <c:if test="${empty s.costType || s.costType == '1'}">固定成本</c:if>
+                            <c:if test="${s.costType == '2'}">比例成本</c:if>
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>商品名</th>
+                        <th>规格</th>
+                        <th>数量<%--(赠品)--%></th>
+                        <th>退货</th>
+                        <th colspan="3">单价</th>
+                        <th colspan="3">机构税率 / 单税费 / 总税费</th>
+                        <th>总价</th>
+                        <th>佣金(单)</th>
+                        <th>佣金(总)</th>
+                        <th colspan="3">供应商税率 / 单税费 / 总税费</th>
+                        <th>成本(单)</th>
+                        <th>成本(总)</th>
+                    </tr>
+                    <c:forEach items="${s.newOrderProducts}" var="p" varStatus="pIndex">
+                        <tr class="pay-product-item">
+                            <input type="hidden" class="p-copId" value="${p.orderProductID}">
+                            <td style="width:300px;" class="p-name">
+                                <c:if test="${p.productType eq 1}"><font color="red">协商赠品:</font></c:if>
+                                <c:if test="${p.productType eq 2}"><font color="red">促销赠品:</font></c:if>
+                                    ${p.name}
+                            </td>
+                            <td style="width:80px;">${p.unit}</td>
+                            <td class="p-num" data-num="${p.num + p.presentNum}">
+                                    ${p.num}
+                                <c:if test="${p.presentNum > 0}">(赠:${p.presentNum})</c:if>
+                            </td>
+                            <td><font color="${p.returnedNum>0?'red':''}">${p.returnedNum}</font></td>
+                            <td colspan="3"><fmt:formatNumber value="${empty p.touchPrice?p.discountPrice:p.touchPrice}"
+                                                              type="number" pattern="#,##0.00"/>
+                                <c:if test="${p.includedTax != null and p.includedTax != '' and p.includedTax ne 2}">
+                                    <label style="color: red">
+                                        (${p.includedTax eq 1?'含税':(p.invoiceType eq 1 or p.invoiceType eq 2)?'不含税-能开票':'不含税-不能开票'})
+                                    </label>
+                                </c:if>
+                            </td>
+                            <td>${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'---':empty p.taxRate?0.0:p.taxRate}${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'':'%'}</td>
+                            <td>${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))?'---': empty p.addedValueTax ?0.00:p.addedValueTax}</td>
+                            <td><c:choose>
+                                <c:when test="${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))}">
+                                    ---
+                                </c:when>
+                                <c:otherwise>
+                                    <fmt:formatNumber
+                                            value="${empty p.totalAddedValueTax ?0.00:(p.addedValueTax * (p.num+p.presentNum-p.returnedNum))}"
+                                            type="number" pattern="#,##0.00"/>
+                                </c:otherwise>
+                            </c:choose></td>
+                            <td><fmt:formatNumber
+                                    value="${((empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax)*(p.num+p.presentNum-p.returnedNum)}"
+                                    type="number" pattern="#,##0.00"/></td>
+                            <td><fmt:formatNumber
+                                    value="${(empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax - p.costPrice - p.singleShouldPayTotalTax}"
+                                    pattern="#,##0.00"/></td>
+
+                            <td class="payCm"><fmt:formatNumber
+                                    value="${((empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax - p.costPrice - p.singleShouldPayTotalTax) * (p.num + p.presentNum - p.returnedNum)}"
+                                    pattern="#,##0.00"/></td>
+
+                            <td class="p-taxes">${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'---':empty p.supplierTaxRate?0.0:p.supplierTaxRate}${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'':'%'}</td>
+                            <td class="p-taxes">${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))?'---': empty p.singleShouldPayTotalTax ?0.00:p.singleShouldPayTotalTax}</td>
+                            <td class="p-taxes-t"><c:choose>
+                                <c:when test="${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))}">
+                                    ---
+                                </c:when>
+                                <c:otherwise>
+                                    <fmt:formatNumber
+                                            value="${empty p.shouldPayTotalTax ?0.00:(p.singleShouldPayTotalTax * (p.num+p.presentNum-p.returnedNum))}"
+                                            type="number" pattern="#,##0.00"/>
+                                </c:otherwise>
+                            </c:choose></td>
+                            <td class="p-costprice"><fmt:formatNumber value="${p.costPrice}" type="number"
+                                                                      pattern="#,##0.00"/></td>
+                            <td><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}"
+                                                  type="number" pattern="#,##0.00"/></td>
+                        </tr>
+                    </c:forEach>
+                </table>
+            </c:forEach>
+        </div>
+        <div class="inputForm">
+            <table border="0" cellspacing="0" cellpadding="0" width="100%">
+                <tr>
+                    <th><span
+                            style="font-weight:bold;font-size:18px">${cmPayShop.paymentType eq 2 ? "结算供应商总金额":"结算供应商总金额"}:</span>
+                    </th>
+                    <td colspan="3">
+                        <span id="totalAmount" style="font-weight: bold;font-size:18px"><fmt:formatNumber
+                                value="${cmPayShop.totalAmount}" pattern="#,##0.00"/></span>
+                        <input type="hidden" id="totalAmount-hidden" name="totalAmount"
+                               value="${cmPayShop.totalAmount}">
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan="4" style="text-align:center;">
+                        <button class="apply-btn btn btn-primary" type="button">确定</button>
+                        <button class="return-btn btn" type="button" onclick="history.go(-1)">返回</button>
+                    </td>
+                </tr>
+            </table>
+        </div>
+    </div>
+</form>
+<script>
+    (function () {
+        var payTableEle = $('.pay-table'),
+            listenClickNumStatus = true,
+            payProductEle = $('.pay-product-item');
+        payTableEle.each(function (i, l) {
+            var productLength = $(this).find('.pay-product-item').length;
+            // 商品列表合并单元格
+            /*$(this).find('.mergeRows').attr('rowspan',productLength);*/
+        });
+        $(window).on("load", function () {
+            $('.need-to-pay').each(function (index, ele) {
+                var thisEle = $(this),
+                    wrapper = thisEle.parents(".supplier-fee"),
+                    shouldPay = thisEle.attr('data-pay') * 1,
+                    differencePrice = thisEle.attr('data-difference') * 1,
+                    differenceType = thisEle.attr('data-type'),
+                    alreadyPaid = thisEle.attr('data-payed') * 1;
+                if (thisEle.val().length > 8) {
+                    thisEle.val(thisEle.val().slice(0, 8));
+                }
+                if (differenceType == 2) {
+                    differencePrice = -differencePrice;
+                }
+                if ((thisEle.val() > shouldPay - alreadyPaid + differencePrice) || thisEle.val() < 0) {
+                    thisEle.val((shouldPay - alreadyPaid + differencePrice).toFixed(2));
+                }
+                var wipe = parseFloat((shouldPay - alreadyPaid - thisEle.val() + differencePrice).toFixed(12));
+                if (wipe > 0) {
+                    wrapper.find('.wipeBtn').show();
+                } else {
+                    wrapper.find('.wipeBtn').hide();
+                    wrapper.find('.wipeFee').prop("checked", false);
+                }
+                wrapper.find('.wipeFee').val(wipe);
+                wrapper.find('.wipeText').text('¥' + wipe.toFixed(2));
+            });
+        });
+        $('.tips-cancel-btn, #close-btn1').on('click', function () {
+            $('.tips-popup').hide();
+        });
+        $('.tips-cfm-directly').on('click', function () {
+            if ($('.tips-cfm-btn').hasClass('tips-cfm-directly')) {
+                $('.tips-popup').hide();
+            } else {
+                if (listenClickNumStatus) {
+                    $('#form').submit();
+                    listenClickNumStatus = false;
+                }
+            }
+        })
+
+        function showTips(title, text) {
+            $('.tips-popup h4').text(title);
+            $('.tips-popup p').text(text);
+            $('.tips-popup').show();
+        }
+
+        $('body').on('keyup', '#wipeRemarks', function () {
+            $('#remarkLen').text($(this).val().length);
+        });
+        $('body').on('change', '.wipeBtn input', function () {
+            var wrapper = $(this).parents(".supplier-fee");
+            wrapper.find('.need-to-pay').trigger("input");
+            wrapper.find('.need-to-pay').trigger("propertychange");
+        });
+        //  待付<=应付-已付
+        $('body').on('input propertychange', '.need-to-pay', function () {
+            var thisEle = $(this),
+                wrapper = thisEle.parents(".supplier-fee"),
+                shouldPay = thisEle.attr('data-pay') * 1,
+                differencePrice = thisEle.attr('data-difference') * 1,
+                differenceType = thisEle.attr('data-type'),
+                alreadyPaid = thisEle.attr('data-payed') * 1;
+            if (thisEle.val().length > 8) {
+                thisEle.val(thisEle.val().slice(0, 8));
+            }
+            if (differenceType == 2) {
+                differencePrice = -differencePrice;
+            }
+            if ((thisEle.val() > shouldPay - alreadyPaid + differencePrice) || thisEle.val() < 0) {
+                thisEle.val((shouldPay - alreadyPaid + differencePrice).toFixed(2));
+            }
+            var wipe = parseFloat((shouldPay - alreadyPaid - thisEle.val() + differencePrice).toFixed(12));
+            if (wipe > 0) {
+                wrapper.find('.wipeBtn').show();
+            } else {
+                wrapper.find('.wipeBtn').hide();
+                wrapper.find('.wipeFee').prop("checked", false);
+            }
+            wrapper.find('.wipeFee').val(wipe);
+            wrapper.find('.wipeText').text('¥' + wipe.toFixed(2));
+            var totalAmount = 0, wipeTotalFee = 0;
+            $('.need-to-pay').each(function (index, ele) {
+                totalAmount += Number($(this).val());
+            });
+            $('.wipeFee:checked').each(function (index, ele) {
+                wipeTotalFee += Number($(this).val());
+            });
+            totalAmount = totalAmount.toFixed(2);
+            wipeTotalFee = wipeTotalFee.toFixed(2);
+            if (Number(wipeTotalFee) > 0) {
+                $('.wipeVisible').show();
+                $('#wipePayment').val(wipeTotalFee);
+                $('.wipeTotalFee').text('¥' + wipeTotalFee);
+            } else {
+                $('.wipeVisible').hide();
+                $('#wipePayment').val(0);
+                $('.wipeTotalFee').text('¥0.00');
+            }
+            $('#totalAmount').text(totalAmount);
+            $('#totalAmount-hidden').val(totalAmount);
+            $('#transferPayFee').text(totalAmount);
+            $('#transferPayFee-hidden').val(totalAmount);
+            $('#ableRebateAmount').text($('#ableRebateAmount-hidden').val());
+            $('#remainingBalance').text($('#ableRebateAmount-hidden').val());
+            $('.used-amount').val(0);
+            var payInfo = wrapper.find('.payInfo');
+            var checkedWipe = wrapper.find('.wipeFee:checked').length > 0 ? wrapper.find('.wipeFee:checked').val() : 0;
+            payInfo.val(payInfo.attr('data-shoporderid') + '_' + thisEle.val() + '_' + checkedWipe);
+        });
+
+//			使用余额<总余额
+        $('body').on('input propertychange', '.used-amount', function () {
+            var thisEle = $(this),
+                thisVal = Number(thisEle.val()),
+                //totalAmount = Number($('#totalAmount').text()),
+                totalAmount = ${cmPayShop.totalAmount},
+                rebateAmount = Number($('#rebateAmount-hidden').val()),
+                ableRebateAmount = Number($('#ableRebateAmount-hidden').val());
+
+            if ((thisVal > ableRebateAmount) || thisVal < 0 || thisVal > totalAmount) {
+                thisEle.val(0);
+                $('#transferPayFee').text(totalAmount);
+                $('#transferPayFee-hidden').val(totalAmount);
+                $('#ableRebateAmount').text($('#ableRebateAmount-hidden').val());
+                $('#remainingBalance').text(rebateAmount);
+            } else {
+                $('#transferPayFee').text((totalAmount - thisVal).toFixed(2));
+                $('#transferPayFee-hidden').val((totalAmount - thisVal).toFixed(2));
+                $('#ableRebateAmount').text((ableRebateAmount - thisVal).toFixed(2));
+                $('#remainingBalance').text((rebateAmount - thisVal).toFixed(2));
+            }
+        });
+
+        $('.pay-table').each(function () {
+            debugger
+            var thisEle = $(this),
+                totalComissionVal = 0,
+                resVal = '';
+            totalComissionEle = thisEle.find('.payCm'),//单个商品总佣金
+                comissionEle = thisEle.find('.payCm-t'),//子订单佣金
+                thirdPartyVal = thisEle.find('.third-party-fee').text().replace(',', ''),//付第三方
+                freightVal = thisEle.find('.freight').text().replace(',', ''),//供应商运费
+                clubFreight = Number(thisEle.find('.clubFreight').text().replace(',', '')),//机构运费
+                discountFee = Number(thisEle.find('.discountFee').text().replace(',', '')),//经理折扣
+                eachDiscount = Number(thisEle.find('.eachDiscount').text().replace(',', ''));//分摊优惠
+            totalComissionEle.each(function () {
+                totalComissionVal += Number($(this).text().replace(',', ''));
+            })
+            // 子订单佣金=单个商品总佣金+机构运费-付第三方-供应商运费-子订单分摊优惠
+            resVal = (totalComissionVal - thirdPartyVal - eachDiscount).toFixed(2);
+            comissionEle.text(resVal);
+        })
+
+        $('.apply-btn').on('click', function () {
+            var settleAmount = $('#totalAmount-hidden').val();
+            var shopOrderId = $('#shopOrderId-hidden').val();
+            console.log("settleAmount---------->"+settleAmount);
+            console.log("shopOrderId---------->"+shopOrderId);
+            window.location.href = '${ctx}/order/cmPayShop/settlement?settleAmount=' + settleAmount+'&shopOrderId='+ shopOrderId;
+        })
+
+    })();
+</script>
+</body>
+</html>

+ 1129 - 0
src/main/webapp/WEB-INF/views/modules/order/cmSettlementList.jsp

@@ -0,0 +1,1129 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>申请付款</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th {
+            text-align: center
+        }
+
+        .table td {
+            text-align: center
+        }
+
+        .pay-wrapper {
+            padding: 0 10px
+        }
+
+        .pay-list-item {
+            margin-bottom: 30px
+        }
+
+        .pay-table th {
+            background: #f9f9f9
+        }
+
+        .pay-table tr:first-child th {
+            background: #eee !important
+        }
+
+        .pay-table td {
+            background: #fff !important
+        }
+
+        input[type="checkbox"]::before {
+            content: '\a0';
+            display: inline-block;
+            vertical-align: .2em;
+            width: .8em;
+            height: .8em;
+            margin-right: .2em;
+            border-radius: .2em;
+            text-indent: .15em;
+            line-height: .65
+        }
+
+        .t-btn {
+            width: 100px;
+            height: 30px;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            background: #fff;
+            border: 1px solid #ddd;
+            margin-bottom: 10px
+        }
+
+        #select-all {
+            width: 70px;
+            height: 30px;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            background: #fff;
+            border: 1px solid #ddd;
+            margin-bottom: 10px
+        }
+
+        #select-all:active {
+            background: #3daae9;
+            color: #fff
+        }
+
+        .pay-more-func {
+            float: right;
+            color: #2fa4e7;
+            cursor: pointer
+        }
+
+        .pay-more-func span:first-child {
+            margin-right: 6px
+        }
+
+        .pay-more-func span:hover {
+            color: #7aa9c3
+        }
+
+        .mask {
+            width: 100%;
+            height: 100%;
+            position: fixed;
+            top: 0;
+            background: rgba(0, 0, 0, 0.7);
+            display: none
+        }
+
+        .revise-popup-content, .tips-popup-content {
+            width: 40%;
+            height: auto;
+            padding-bottom: 30px;
+            background: #fff;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            position: absolute;
+            top: 50%;
+            left: 50%;
+            transform: translate(-50%, -50%)
+        }
+
+        .revise-popup-content {
+            width: 450px;
+            height: 360px;
+            overflow-y: scroll;
+            padding: 0 15px 30px 15px
+        }
+
+        .tips-popup-content {
+            width: 30%
+        }
+
+        .tips-popup-content p {
+            text-align: center;
+            padding: 80px;
+            font-size: 20px
+        }
+
+        .revise-popup-content h4, .tips-popup-content h4 {
+            padding-left: 10px;
+            height: 40px;
+            line-height: 40px;
+            border-bottom: 1px solid #eee;
+            margin-bottom: 20px
+        }
+
+        .revise-popup-content div {
+            margin-top: 7px;
+            text-align: center
+        }
+
+        .revise-popup-content label {
+            width: 70px;
+            text-align: right;
+            vertical-align: text-bottom
+        }
+
+        .revise-popup-content button {
+            width: 80px;
+            height: 30px;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px
+        }
+
+        .revise-popup-content > div:nth-of-type(4) > span:first-child {
+            margin-left: -104px
+        }
+
+        .revise-popup-content > div:nth-of-type(4) > span:last-child {
+            margin-left: 30px
+        }
+
+        .revise-popup-content > div:nth-of-type(4) > span span {
+            margin-left: 10px
+        }
+
+        .revise-popup-content > div:last-child {
+            text-align: center;
+            margin-top: 20px
+        }
+
+        .revise-popup-content input {
+            width: 100px;
+            margin-bottom: 0px
+        }
+
+        .popup-cfm-btn, .tips-cfm-btn {
+            background: #3daae9;
+            color: #fff;
+            border: none
+        }
+
+        .tips-cfm-btn {
+            width: 100px;
+            height: 40px;
+            margin: auto;
+            display: block;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px
+        }
+
+        .popup-cancel-btn {
+            background: #fff;
+            color: #555;
+            border: 1px solid #ddd;
+            margin-left: 20px
+        }
+
+        .popup-tips {
+            color: red;
+            display: none
+        }
+
+        #close-btn, #close-btn1 {
+            top: 8px;
+            right: 10px;
+            width: 18px;
+            position: absolute;
+            cursor: pointer
+        }
+
+        .tips-input-wrapper {
+            width: 100px
+        }
+
+        .reset-btn {
+            background: #fff;
+            color: #555;
+            border: 1px solid #ddd;
+            margin-right: 20px
+        }
+
+        .pay-status {
+            height: 40px;
+            line-height: 40px;
+            display: block
+        }
+
+        .form-search label {
+            width: 80px;
+            text-align: left;
+            margin-top: 12px
+        }
+
+        .remark-textarea {
+            width: 95%;
+            height: 100px;
+            resize: none
+        }
+
+        .remark-title {
+            text-align: left !important
+        }
+
+        .remark-title span {
+            color: red
+        }
+
+        .ul-form {
+            white-space: nowrap;
+            margin-left: -10px !important
+        }
+
+        .ul-form label {
+            width: 90px;
+            text-align: left;
+            margin-top: 15px
+        }
+
+        .time-space-symbols {
+            width: 100px;
+            display: inline-block;
+            text-align: center
+        }
+
+        #btnSubmit {
+            width: 128px;
+            margin-left: 165px
+        }
+
+        .pay-status label {
+            margin-left: 0
+        }
+
+        .pay-status label:first-child {
+            margin-left: 10px
+        }
+
+        .weishaIcon {background:darkorange;color:white;margin:0 0px;padding:0 3px;font-style:normal;font-size: 12px; display:inline-block;border-radius:2px}
+
+    </style>
+    <script type="text/javascript">
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/order/cmPayShop">付款列表</a></li>
+    <li><a href="${ctx}/shopOrder/payOrderList?operatingMode=1">申请付款</a></li>
+    <li><a href="${ctx}/shopOrder/payOrderList?operatingMode=3">已付款子订单</a></li>
+    <shiro:hasPermission name="order:cmPayShop:split">
+        <li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
+    </shiro:hasPermission>
+    <li class="active tab-li"><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
+</ul>
+<form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newShopOrder"
+           action="${ctx}/shopOrder/settlement" method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>子订单ID:</label>
+        <form:input path="shopOrderID" htmlEscape="false" onkeyup="onlynum(this)" maxlength="8" class="input-medium"/>
+        <label>子订单编号:</label>
+        <form:input path="shopOrderNo" htmlEscape="false" maxlength="20" class="input-medium"/>
+        <label>订单ID:</label>
+        <form:input path="orderID" htmlEscape="false" onkeyup="onlynum(this)" maxlength="8" class="input-medium"/>
+        <label>订单编号:</label>
+        <form:input path="orderNo" htmlEscape="false" maxlength="20" class="input-medium"/><br>
+        <label>供应商:</label>
+        <form:input path="shopName" htmlEscape="false" maxlength="20" class="input-medium"/>
+        <label>机构:</label>
+        <form:input path="clubName" htmlEscape="false" maxlength="20" class="input-medium"/>
+        <label class="control-label">下单时间:</label>
+        <form:input path="startTime" type="text" maxlength="10" class="input-medium Wdate" value="${startTime}"
+                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowClear:false});"/>
+        <span class="time-space-symbols">至</span>
+        <form:input path="endTime" type="text" maxlength="10" class="input-medium Wdate" value="${endTime}"
+                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowClear:false});"/>
+        <div class="pay-status">
+            <form>
+                <label>结算状态:</label>
+                <label><input name="payStatus" type="checkbox" class="pay-other-status pay-checkbox" value="1"/>未结算
+                </label>
+                <label><input name="payStatus" type="checkbox" class="pay-other-status pay-checkbox" value="2"/>部分结算
+                </label>
+            </form>
+            <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        </div>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<div class="pay-wrapper">
+    <button id="apply" class="t-btn" style="color:white;background-color:#2F6FAB">申请结算</button>
+    <c:forEach items="${page.list}" var="s" varStatus="sIndex">
+        <div class="pay-list-item">
+            <table class="table table-striped table-bordered table-condensed pay-table">
+                <tr>
+                    <th style="width:20px;">
+                        <input type="checkbox" class="checkShop" data-shoporderid="${s.shopOrderID}" data-shopid="${s.shopID}" data-isPayShopOtherFee="${s.payShopOtherFee}" onclick="changeCheck()"/>
+                    </th>
+                    <th>子订单编号(ID)</th>
+                    <th colspan="3">订单编号(ID)</th>
+                    <th colspan="2">订单金额</th>
+                    <th colspan="3">下单时间</th>
+                    <th>收款状态</th>
+                    <th>收款金额</th>
+                    <th colspan="3">经理折扣</th>
+                    <th>优惠券</th>
+                    <th>成本类型</th>
+                </tr>
+                <tr>
+                    <td><a href="${ctx}/order/detail?id=${s.orderID}">${s.shopOrderNo}(${s.shopOrderID})</a></td>
+                    <td colspan="3"><a href="${ctx}/order/detail?id=${s.orderID}">${s.orderNo}(${s.orderID})</a></td>
+                    <td colspan="2"><fmt:formatNumber value="${s.payTotalFee}" type="number" pattern="#,##0.00"/></td>
+                    <td colspan="3">${s.orderTime}</td>
+                        <%--此处对应订单列表收款状态--%>
+                    <td><a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline">
+                        <c:if test="${s.receiptStatus == 1}"><font color="red">待收款</font></c:if>
+                        <c:if test="${s.receiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                        <c:if test="${s.receiptStatus == 3}"><font color="green">已收款</font></c:if></a>
+                    </td>
+                    <td><a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline">${s.receiptTotalFee}</a></td>
+                    <td colspan="3">
+                        <c:if test="${s.discountTotalFee gt 0}">
+                            <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
+                                <fmt:formatNumber value="${s.discountTotalFee - s.returnedPurchaseTotalFee}"
+                                                  type="currency"/>
+                            </c:if>
+                            <c:if test="${s.discountTotalFee le s.returnedPurchaseTotalFee}">
+                                ¥0.00
+                            </c:if>
+                            <c:if test="${s.returnedPurchaseTotalFee gt 0}">
+                                <span style="color: red">
+                                    (原<fmt:formatNumber value="${s.discountTotalFee}" type="currency"/>,因退货折扣取消
+                                    <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
+                                        <fmt:formatNumber value="${s.returnedPurchaseTotalFee}" type="currency"/>
+                                    </c:if>
+                                    <c:if test="${s.discountTotalFee le s.returnedPurchaseTotalFee}">
+                                        <fmt:formatNumber value="${s.discountTotalFee}" type="currency"/>
+                                    </c:if>)
+                                </span>
+                            </c:if>
+                        </c:if>
+                        <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
+                    </td>
+                    <td>
+                            ${s.couponAmount}
+                    </td>
+                    <td><c:if test="${empty s.costType || s.costType == '1'}">固定成本</c:if><c:if
+                            test="${s.costType == '2'}">比例成本</c:if></td>
+                </tr>
+                <tr>
+                    <th>供应商</th>
+                    <th colspan="3">机构</th>
+                    <th>机构运费</th>
+                    <th>供应商运费</th>
+                    <th colspan="3">商品费</th>
+                    <th colspan="2">结算状态</th>
+                    <th colspan="3">应付税费</th>
+                    <th>付供应商</th>
+                    <th>付第三方</th>
+                </tr>
+                <tr>
+                    <td>${s.shopName}</td>
+                    <td colspan="3">
+                        <c:if test="${s.organizeID eq 1}"><span class="org-note">星范</span></c:if>
+                            ${s.clubName}
+                        <c:if test="${s.orderType eq 2}"><font color="red">(呵呵商城)</font></c:if>
+                        <c:if test="${s.organizeID == 3}"></c:if>
+                    </td>
+                    <td>
+                        <c:if test="${s.freight == 0}">
+                            包邮
+                        </c:if>
+                        <c:if test="${s.freight == -1}">
+                            到付
+                        </c:if>
+                        <c:if test="${s.freight == -2}">
+                            仪器到付-产品包邮
+                        </c:if>
+                        <c:if test="${s.freight != -1 && s.freight != 0 && s.freight != -2}">
+                            <fmt:formatNumber value="${s.freight}" type="currency"/>
+                            <c:if test="${s.returnedFreightFlag eq true}"><font color="red">(已退)</font></c:if>
+                        </c:if>
+                        <c:if test="${s.userBeans > 0}">
+                            <br><font color="red">(采美豆抵用:${s.userBeans})</font>
+                        </c:if>
+                    </td>
+                    <td class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
+                                                          pattern="#,##0.00"/></td>
+                    <td colspan="3" class="product-fee"><fmt:formatNumber value="${s.shopProductAmount}" type="number"
+                                                                          pattern="#,##0.00"/></td>
+                    <td colspan="2"><c:if test="${s.settleStatus == 1}"><font
+                            color="red">待结算</font></c:if>
+                        <c:if test="${s.settleStatus == 2}"><font color="#ff8c00">部分结算</font></c:if>
+                        <c:if test="${s.settleStatus == 3 || empty s.settleStatus}"><font color="green">已结算</font></c:if></td>
+                    <td colspan="3" class="taxes"><fmt:formatNumber value="${s.shopTaxFee}" type="number"
+                                                                    pattern="#,##0.00"/></td>
+                    <td class="supplier-fee">
+                        <c:if test="${s.differenceType ne 1 && s.differenceType ne 2 }">
+                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></font>
+                        </c:if>
+                        <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
+                            <font color="black">${s.shouldPayShopAmount+s.differencePrice}</font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                        </c:if>
+                        <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
+                            <font color="black">${s.shouldPayShopAmount-s.differencePrice}</font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                        </c:if>
+                    </td>
+                    <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">
+                    <input type="hidden" class="productAmount" value="${s.productAmount}">
+                    <input type="hidden" class="costType" value="${s.costType}">
+                    <input type="hidden" class="proportional" value="${s.proportional}">
+                    <input type="hidden" class="modifyShouldPayNote" value="${s.modifyShouldPayNote}">
+                    <td class="third-party-fee"><fmt:formatNumber value="${s.shopOtherFee}" type="number"
+                                                                  pattern="#,##0.00"/></td>
+                </tr>
+                <tr>
+                    <th>商品名</th>
+                    <th>规格</th>
+                    <th>数量<%--(赠品)--%></th>
+                    <th>退货</th>
+                    <th colspan="2">单价</th>
+                    <th colspan="3">机构税率 / 单税费 / 总税费</th>
+                    <th colspan="2">总价</th>
+                    <th colspan="3">供应商税率 / 单税费 / 总税费</th>
+                    <th>成本(单)</th>
+                    <th>成本(总)</th>
+                </tr>
+                <c:forEach items="${s.newOrderProducts}" var="p" varStatus="pIndex">
+                    <tr class="pay-product-item">
+                        <input type="hidden" class="p-copId" value="${p.orderProductID}">
+                        <td style="width:300px;" class="p-name">
+                            <c:if test="${p.productType eq 1}"><font color="red">协商赠品:</font></c:if>
+                            <c:if test="${p.productType eq 2}"><font color="red">促销赠品:</font></c:if>
+                                ${p.name}
+                        </td>
+                        <td style="width:80px;">${p.unit}</td>
+                        <td class="p-num" data-num="${p.num + p.presentNum}">
+                                ${p.num}
+                            <c:if test="${p.presentNum > 0}">(赠:${p.presentNum})</c:if>
+                        </td>
+                        <td><font color="${p.returnedNum>0?'red':''}">${p.returnedNum}</font></td>
+                        <td colspan="2"><fmt:formatNumber value="${empty p.touchPrice?p.discountPrice:p.touchPrice}"
+                                                          type="number" pattern="#,##0.00"/>
+                            <c:if test="${p.includedTax != null and p.includedTax != '' and p.includedTax ne 2}">
+                                <label style="color: red">
+                                    (${p.includedTax eq 1?'含税':(p.invoiceType eq 1 or p.invoiceType eq 2)?'不含税-能开票':'不含税-不能开票'})
+                                </label>
+                            </c:if>
+                        </td>
+                        <td>${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'---':empty p.taxRate?0.0:p.taxRate}${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'':'%'}</td>
+                        <td>${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))?'---': empty p.addedValueTax ?0.00:p.addedValueTax}</td>
+                        <td>
+                            <c:choose>
+                                <c:when test="${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))}">
+                                    ---
+                                </c:when>
+                                <c:otherwise>
+                                    <fmt:formatNumber
+                                            value="${empty p.totalAddedValueTax ?0.00:(p.addedValueTax * (p.num+p.presentNum-p.returnedNum))}"
+                                            type="number" pattern="#,##0.00"/>
+                                </c:otherwise>
+                            </c:choose>
+                        </td>
+                        <td colspan="2"><fmt:formatNumber
+                                value="${((empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax)*(p.num+p.presentNum-p.returnedNum)}"
+                                type="number" pattern="#,##0.00"/></td>
+                        <td class="p-taxes">${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'---':empty p.supplierTaxRate?0.0:p.supplierTaxRate}${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'':'%'}</td>
+                        <td class="p-taxes">${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))?'---': empty p.singleShouldPayTotalTax ?0.00:p.singleShouldPayTotalTax}</td>
+                        <td class="p-taxes-t">
+                            <c:choose>
+                                <c:when test="${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))}">
+                                    ---
+                                </c:when>
+                                <c:otherwise>
+                                    <fmt:formatNumber
+                                            value="${empty p.shouldPayTotalTax ?0.00:(p.singleShouldPayTotalTax * (p.num+p.presentNum-p.returnedNum))}"
+                                            type="number" pattern="#,##0.00"/>
+                                </c:otherwise>
+                            </c:choose>
+                        </td>
+                        <td class="p-costprice"><fmt:formatNumber value="${p.costPrice}" type="number"
+                                                                  pattern="#,##0.00"/></td>
+                        <td><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}"
+                                              type="number" pattern="#,##0.00"/></td>
+                    </tr>
+                </c:forEach>
+            </table>
+            <div class="pay-more-func">
+                <a href="${ctx}/shopOrder/settleRecord?shopOrderID=${s.shopOrderID}">结算记录</a>
+            </div>
+        </div>
+    </c:forEach>
+</div>
+<div class="mask revise-popup">
+    <div class="revise-popup-content">
+        <h4>确认提示</h4>
+        <ul class="nav nav-tabs" id="myTab">
+            <li class="active" id="li-fixed-cost"><a class="revise-tab" href="#fixed-cost">固定成本修改</a></li>
+            <li id="li-proportional-cost"><a class="revise-tab" href="#proportional-cost">销售比例成本修改</a></li>
+        </ul>
+        <div class="tab-content">
+            <div class="tab-pane active revise-content" id="fixed-cost">
+                <table class="table table-striped table-bordered table-condensed pay-table div-table">
+                    <tr>
+                        <th>商品名</th>
+                        <th>成本(单)</th>
+                        <th>税费(单)</th>
+                    </tr>
+                </table>
+            </div>
+            <div class="tab-pane revise-content" id="proportional-cost">
+                <div>
+                    <div style="display: inline-block">
+                        <p>
+                            <span>子订单金额:<span id="div-productAmount"></span></span>
+                        </p>
+                    </div>
+                    <div style="display: inline-block">
+                        <p>
+                            <span>成本(总)占订单金额的<input type="number" id="proportional">%</span>
+                        </p>
+                    </div>
+                </div>
+            </div>
+            <div>
+                <div style="display: inline-block">
+                    <p>
+                        <span>运费:<input type="number" id="div-freight" onchange="inputnum(this)"></span>
+                    </p>
+                </div>
+                <div style="display: inline-block">
+                    <p>
+                        <span>付第三方:<input type="number" id="div-third-party-fee" onchange="inputnum(this)"></span>
+                    </p>
+                </div>
+            </div>
+            <div>
+                <div style="display: inline-block">
+                    <p>
+                        <span>付供应商:<span id="div-supplier-fee"></span></span>
+                    </p>
+                </div>
+                <div style="display: inline-block">
+                    <p>
+                        <span>已付供应商:<span id="div-payedShopAmount"></span></span>
+                    </p>
+                </div>
+                <div>
+                    <div class="remark-title"><span>* </span>备注:</div>
+                    <textarea name="modifyShouldPayNote" class="remark-textarea" maxlength="200"
+                              placeholder="建议填写修改前和修改后的金额对比" cols="100" rows="10"></textarea>
+                </div>
+            </div>
+        </div>
+        <div class="popup-tips">不能为空</div>
+        <div>
+            <button class="reset-btn">恢复默认值</button>
+            <button class="popup-cfm-btn">确定</button>
+            <button class="popup-cancel-btn">取消</button>
+        </div>
+        <img id="close-btn" src="/static/images/close-btn.png" alt="close-btn">
+    </div>
+</div>
+
+<div class="mask tips-popup">
+    <div class="tips-popup-content">
+        <h4>信息提示</h4>
+        <p></p>
+        <button class="tips-cfm-btn" onclick="$('.tips-popup').hide()">确定</button>
+        <img id="close-btn1" src="/static/images/close-btn.png" alt="close-btn">
+    </div>
+</div>
+<div class="pagination">${page}</div>
+
+<script>
+    function changeCheck(){
+        var checked = $('input[type=checkbox]:checked');
+        if (checked.length >= 1) {
+            // $(".checkShop").attr('disabled','true');
+            alertx("请最多选择一个子订单进行结算");
+            return false;
+        }
+    }
+    (function () {
+        var payTableEle = $('.pay-table'),
+            payProductEle = $('.pay-product-item');
+        payTableEle.each(function (i, l) {
+            var leftLength = $(this).find('tr').length,
+                productLength = $(this).find('.pay-product-item').length;
+            // 左侧栏合并单元格
+            $(this).find('tr:first-child th:first-child').attr('rowspan', leftLength);
+            // 商品列表合并单元格
+            /*$(this).find('.mergeRows').attr('rowspan',productLength);*/
+        });
+
+
+        var getCheckedArr = sessionStorage.getItem('checkedIndexArr'),
+            allCheckedEle = $('.pay-all-status');
+        if (getCheckedArr) {
+            getCheckedArr = JSON.parse(getCheckedArr);
+            if (getCheckedArr.length > 0) {
+                allCheckedEle.prop('checked', false);
+                $.each(getCheckedArr, function (index, value) {
+                    $('.pay-checkbox').eq(value).prop('checked', true);
+                })
+            } else {
+                allCheckedEle.prop('checked', true);
+            }
+        } else {
+            allCheckedEle.prop('checked', true);
+        }
+
+        $('.tab-li').on('click', function () {
+            if (getCheckedArr) {
+                sessionStorage.removeItem('checkedIndexArr');
+            }
+        })
+
+        // 点击全选
+        var selectAllBtn = $('#select-all'),
+            selectedInput = $('.pay-wrapper input[type=checkbox]');
+        selectAllBtn.on('click', function () {
+            if (selectedInput.length > 0) {
+                var shopid = '';
+                for (var i = 0; i < selectedInput.length; i++) {
+                    var id = $(selectedInput[i]).attr('data-shopid');
+                    if (shopid == '') {
+                        //第一个选中的 选择框
+                        shopid = id;
+                    } else {
+                        //后面的
+                        if (shopid != id) {
+                            alertx("应付多个订单时,它们必须属于同一个供应商");
+                            return false;
+                        }
+                    }
+                }
+                if ($(this).text() === '全选') {
+                    for (var i = 0; i < selectedInput.length; i++) {
+                        selectedInput[i].checked = true;
+                    }
+                    $(this).text('取消全选');
+                } else {
+                    for (var i = 0; i < selectedInput.length; i++) {
+                        selectedInput[i].checked = false;
+                    }
+                    $(this).text('全选');
+                }
+            }
+        });
+
+        function renderPopup(p, f, t, th, s, ps, plist) {
+            if (plist == '') {
+                $('.div-table tr:gt(0)').remove();
+                return;
+            }
+            var tsize = plist.size(),
+                str = '';
+            for (var i = 0; i < tsize; i++) {
+                var current = $(plist.get(i));
+                str += '<tr>' +
+                    '<td>' + current.find('.p-name').text() + '</td>' +
+                    '<td class="tips-input-wrapper">' +
+                    '<input type="number" onchange="inputnum(this)" data-num=' + current.find('.p-num').attr('data-num') + ' data-copid=' + current.find('.p-copId').attr('value') + ' data-ov=' + current.find('.p-costprice').text().replace(',', '') + ' value=' + current.find('.p-costprice').text().replace(',', '') + ' class="modify-product-costprice">' +
+                    '</td>' +
+                    '<td class="tips-input-wrapper">' +
+                    '<input type="number" onchange="inputnum(this)" data-num=' + current.find('.p-num').attr('data-num') + '  data-ov=' + current.find('.p-taxes').text().replace(',', '') + ' value=' + current.find('.p-taxes').text().replace(',', '') + ' class="modify-product-taxes">' +
+                    '</td>' +
+                    '</tr>';
+            }
+            $('.div-table').append(str);
+        }
+
+        function showTips1(content) {
+            var block = $('.popup-tips');
+            block.text(content);
+            block.show();
+        }
+
+        function btnToGrey() {
+            $('.popup-cfm-btn').css({'background': '#ddd', 'color': '#555'});
+            $('.popup-cfm-btn').attr('disabled', true);
+        }
+
+        function btnToNormal() {
+            $('.popup-cfm-btn').css({'background': '#3daae9', 'color': '#fff'});
+            $('.popup-cfm-btn').attr('disabled', false);
+        }
+
+        function renderSupplierFee() {
+            var productFee = Number($('#popup-product-fee').val()),
+                supplierPaidFee = Number($('#popup-sPaid-fee').text()),
+                freight = Number($('#popup-freight').val()),
+                taxes = Number($('#popup-taxes').val()),
+                totalFee = productFee + freight + taxes;
+            $('#popup-supplier-fee').text(totalFee);
+            if (totalFee < supplierPaidFee) {
+                showTips1('付供应商的金额不能小于已付款金额');
+                btnToGrey();
+            } else {
+                showTips1('');
+                $('.popup-tips').hide();
+                btnToNormal();
+            }
+        }
+
+        function showTips(text) {
+            $('.tips-popup p').text(text);
+            $('.tips-popup').show();
+        }
+
+        function toZero(thisEle) {
+            if (Number(thisEle.val()) < 0) {
+                thisEle.val(0);
+            }
+        }
+
+//			点击修改应付
+        $('body').on('click', '.revise-amount', function () {
+            var index = $(this).index(),
+                wrapper = $(this).closest('.pay-list-item'),
+                plist = wrapper.find('.pay-product-item'),
+                productFee = wrapper.find('.product-fee').text().replace(',', ''),
+                freight = wrapper.find('.freight').text().replace(',', ''),
+                taxes = wrapper.find('.taxes').text().replace(',', ''),
+                supplierFee = wrapper.find('.supplier-fee').text().replace(',', ''),
+                thirdPartyFee = wrapper.find('.third-party-fee').text().replace(',', ''),
+                payedShopAmount = wrapper.find('.payedShopAmount').val(),
+                productAmount = wrapper.find('.productAmount').val(),
+                costType = wrapper.find('.costType').val(),
+                modifyShouldPayNote = wrapper.find('.modifyShouldPayNote').val();
+            $('.revise-popup').attr('data-shoporderid', $(this).attr('data-shoporderid'));
+            $('.revise-popup').show();
+            $('#div-freight').attr('value', freight);
+            $('#div-freight').attr('data-ov', freight);
+            $('#div-third-party-fee').attr('value', thirdPartyFee);
+            $('#div-third-party-fee').attr('data-ov', thirdPartyFee);
+            $('#div-supplier-fee').text(Number(supplierFee).toFixed(2));
+            $('#div-supplier-fee').attr('data-ov', Number(supplierFee).toFixed(2));
+            $('#div-payedShopAmount').text(payedShopAmount);
+            $('#div-productAmount').text(productAmount);
+            $('.remark-textarea').val(modifyShouldPayNote);
+            $('#proportional').attr('value', wrapper.find('.proportional').attr('value'));
+            $('#proportional').attr('data-ov', wrapper.find('.proportional').attr('value'));
+            $('#myTab li:first').addClass('active').siblings().removeClass('active');
+            if (costType == '1') { //显示固定成本编辑
+                renderPopup(productFee, freight, taxes, thirdPartyFee, supplierFee, payedShopAmount, plist);
+                //隐藏比例成本
+                $('#proportional-cost').css('display', 'none');
+                $('#li-proportional-cost').css('display', 'none');
+                $('#fixed-cost').css('display', 'block');
+                $('#li-fixed-cost').css('display', 'block');
+                $('#li-fixed-cost').addClass('active');
+            } else if (costType == '2') { //显示比例成本编辑
+                //隐藏固定成本
+                $('#fixed-cost').css('display', 'none');
+                $('#li-fixed-cost').css('display', 'none');
+                $('#proportional-cost').css('display', 'block');
+                $('#li-proportional-cost').css('display', 'block');
+                $('#li-proportional-cost').addClass('active');
+            } else { //第一次设置两种编辑方式都显示
+                renderPopup(productFee, freight, taxes, thirdPartyFee, supplierFee, payedShopAmount, plist);
+                $('#proportional-cost').css('display', 'none');
+                $('#li-proportional-cost').css('display', 'block');
+                $('#fixed-cost').css('display', 'block');
+                $('#li-fixed-cost').css('display', 'block');
+                $('#li-fixed-cost').addClass('active');
+            }
+        });
+
+        $('#apply').on('click', function () {
+            var checked = $('.pay-wrapper input[type=checkbox]:checked'), params = '?';
+            for (var i = 0; i < checked.length; i++) {
+                var shoporderId = $(checked[i]).attr('data-shoporderid');
+                params += ('&shopOrderIDs=' + shoporderId);
+            }
+            if (checked.length < 1 || params == '?') {
+                alertx('请至少选择一个订单');
+                return false;
+            }
+            if (checked.length > 1) {
+                alertx('每次只能选择一个子订单进行结算申请');
+                return false;
+            }
+            window.location.href = '${ctx}/order/cmPayShop/settleEdit' + params;
+        });
+
+        //付第三方
+        $('#applyShopOtherFee').on('click', function () {
+            var checked = $('.pay-wrapper input[type=checkbox]:checked');
+            if (checked.length < 1) {
+                alertx('请选择一个子订单');
+                return false;
+            }
+            if (checked.length > 1) {
+                alertx('每次只能选择一个子订单进行付第三方申请');
+                return false;
+            }
+            var isPayShopOtherFee = $(checked[0]).attr('data-isPayShopOtherFee');
+            if ("false" == isPayShopOtherFee) {
+                alertx("付第三方处于待审核状态,暂不能操作");
+                return false;
+            }
+            var shopOrderId = $(checked[0]).attr('data-shoporderid');
+
+            window.location.href = '${ctx}/order/cmPayShop/shopOtherFeeForm?shopOrderId=' + shopOrderId;
+        });
+
+        $('#refund').on('click', function () {
+            var checked = $('.pay-wrapper input[type=checkbox]:checked'), params = '?';
+            for (var i = 0; i < checked.length; i++) {
+                params += ('&shopOrderIDs=' + $(checked[i]).attr('data-shoporderid'));
+            }
+            if (checked.length < 1 || params == '?') {
+                alertx('请至少选择一个订单');
+                return false;
+            }
+            window.location.href = '${ctx}/order/cmRefundShop/toRefund' + params;
+        });
+
+        //恢复默认值
+        $('.reset-btn').on('click', function () {
+            var elements = $('.modify-product-costprice,#div-freight,.modify-product-taxes,#div-third-party-fee,#proportional');
+            elements.each(function () {
+                $(this).attr('value', $(this).attr('data-ov'));
+            });
+            validAndAdd();
+        });
+
+        $('#close-btn, .popup-cancel-btn').on('click', function () {
+            $('.revise-popup').hide();
+            renderPopup('', '', '', '', '', '', '');
+        })
+
+        $("#popup-product-fee").on("input propertychange", function () {
+            toZero($(this));
+            renderSupplierFee();
+        })
+
+        $("#popup-freight").on("input propertychange", function () {
+            toZero($(this));
+            renderSupplierFee();
+        })
+
+        $("#popup-taxes").on("input propertychange", function () {
+            toZero($(this));
+            renderSupplierFee();
+        })
+
+        $("#popup-third-party").on("input propertychange", function () {
+            toZero($(this));
+            if (!$(this).text().trim()) {
+                showTips1('');
+                $('.popup-tips').hide();
+                btnToNormal();
+            }
+        });
+
+        $('#close-btn1').on('click', function () {
+            $('.tips-popup').hide();
+        });
+
+
+        $('.popup-cfm-btn').on('click', function () {
+            var freight = Number($('#div-freight').attr('value')), //运费
+                third_party_fee = Number($('#div-third-party-fee').attr('value')), //运费
+                shopOrderID = $(this).parents('.revise-popup').attr('data-shoporderid'),//子订单ID
+                params = '?shopOrderID=' + shopOrderID + '&freight=' + freight + '&thirdPartyFee=' + third_party_fee;
+            if ($('#fixed-cost').css('display') == 'block') { //固定成本显示
+                params += '&costType=1';
+                var tr_items = $('.div-table tr:gt(0)');
+                for (var i = 0; i < tr_items.size(); i++) {
+                    var item = $(tr_items.get(i)),
+                        param = item.find('.modify-product-costprice').attr('data-copid');
+                    param += ('_' + Number(item.find('.modify-product-costprice').val()));
+                    param += ('_' + Number(item.find('.modify-product-taxes').val()));
+                    params += ('&param=' + param);
+                }
+            }
+            if ($('#proportional-cost').css('display') == 'block') { //比例成本显示
+                params += '&costType=2';
+                params += '&proportional=' + $('#proportional').val();
+            }
+            var remark = $('.remark-textarea').val();
+            if (!remark) {
+                showTips('备注不能为空');
+                return false;
+            }
+            $.ajax({
+                url: "${ctx}/order/cmPayShop/modifyPayShopAmount" + params,
+                type: "POST",
+                data: {'modifyShouldPayNote': remark},
+                success: function (res) {
+                    if (res.success) {
+                        $('.revise-popup').hide();
+                        $('#searchForm').submit();
+                    } else {
+                        alertx(res.msg);
+                    }
+                }
+            });
+        });
+
+        $('body').on('input propertychange', '.modify-product-costprice', function () {
+            validAndAdd();
+        });
+        $('body').on('input propertychange', '#div-freight', function () {
+            validAndAdd();
+        });
+        $('body').on('input propertychange', '.modify-product-taxes', function () {
+            validAndAdd();
+        });
+        $('body').on('input propertychange', '#div-third-party-fee', function () {
+            validAndAdd();
+        });
+        $('body').on('input propertychange', '#proportional', function () {
+            validAndAdd();
+        });
+
+        function validAndAdd() {
+            //先还原按钮
+            showTips1('');
+            $('.popup-tips').hide();
+            btnToNormal();
+            var total = 0;
+            if ($('#fixed-cost').css('display') == 'block') { //固定成本显示
+                var elements = $('.modify-product-costprice,#div-freight,.modify-product-taxes,#div-third-party-fee');
+                elements.each(function () {
+                    var ele = $(this);
+                    if (ele.attr('value') == '') {
+                        showTips1('成本/运费/税费/付第三方不能为空');
+                        btnToGrey();
+                        return false;
+                    }
+                    if (Number(ele.attr('value')) < 0) {
+                        // ele.attr('value', 0.01);
+                        showTips1('金额不可以为负');
+                        btnToGrey();
+                        return false;
+                    }
+                    /*if (ele.hasClass('modify-product-costprice') && Number(ele.attr('value')) == 0) {
+                        showTips1('成本必须大于零');
+                        btnToGrey();
+                        return false;
+                    }*/
+                    if (ele.attr('id') != 'div-third-party-fee') {
+                        if (ele.hasClass('modify-product-costprice') || ele.hasClass('modify-product-taxes')) {
+                            total += (Number($(this).attr('value')) * Number($(this).attr('data-num')));
+                        } else {
+                            total += Number($(this).attr('value'));
+                        }
+                    }
+                });
+            }
+            if ($('#proportional-cost').css('display') == 'block') { //比例成本显示
+                var productAmount = Number($('#div-productAmount').text()),
+                    proportional = $('#proportional').attr('value'),
+                    freight = $('#div-freight').attr('value'),   //运费
+                    third_party_fee = $('#div-third-party-fee').attr('value');  //付第三方
+                if (proportional == '' || isNaN(Number(proportional))) {
+                    showTips1('请输入成本比例');
+                    btnToGrey();
+                    return false;
+                }
+                if (Number(proportional) <= 0) {
+                    showTips1('成本比例必须大于零');
+                    btnToGrey();
+                    return false;
+                }
+                if (freight == '' || isNaN(Number(freight))) {
+                    showTips1('请输入运费');
+                    btnToGrey();
+                    return false;
+                }
+                if (Number(freight) < 0) {
+                    showTips1('运费不能小于零');
+                    btnToGrey();
+                    return false;
+                }
+                if (third_party_fee == '' || isNaN(Number(third_party_fee))) {
+                    showTips1('请输入付第三方金额');
+                    btnToGrey();
+                    return false;
+                }
+                if (Number(third_party_fee) < 0) {
+                    showTips1('付第三方金额不能小于零');
+                    btnToGrey();
+                    return false;
+                }
+                total = (productAmount * Number(proportional) / 100) + Number(freight);
+            }
+            if (Number($('#div-payedShopAmount').text()) > total) {
+                //已付供应商 > 付供应商   不能够
+                showTips1('付供应商的金额不能小于已付款金额');
+                btnToGrey();
+                return false;
+            }
+            $('#div-supplier-fee').text(total.toFixed(2));
+        }
+
+        var shopid = '';
+        $('body').on('click', '.pay-wrapper input[type=checkbox]', function () {
+            var that = $(this),
+                sid = $(this).data('shopid'),
+                status = Boolean($(this).attr('checked'));
+            if (status) {
+                if (shopid != '' && shopid != sid) {
+                    that.get(0).checked = false;
+//						showTips('应付多个订单时,它们必须属于同一个供应商');
+                    alertx("应付多个订单时,它们必须属于同一个供应商")
+                } else {
+                    shopid = sid;
+                }
+            } else {
+                shopid = '';
+            }
+        });
+
+        // $('#myTab a:first').tab('show');
+        $('#myTab a').click(function (e) {
+            e.preventDefault();
+            var parentLi = $(this).closest('li'),
+                index = parentLi.index(),
+                reviseContentEle = $('.revise-content');
+            parentLi.addClass('active').siblings().removeClass('active');
+            reviseContentEle.eq(index).show().siblings('.revise-content').hide();
+            if ($('#li-fixed-cost,#li-proportional-cost').length == 2) {
+                validAndAdd();
+            }
+        })
+
+        $('.pay-all-status').on('click', function () {
+            var thisStatus = $(this).prop('checked');
+            if (thisStatus) {
+                $('.pay-other-status').prop('checked', false);
+            }
+        })
+
+        $('.pay-other-status').on('click', function () {
+            var thisStatus = $(this).prop('checked');
+            if (thisStatus) {
+                $('.pay-all-status').prop('checked', false);
+            }
+        })
+    })()
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+
+    function submitFunc() {
+        var checkedArr = [];
+        $('.pay-checkbox').each(function (index) {
+            var thisStatus = $(this).prop('checked');
+            if (thisStatus) {
+                checkedArr.push(index);
+            }
+        })
+        if (checkedArr.length > 0) {
+            sessionStorage.setItem('checkedIndexArr', JSON.stringify(checkedArr));
+        } else {
+            sessionStorage.setItem('checkedIndexArr', []);
+        }
+    }
+
+    function inputnum(obj, val) {
+        obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+        obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+        obj.value = obj.value.replace(/\.{2,}/g, ""); //只保留第一个, 清除多余的
+        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+    }
+</script>
+</body>
+</html>

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/order/cmSplitAccountList.jsp

@@ -298,6 +298,7 @@
      <shiro:hasPermission name="order:cmPayShop:split">
          <li class="active tab-li"><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
      </shiro:hasPermission>
+     <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
 </ul>
 <form:form id="searchForm"
            action="${ctx}/splitAccount/split" method="post" class="breadcrumb form-search">

+ 6 - 2
src/main/webapp/WEB-INF/views/modules/order/differencePriceForm.jsp

@@ -259,6 +259,7 @@
     <li class="active"><a href="${ctx}/order/cmPayShop/differencePriceForm?shopOrderId=${payShopDifference.shopOrderId}">供应商差价</a></li>
 </ul>
 <form:form id="inputForm" modelAttribute="payShopDifference" action="${ctx}/order/cmPayShop/saveDifferencePrice" method="post" class="form-horizontal">
+    <input type="hidden" id="ShopReceiptStatus" value="${payShopDifference.shopReceiptStatus}">
     <form:hidden path="shopOrderId"/>
     <br>
     <div class="control-group">
@@ -500,11 +501,14 @@
     }
 
     function showInfo() {
+        debugger
         var type = $("input[name='type']:checked").val();
+        var ShopReceiptStatus=$('#ShopReceiptStatus').val();
+        console.log(ShopReceiptStatus)
         if (type == 1){
             $("#refundShow").hide();
             $("#payShopShow").show();
-        } else {
+        } else if(ShopReceiptStatus!=2){
             $("#payShopShow").hide();
             var differencePrice = $("#differencePrice").val();
             var waitPayShop = ${payShopDifference.waitPayShop};
@@ -517,4 +521,4 @@
     }
 </script>
 </body>
-</html>
+</html>

+ 9 - 9
src/main/webapp/WEB-INF/views/modules/order/newOrderList.jsp

@@ -331,35 +331,35 @@
             </li>
             <li>
                 <c:if test="${order.payStatus == 1}">
-                    待付款
+                     <font color="red">待付款</font>
                 </c:if>
                 <c:if test="${order.payStatus == 2}">
-                    部分付款
+                     <font color="#ff8c00">部分付款</font>
                 </c:if>
                 <c:if test="${order.payStatus == 3}">
-                    已付款
+                    <font color="green">已付款</font>
                 </c:if>
             </li>
             <li>
                 <c:if test="${order.sendOutStatus == 1}">
-                    待发货
+                      <font color="red">待发货</font>
                 </c:if>
                 <c:if test="${order.sendOutStatus == 2}">
-                    部分发货
+                       <font color="#ff8c00">部分发货</font>
                 </c:if>
                 <c:if test="${order.sendOutStatus == 3}">
-                    已发货
+                     <font color="green">已发货</font>
                 </c:if>
             </li>
             <li>
                 <c:if test="${order.refundType == 1}">
-                    部分退款
+                      <font>部分退款</font>
                 </c:if>
                 <c:if test="${order.refundType == 2}">
-                    已退款
+                      <font>已退款</font>
                 </c:if>
                 <c:if test="${order.refundType ne 1 and order.refundType ne 2 }">
-                    无退款
+                     <font>无退款</font>
                 </c:if>
             </li>
             <li>

+ 48 - 20
src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp

@@ -491,13 +491,13 @@
             <td>
                 退款状态:
                 <c:if test="${order.refundType == 0}">
-                    无退款
+                     <font>无退款</font>
                 </c:if>
                 <c:if test="${order.refundType == 1}">
-                    部分退款
+                     <font>部分退款</font>
                 </c:if>
                 <c:if test="${order.refundType == 2}">
-                    已退款
+                    <font>已退款</font>
                 </c:if>
             </td>
         </c:if>
@@ -664,25 +664,28 @@
                     </c:if>
                 </shiro:hasPermission>
                 <shiro:hasPermission name="order:order:applyrefound">
-                    <c:if test="${order.status == 12 || order.status == 13 || order.status == 21 || order.status == 22 || order.status == 23 || order.status == 31 || order.status == 32 || order.status == 33 || order.status == 4 || order.status == 5}">
-                        <%--  返佣订单不能申请退款(退货) --%>
-                        <c:if test="${order.rebateOrder == '0'}">
-                            <c:if test="${order.toAudit eq 1}">
-                                <%--如果存在审核收款则不允许申请:1不能申请,其它可以申请--%>
+                    <%--线下订单以主订单为单位退款--%>
+                    <c:if test="${order.onlinePayFlag == 1}">
+                        <c:if test="${order.status == 12 || order.status == 13 || order.status == 21 || order.status == 22 || order.status == 23 || order.status == 31 || order.status == 32 || order.status == 33 || order.status == 4 || order.status == 5}">
+                            <%--  返佣订单不能申请退款(退货) --%>
+                            <c:if test="${order.rebateOrder == '0'}">
                                 <c:if test="${order.toAudit eq 1}">
-                                    <%--弹窗提示--%>
-                                    <a href="#" onclick="return alertx('订单存在未审核的收款,暂不能退款。请将收款审核通过后再操作退款。')">申请退款</a>
-                                </c:if>
-                            </c:if>
-                            <c:if test="${order.toAudit ne 1}">
-                                <c:if test="${order.applyReturnedPurchaseFlag eq 1}">
-                                    <a href="${ctx}/bulkpurchase/cmRefundsProduct/applyRefound.rpc?orderID=${order.orderID}"
-                                       <c:if test="${order.status == 21 || order.status == 22 || order.status == 23}">onclick="return confirmx('部分收款的订单、申请退款只能申请全部退款!', this.href)"
+                                    <%--如果存在审核收款则不允许申请:1不能申请,其它可以申请--%>
+                                    <c:if test="${order.toAudit eq 1}">
+                                        <%--弹窗提示--%>
+                                        <a href="#" onclick="return alertx('订单存在未审核的收款,暂不能退款。请将收款审核通过后再操作退款。')">申请退款</a>
                                     </c:if>
-                                    >申请退款</a>
                                 </c:if>
-                                <c:if test="${order.applyReturnedPurchaseFlag ne 1}">
-                                    <font title="存在未处理完的申请,请前往退款列表处理!">申请退款</font>
+                                <c:if test="${order.toAudit ne 1}">
+                                    <c:if test="${order.applyReturnedPurchaseFlag eq 1}">
+                                        <a href="${ctx}/bulkpurchase/cmRefundsProduct/applyRefound.rpc?orderID=${order.orderID}&refundType=1"
+                                           <c:if test="${order.status == 21 || order.status == 22 || order.status == 23}">onclick="return confirmx('部分收款的订单、申请退款只能申请全部退款!', this.href)"
+                                        </c:if>
+                                        >申请退款</a>
+                                    </c:if>
+                                    <c:if test="${order.applyReturnedPurchaseFlag ne 1}">
+                                        <font title="存在未处理完的申请,请前往退款列表处理!">申请退款</font>
+                                    </c:if>
                                 </c:if>
                             </c:if>
                         </c:if>
@@ -722,7 +725,7 @@
                         </c:if>
                     </c:if>
                     <%--包含订单充值商品就不显示--%>
-                    <c:if test="${empty order.rechargeGoods}">
+                    <c:if test="${order.rechargeGoods ne 1 and order.rechargeGoods ne 2}">
                         <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 21 && order.status ne 6}">
                             <a href="${ctx}/order/logisticsDetails?orderID=${order.orderID}">发货记录</a>
                         </c:if>
@@ -773,6 +776,31 @@
                 <c:if test="${order.status ne '0'}">
                     <a onclick="copyText('${shopOrder.shopOrderID}')" style="cursor:pointer;">供应商订单二维码</a>
                 </c:if>
+                <c:if test="${order.onlinePayFlag eq 0}">
+                    <c:if test="${order.status == 12 || order.status == 13 || order.status == 21 || order.status == 22 || order.status == 23 || order.status == 31 || order.status == 32 || order.status == 33 || order.status == 4 || order.status == 5}">
+                        <%--  返佣订单不能申请退款(退货) --%>
+                        <c:if test="${order.rebateOrder == '0'}">
+                            <c:if test="${order.toAudit eq 1}">
+                                <%--如果存在审核收款则不允许申请:1不能申请,其它可以申请--%>
+                                <c:if test="${order.toAudit eq 1}">
+                                    <%--弹窗提示--%>
+                                    <a href="#" onclick="return alertx('订单存在未审核的收款,暂不能退款。请将收款审核通过后再操作退款。')">申请退款</a>
+                                </c:if>
+                            </c:if>
+                            <c:if test="${order.toAudit ne 1}">
+                                <c:if test="${order.applyReturnedPurchaseFlag eq 1}">
+                                    <a href="${ctx}/bulkpurchase/cmRefundsProduct/applyRefound.rpc?orderID=${order.orderID}&onlineShopOrderId=${shopOrder.shopOrderID}&refundType=1"
+                                       <c:if test="${order.status == 21 || order.status == 22 || order.status == 23}">onclick="return confirmx('部分收款的订单、申请退款只能申请全部退款!', this.href)"
+                                    </c:if>
+                                    >申请退款</a>
+                                </c:if>
+                                <c:if test="${order.applyReturnedPurchaseFlag ne 1}">
+                                    <font title="存在未处理完的申请,请前往退款列表处理!">申请退款</font>
+                                </c:if>
+                            </c:if>
+                        </c:if>
+                    </c:if>
+                </c:if>
                 <c:if test="${shopOrder.orderArchiveId ne null}">
                     <a href="${ctx}/archive/cmOrderArchive/form?id=${shopOrder.orderArchiveId}">查看订单资料</a>
                 </c:if>

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/order/paidShopOrderList.jsp

@@ -255,6 +255,7 @@
     <shiro:hasPermission name="order:cmPayShop:split">
     <li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
     </shiro:hasPermission>
+    <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
 </ul>
 <form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newShopOrder"
            action="${ctx}/shopOrder/payOrderList?operatingMode=${operatingMode

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/order/refundRecord.jsp

@@ -178,13 +178,13 @@
                 </td>
                 <td>
                     <c:if test="${order.refundType == 1}">
-                        部分退款
+                          <font color="#ff8c00">部分退款</font>
                     </c:if>
                     <c:if test="${order.refundType == 2}">
-                        已退款
+                         <font color="green">已退款</font>
                     </c:if>
                     <c:if test="${order.refundType != 1 && order.refundType != 2}">
-                        无退款
+                         <font color="red">无退款</font>
                     </c:if>
                 </td>
                 <td><fmt:formatNumber value="${order.returnValue}" type="number" pattern="#,##0.00"/></td>

+ 285 - 0
src/main/webapp/WEB-INF/views/modules/order/settleRecordList.jsp

@@ -0,0 +1,285 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>退/付款记录</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th {
+            text-align: center
+        }
+
+        .table td {
+            text-align: center
+        }
+
+        .payment th {
+            text-align: center;
+            background-color: #199ed8;
+            color: #ffffff;
+            height: 25px
+        }
+
+        .payment td {
+            text-align: center
+        }
+
+        .label-justify {
+            float: left
+        }
+
+        .text-left {
+            display: flex;
+            justify-content: center;
+            -webkit-display: flex;
+            -webkit-justify-content: center;
+            -moz-display: flex;
+            -moz-justify-content: center;
+            -ms-display: flex;
+            -ms-justify-content: center
+        }
+
+        .zeroCost .message {
+            display: none;
+            position: absolute;
+            background: #FFF;
+            white-space: nowrap;
+            border: 1px solid black;
+
+        }
+
+        .zeroCost:hover .message {
+            display: inline-block;
+            color: black;
+            padding: 5px;
+            margin-left: 10px;
+        }
+
+        .weishaIcon {
+            background: darkorange;
+            color: white;
+            margin: 0 0px;
+            padding: 0 3px;
+            font-style: normal;
+            font-size: 12px;
+            display: inline-block;
+            border-radius: 2px
+        }
+
+    </style>
+    <script type="text/javascript">
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
+    <li class="active"><a href="${ctx}/shopOrder/settleRecord?shopOrderID=${s.shopOrderID}">退/付款记录</a></li>
+</ul>
+<table class="table table-striped table-bordered table-condensed pay-table">
+    <tr>
+        <th>子订单编号(ID)</th>
+        <th colspan="3">订单编号(ID)</th>
+        <th colspan="2">订单金额</th>
+        <th colspan="3">下单时间</th>
+        <th>收款状态</th>
+        <th>收款金额</th>
+        <th colspan="2">经理折扣</th>
+        <th>优惠券</th>
+        <th>成本类型</th>
+        <th>付第三方</th>
+    </tr>
+    <tr>
+        <td><a href="${ctx}/order/detail?id=${s.orderID}">${s.shopOrderNo}(${s.shopOrderID})</a></td>
+        <td colspan="3"><a href="${ctx}/order/detail?id=${s.orderID}">${s.orderNo}(${s.orderID})</a></td>
+        <td colspan="2">${s.payTotalFee}</td>
+        <td colspan="3">${s.orderTime}</td>
+        <td><a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
+               style="text-decoration: underline">
+            <c:if test="${s.receiptStatus == 1}"><font color="red">待收款</font></c:if>
+            <c:if test="${s.receiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+            <c:if test="${s.receiptStatus == 3}"><font color="green">已收款</font></c:if></a></td>
+        <td><a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
+               style="text-decoration: underline">${s.receiptTotalFee}</a></td>
+        <td colspan="2">
+            <c:if test="${s.discountTotalFee gt 0}">
+                <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
+                    <fmt:formatNumber value="${s.discountTotalFee - s.returnedPurchaseTotalFee}" type="currency"/>
+                </c:if>
+                <c:if test="${s.discountTotalFee le s.returnedPurchaseTotalFee}">
+                    ¥0.00
+                </c:if>
+                <c:if test="${s.returnedPurchaseTotalFee gt 0}">
+                                <span style="color: red">
+                                    (原<fmt:formatNumber value="${s.discountTotalFee}" type="currency"/>,因退货折扣取消
+                                    <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
+                                        <fmt:formatNumber value="${s.returnedPurchaseTotalFee}" type="currency"/>
+                                    </c:if>
+                                    <c:if test="${s.discountTotalFee le s.returnedPurchaseTotalFee}">
+                                        <fmt:formatNumber value="${s.discountTotalFee}" type="currency"/>
+                                    </c:if>)
+                                </span>
+                </c:if>
+            </c:if>
+            <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
+        </td>
+        <td>
+            ${s.couponAmount}
+        </td>
+        <td><c:if test="${empty s.costType || s.costType == '1'}">固定成本</c:if><c:if
+                test="${s.costType == '2'}">比例成本</c:if></td>
+        <td class="third-party-fee">${s.shopOtherFee}</td>
+    </tr>
+    <tr>
+        <th>供应商</th>
+        <th colspan="3">客户</th>
+        <th>机构运费</th>
+        <th>供应商运费</th>
+        <th colspan="3">商品费</th>
+        <th colspan="2">结算状态</th>
+        <th colspan="3">应付税费</th>
+        <th colspan="2">付供应商</th>
+    </tr>
+    <tr>
+        <td>${s.shopName}</td>
+        <td colspan="3">
+            <c:if test="${s.organizeID == 1}"><span class="org-note">星范</span></c:if>
+            ${s.buyer}
+            <c:if test="${s.organizeID == 3}"></c:if>
+        </td>
+        <td>
+            <c:if test="${s.freight == 0}">
+                包邮
+            </c:if>
+            <c:if test="${s.freight == -1}">
+                到付
+            </c:if>
+            <c:if test="${s.freight == -2}">
+                仪器到付-产品包邮
+            </c:if>
+            <c:if test="${s.freight != -1 && s.freight != 0 && s.freight != -2}">
+                <fmt:formatNumber value="${s.freight}" type="currency"/>
+                <c:if test="${s.returnedFreightFlag eq true}"><font color="red">(已退)</font></c:if>
+            </c:if>
+        </td>
+        <td class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/></td>
+        <td colspan="3" class="product-fee">${s.shopProductAmount}</td>
+        <td colspan="2">
+            <c:if test="${s.settleStatus == 1}"><font color="red">待结算</font></c:if>
+            <c:if test="${s.settleStatus == 2}"><font color="#ff8c00">部分结算</font></c:if>
+            <c:if test="${s.settleStatus == 3 || empty s.settleStatus}"><font color="green">已结算</font></c:if>
+        </td>
+        <td colspan="3" class="taxes"><fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/></td>
+        <td colspan="2" class="supplier-fee">
+                <c:if test="${s.differenceType ne 1 && s.differenceType ne 2 }">
+                    <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></font>
+                </c:if>
+            <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
+                <font color="black">${s.shouldPayShopAmount+s.differencePrice}</font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+            </c:if>
+            <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
+                <font color="black">${s.shouldPayShopAmount-s.differencePrice}</font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+            </c:if>
+        </td>
+    </tr>
+    <tr>
+        <th>商品名</th>
+        <th>规格</th>
+        <th>数量<%--(赠品)--%></th>
+        <th>退货</th>
+        <th colspan="2">单价</th>
+        <th colspan="3">机构税率 / 单税费 / 总税费</th>
+        <th colspan="2">总价</th>
+        <th colspan="3">供应商税率 / 单税费 / 总税费</th>
+        <th>成本(单)</th>
+        <th>成本(总)</th>
+    </tr>
+    <c:forEach items="${s.newOrderProducts}" var="p" varStatus="pIndex">
+        <tr class="pay-product-item">
+            <input type="hidden" class="p-copId" value="${p.orderProductID}">
+            <td style="width:300px;" class="p-name">
+                <c:if test="${p.productType eq 1}"><font color="red">协商赠品:</font></c:if>
+                <c:if test="${p.productType eq 2}"><font color="red">促销赠品:</font></c:if>
+                    ${p.name}
+            </td>
+            <td style="width:80px;">${p.unit}</td>
+            <td class="p-num" data-num="${p.num + p.presentNum}">
+                    ${p.num}
+                <c:if test="${p.presentNum > 0}">(赠:${p.presentNum})</c:if>
+            </td>
+            <td><font color="${p.returnedNum>0?'red':''}">${p.returnedNum}</font></td>
+            <td colspan="2"><fmt:formatNumber value="${empty p.touchPrice?p.discountPrice:p.touchPrice}" type="number"
+                                              pattern="#,##0.00"/>
+                <c:if test="${p.includedTax != null and p.includedTax != '' and p.includedTax ne 2}">
+                    <label style="color: red">
+                        (${p.includedTax eq 1?'含税':(p.invoiceType eq 1 or p.invoiceType eq 2)?'不含税-能开票':'不含税-不能开票'})
+                    </label>
+                </c:if>
+            </td>
+            <td>${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'---':empty p.taxRate?0.0:p.taxRate}${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'':'%'}</td>
+            <td>${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))?'---': empty p.addedValueTax ?0.00:p.addedValueTax}</td>
+            <td><c:choose>
+                <c:when test="${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))}">
+                    ---
+                </c:when>
+                <c:otherwise>
+                    <fmt:formatNumber
+                            value="${empty p.totalAddedValueTax ?0.00:(p.addedValueTax * (p.num+p.presentNum-p.returnedNum))}"
+                            type="number" pattern="#,##0.00"/>
+                </c:otherwise>
+            </c:choose></td>
+
+            <td colspan="2"><fmt:formatNumber
+                    value="${((empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax)*(p.num+p.presentNum-p.returnedNum)}"
+                    type="number" pattern="#,##0.00"/></td>
+
+            <td>${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'---':empty p.supplierTaxRate?0.0:p.supplierTaxRate}${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'':'%'}</td>
+            <td>${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))?'---': empty p.singleShouldPayTotalTax ?0.00:p.singleShouldPayTotalTax}</td>
+            <td><c:choose>
+                <c:when test="${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))}">
+                    ---
+                </c:when>
+                <c:otherwise>
+                    <fmt:formatNumber
+                            value="${empty p.shouldPayTotalTax ?0.00:(p.singleShouldPayTotalTax * (p.num+p.presentNum-p.returnedNum))}"
+                            type="number" pattern="#,##0.00"/>
+                </c:otherwise>
+            </c:choose></td>
+
+            <td class="p-costprice"><fmt:formatNumber value="${p.costPrice}" type="number" pattern="#,##0.00"/></td>
+            <td><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}" type="number"
+                                  pattern="#,##0.00"/></td>
+        </tr>
+    </c:forEach>
+</table>
+<span style="font-weight:bold">结算记录</span>
+<table id="contentTable" class="payment" width="70%" border="1">
+    <thead>
+    <tr>
+        <th>序号</th>
+        <th>结算时间</th>
+        <th>结算类型</th>
+        <th>结算金额</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${pr}" var="p" varStatus="pvs">
+        <tr>
+            <td>${pvs.index}</td>
+            <td><fmt:formatDate value="${p.settleTime}" pattern="yyyy-MM-dd HH:mm"/></td>
+            <td>${p.settleType eq 1 ? "成本结算":"佣金结算"}</td>
+            <td>${p.settleAmount}</td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<br>
+</body>
+<script>
+</script>
+</html>

+ 1247 - 0
src/main/webapp/WEB-INF/views/modules/product/cmSecondDetailForm.jsp

@@ -0,0 +1,1247 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>二手估价商品添加 / 编辑</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();订单来源
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    var costCheckFlag = $("input[name='costCheckFlag']:checked").val();
+                    var find = $("input[name='ids']:checked").val();
+                    if (!find >= 1) {
+                        alertx("请选择商品包含的文件!");
+                        return false;
+                    }
+                    var publishIdentity = $("input[name='publishIdentity']:checked").val();
+                    console.log(publishIdentity);
+                    if (!publishIdentity > 0) {
+                        alertx("请选择用户身份");
+                        return false;
+                    }
+                    if (publishIdentity * 1 === 2) {
+                        if ($("#companyName").val() == '') {
+                            alertx("公司名称不能为空!");
+                            return false;
+                        }
+                    }
+                    if (costCheckFlag * 1 === 1) {
+                        if ($("#costPrice").val() == '') {
+                            alertx("请输入成本价");
+                            return false;
+                        }
+                        var costPrice = $("#costPrice").val();
+                        if (0 == costPrice) {
+                            alertx('成本价不能为0');
+                            return false;
+                        }
+                    } else {
+                        if ($("#costProportional").val() == '') {
+                            alertx("请输入成本比例");
+                            return false;
+                        }
+                    }
+
+                    // 验证填写参数
+                    var payStatus = $('#payStatus').val();
+                    if (payStatus == 2) {
+                        var payAmount = $("#payAmount").val();
+                        // (验证付款金额)
+                        if (payAmount == "" || payAmount == null) {
+                            alertx('请填写付款金额');
+                            return false;
+                        }
+                        if (0 == payAmount) {
+                            alertx('付款金额不能为0');
+                            return false;
+                        }
+                    }
+
+                    var price = $("#price").val();
+                    if (0 == price) {
+                        alertx('交易价不能为0');
+                        return false;
+                    }
+
+                    var secondHandType = $("input[name ='secondHandType']:checked").val();
+                    if (secondHandType == 2) {
+                        var maturityYears = $("#maturityYears").val();
+                        // (验证到期时期)
+                        if (maturityYears == null || maturityYears == "") {
+                            alertx('请输入产品到期日');
+                            return false;
+                        }
+                        //(验证临期价格信息)
+                        var normalPrice = $("#normalPrice").val();
+                        if (null == normalPrice || normalPrice == "") {
+                            alertx('请输入市场价');
+                            return false;
+                        }
+                        if (0 == normalPrice) {
+                            alertx('市场价不能为0');
+                            return false;
+                        }
+                        //
+                        var originalPrice = $("#originalPrice").val();
+                        if (null == originalPrice || originalPrice == "") {
+                            alertx('请输入采购价/原价');
+                            return false;
+                        }
+                        if (0 == originalPrice) {
+                            alertx('采购价/原价不能为0');
+                            return false;
+                        }
+
+                        var stock = $("#stock").val();
+                        if (null == stock || stock == "") {
+                            alertx('请输入数量');
+                            return false;
+                        }
+                    }
+                    //获取选中townID给Form标签
+                    var townId = $("#town option:selected").attr("townId");
+                    $("#townId").val(townId);
+
+                    var peopleMobile = $("#dockingPeopleMobile").val();
+                    if (peopleMobile != '' && peopleMobile != undefined) {
+                        var reg = new RegExp('^1[0-9]{10}$');
+                        if (!reg.test(peopleMobile)) {
+                            alertx('请填写正确的采美对接人联系方式');
+                            return false;
+                        }
+                    }
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+
+    </script>
+    <style>
+        .form-horizontal .controls {
+            margin-left: 0;
+        }
+
+        .form-horizontal .control-label {
+            float: left;
+            width: 181px;
+            padding-top: 5px;
+            text-align: right;
+        }
+
+        #increase, #decrease, .lineNum {
+            width: 30px;
+            height: 30px;
+        }
+
+        .lineNum {
+            text-align: center;
+        }
+
+        .dateInput input {
+            width: 150px;
+        }
+
+        .clause span {
+            margin-left: 30px;
+        }
+
+        #productTable th {
+            text-align: center;
+            white-space: nowrap;
+        }
+
+        #productTable td {
+            text-align: center;
+            white-space: nowrap;
+        }
+
+        .iconBox {
+            font-size: 0;
+        }
+
+        .controls .conList {
+            display: inline-block;
+            margin-right: 15px;
+        }
+
+        .conList .btn:nth-of-type(1) {
+            margin-left: 25px;
+        }
+
+        .select2-choice {
+            width: 100px;
+        }
+
+        .upload-content {
+            margin-top: -70px;
+            display: inline-block;
+        }
+
+        .upload-content .conList .btn:nth-of-type(1) {
+            width: 90px;
+            height: 100px;
+            border: 2px solid #eee;
+            background: #fff;
+            position: relative;
+        }
+
+        .upload-content .conList .btn:nth-of-type(1) > div {
+            position: absolute;
+            top: 50%;
+            left: 50%;
+            transform: translate(-50%, -50%);
+            color: #666;
+        }
+
+        .upload-content .conList .btn:nth-of-type(1) span {
+            font-size: 35px;
+        }
+
+        .upload-content .conList .btn:nth-of-type(1) h5 {
+            color: #666;
+        }
+
+        .cancel-upload {
+            background: transparent;
+            border: none;
+            box-shadow: none;
+            position: relative;
+            top: -38px;
+            left: -25px;
+            cursor: pointer;
+            z-index: 100;
+        }
+
+        .upload-content .conList ol li {
+            width: 114px;
+            min-height: 80px;
+            text-align: center;
+            background: #fff;
+            position: relative;
+            top: 120px;
+            margin-left: 2px;
+        }
+
+        .upload-content-image {
+            margin-top: -70px;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) {
+            width: 90px;
+            height: 100px;
+            border: 2px solid #eee;
+            background: #fff;
+            position: relative;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) > div {
+            position: absolute;
+            top: 50%;
+            left: 50%;
+            transform: translate(-50%, -50%);
+            color: #666;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) span {
+            font-size: 35px;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) h5 {
+            color: #666;
+        }
+
+        .upload-content-image .conList ol li {
+            width: 114px;
+            min-height: 80px;
+            text-align: center;
+            background: #fff;
+            position: relative;
+            top: 120px;
+            margin-left: 2px;
+        }
+
+        .cancel-upload-image {
+            background: transparent;
+            border: none;
+            box-shadow: none;
+            position: relative;
+            top: -38px;
+            left: -25px;
+            cursor: pointer;
+            z-index: 100;
+        }
+
+        .hide-pic {
+            display: none !important;
+        }
+
+        .hide-pic-image {
+            display: none !important;
+        }
+
+        .upload-tips {
+            margin: 10px 0;
+        }
+    </style>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/product/new/list?searchProductCategory=2">二手商品列表</a></li>
+    <li class="active"><a href="${ctx}/product/cmSecondHandDetail/cmSecondDetailForm">二手估价商品添加 / 编辑</a></li>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="cmSecondHandDetail"
+           action="${ctx}/product/cmSecondHandDetail/save?searchName=${cmSecondHandDetail.searchName}&searchShopID=${cmSecondHandDetail.searchShopID}&searchShopName=${cmSecondHandDetail.searchShopName}&searchBigTypeID=${cmSecondHandDetail.searchBigTypeID}&searchSmallTypeID=${cmSecondHandDetail.searchSmallTypeID}&searchTinyTypeID=${cmSecondHandDetail.searchTinyTypeID}&searchValidFlag=${cmSecondHandDetail.searchValidFlag}&searchActStatus=${cmSecondHandDetail.searchActStatus}&searchProductType=${cmSecondHandDetail.searchProductType}&searchBrandID=${cmSecondHandDetail.searchBrandID}&searchPreferredFlag=${cmSecondHandDetail.searchPreferredFlag}&searchProductCategory=${cmSecondHandDetail.searchProductCategory}&editFlag=${cmSecondHandDetail.editFlag}"
+           method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="validFlag"/>
+    <form:hidden path="payType"/>
+    <sys:message content="${message}"/>
+    <%--		新增加不需要显示--%>
+    <c:if test="${ not empty cmSecondHandDetail.id}">
+        <div class="control-group">
+            <label class="control-label">商品状态:</label>
+            <div class="controls" style="margin-top: 5px">
+                <c:if test="${cmSecondHandDetail.validFlag eq 1}">待审核</c:if>
+                <c:if test="${cmSecondHandDetail.validFlag eq 2}">已上架</c:if>
+                <c:if test="${cmSecondHandDetail.validFlag eq 3}">已下架</c:if>
+                <c:if test="${cmSecondHandDetail.validFlag eq 4}">审核未通过</c:if>
+            </div>
+        </div>
+        <div class="control-group">
+            <label class="control-label">来源:</label>
+            <div class="controls" style="margin-top: 5px">
+                <c:if test="${cmSecondHandDetail.source eq '1'}">
+                    网站
+                </c:if>
+                <c:if test="${cmSecondHandDetail.source eq '2'}">
+                    小程序
+                </c:if>
+                <c:if test="${cmSecondHandDetail.source eq '3'}">
+                    后台
+                </c:if>
+                </span>
+            </div>
+        </div>
+    </c:if>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>发布者:</label>
+        <div class="controls" style="margin-top: 5px">
+            <form:input path="publisher" htmlEscape="false" maxlength="45" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>交易状态:</label>
+        <div class="controls" style="margin-top: 5px">
+            <form:radiobutton path="sold" value="0" label="未售" checked="true"/>
+            <form:radiobutton path="sold" value="1" label="已售"/>
+        </div>
+    </div>
+    <%--	<div class="control-group">--%>
+    <%--		<label class="control-label"><font color="red">*</font>付款状态:</label>--%>
+    <%--		<div class="controls">--%>
+    <%--			<form:select path="payStatus" class="input-mini required">--%>
+    <%--				<form:option value="3" checked="true">无需付款</form:option>--%>
+    <%--				<form:option value="1">待付款</form:option>--%>
+    <%--				<form:option value="2">已付款</form:option>--%>
+    <%--			</form:select>--%>
+    <%--		</div>--%>
+    <%--	</div>--%>
+    <%--	<div class="control-group payAmount">--%>
+    <%--		<label class="control-label"><font color="red">*</font>付款金额:¥ </label>--%>
+    <%--		<div class="controls">--%>
+    <%--			<input id="payAmount" name="payAmount"  maxlength="11" style="padding-left: 7px;padding-top: 8px;border-radius: 4px;background: white;border: 1px solid #ccc;padding-right: 5px" onkeyup="num(this)" value="<fmt:formatNumber type='number' value='${cmSecondHandDetail.payAmount}' pattern='0.00'/>"  class="input-xlarge required"/>--%>
+    <%--		</div>--%>
+    <%--	</div>--%>
+    <div class="control-group">
+        <label class="control-label">浏览量:</label>
+        <div class="controls">
+            <form:input path="viewingNum" htmlEscape="false" onkeyup="onlynum(this)" maxlength="9"
+                        class="input-xlarge "/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>发布者身份:</label>
+        <div class="controls">
+            <form:radiobutton path="publishIdentity" checked="true" value="1" label="个人身份" onchange="Idcheck(1)"/>
+            <form:radiobutton path="publishIdentity" value="2" label="公司身份" onchange="Idcheck(2)"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>分类:</label>
+        <div class="controls c-s" style="margin-top: 5px">
+            <form:radiobutton path="secondHandType" value="1" label="二手仪器"/>
+            <form:radiobutton path="secondHandType" value="3" label="其他"/>
+        </div>
+        <div class="controls c-s bigTypeList" style="margin-left: 181px">
+<%--            <form:checkboxes path="bigTypeList" items="" itemLabel="name" itemValue="id" htmlEscape="false"--%>
+<%--                             class="input-small  stylema required"/>--%>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品可见度:</label>
+        <div class="controls">
+            <form:select path="visibility" class="input-large required" id="visibility">
+                <form:option value="1" label="仅会员机构可见"/>
+                <form:option value="3" label="所有人可见"/>
+                <form:option value="2" label="所有机构可见"/>
+                <form:option value="4" label="仅医美机构可见"/>
+            </form:select>
+        </div>
+    </div>
+    <c:if test="${not empty cmSecondHandDetail.id}">
+    <div class="control-group">
+        <label class="control-label">线上分账账号:</label>
+        <div class="controls">
+            <form:select path="splitCode" class="select-ele input-medium">
+                <form:option value="" label="请选择"/>
+                <c:forEach items="${splitCodeList}" var="splitCodeList" varStatus="index">
+                    <form:option value="${splitCodeList.splitCode}" label="${splitCodeList.codeRemark}"/>
+                </c:forEach>
+            </form:select>
+        </div>
+    </div>
+    </c:if>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品品牌:</label>
+        <div class="controls">
+            <form:select path="brandID" class="input-medium required">
+                <form:option value="">请选择</form:option>
+                <c:forEach items="${brandList}" var="brand">
+                    <form:option value="${brand.id}">${brand.name}</form:option>
+                </c:forEach>
+                <form:option value="161">
+                    其他
+                </form:option>
+            </form:select>
+            <form:input path="brandName" value="${cmSecondHandDetail.brandName}" maxlength="20" class="input-medium"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品名称:</label>
+        <div class="controls">
+            <form:input path="name" htmlEscape="false" maxlength="40" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">出厂日期:</label>
+        <div class="controls">
+            <form:input path="fixedYears" htmlEscape="false" maxlength="50" class="input-xlarge"/>
+        </div>
+    </div>
+<%--    <div class="control-group maturityYears showClassDiv">--%>
+<%--        <label class="control-label"><font color="red">*</font>产品到期日期:</label>--%>
+<%--        <div class="controls">--%>
+<%--            <form:input path="maturityYears" htmlEscape="false" maxlength="50" class="input-xlarge"/>--%>
+<%--        </div>--%>
+<%--    </div>--%>
+    <div class="control-group" id="gsmc">
+        <label class="control-label"><font color="red">*</font>公司名称:</label>
+        <div class="controls">
+            <form:input path="companyName" htmlEscape="false" maxlength="20" class="input-xlarge "/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>交易价:</label>
+        <div class="controls">
+            <form:input path="price" htmlEscape="false" maxlength="11" onkeyup="num(this)"
+                        class="input-xlarge required"/>
+            <label>
+                <input id="detailTalkFlag" name="detailTalkFlag" type="hidden"/>
+                <input style="padding-left: 7px;padding-top: 8px;border-radius: 4px;background: white;border: 1px solid #ccc;padding-right: 5px"
+                       id="detailTalk" name="detailTalk" type="checkbox" onclick="detailTalkFlagCheckd()"
+                       <c:if test="${cmSecondHandDetail.detailTalkFlag eq 2}">checked="checked"</c:if> /><font
+                    color="red">价格详聊</font>(勾选代表同意不显示交易价)
+            </label>
+        </div>
+    </div>
+<%--    <div class="control-group showClassDiv">--%>
+<%--        <label class="control-label"><font color="red">*</font>市场价:</label>--%>
+<%--        <div class="controls">--%>
+<%--            <input style="padding-left: 7px;padding-top: 8px;border-radius: 4px;background: white;border: 1px solid #ccc;padding-right: 5px"--%>
+<%--                   id="normalPrice" name="normalPrice"--%>
+<%--                   value="<fmt:formatNumber type='number' value='${cmSecondHandDetail.normalPrice}' pattern='0.00'/>"--%>
+<%--                   onkeyup="num(this)" class="input-xlarge"/>--%>
+<%--        </div>--%>
+<%--    </div>--%>
+<%--    <div class="control-group showClassDiv">--%>
+<%--        <label class="control-label"><font color="red">*</font>采购价/原价:</label>--%>
+<%--        <div class="controls">--%>
+<%--            <input style="padding-left: 7px;padding-top: 8px;border-radius: 4px;background: white;border: 1px solid #ccc;padding-right: 5px"--%>
+<%--                   id="originalPrice" name="originalPrice"--%>
+<%--                   value="<fmt:formatNumber type='number' value='${cmSecondHandDetail.originalPrice}' pattern='0.00'/>"--%>
+<%--                   onkeyup="num(this)" class="input-xlarge"/>--%>
+<%--        </div>--%>
+<%--    </div>--%>
+<%--    <div class="control-group showClassDiv">--%>
+<%--        <label class="control-label"><font color="red">*</font>数量:</label>--%>
+<%--        <div class="controls">--%>
+<%--            <form:input path="stock" htmlEscape="false" class="input-xlarge  number"/>--%>
+<%--        </div>--%>
+<%--    </div>--%>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>成本:</label>
+        <div class="controls">
+            <label><input type="radio" name="costCheckFlag" value="1"
+                          onchange="changeCostPriceShow()" ${cmSecondHandDetail.costCheckFlag eq "1" ? "checked" : ""} />固定成本</label>
+            <label><input type="radio" name="costCheckFlag" value="2"
+                          onchange="changeCostPriceShow()" ${cmSecondHandDetail.costCheckFlag eq "1" ? "" : "checked"} />比例成本</label>
+        </div>
+    </div>
+    <div class="control-group costPriceShow">
+        <label class="control-label"><font color="red">*</font>成本价:</label>
+        <div class="controls">
+            <input style="padding-left: 7px;padding-top: 8px;border-radius: 4px;background: white;border: 1px solid #ccc;padding-right: 5px"
+                   id="costPrice" name="costPrice"
+                   value="<fmt:formatNumber type='number' value='${cmSecondHandDetail.costPrice}' pattern='0.00'/>"
+                   onkeyup="num(this)" class="input-xlarge"/>
+        </div>
+    </div>
+    <div class="control-group costPropShow">
+        <label class="control-label"><font color="red">*</font>比例成本百分比:</label>
+        <div class="controls">
+            <input style="padding-left: 7px;padding-top: 8px;border-radius: 4px;background: white;border: 1px solid #ccc;padding-right: 5px"
+                   id="costProportional" name="costProportional"
+                   value="<fmt:formatNumber type='number' value='${cmSecondHandDetail.costProportional}' pattern='0.00'/>"
+                   onkeyup="num(this)" class="input-xlarge"/> %
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品成色:</label>
+        <div class="controls">
+            <form:input path="productQuality" htmlEscape="false" maxlength="30" class="input-xlarge required"/>
+        </div>
+    </div>
+
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>联系人:</label>
+        <div class="controls">
+            <form:input path="contactName" htmlEscape="false" maxlength="15" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>联系方式:</label>
+        <div class="controls">
+            <form:input path="contactMobile" htmlEscape="false" maxlength="11" class="input-xlarge required"/>
+        </div>
+    </div>
+
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>是否显示联系人和联系方式:</label>
+        <div class="controls" style="margin-top: 5px">
+            <form:radiobutton cssStyle="position: relative" path="showContactFlag" value="1" checked="true"
+                              label="不显示"/>
+            <form:radiobutton cssStyle="position: relative" path="showContactFlag" value="2" label="显示"/>
+        </div>
+    </div>
+
+    <div class="control-group" id="yyzz" hidden>
+        <label class="control-label">营业执照照片:</label>
+        <div class="controls upload-content-image iconBox">
+            <div class="conList">
+                <form:hidden id="licenseImage" path="licenseImage" value="${cmSecondHandDetail.licenseImage}"
+                             htmlEscape="false" maxlength="255" class="input-xlarge"/>
+                <sys:ckfinder input="licenseImage" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100"
+                              maxHeight="100"/>
+                <br>
+            </div>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">采美对接人:</label>
+        <div class="controls">
+            <form:input path="dockingPeopleName" htmlEscape="false" maxlength="15" class="input-xlarge"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">采美对接人联系方式:</label>
+        <div class="controls">
+            <form:input path="dockingPeopleMobile" id="dockingPeopleMobile" htmlEscape="false" maxlength="11"
+                        class="input-xlarge"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">商品类型:</label>
+        <div class="controls" style="margin-top: 5px">
+            <form:radiobutton path="secondProductType" value="1" label="医美"/>
+            <form:radiobutton path="secondProductType" value="2" label="非医美"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <input type="hidden" id="curProvince" name="curProvince" value="${cmSecondHandDetail.province }">
+        <input type="hidden" id="curCity" name="curCity" value="${cmSecondHandDetail.city }">
+        <input type="hidden" id="curTown" name="curTown" value="${cmSecondHandDetail.town }">
+        <form:input path="townId" Id="townId" type="hidden" value="${cmSecondHandDetail.townId}"/>
+        <label class="control-label"><font color="red">*</font>联系地址:</label>
+        <div>
+            <form:select path="province" class="input-xlarge required" id="province"
+                         onchange="loadCity()" style="width:100px;">
+                <form:option value="" label="省" provinceId=""/>
+            </form:select>&nbsp;&nbsp;
+            <form:select path="city" class="input-xlarge required" id="city" onchange="loadTown()"
+                         style="width:100px;">
+                <form:option value="" label="市" cityId=""/>
+            </form:select>&nbsp;&nbsp;
+            <form:select path="town" class="input-xlarge required" id="town" style="width:100px;">
+                <form:option value="" label="区"/>
+            </form:select>&nbsp;&nbsp;
+            <form:input path="address" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label" style="margin-top: 17px">图片:</label>
+        <div class="controls upload-content" id="secondHandImage">
+            <div class="conList">
+                <form:hidden value="${cmSecondHandDetail.image1}" id="image1" path="image1" htmlEscape="false"
+                             maxlength="255" class="input-xlarge"/>
+                <sys:ckfinder input="image1" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
+                              maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden value="${cmSecondHandDetail.image2}" id="image2" path="image2" htmlEscape="false"
+                             maxlength="255" class="input-xlarge"/>
+                <sys:ckfinder input="image2" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
+                              maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden value="${cmSecondHandDetail.image3}" id="image3" path="image3" htmlEscape="false"
+                             maxlength="255" class="input-xlarge"/>
+                <sys:ckfinder input="image3" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
+                              maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden value="${cmSecondHandDetail.image4}" id="image4" path="image4" htmlEscape="false"
+                             maxlength="255" class="input-xlarge"/>
+                <sys:ckfinder input="image4" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
+                              maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden value="${cmSecondHandDetail.image5}" id="image5" path="image5" htmlEscape="false"
+                             maxlength="255" class="input-xlarge"/>
+                <sys:ckfinder input="image5" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
+                              maxHeight="100"/>
+            </div>
+        </div>
+        <div class="conList upload-tips" style="margin-left: 205px">
+            <font color="red">最多上传5张二手商品图片,请尽量全部上传,单张图片不能超过5M</font>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">商品详细信息:</label>
+        <div class="controls">
+            <form:textarea path="productDetails" style="width: 500px;height: 180px;"
+                           placeholder="请填写商品详细信息,对商品进行更详细的描述,不超过200字" htmlEscape="false" maxlength="250"
+                           class="input-xlarge "/>
+        </div>
+    </div>
+
+    <c:if test="${not empty cmSecondHandDetail.productID}">
+        <div class="control-group">
+            <label class="control-label">提交时间:</label>
+            <div class="controls" style="margin-top: 5px">
+                <fmt:formatDate value="${cmSecondHandDetail.submitDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </div>
+        </div>
+        <c:if test="${ not empty cmSecondHandDetail.reviewedDate}">
+            <div class="control-group">
+                <label class="control-label">审核时间:</label>
+                <div class="controls" style="margin-top: 5px">
+                    <fmt:formatDate value="${cmSecondHandDetail.reviewedDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+                </div>
+            </div>
+        </c:if>
+        <c:if test="${ not empty cmSecondHandDetail.onLineDate && cmSecondHandDetail.validFlag ne 4}">
+            <div class="control-group">
+                <label class="control-label">到期时间:</label>
+                <div class="controls" style="margin-top: 5px">
+                    <fmt:formatDate value="${cmSecondHandDetail.onLineDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+                </div>
+            </div>
+        </c:if>
+    </c:if>
+    <div class="form-actions">
+        <c:if test="${empty cmSecondHandDetail.id}">
+            <shiro:hasPermission name="product:cmSecondHandDetail:edit"><input id="btnSubmit" class="btn btn-primary"
+                                                                               type="submit" onclick="onLine()"
+                                                                               value="直接上架"/>&nbsp;</shiro:hasPermission>
+        </c:if>
+        <shiro:hasPermission name="product:cmSecondHandDetail:edit"><input id="btnSubmit" class="btn btn-primary"
+                                                                           type="submit"
+                                                                           value="保 存"/>&nbsp;</shiro:hasPermission>
+        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+    </div>
+</form:form>
+<script>
+
+    //图片初始化
+    $(function () {
+        var ids = [];
+        if (999 !=${cmSecondHandDetail.fileTypes}) {
+            ids =${cmSecondHandDetail.fileTypes};
+            for (let i = 0; i < ids.length; i++) {
+                if (1 == ids[i]) {
+                    $("#yqht").attr("checked", true);
+                }
+                if (2 == ids[i]) {
+                    $("#yqzc").attr("checked", true);
+                }
+                if (3 == ids[i]) {
+                    $("#yqfp").attr("checked", true);
+                }
+                if (4 == ids[i]) {
+                    $("#yqbg").attr("checked", true);
+                }
+                if (5 == ids[i]) {
+                    $("#wrh").attr("checked", true);
+                }
+            }
+        }
+
+        var publishIdentity = $("input[name='publishIdentity']:checked").val();
+        if (publishIdentity * 1 === 1) {
+            $("#gsmc").hide();
+            $("#yyzz").hide();
+            $("#sfz").show();
+        } else {
+            $("#gsmc").show();
+            $("#sfz").hide();
+            $("#yyzz").show();
+        }
+
+        $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
+        $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
+        $('.upload-content .conList').find('.cancel-upload').hide();
+        var observeEle = document.getElementsByClassName('upload-content')[0];
+
+        var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
+        var MutationObserverConfig = {
+            childList: true,
+            subtree: true,
+            characterData: true
+        };
+        var observer = new MutationObserver(function (mutations) {
+            $.each(mutations, function (index, item) {
+                if (item.type === 'childList') {
+                    // 在创建新的 element 时调用
+                    var target = $(item.target),
+                        thisWrapper = target.closest('.conList'),
+                        nextEle = thisWrapper.next();
+                    thisWrapper.find('li').css('z-index', 99);
+                    thisWrapper.find('.cancel-upload').show();
+                    if (nextEle.hasClass('hide-pic')) {
+                        nextEle.removeClass('hide-pic');
+                    }
+                }
+            })
+        });
+        observer.observe(observeEle, MutationObserverConfig);
+
+
+        $('body').on('click', '.upload-content li', function () {
+            var index = $(this).closest('.conList').index() + 1,
+                str = 'image' + index + 'FinderOpen';
+            eval(str + '()');
+        });
+        $('body').on('click', '.cancel-upload', function () {
+            debugger
+            var wrapper = $(this).closest('.conList');
+            wrapper.find('li').css('z-index', '-1');
+            wrapper.find('input').val('');
+            $(this).hide();
+            if ($('.cancel-upload:visible').length < 9) {
+                wrapper.addClass("hide-pic");
+            } else {
+                wrapper.removeClass("hide-pic");
+            }
+            wrapper.parent().append(wrapper.clone());
+            wrapper.remove();
+            $(".conList").each(function (i, ele) {
+                if ($(ele).find("input.input-xlarge").val()) {
+                    $(ele).next().removeClass("hide-pic")
+                }
+            })
+        });
+        $(window).on("load", function () {
+            setTimeout(function () {
+                $("#secondHandImage").find("input.input-xlarge").each(function (i, ele) {
+                    if ($(ele).val()) {
+                        $(ele).next().find("li").css("z-index", "99");
+                        $(ele).parents(".conList").find(".cancel-upload").show();
+                        $(ele).parents(".conList").next().removeClass("hide-pic")
+                    }
+                })
+            }, 500);
+        });
+
+
+        $('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
+        $('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
+        $('.upload-content-image .conList').find('.cancel-upload-image').hide();
+        var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
+        var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
+        var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
+        var MutationObserverConfigImage = {
+            childList: true,
+            subtree: true,
+            characterData: true
+        };
+        var observerImage = new MutationObserverImage(function (mutations) {
+            $.each(mutations, function (index, item) {
+                if (item.type === 'childList') {
+                    // 在创建新的 element 时调用
+                    var target = $(item.target),
+                        thisWrapper = target.closest('.conList'),
+                        nextEle = thisWrapper.next();
+                    thisWrapper.find('li').css('z-index', 99);
+                    thisWrapper.find('.cancel-upload-image').show();
+                    if (nextEle.hasClass('hide-pic-image')) {
+                        nextEle.removeClass('hide-pic-image');
+                    }
+                }
+            })
+        });
+        observerImage.observe(observeEleImage, MutationObserverConfigImage);
+        observerImage.observe(observeEleImage1, MutationObserverConfigImage);
+
+        $('body').on('click', '.upload-content-image li', function () {
+            var index = $(this).closest('.conList').index() + 1,
+                str = 'remarkImage' + index + 'FinderOpen';
+            eval(str + '()');
+        });
+        $('body').on('click', '.cancel-upload-image', function () {
+            var wrapper = $(this).closest('.conList');
+            wrapper.find('li').css('z-index', '-1');
+            wrapper.find('input').val('');
+            $(this).hide();
+            wrapper.removeClass("hide-pic-image");
+            wrapper.parent().append(wrapper.clone());
+            wrapper.remove();
+            $(".conList").each(function (i, ele) {
+                if ($(ele).find("input.input-xlarge").val()) {
+                    $(ele).next().removeClass("hide-pic-image")
+                }
+            })
+        });
+        $(window).on("load", function () {
+            setTimeout(function () {
+                var input = $("#authenticationImage");
+                if (input.val()) {
+                    input.next().find("li").css("z-index", "99");
+                    input.parents(".conList").find(".cancel-upload-image").show();
+                    input.parents(".conList").next().removeClass("hide-pic-image")
+                }
+                var input = $("#authenticationBackImage");
+                if (input.val()) {
+                    input.next().find("li").css("z-index", "99");
+                    input.parents(".conList").find(".cancel-upload-image").show();
+                    input.parents(".conList").next().removeClass("hide-pic-image")
+                }
+                var input = $("#licenseImage");
+                if (input.val()) {
+                    input.next().find("li").css("z-index", "99");
+                    input.parents(".conList").find(".cancel-upload-image").show();
+                    input.parents(".conList").next().removeClass("hide-pic-image")
+                }
+                input = $("#commitmentImage");
+                if (input.val()) {
+                    input.next().find("li").css("z-index", "99");
+                    input.parents(".conList").find(".cancel-upload-image").show();
+                    input.parents(".conList").next().removeClass("hide-pic-image")
+                }
+            }, 500);
+        });
+
+        var controlsFiles = document.getElementById("controlsFiles");
+        controlsFiles.addEventListener("change", function () {
+            $('#uploadFileName').val(name.substring(0, name.indexOf('.')));
+            var files = $('#controlsFiles').prop('files');
+            var data = new FormData();
+            var url = "${ctx}/oss/cmOssArchive/fileUpload";
+            data.append('file', files[0]);
+            $.ajax({
+                url: url,
+                data: data,
+                type: "POST",
+                processData: false,
+                contentType: false,
+                dataType: "json",
+                success: function (res) {
+                    var html = "<span>" + res.fileName + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=" + res.url + " style='position: relative' target='_blank'>预览</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href='${ctx}/oss/cmOssArchive/fileDownload?ossName=" + res.ossName + "&fileName=" + res.fileName + "' style='position: relative'>下载</a></span>";
+                    $("#file-list-display").html(html);
+                    $("#controlsFiles").val("");
+                    $("#ossName").val(res.ossName);
+                    $("#fileName").val(res.fileName);
+                },
+                error: function (error) {
+                    alertx(error);
+                }
+            });
+        })
+    });
+    $(function () {
+        // 加载地址
+        loadProvince();
+
+        // 初始化付款状态
+        if ($('#payStatus').val() == '1' || $('#payStatus').val() == '3') {
+            //待支付情况下不能填写付款金额
+            $('.payAmount').hide();
+            $('#payAmount').removeClass('required');
+        }
+
+        if ($('#payStatus').val() == '2') {
+            //已支付情况下需要填写付款金额, 而且必填
+            $('.payAmount').show();
+            $('#payAmount').addClass('required');
+        }
+
+        // 初始化分类
+        var val = $("input[name ='secondHandType']:checked").val();
+        // 分类控制
+        if (val == 2 || val == 3 || val == undefined) {
+            $('.bigTypeList').hide();
+        }
+        if (val == 1) {
+            $('.bigTypeList').show();
+        }
+
+
+        // 价格控制
+        if (val == 1 || val == 3) {
+            $('.showClassDiv').hide();
+        }
+        if (val == 2) {
+            $('.showClassDiv').show();
+        }
+
+
+        $('#brandID').change(function () {
+            var val = $(this).val();
+            if (val == '161') {
+                //显示输入框
+                $("#brandName").show();
+            }
+            if (val != '161') {
+                //隐藏输入框
+                $("#brandName").hide();
+            }
+        });
+
+        //初始化
+        var val = $("#brandID option:selected").val();
+        if (val == '161') {
+            //显示输入框
+            $("#brandName").show();
+        }
+        if (val != '161') {
+            //隐藏输入框
+            $("#brandName").hide();
+        }
+
+        //	修改支付状态
+        $('#payStatus').change(function () {
+                var val = $("#payStatus").val();
+                if (val == 1 || val == 3) {
+                    //待支付情况下不能填写付款金额
+                    $('.payAmount').hide();
+                    $('#payAmount').removeClass('required');
+                }
+                if (val == 2) {
+                    //待支付情况下不能填写付款金额
+                    $('.payAmount').show();
+                    $('#payAmount').addClass('required');
+                }
+            }
+        );
+        // 修改分类
+        $("input[name='secondHandType']").change(function () {
+            var val = $(this).val();
+            // 分类控制
+            if (val == 2 || val == 3) {
+                $('.bigTypeList').hide();
+            }
+            if (val == 1) {
+                $('.bigTypeList').show();
+            }
+
+            // 价格控制
+            if (val == 1 || val == 3) {
+                $('.showClassDiv').hide();
+            }
+            if (val == 2) {
+                $('.showClassDiv').show();
+            }
+
+        });
+
+    });
+
+    /**
+     * 加载省份
+     * @param curProvince
+     */
+    function loadProvince() {
+        var curProvince = $("#curProvince").val();
+        $.ajax({
+            type: 'POST',
+            dataType: 'json',
+            url: '/area/loadProvince',
+            success: function (data) {
+                $("#s2id_province .select2-chosen").html("市");
+                $("#province").html("");
+                $("#province").append("<option value=''>省</option>");
+                for (var i = 0; i < data.length; i++) {
+                    if (curProvince != '' && curProvince != null && typeof (curProvince) != "undefined" && curProvince == data[i].name) {
+                        $("#province").append("<option value='" + data[i].name + "' provinceId=" + data[i].id + " selected>" + data[i].name + "</option>");
+                        $("#s2id_province .select2-chosen").html(curProvince);
+                        loadCity($("#curCity").val());
+                    } else {
+                        $("#province").append("<option value='" + data[i].name + "' provinceId=" + data[i].id + ">" + data[i].name + "</option>");
+                    }
+                }
+            }
+
+        });
+    }
+
+    /**
+     * 加载城市
+     */
+    function loadCity(curCity) {
+        var provinceId = $("#province option:selected").attr("provinceId");
+        if (typeof (provinceId) != "undefined" && provinceId * 1 > 0) {
+            $.ajax({
+                type: 'POST',
+                dataType: 'json',
+                data: {'provinceId': provinceId},
+                url: '/area/loadCity',
+                success: function (data) {
+                    $("#s2id_city .select2-chosen").html("市");
+                    $("#city").html("");
+                    $("#city").append("<option value=''>市</option>");
+                    for (var i = 0; i < data.length; i++) {
+                        if (curCity != null && typeof (curCity) != "undefined" && curCity == data[i].name) {
+                            $("#city").append("<option value='" + data[i].name + "' selected cityId=" + data[i].id + ">" + data[i].name + "</option>");
+                            $("#s2id_city .select2-chosen").html(curCity);
+                            loadTown($("#curTown").val());
+                        } else {
+                            $("#city").append("<option value='" + data[i].name + "' cityId=" + data[i].id + ">" + data[i].name + "</option>");
+                        }
+
+
+                    }
+                }
+
+            });
+        } else {
+            $("#city").html("");
+            $(".select2-chosen").eq(3).html("市");
+            $("#city").append("<option value=''>市</option>");
+
+            $("#town").html("");
+            $(".select2-chosen").eq(4).html("区");
+            $("#town").append("<option value=''>区</option>");
+        }
+    }
+
+    /**
+     * 加载县区
+     * @param curTown
+     */
+    function loadTown(curTown) {
+        var cityId = $("#city option:selected").attr("cityId");
+        if (typeof (cityId) != "undefined" && cityId * 1 > 0) {
+            $.ajax({
+                type: 'POST',
+                dataType: 'json',
+                data: {'cityId': cityId},
+                url: '/area/loadTown',
+                success: function (data) {
+                    $("#s2id_town .select2-chosen").html("区");
+                    $("#town").html("");
+                    $("#town").append("<option value='' >区</option>");
+                    for (var i = 0; i < data.length; i++) {
+                        if (curTown != null && typeof (curTown) != "undefined" && curTown == data[i].name) {
+                            $("#town").append("<option value='" + data[i].name + "' selected townId=" + data[i].id + ">" + data[i].name + "</option>");
+                            $("#s2id_town .select2-chosen").html(curTown);
+                        } else {
+                            $("#town").append("<option value='" + data[i].name + "' townId=" + data[i].id + ">" + data[i].name + "</option>");
+                        }
+                    }
+                }
+
+            });
+        } else {
+            $("#town").html("");
+            $(".select2-chosen").eq(4).html("区");
+            $("#town").append("<option value=''>区</option>");
+        }
+
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字和两位小数
+     */
+    function num(obj) {
+        obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+        obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
+        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+    }
+
+    function Idcheck(val) {
+        var c = val;
+        console.log(c);
+        if (1 === c) {
+            $("#yyzz").hide();
+            $("#sfz").show();
+            $("#gsmc").hide();
+        } else {
+            $("#gsmc").show();
+            $("#sfz").hide();
+            $("#yyzz").show();
+        }
+    }
+
+</script>
+</body>
+<head>
+    <title>二手商品管理</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();订单来源
+
+            //获取是否是选中状态
+            var check = $("#detailTalk").is(':checked');
+            if (check) {
+                $("#detailTalkFlag").val(2);
+            } else {
+                $("#detailTalkFlag").val(1);
+            }
+
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+
+                    // 验证填写参数
+                    var payStatus = $('#payStatus').val();
+                    if (payStatus == 2) {
+                        var payAmount = $("#payAmount").val();
+                        // (验证付款金额)
+                        if (payAmount == "" || payAmount == null) {
+                            alertx('请填写付款金额');
+                            return false;
+                        }
+                    }
+
+                    var secondHandType = $("input[name ='secondHandType']:checked").val();
+                    if (secondHandType == 2) {
+                        var maturityYears = $("#maturityYears").val();
+                        // (验证到期时期)
+                        if (maturityYears == null || maturityYears == "") {
+                            alertx('请输入产品到期日');
+                            return false;
+                        }
+                        //(验证临期价格信息)
+                        var normalPrice = $("#normalPrice").val();
+                        if (null == normalPrice || normalPrice == "") {
+                            alertx('请输入市场价');
+                            return false;
+                        }
+                        //
+                        var originalPrice = $("#originalPrice").val();
+                        if (null == originalPrice || originalPrice == "") {
+                            alertx('请输入采购价/原价');
+                            return false;
+                        }
+
+                        var stock = $("#stock").val();
+                        if (null == stock || stock == "") {
+                            alertx('请输入采购价/原价');
+                            return false;
+                        }
+
+
+                    }
+
+
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+
+        $(document).ready(function () {
+            changeCostPriceShow();
+        });
+
+        function detailTalkFlagCheckd() {
+            //获取是否是选中状态
+            var check = $("#detailTalk").is(':checked');
+            if (check) {
+                $("#detailTalkFlag").val(2);
+            } else {
+                $("#detailTalkFlag").val(1);
+            }
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+//            alertx("排序值只能填写大于等于1的整数!");
+        }
+
+        function onLine() {
+            // 设置已上架
+            $("#validFlag").val("2")
+        }
+
+        // 是否固定成本
+        function changeCostPriceShow() {
+            var costCheckFlag = $("input[name='costCheckFlag']:checked").val();
+            if (costCheckFlag * 1 === 1) {
+                $(".costPriceShow").show();
+                $(".costPropShow").hide();
+            } else {
+                $(".costPriceShow").hide();
+                $(".costPropShow").show();
+            }
+        }
+
+
+    </script>
+    <style>
+
+    </style>
+</head>
+</html>
+

+ 14 - 14
src/main/webapp/WEB-INF/views/modules/userNew/cmAgencyRemarksList.jsp

@@ -66,9 +66,9 @@
 				</div>
 				<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
 					<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">咨询人:</div>
-					<div style="width: 800px;float: left;margin: 10px 0;">${clubRemarks.questionMan}</div>
+					<div style="width: 150px;float: left;margin: 10px 0;">${clubRemarks.questionMan}</div>
 					<c:if test="${not empty clubRemarks.clubType}">
-						<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;">
+						<div style="width: 350px;font-weight: bold;margin: 10px 0;float: left;text-align: right;">
 							机构类型:
 						</div>
 						<div style="width: 300px;float: left;margin: 10px 0;">${clubRemarks.clubType}</div>
@@ -76,7 +76,7 @@
 				</div>
 				<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
 					<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">咨询类别:</div>
-					<div style="width: 800px;float: left;margin: 10px 0;">${clubRemarks.consultType}</div>
+					<div style="width: 150px;float: left;margin: 10px 0;">${clubRemarks.consultType}</div>
 				</div>
 				<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
 					<c:if test="${not empty clubRemarks.pinceSensitve}">
@@ -84,16 +84,16 @@
 							价格敏感度 :
 						</div>
 						<c:if test="${clubRemarks.pinceSensitve eq 1}">
-							<div style="width: 300px;float: left;margin: 10px 0;">敏感</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">敏感</div>
 						</c:if>
 						<c:if test="${clubRemarks.pinceSensitve eq 2}">
-							<div style="width: 300px;float: left;margin: 10px 0;">适中</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">适中</div>
 						</c:if>
 						<c:if test="${clubRemarks.pinceSensitve eq 3}">
-							<div style="width: 300px;float: left;margin: 10px 0;">不敏感</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">不敏感</div>
 						</c:if>
 						<c:if test="${clubRemarks.pinceSensitve eq 4}">
-							<div style="width: 300px;float: left;margin: 10px 0;">不明确</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">不明确</div>
 						</c:if>
 
 					</c:if>
@@ -102,16 +102,16 @@
 							意向程度:
 						</div>
 						<c:if test="${clubRemarks.satisfied eq 1}">
-							<div style="width: 300px;float: left;margin: 10px 0;">意向强烈</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">意向强烈</div>
 						</c:if>
 						<c:if test="${clubRemarks.satisfied eq 2}">
-							<div style="width: 300px;float: left;margin: 10px 0;">意向一般</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">意向一般</div>
 						</c:if>
 						<c:if test="${clubRemarks.satisfied eq 3}">
-							<div style="width: 300px;float: left;margin: 10px 0;">意向平淡</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">意向平淡</div>
 						</c:if>
 						<c:if test="${clubRemarks.satisfied eq 4}">
-							<div style="width: 300px;float: left;margin: 10px 0;">随便看看</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">随便看看</div>
 						</c:if>
 
 					</c:if>
@@ -120,13 +120,13 @@
 							跟进状态:
 						</div>
 						<c:if test="${clubRemarks.followup eq 1}">
-							<div style="width: 300px;float: left;margin: 10px 0;">跟进中</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">跟进中</div>
 						</c:if>
 						<c:if test="${clubRemarks.followup eq 2}">
-							<div style="width: 300px;float: left;margin: 10px 0;">跟进完成</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">跟进完成</div>
 						</c:if>
 						<c:if test="${clubRemarks.followup eq 3}">
-							<div style="width: 300px;float: left;margin: 10px 0;">已放弃</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">已放弃</div>
 						</c:if>
 
 					</c:if>

+ 14 - 14
src/main/webapp/WEB-INF/views/modules/userNew/cmRegistRemarksList.jsp

@@ -143,16 +143,16 @@
                         <div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">
                             咨询人 :
                         </div>
-                        <div style="width: 300px;float: left;margin: 10px 0;">${clubRemarks.questionMan}</div>
+                        <div style="width: 150px;float: left;margin: 10px 0;">${clubRemarks.questionMan}</div>
                         <div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">
                             机构名称:
                         </div>
-                        <div style="width: 300px;float: left;margin: 10px 0;">${clubRemarks.clubName}</div>
+                        <div style="width: 150px;float: left;margin: 10px 0;">${clubRemarks.clubName}</div>
                         <c:if test="${not empty clubRemarks.clubType}">
                         <div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">
                             机构类型:
                         </div>
-                        <div style="width: 300px;float: left;margin: 10px 0;">${clubRemarks.clubType}</div>
+                        <div style=" width: 150px;float: left;margin: 10px 0;position: relative;">${clubRemarks.clubType}</div>
                         </c:if>
                     </div>
                     <div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
@@ -167,16 +167,16 @@
                             价格敏感度 :
                         </div>
                             <c:if test="${clubRemarks.pinceSensitve eq 1}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">敏感</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">敏感</div>
                             </c:if>
                             <c:if test="${clubRemarks.pinceSensitve eq 2}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">适中</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">适中</div>
                             </c:if>
                             <c:if test="${clubRemarks.pinceSensitve eq 3}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">不敏感</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">不敏感</div>
                             </c:if>
                             <c:if test="${clubRemarks.pinceSensitve eq 4}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">不明确</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">不明确</div>
                             </c:if>
 
                         </c:if>
@@ -185,16 +185,16 @@
                             意向程度:
                         </div>
                             <c:if test="${clubRemarks.satisfied eq 1}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">意向强烈</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">意向强烈</div>
                             </c:if>
                             <c:if test="${clubRemarks.satisfied eq 2}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">意向一般</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">意向一般</div>
                             </c:if>
                             <c:if test="${clubRemarks.satisfied eq 3}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">意向平淡</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">意向平淡</div>
                             </c:if>
                             <c:if test="${clubRemarks.satisfied eq 4}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">随便看看</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">随便看看</div>
                             </c:if>
 
                         </c:if>
@@ -203,13 +203,13 @@
                             跟进状态:
                         </div>
                             <c:if test="${clubRemarks.followup eq 1}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">跟进中</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">跟进中</div>
                             </c:if>
                             <c:if test="${clubRemarks.followup eq 2}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">跟进完成</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">跟进完成</div>
                             </c:if>
                             <c:if test="${clubRemarks.followup eq 3}">
-                                <div style="width: 300px;float: left;margin: 10px 0;">已放弃</div>
+                                <div style="width: 150px;float: left;margin: 10px 0;">已放弃</div>
                             </c:if>
 
                         </c:if>

+ 18 - 18
src/main/webapp/WEB-INF/views/modules/userNew/cmUnRegistRemarksList.jsp

@@ -112,35 +112,35 @@
                     <span style="float: left;margin-left:120px;">管理员:${visitRemarks.leaderName}</span>
                 </div>
 				<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
-					<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">咨询人:</div>
-					<div style="width: 800px;float: left;margin: 10px 0;">${visitRemarks.questionMan}</div>
+					<div style="width: 80px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">咨询人:</div>
+					<div style="width: 150px;float: left;margin: 10px 0;">${visitRemarks.questionMan}</div>
 					<c:if test="${not empty visitRemarks.clubType}">
-						<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;">
+						<div style="width: 350px;font-weight: bold;margin: 10px 0;float: left;text-align: right;">
 							机构类型:
 						</div>
 						<div style="width: 300px;float: left;margin: 10px 0;">${visitRemarks.clubType}</div>
 					</c:if>
 				</div>
 				<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
-					<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">咨询类别:</div>
+					<div style="width: 80px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">咨询类别:</div>
 					<div style="width: 800px;float: left;margin: 10px 0;">${visitRemarks.consultType}</div>
 				</div>
 				<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
 					<c:if test="${not empty visitRemarks.pinceSensitve}">
-						<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">
+						<div style="width: 80px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">
 							价格敏感度 :
 						</div>
 						<c:if test="${visitRemarks.pinceSensitve eq 1}">
-							<div style="width: 300px;float: left;margin: 10px 0;">敏感</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">敏感</div>
 						</c:if>
 						<c:if test="${visitRemarks.pinceSensitve eq 2}">
-							<div style="width: 300px;float: left;margin: 10px 0;">适中</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">适中</div>
 						</c:if>
 						<c:if test="${visitRemarks.pinceSensitve eq 3}">
-							<div style="width: 300px;float: left;margin: 10px 0;">不敏感</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">不敏感</div>
 						</c:if>
 						<c:if test="${visitRemarks.pinceSensitve eq 4}">
-							<div style="width: 300px;float: left;margin: 10px 0;">不明确</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">不明确</div>
 						</c:if>
 
 					</c:if>
@@ -149,16 +149,16 @@
 							意向程度:
 						</div>
 						<c:if test="${visitRemarks.satisfied eq 1}">
-							<div style="width: 300px;float: left;margin: 10px 0;">意向强烈</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">意向强烈</div>
 						</c:if>
 						<c:if test="${visitRemarks.satisfied eq 2}">
-							<div style="width: 300px;float: left;margin: 10px 0;">意向一般</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">意向一般</div>
 						</c:if>
 						<c:if test="${visitRemarks.satisfied eq 3}">
-							<div style="width: 300px;float: left;margin: 10px 0;">意向平淡</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">意向平淡</div>
 						</c:if>
 						<c:if test="${visitRemarks.satisfied eq 4}">
-							<div style="width: 300px;float: left;margin: 10px 0;">随便看看</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">随便看看</div>
 						</c:if>
 
 					</c:if>
@@ -167,26 +167,26 @@
 							跟进状态:
 						</div>
 						<c:if test="${visitRemarks.followup eq 1}">
-							<div style="width: 300px;float: left;margin: 10px 0;">跟进中</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">跟进中</div>
 						</c:if>
 						<c:if test="${visitRemarks.followup eq 2}">
-							<div style="width: 300px;float: left;margin: 10px 0;">跟进完成</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">跟进完成</div>
 						</c:if>
 						<c:if test="${visitRemarks.followup eq 3}">
-							<div style="width: 300px;float: left;margin: 10px 0;">已放弃</div>
+							<div style="width: 150px;float: left;margin: 10px 0;">已放弃</div>
 						</c:if>
 
 					</c:if>
 				</div>
 				<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
-					<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">关键词记录:</div>
+					<div style="width: 80px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">关键词记录:</div>
 					<div style="width: 800px;float: left;margin: 10px 0;">
 						${visitRemarks.remarks}
 					</div>
 				</div>
 				<c:if test="${not empty visitRemarks.extra}">
 					<div class="td-text" style="width: 100%;float: left;margin-top: 20px;">
-						<div style="width: 100px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">
+						<div style="width: 80px;font-weight: bold;margin: 10px 0;float: left;text-align: right;margin-right: 10px;">
 							额外说明:
 						</div>
 						<div style="width: 800px;float: left;margin: 10px 0;">