zhijiezhao пре 2 година
родитељ
комит
5d18c71557
21 измењених фајлова са 3369 додато и 22 уклоњено
  1. 14 0
      src/main/java/com/caimei/modules/order/dao/NewOrderDao.java
  2. 5 0
      src/main/java/com/caimei/modules/order/dao/NewShopOrderDao.java
  3. 62 14
      src/main/java/com/caimei/modules/order/entity/Constant.java
  4. 9 0
      src/main/java/com/caimei/modules/order/entity/NewShopOrder.java
  5. 59 0
      src/main/java/com/caimei/modules/order/entity/SettleRecord.java
  6. 81 0
      src/main/java/com/caimei/modules/order/entity/SettleResult.java
  7. 181 5
      src/main/java/com/caimei/modules/order/service/CmPayShopService.java
  8. 20 2
      src/main/java/com/caimei/modules/order/service/NewShopOrderService.java
  9. 404 0
      src/main/java/com/caimei/modules/order/utils/RSA.java
  10. 69 0
      src/main/java/com/caimei/modules/order/utils/SettlePostFormUtil.java
  11. 26 0
      src/main/java/com/caimei/modules/order/web/CmPayShopController.java
  12. 18 0
      src/main/java/com/caimei/modules/order/web/CmShopOrderController.java
  13. 35 0
      src/main/resources/mappings/modules/order/OrderMapper.xml
  14. 137 1
      src/main/resources/mappings/modules/order/ShopOrderMapper.xml
  15. 1 0
      src/main/webapp/WEB-INF/views/modules/order/cmPayFormList.jsp
  16. 1 0
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopList.jsp
  17. 839 0
      src/main/webapp/WEB-INF/views/modules/order/cmSettlementForm.jsp
  18. 1121 0
      src/main/webapp/WEB-INF/views/modules/order/cmSettlementList.jsp
  19. 1 0
      src/main/webapp/WEB-INF/views/modules/order/cmSplitAccountList.jsp
  20. 1 0
      src/main/webapp/WEB-INF/views/modules/order/paidShopOrderList.jsp
  21. 285 0
      src/main/webapp/WEB-INF/views/modules/order/settleRecordList.jsp

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

@@ -240,4 +240,18 @@ 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);
 }

+ 5 - 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,8 @@ 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);
 }

+ 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";
 }

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

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

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

@@ -1,11 +1,16 @@
 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;
@@ -23,10 +28,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;
 
@@ -252,7 +258,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()));
                 }
                 //机构运费是否已退
@@ -338,7 +344,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()));
                 }
                 //机构运费是否已退
@@ -1096,4 +1102,174 @@ 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);
+        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);
+                }
+            }
+        }
+    }
 }

+ 20 - 2
src/main/java/com/caimei/modules/order/service/NewShopOrderService.java

@@ -275,9 +275,9 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         return page;
     }
 
-    public void setValue(List<NewShopOrder> payOrderList){
+    public void setValue(List<NewShopOrder> payOrderList) {
         for (NewShopOrder so : payOrderList) {
-            Integer onlineFlag=newOrderDao.findOnlinePay(so.getOrderID())>0?1:0;
+            Integer onlineFlag = newOrderDao.findOnlinePay(so.getOrderID()) > 0 ? 1 : 0;
             so.setOnlineFlag(onlineFlag);
             //统计该子订单的主的收款金额和收款状态
             NewOrder newOrder = newOrderDao.get(so.getOrderID().toString());
@@ -668,4 +668,22 @@ 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);
+    }
 }

+ 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);
+    }
+
+}

+ 26 - 0
src/main/java/com/caimei/modules/order/web/CmPayShopController.java

@@ -595,6 +595,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 +735,17 @@ 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) throws Exception {
+        cmPayShopService.settlement(shopOrderId, settleAmount);
+        return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
+    }
+
 
     ////applyPayWipe
     @RequiresPermissions("order:cmPayShop:edit")

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

@@ -114,6 +114,15 @@ public class CmShopOrderController extends BaseController {
         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 +194,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) {

+ 35 - 0
src/main/resources/mappings/modules/order/OrderMapper.xml

@@ -974,6 +974,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
@@ -1325,6 +1335,27 @@
           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>
     <insert id="insertSplitAccount">
         INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId, vipRecordId,
                                       authVipRecordId, type, subUserNo, splitAccount,
@@ -1345,4 +1376,8 @@
         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>
 </mapper>

+ 137 - 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,
@@ -1157,5 +1158,140 @@
         FROM `cm_order_product`
         WHERE orderID = #{orderid}
     </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 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>
 </mapper>

+ 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 - 0
src/main/webapp/WEB-INF/views/modules/order/cmPayShopList.jsp

@@ -304,6 +304,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

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

@@ -0,0 +1,839 @@
+<%@ 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) {
+                if ($(this).val() <= 0) {
+                    alertx("待付金额为负数,不能操作付款抹平。请先去操作供应商退款,使数据恢复正常", function () {
+                        window.location.href = "${ctx}/shopOrder/refundRecordList?operatingMode=2"
+                    });
+                }
+                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>

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

@@ -0,0 +1,1121 @@
+<%@ 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" data-shoporderid="${s.shopOrderID}" data-shopid="${s.shopID}" data-isPayShopOtherFee="${s.payShopOtherFee}"/>
+                    </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 () {
+        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 class="active tab-li"><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
 </ul>
 <form:form id="searchForm"
            action="${ctx}/splitAccount/split" method="post" class="breadcrumb form-search">

+ 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

+ 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>${p.settleTime}</td>
+            <td>${p.settleType eq 1 ? "成本结算":"佣金结算"}</td>
+            <td>${p.settleAmount}</td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<br>
+</body>
+<script>
+</script>
+</html>