Browse Source

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

# Conflicts:
#	src/main/resources/mappings/modules/cmpage/CmPageCentreMapper.xml
kaick 1 year ago
parent
commit
95ab42803e
67 changed files with 4817 additions and 2729 deletions
  1. 6 2
      src/main/java/com/caimei/modules/order/dao/CmReceiptOrderRelationDao.java
  2. 20 7
      src/main/java/com/caimei/modules/order/dao/NewOrderDao.java
  3. 16 0
      src/main/java/com/caimei/modules/order/dao/NewShopOrderDao.java
  4. 1 1
      src/main/java/com/caimei/modules/order/entity/ChangePayShopDifference.java
  5. 13 0
      src/main/java/com/caimei/modules/order/entity/ChangePayShopOther.java
  6. 9 0
      src/main/java/com/caimei/modules/order/entity/NewOrder.java
  7. 55 2
      src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java
  8. 63 0
      src/main/java/com/caimei/modules/order/entity/NewShopOrder.java
  9. 11 1
      src/main/java/com/caimei/modules/order/entity/OrderProductVo.java
  10. 10 0
      src/main/java/com/caimei/modules/order/entity/ShopOrderVo.java
  11. 1 1
      src/main/java/com/caimei/modules/order/entity/SplitAccountPo.java
  12. 97 40
      src/main/java/com/caimei/modules/order/service/CmPayShopService.java
  13. 19 19
      src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java
  14. 23 19
      src/main/java/com/caimei/modules/order/service/NewOrderService.java
  15. 87 35
      src/main/java/com/caimei/modules/order/service/NewShopOrderService.java
  16. 256 288
      src/main/java/com/caimei/modules/order/service/SplitAccountService.java
  17. 133 75
      src/main/java/com/caimei/modules/order/web/CmPayShopController.java
  18. 57 17
      src/main/java/com/caimei/modules/order/web/CmShopOrderController.java
  19. 2 2
      src/main/java/com/caimei/modules/product/dao/CmOrganizeProductInfoMapper.java
  20. 2 0
      src/main/java/com/caimei/modules/product/dao/ProductDao.java
  21. 12 0
      src/main/java/com/caimei/modules/product/entity/CmOrganizeProductInfo.java
  22. 19 1
      src/main/java/com/caimei/modules/product/entity/CmSku.java
  23. 9 0
      src/main/java/com/caimei/modules/product/entity/Product.java
  24. 23 5
      src/main/java/com/caimei/modules/product/service/ProductService.java
  25. 11 4
      src/main/java/com/caimei/modules/product/web/ProductNewController.java
  26. 4 2
      src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml
  27. 1 0
      src/main/resources/mappings/modules/cmpage/CmPageCentreMapper.xml
  28. 1 1
      src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml
  29. 5 3
      src/main/resources/mappings/modules/order/CmPayShopMapper.xml
  30. 20 1
      src/main/resources/mappings/modules/order/CmReceiptOrderRelationMapper.xml
  31. 82 19
      src/main/resources/mappings/modules/order/OrderMapper.xml
  32. 15 2
      src/main/resources/mappings/modules/order/OrderProductMapper.xml
  33. 766 490
      src/main/resources/mappings/modules/order/ShopOrderMapper.xml
  34. 7 4
      src/main/resources/mappings/modules/product/CmOrganizeProductInfoMapper.xml
  35. 14 6
      src/main/resources/mappings/modules/product/CmPromotionMapper.xml
  36. 1 1
      src/main/resources/mappings/modules/product/CmSecondHandDetailMapper.xml
  37. 109 49
      src/main/resources/mappings/modules/product/ProductMapper.xml
  38. 8 2
      src/main/resources/mappings/modules/product/ProductNewMapper.xml
  39. 1 1
      src/main/resources/mappings/modules/product/RepeatPurchasePriceMapper.xml
  40. 1 1
      src/main/resources/mappings/modules/weisha/CmOrganizeProductMapper.xml
  41. 144 187
      src/main/webapp/WEB-INF/views/modules/order/checkPaymentOrder.jsp
  42. 2 2
      src/main/webapp/WEB-INF/views/modules/order/cmPayFormList.jsp
  43. 447 320
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopChange.jsp
  44. 123 14
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopChange1.jsp
  45. 5 5
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopCheck.jsp
  46. 264 227
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopDetail.jsp
  47. 119 78
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopEdit.jsp
  48. 91 57
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopForm.jsp
  49. 29 27
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopList.jsp
  50. 2 2
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherCheck.jsp
  51. 51 29
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherPrintDetail.jsp
  52. 26 12
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherPrintDetails.jsp
  53. 260 218
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopPrintDetail.jsp
  54. 1 1
      src/main/webapp/WEB-INF/views/modules/order/cmRefundRecordList.jsp
  55. 2 2
      src/main/webapp/WEB-INF/views/modules/order/cmRefundShopDetail.jsp
  56. 6 6
      src/main/webapp/WEB-INF/views/modules/order/cmRefundShopForm.jsp
  57. 2 2
      src/main/webapp/WEB-INF/views/modules/order/cmSettlementForm.jsp
  58. 24 22
      src/main/webapp/WEB-INF/views/modules/order/cmSettlementList.jsp
  59. 36 50
      src/main/webapp/WEB-INF/views/modules/order/cmSplitAccountList.jsp
  60. 1 1
      src/main/webapp/WEB-INF/views/modules/order/differencePriceForm.jsp
  61. 12 5
      src/main/webapp/WEB-INF/views/modules/order/newOrderList.jsp
  62. 24 24
      src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp
  63. 7 7
      src/main/webapp/WEB-INF/views/modules/order/paidShopOrderList.jsp
  64. 594 0
      src/main/webapp/WEB-INF/views/modules/order/payThirdParties.jsp
  65. 164 147
      src/main/webapp/WEB-INF/views/modules/order/refundRecord.jsp
  66. 129 91
      src/main/webapp/WEB-INF/views/modules/order/shopOtherFeeForm.jsp
  67. 262 92
      src/main/webapp/WEB-INF/views/modules/product-new/productEdit.jsp

+ 6 - 2
src/main/java/com/caimei/modules/order/dao/CmReceiptOrderRelationDao.java

@@ -26,9 +26,13 @@ public interface CmReceiptOrderRelationDao extends CrudDao<CmReceiptOrderRelatio
 
     Double findPayFeeByOrderID(@Param("orderID")String orderID);
 
+    Double findReceiptByShopOrderId(@Param("shopOrderId")String shopOrderId);
+
     List<Integer> toAudit(@Param("orderID")Integer orderID);
 
-    CmReceiptOrderRelation findOrderRelation(Integer orderID);
+    CmReceiptOrderRelation findOrderRelation(@Param("orderId") Integer orderId, @Param("shopOrderId") Integer shopOrderId);
+
+    Integer getDiscernPayWay(Integer orderID);
 
     Date findOnlinePayment(Integer orderID);
 
@@ -37,4 +41,4 @@ public interface CmReceiptOrderRelationDao extends CrudDao<CmReceiptOrderRelatio
     String findUserId(Integer orderId);
 
     List<CmReceiptOrderRelation> findByShopOrderIds(@Param("shopOrderIds")List<Integer> shopOrderIds);
-}
+}

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

@@ -203,9 +203,6 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
     List<OrderReceiptRelationPo> getUndividedPaidReceipt(@Param("currentTime")String currentTime,@Param("shopOrderIds")String shopOrderIds);
 
     List<OrderProductVo> getOrderProductByOrderId(Integer orderId);
-
-    Double getOrderProductPaidAmount(Integer orderProductId);
-
     ShopOrderVo getShopOrderListByOrderId(Integer shopOrderId);
 
     List<ShopOrderVo> getShopOrderByOrderId(Integer orderId);
@@ -268,7 +265,7 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
 
     List<SplitAccountPo> getSplitRecord(Integer orderID);
 
-    Integer getSplitTime(Integer shopOrderId);
+    Integer getSplitTime(String shopOrderId);
 
     /**
      * 查询用户模块重构-主订单
@@ -276,7 +273,7 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
      * @param orderID 用户模块重构-主订单主键
      * @return 用户模块重构-主订单
      */
-    public NewOrder getCmOrderByOrderID(String orderID);
+    NewOrder getCmOrderByOrderID(String orderID);
 
     /**
      * 查询用户模块重构-主订单Id
@@ -347,7 +344,7 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
      * @param orderIDs 需要删除的数据主键集合
      * @return 结果
      */
-    public int delCmOrderByOrderIDs(@Param("orderIDs") String[] orderIDs);
+    int delCmOrderByOrderIDs(@Param("orderIDs") String[] orderIDs);
 
     /**
      * 修改批量删除用户模块重构-主订单
@@ -355,5 +352,21 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
      * @param orderIDs 需要删除的数据主键集合
      * @return 结果
      */
-    public int updateDelCmOrderByOrderIDs(@Param("orderIDs") String[] orderIDs,@Param("delFlag") Integer delFlag);
+    int updateDelCmOrderByOrderIDs(@Param("orderIDs") String[] orderIDs,@Param("delFlag") Integer delFlag);
+
+    Double getPaidOrganizePrice(Integer shopOrderId);
+
+    String findSplitCodeByOrganize(Integer organizeId);
+
+    double findPayOther(Integer shopOrderId);
+
+    Double getShopOrderPaidAmount(Integer shopOrderId);
+
+    Double getOtherPaid(String shopOrderId);
+
+    Double findShopCost(String shopOrderId);
+
+    Double findPayOrganize(String shopOrderId);
+
+    String findOrganizeSplitByShopOrder(String shopOrderId);
 }

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

@@ -26,6 +26,8 @@ public interface NewShopOrderDao extends CrudDao<NewShopOrder> {
 
     NewShopOrder findByShopOrderID(@Param("shopOrderID") Integer shopOrderID);
 
+    Double findByPayShopID(@Param("shopOrderID") Integer shopOrderID);
+
     List<NewShopOrder> findListByOrderID(@Param("orderID") Integer orderID);
 
     List<String> findCommercialCode(@Param("orderID") Integer orderID);
@@ -46,6 +48,20 @@ public interface NewShopOrderDao extends CrudDao<NewShopOrder> {
 
     List<NewShopOrder> findPayOrderList(NewShopOrder shopOrder);
 
+    List<NewShopOrder> payThirdParties(NewShopOrder shopOrder);
+
+    List<NewShopOrder> findShopOrderList(NewShopOrder shopOrder);
+
+    Double payAmountByShopOrderId(Integer shopOrderId);
+
+    Double settleAmountByShopOrderId(Integer shopOrderId);
+
+    Double payShopAmountShopOrderId(Integer shopOrderId);
+
+    Double returnedPurchaseFeeByShopOrderId(Integer shopOrderId);
+
+    Integer findSplitCount(Integer shopOrderId);
+
     void updatePayShopAmount(NewShopOrder shopOrder);
 
     List<NewShopOrder> findByShopOrderIDs(@Param("shopOrderIDs") List<String> shopOrderIDs);

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

@@ -33,7 +33,7 @@ public class ChangePayShopDifference implements Serializable {
     private BigDecimal differencePrice;
 
     /**
-     * 差价类型:1 少付;2 多付
+     * 差价类型:1 成本上升;2 成本降低
      */
     private Integer type;
 

+ 13 - 0
src/main/java/com/caimei/modules/order/entity/ChangePayShopOther.java

@@ -11,6 +11,11 @@ import java.util.Date;
  * @date : 2021/5/26
  */
 public class ChangePayShopOther implements Serializable {
+
+    /**
+     * 1线下付第三方  2 线上付三方
+     */
+    private Integer payType;
     private Integer id;
     /**
      * 子订单Id
@@ -102,6 +107,14 @@ public class ChangePayShopOther implements Serializable {
         this.id = id;
     }
 
+    public Integer getPayType() {
+        return payType;
+    }
+
+    public void setPayType(Integer payType) {
+        this.payType = payType;
+    }
+
     public Integer getShopOrderId() {
         return shopOrderId;
     }

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

@@ -25,6 +25,7 @@ public class NewOrder extends DataEntity<NewOrder> {
     private Integer organizeStoreId;    // 组织门店id
     private Integer shopOrderID;        // varchar(100) comment '子订单ID',
     private String shopOrderIDs;        // varchar(100) comment '子订单ID',
+    private String shopOrderNoAndId;     // 子订单Id和子订单编号
     private String orderSubmitType;     // char(2) comment '订单提交类型',
     private String status;      // char(2) comment '订单状态'
     // v5.0.0新状态 '0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退'
@@ -422,6 +423,14 @@ public class NewOrder extends DataEntity<NewOrder> {
         this.userID = userID;
     }
 
+    public String getShopOrderNoAndId() {
+        return shopOrderNoAndId;
+    }
+
+    public void setShopOrderNoAndId(String shopOrderNoAndId) {
+        this.shopOrderNoAndId = shopOrderNoAndId;
+    }
+
     public String getShopOrderIDs() {
         return shopOrderIDs;
     }

+ 55 - 2
src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java

@@ -31,6 +31,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Double totalAmount;//     float comment '总价',
     private Double discount;//     decimal(20,6) comment '折扣',
     private Double discountPrice;//     decimal(20,6) comment '折后单价',
+    private Double oldDiscountPrice;//     decimal(20,6) comment '折后单价',
     private String includedTax;//   char(2) comment '是否含税 0不含税 1含税 2未知',
     private String invoiceType;//   char(2) comment '发票类型 1增值税专用发票 2增值税普通发票 3不开发票',
     private Double taxRate;//     decimal(20,0) comment '税率',
@@ -45,6 +46,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Double singleOtherFee;//   decimal(20,6) comment '单个应付第三方金额',
     private Double singleCmFee;//   decimal(20,6) comment '单个应付采美金额',
     private Double shouldPayFee;//   decimal(20,6) comment '应付金额',
+    private Double brokerage;   // 利润
     //private String commentFlag;//        national char(1) comment '是否已评论:1是,空或0未评论',
 //    private Double price0;//   float(10,2),
 //    private Double price1;//   float comment '普通会员价',
@@ -75,7 +77,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Integer orderPromotionsId; //` INT(11) NULL   COMMENT '订单促销id
     private String image; // 商品图片
     private Double discountFee; //协销订单:经理折扣(平摊到每个商品上,  按照每种商品的总价占订单总价的比例来均分);普通订单 无'
-    private String productUnit;
+    private String productUnit; // sku规格
     private String productImage;
     private String shopFee1; // 单个应付供应商金额
     private String otherFee1; // 单个应付第三方金额
@@ -87,6 +89,8 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Integer deliveryNum; // 发货数量
     private Integer outStoreTimes;  // 发货批次
     private Double costPrice; // 成本价(快照商品成本价格)
+    private Double organizeCostPrice; // 集团成本价
+    private Double cmCostPrice; // 采美成本价
     private Integer stock; // 库存
     private Integer status; // 状态
     private String logisticsBatchID; // 发货批次ID
@@ -94,7 +98,9 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private List<NewCmFinanceReceipts> newCmFinanceReceiptsList; //订单商品id对应一个进账记录  订单id对应多个
     private String splitFlag;//订单商品是否可拆分   1可拆分(不可以进账确认) 0不可拆分----统计子订单中的
     private String costCheckFlag; //成本价选中标志:1固定成本 2比例成
-    private Double shopPercent;//比例成本百分比
+    private Double shopPercent;//供应商成本百分比
+    private Double organizePercent;//集团百分比
+    private Double cmPercent;//采美百分比
     private Integer heUserId; //分销者id(呵呵商城订单使用)
     private String heUserName; //分销者名称
     private List<CmProductSn> cmProductSnList; //(重光电/轻光电)SN码
@@ -335,6 +341,14 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.discountPrice = discountPrice;
     }
 
+    public Double getOldDiscountPrice() {
+        return oldDiscountPrice;
+    }
+
+    public void setOldDiscountPrice(Double oldDiscountPrice) {
+        this.oldDiscountPrice = oldDiscountPrice;
+    }
+
     public Double getTaxRate() {
         return taxRate;
     }
@@ -415,6 +429,13 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.shouldPayFee = shouldPayFee;
     }
 
+    public Double getBrokerage() {
+        return brokerage;
+    }
+
+    public void setBrokerage(Double brokerage) {
+        this.brokerage = brokerage;
+    }
 //    public String getCommentFlag() {
 //        return commentFlag;
 //    }
@@ -634,6 +655,22 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.costPrice = costPrice;
     }
 
+    public Double getOrganizeCostPrice() {
+        return organizeCostPrice;
+    }
+
+    public void setOrganizeCostPrice(Double organizeCostPrice) {
+        this.organizeCostPrice = organizeCostPrice;
+    }
+
+    public Double getCmCostPrice() {
+        return cmCostPrice;
+    }
+
+    public void setCmCostPrice(Double cmCostPrice) {
+        this.cmCostPrice = cmCostPrice;
+    }
+
     @Transient
     public Integer getStock() {
         return stock;
@@ -767,6 +804,22 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.shopPercent = shopPercent;
     }
 
+    public Double getOrganizePercent() {
+        return organizePercent;
+    }
+
+    public void setOrganizePercent(Double organizePercent) {
+        this.organizePercent = organizePercent;
+    }
+
+    public Double getCmPercent() {
+        return cmPercent;
+    }
+
+    public void setCmPercent(Double cmPercent) {
+        this.cmPercent = cmPercent;
+    }
+
     public List<CmProductSn> getCmProductSnList() {
         return cmProductSnList;
     }

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

@@ -50,6 +50,7 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private Double eachDiscount;        // 分摊优惠金额
     private Double receiptAmount;       // 已付金额
     private Double restAmount;      // 待付金额
+    private Double payShopAmount;   // 已付金额 -- 付供应商
     private Integer shopReceiptStatus;      // 子订单收款状态:1待收款,2部分收款,3已收款
     private String splitCode;   // 分账号
     private Double canRefundAmount;//   float comment '退款金额',
@@ -67,12 +68,17 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private Double freePostageFee;//    decimal(10,2) comment '订单包邮时本该支付的运费',
     private String associationType;//订单关联方式: 1手动 2自动
     private String confirmType;    // 收款确认类型(1 小额抹平确认,2 大额抹平确认,3 大额退款余额,4 确认关联)
+    private String confirmTime;    // 订单确认时间
     private boolean receiptOrderFlag;// 判断订单中抹平的订单是否是和多个订单一起支付的,
     private Double orderReceivedAmount;//订单已收金额(此收款只计算线上线下收款记录payableAmount表金额)
     private Double returnBalanceAmount;// 退款余额金额
+    private Double allServeAmount;   // 总平台服务费
 
 
 
+    private String rebateOrder;  //是不是返佣订单 是的1,  不是的0
+    private Integer splitCount; //分账记录数
+    private Integer settleRecordNum;   //佣金结算数量
     private Integer isColdChina;//    是否包含冷链费 0不包含 1包含
     private Integer freePostageTicketID;//  int(11) comment '使用的包邮券Id,为空表示未使用包邮券',
     private Double brokerage;//        decimal(11,2) comment '佣金',
@@ -105,6 +111,7 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private Integer userBeans; //订单采美豆数量
     private Double svipShopReduction;   //超级会员优惠
     private Integer settleStatus;    //结算状态   1未结算2部分结算3已结算
+    private Double settleAmount;    // 结算金额
     private Integer payWay; //线上支付状态 1线上 2线下 3余额抵扣
     //-------------        虚拟字段   ----------------------------
     private Double income;       //主订单总佣金
@@ -282,6 +289,13 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.settleStatus = settleStatus;
     }
 
+    public Double getSettleAmount() {
+        return settleAmount;
+    }
+
+    public void setSettleAmount(Double settleAmount) {
+        this.settleAmount = settleAmount;
+    }
 
     public Integer getPayWay() {
         return payWay;
@@ -338,6 +352,31 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     public void setPromotionFullReduction(Double promotionFullReduction) {
         this.promotionFullReduction = promotionFullReduction;
     }
+
+    public String getRebateOrder() {
+        return rebateOrder;
+    }
+
+    public void setRebateOrder(String rebateOrder) {
+        this.rebateOrder = rebateOrder;
+    }
+
+    public Integer getSplitCount() {
+        return splitCount;
+    }
+
+    public void setSplitCount(Integer splitCount) {
+        this.splitCount = splitCount;
+    }
+
+    public Integer getSettleRecordNum() {
+        return settleRecordNum;
+    }
+
+    public void setSettleRecordNum(Integer settleRecordNum) {
+        this.settleRecordNum = settleRecordNum;
+    }
+
     public Integer getIsColdChina() {
         return isColdChina;
     }
@@ -641,6 +680,14 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.confirmType = confirmType;
     }
 
+    public String getConfirmTime() {
+        return confirmTime;
+    }
+
+    public void setConfirmTime(String confirmTime) {
+        this.confirmTime = confirmTime;
+    }
+
     public boolean isReceiptOrderFlag() {
         return receiptOrderFlag;
     }
@@ -665,6 +712,14 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.returnBalanceAmount = returnBalanceAmount;
     }
 
+    public Double getAllServeAmount() {
+        return allServeAmount;
+    }
+
+    public void setAllServeAmount(Double allServeAmount) {
+        this.allServeAmount = allServeAmount;
+    }
+
     public Integer getFreePostageTicketID() {
         return freePostageTicketID;
     }
@@ -1397,6 +1452,14 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.restAmount = restAmount;
     }
 
+    public Double getPayShopAmount() {
+        return payShopAmount;
+    }
+
+    public void setPayShopAmount(Double payShopAmount) {
+        this.payShopAmount = payShopAmount;
+    }
+
     public Integer getShopReceiptStatus() {
         return shopReceiptStatus;
     }

+ 11 - 1
src/main/java/com/caimei/modules/order/entity/OrderProductVo.java

@@ -15,6 +15,8 @@ import java.math.BigDecimal;
 @Data
 public class OrderProductVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Integer organizeId;
     /**
      * 商品分账商户号
      */
@@ -52,7 +54,15 @@ public class OrderProductVo implements Serializable {
      */
     private Integer costCheckFlag;
     /**
-     * 成本价
+     * 集团/组织固定成本
+     */
+    private Double organizeCostPrice;
+    /**
+     * 平台服务费,采美固定成本
+     */
+    private Double cmCostPrice;
+    /**
+     * 供应商成本价,商品成本
      */
     private Double costPrice;
     /**

+ 10 - 0
src/main/java/com/caimei/modules/order/entity/ShopOrderVo.java

@@ -13,6 +13,8 @@ import java.util.List;
  */
 public class ShopOrderVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Integer organizeId;
     /**
      * 子订单ID
      */
@@ -194,6 +196,14 @@ public class ShopOrderVo implements Serializable {
      */
     private String splitCode;
 
+    public Integer getOrganizeId() {
+        return organizeId;
+    }
+
+    public void setOrganizeId(Integer organizeId) {
+        this.organizeId = organizeId;
+    }
+
     public String getSplitCode() {
         return splitCode;
     }

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

@@ -71,7 +71,7 @@ public class SplitAccountPo implements Serializable {
      */
     private Integer payStatus;
     /**
-     * 商品类型:1商品成本,2供应商运费,3佣金,4二手发布
+     * 商品类型:1商品成本,2供应商运费,3佣金,4二手发布,5组织佣金
      */
     private Integer productType;
     /**

+ 97 - 40
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -15,10 +15,8 @@ import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.user.dao.NewCmShopDao;
 import com.caimei.modules.user.entity.NewCmShop;
-import com.caimei.redis.RedisService;
 import com.caimei.utils.MathUtil;
 import com.caimei.utils.StringUtil;
-import com.opensymphony.module.sitemesh.html.CustomTag;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
@@ -32,8 +30,6 @@ 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.text.SimpleDateFormat;
 import java.util.*;
@@ -75,8 +71,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
     private HeHeNewOrderDao heHeNewOrderDao;
     @Resource
     private CmRefundShopDao cmRefundShopDao;
-    @Resource
-    private RedisService redisService;
 
 
     public List<CmPayShop> exports(Page<CmPayShop> cmPayShopPage, CmPayShop cmPayShop) {
@@ -231,6 +225,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 } else if (so.getDifferenceType() != null && so.getDifferenceType() == 2) {
                     totalAmount = MathUtil.sub(totalAmount, so.getDifferencePrice()).doubleValue();
                 }
+                // 子订单已收金额
+                Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+                so.setReceiptAmount(receiptAmount);
+                totalAmount -= so.getShopOtherFee();
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
                 /*
                  1. 若发生退货,数量要减去已退货和已取消的数量
@@ -238,11 +236,31 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                  */
 
                 Integer returnNum = 0;
+                // 平台服务费
+                Double allServeAmount = 0d;
+                Double brokerage = 0d;
                 for (NewOrderProduct p : orderProductList) {
                     returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                     returnNum = returnNum == null ? 0 : returnNum;
                     p.setReturnedNum(returnNum);
+                    // 还原下单时商品成本
+                    /*Double newCostPrice = 0d;
+                    newCostPrice = p.getCostPrice();
+                    p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100),100)).doubleValue());
+                    p.setNewCostPrice(newCostPrice);*/
+
+                    p.setOldDiscountPrice(p.getDiscountPrice());
+                    if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                        p.setDiscountPrice(MathUtil.div(p.getDiscountPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+                    }
+                    // 付采美总金额
+                    allServeAmount = MathUtil.add(allServeAmount, MathUtil.mul(p.getNum(), p.getCmCostPrice())).doubleValue();
+                    // 子订单利润
+
+                    brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(),p.getNum())).doubleValue();
                 }
+                so.setBrokerage(brokerage);
+                so.setAllServeAmount(allServeAmount);
                 so.setNewOrderProducts(orderProductList);
                 so.setWaitPayShop((so.getShouldPayShopAmount() == null ? 0D : so.getShouldPayShopAmount()) - (so.getPayedShopAmount() == null ? 0D : so.getPayedShopAmount()));
                 if (so.getDifferenceType() != null && so.getDifferenceType() == 1) {
@@ -288,12 +306,12 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 List<Product> product = cmPayShopDao.priceNum(so.getOrderNo());
                 // 计算订单总佣金
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
-                if(returnNum != null) {
-                    if(product != null) {
+                if (returnNum != null) {
+                    if (product != null) {
                         for (Product pro : product) {
                             Integer number = newOrderProductDao.CountReturnedPurchaseProduct(pro.getShopOrderID(), pro.getOrderProductID());
                             Double commission = 0.0;
-                            if(number != null && number != 0) {
+                            if (number != null && number != 0) {
                                 if (pro.getTaxRate() != null && pro.getTaxRate() != 0) {
                                     commission = (pro.getPrice() + pro.getPrice() * (pro.getTaxRate() / 100)) - (Double.parseDouble(pro.getCostPrice()) + Double.parseDouble(pro.getCostPrice()) * (pro.getTaxRate() / 100));
                                 } else {
@@ -310,20 +328,19 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 }
                 //若成本下降太多导致部分收款的钱,已经大于成本重新计算佣金
                 if ("0".equals(newOrder.getOnlinePayFlag()) && so.getShopReceiptStatus() == 2) {
-                    double mum = so.getProductAmount();
+                    // double mum = so.getProductAmount();
                     System.out.println(so.getReceiptTotalFee());
                     System.out.println(so.getShouldPayShopAmount());
                     BigDecimal getShouldPayShopAmount = MathUtil.sub(so.getShouldPayShopAmount(), so.getDifferencePrice());
-                    if (so.getReceiptTotalFee() > Double.valueOf(getShouldPayShopAmount.toString())) {
+                    /*if (so.getReceiptTotalFee() > Double.valueOf(getShouldPayShopAmount.toString())) {
                         //子订单佣金
-
                         mum -= so.getShopOtherFee() + Double.valueOf(getShouldPayShopAmount.toString());
                         // 子订单佣金减供应商运费
-                        mum -= so.getShopPostFee();
+                        mum -= null == so.getShopPostFee()?0:so.getShopPostFee();
                         so.setBrokerage(mum);
                     } else {
                         so.setBrokerage(null);
-                    }
+                    }*/
                 } else {
                     so.setBrokerage(null);
                 }
@@ -373,14 +390,33 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 } else {
                     so.setWaitPayShop(cmPayShopRecord.getPayAmount());
                 }
+                // 子订单已收金额
+                Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+                so.setReceiptAmount(receiptAmount);
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
                 /* 退货数量 */
                 Integer count = 0;
+                Double allServeAmount = 0d;
+                Double brokerage = 0d;
                 for (NewOrderProduct p : orderProductList) {
                     count = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                     count = count == null ? 0 : count;
                     p.setReturnedNum(count);
+                    // 还原下单时商品成本
+                    /*Double newCostPrice = 0d;
+                    newCostPrice = p.getCostPrice();
+                    p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100),100)).doubleValue());
+                    p.setNewCostPrice(newCostPrice);*/
+                    p.setOldDiscountPrice(p.getDiscountPrice());
+                    if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                        p.setDiscountPrice(MathUtil.div(p.getDiscountPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+                    }
+                    // 付采美总金额
+                    allServeAmount = MathUtil.add(allServeAmount, MathUtil.mul(p.getNum(), p.getCmCostPrice())).doubleValue();
+                    brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(),p.getNum())).doubleValue();
                 }
+                so.setBrokerage(brokerage);
+                so.setAllServeAmount(allServeAmount);
                 if (so.getShopPostFee() == null) so.setShopPostFee(0D);
                 if (so.getShopTaxFee() == null) so.setShopTaxFee(0D);
                 if (so.getShopOtherFee() == null) so.setShopOtherFee(0D);
@@ -426,11 +462,11 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 List<Product> product = cmPayShopDao.priceNum(so.getOrderNo());
                 // 计算佣金
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
-                if(count != 0) {
-                    for(Product pro: product) {
+                if (count != 0) {
+                    for (Product pro : product) {
                         Double commission = pro.getPrice() - Double.parseDouble(pro.getCostPrice());
                         Integer number = newOrderProductDao.CountReturnedPurchaseProduct(pro.getShopOrderID(), pro.getOrderProductID());
-                        if(number != null && number != 0) {
+                        if (number != null && number != 0) {
                             if (pro.getTaxRate() != null && pro.getTaxRate() != 0) {
                                 commission = (pro.getPrice() + pro.getPrice() * (pro.getTaxRate() / 100)) - (Double.parseDouble(pro.getCostPrice()) + Double.parseDouble(pro.getCostPrice()) * (pro.getTaxRate() / 100));
                             } else {
@@ -946,6 +982,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
 
     @Transactional(readOnly = false)
     public void saveShopOtherFee(ChangePayShopOther payShopOther) {
+        /**
+         * payType = 2为线上付第三方,创建付款单,无付款银行,开户行,帐号
+         * 生成的记录,审核人/审核时间/审核状态,分别置为:系统自动/同申请时间/审核通过
+         */
         String[] remarkImages = payShopOther.getRemarkImages();
         if (remarkImages != null && remarkImages.length > 0) {
             StringBuilder remarkImage = new StringBuilder();
@@ -967,17 +1007,25 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         CmPayShop payShop = new CmPayShop();
         payShop.setShopID(shopOrder.getShopID().toString());
         payShop.setName(payShopOther.getName());
-        payShop.setBankAccountName(payShopOther.getBankAccountName());
-        payShop.setBankAccount(payShopOther.getBankAccount());
-        payShop.setBankName(payShopOther.getBankName());
-        payShop.setType(payShopOther.getType().toString());
+        String status = "0";
+        if (null != payShopOther.getPayType() && 2 == payShopOther.getPayType()) {
+            String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+            payShop.setApplyTime(format);
+            payShop.setReviewTime(format);
+            status = "1";
+        } else {
+            payShop.setBankAccountName(payShopOther.getBankAccountName());
+            payShop.setBankAccount(payShopOther.getBankAccount());
+            payShop.setBankName(payShopOther.getBankName());
+            payShop.setType(payShopOther.getType().toString());
+        }
         payShop.setTotalAmount(payShopOther.getShopOtherFee().doubleValue());
         payShop.setBalancePayFee(0d);
         payShop.setTransferPayFee(payShopOther.getShopOtherFee().doubleValue());
         payShop.setWipePayment(0d);
         payShop.setApplicant(currentUser.getId());
         payShop.setApplyTime(time);
-        payShop.setStatus("0");
+        payShop.setStatus(status);
         payShop.setDelFlag("0");
         if (payShopOther.getPayShopId() == null) {
             cmPayShopDao.insert(payShop);
@@ -994,7 +1042,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         payShopRecord.setWipePayment(0d);
         payShopRecord.setPaymentType(3);
         payShopRecord.setPayShopID(payShop.getId());
-        payShopRecord.setStatus("0");
+        payShopRecord.setStatus(status);
         payShopRecord.setDelFlag("0");
         if (payShopOther.getPayShopId() == null) {
             cmPayShopRecordDao.insert(payShopRecord);
@@ -1012,7 +1060,8 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         BigDecimal waitPayShop = BigDecimal.ZERO;
         if (shopOrder != null) {
             payShopDifference.setPayStatus(shopOrder.getPayStatus());
-            waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getDifferencePrice());
+            Double paShopAmount = newShopOrderDao.findByPayShopID(shopOrderId);
+            waitPayShop = MathUtil.sub(MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getDifferencePrice()), paShopAmount);
             NewCmShop shop = newCmShopDao.get(shopOrder.getShopID().toString());
             payShopDifference.setBankAccount(shop.getBankAccount());
             payShopDifference.setBankAccountName(shop.getBankAccountName());
@@ -1110,7 +1159,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
 //       List<Integer> payWay= newShopOrderDao.payWay(shopOrderId);
 //       if(payWay==1 && shopOrder.getShopReceiptStatus()==2) {
         if (payShopDifference.getType() == 2 && MathUtil.compare(differencePrice, waitPayShop) > 0) {
-            //多付且差价大于待付金额,会发生供应商退款操作
+            //成本降低且差价大于待付金额,会发生供应商退款操作
             BigDecimal waitRefund = MathUtil.sub(differencePrice, waitPayShop);
             String refundWay = payShopDifference.getRefundWay();
             BigDecimal refundAmount = payShopDifference.getRefundAmount();
@@ -1288,18 +1337,28 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
     }
 
     @Transactional(readOnly = false, rollbackFor = Exception.class)
-    public void settlement(String shopOrderId, Double settleAmount) throws Exception {
+    public void settlement(String shopOrderId) throws Exception {
         // 结算付供应商
         String format = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
         String substring = format.substring(20);
         String P3_customerNumber = newOrderDao.findSplitCode(shopOrderId);
-        redisService.set("SDJSS", 1, 120L);
-        settleOrder("JSCB" + shopOrderId + substring, settleAmount, P3_customerNumber, shopOrderId, 1);
+        Double shopCost = newOrderDao.findShopCost(shopOrderId);
+        settleOrder("JSCB" + shopOrderId + substring, shopCost, P3_customerNumber, shopOrderId, 1);
         // 结算佣金 佣金目前分到网络
         Double payAmount = newOrderDao.findPayAmount(shopOrderId);
         if (null != payAmount && payAmount > 0) {
             settleOrder("JSYJ" + shopOrderId + substring, payAmount, Constant.CUSTOMERNUM2, shopOrderId, 2);
         }
+        // 有组织佣金/付第三方的情况下,还需要结算组织佣金,付第三方
+        Double payOrganize = newOrderDao.findPayOrganize(shopOrderId);
+        if (null != payOrganize && payOrganize > 0) {
+            String split = newOrderDao.findOrganizeSplitByShopOrder(shopOrderId);
+            settleOrder("JSZZ" + shopOrderId + substring, payOrganize, split, shopOrderId, 3);
+        }
+        Double payOther = newOrderDao.getOtherPaid(shopOrderId);
+        if (null != payOther && payOther > 0) {
+            settleOrder("JSDSF" + shopOrderId + substring, payOther, Constant.CUSTOMERNUM3, shopOrderId, 4);
+        }
     }
 
     @Transactional(readOnly = false, rollbackFor = Exception.class)
@@ -1343,16 +1402,16 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     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);
-                    }
+//                    //计算供应商成本,结算金额,修改结算状态
+//                    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);
@@ -1363,8 +1422,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     // 修改cm_split_account settlestatus
                     newOrderDao.updateSettleStatus(shopOrderId, 3);
                 }
-                //解锁
-                redisService.remove("SDJSS");
             }
         }
     }

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

@@ -665,25 +665,25 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                     userBeans = userBeans - num;
                     cmUserDao.updateUserBeans(newOrder.getUserID(), userBeans);
                 }
-                //订单低于1000扣500豆子退回
-                if (newOrder.getPayTotalFee() != null && newOrder.getPayTotalFee() < 1000) {
-                    //查本单是否扣豆子,有就返回
-                    UserBeansHistory bean = newCmClubDao.findLowOrder(newOrder.getOrderID());
-                    if (bean != null) {
-                        //有扣豆子记录
-                        UserBeansHistory beanHistory = new UserBeansHistory();
-                        beanHistory.setUserId(newOrder.getUserID());
-                        beanHistory.setOrderId(newOrder.getOrderID());
-                        beanHistory.setBeansType(16);
-                        beanHistory.setType(1);
-                        beanHistory.setNum(500);
-                        beanHistory.setPushStatus(0);
-                        beanHistory.setAddTime(new Date());
-                        newCmClubDao.insertBeansHistory(beanHistory);
-                        int beans = cmUserDao.findUserBeans(newOrder.getUserID()) + 500;
-                        cmUserDao.updateUserBeans(newOrder.getUserID(), beans);
-                    }
-                }
+//                //订单低于1000扣500豆子退回
+//                if (newOrder.getPayTotalFee() != null && newOrder.getPayTotalFee() < 1000) {
+//                    //查本单是否扣豆子,有就返回
+//                    UserBeansHistory bean = newCmClubDao.findLowOrder(newOrder.getOrderID());
+//                    if (bean != null) {
+//                        //有扣豆子记录
+//                        UserBeansHistory beanHistory = new UserBeansHistory();
+//                        beanHistory.setUserId(newOrder.getUserID());
+//                        beanHistory.setOrderId(newOrder.getOrderID());
+//                        beanHistory.setBeansType(16);
+//                        beanHistory.setType(1);
+//                        beanHistory.setNum(500);
+//                        beanHistory.setPushStatus(0);
+//                        beanHistory.setAddTime(new Date());
+//                        newCmClubDao.insertBeansHistory(beanHistory);
+//                        int beans = cmUserDao.findUserBeans(newOrder.getUserID()) + 500;
+//                        cmUserDao.updateUserBeans(newOrder.getUserID(), beans);
+//                    }
+//                }
             }
             //优惠券退回
             CmCouponOrderRecord couponOrderRecord = newOrder.getCouponOrderRecord();

+ 23 - 19
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -1633,7 +1633,6 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
 
         order.getNewShopOrders().get(0).setStatus(1);//已确认
 
-
 //        //修改订单状态(余额抵扣)
 //        if (order.getPayableAmount() != null) {
 //            if (order.getPayableAmount() == 0 && order.getBalancePayFee() != null && order.getBalancePayFee() > 0) {
@@ -1660,6 +1659,8 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         String curDateStr = sdf.format(date);
         order.setConfirmTime(curDateStr);
 
+        // 订单确认时间
+        order.getNewShopOrders().get(0).setConfirmTime(curDateStr);
 //        if (order.getBalancePayFee() != null && order.getBalancePayFee() > 0) {
         if (balancePayFee != null && balancePayFee > 0) {
             //已付金额
@@ -1772,24 +1773,24 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
             cmUserDao.updateUserBeans(order.getUserID(), userBeans);
         }
 
-        if (order.getPayTotalFee() != null && order.getPayTotalFee() < 1000) {
-            //查本单是否扣豆子,有就返回
-            UserBeansHistory bean = newCmClubDao.findLowOrder(order.getOrderID());
-            if (bean != null) {
-                //有扣豆子记录
-                UserBeansHistory beansHistory = new UserBeansHistory();
-                beansHistory.setUserId(order.getUserID());
-                beansHistory.setOrderId(order.getOrderID());
-                beansHistory.setBeansType(16);
-                beansHistory.setType(1);
-                beansHistory.setNum(500);
-                beansHistory.setPushStatus(0);
-                beansHistory.setAddTime(new Date());
-                newCmClubDao.insertBeansHistory(beansHistory);
-                int beans = cmUserDao.findUserBeans(order.getUserID()) + 500;
-                cmUserDao.updateUserBeans(order.getUserID(), beans);
-            }
-        }
+//        if (order.getPayTotalFee() != null && order.getPayTotalFee() < 1000) {
+//            //查本单是否扣豆子,有就返回
+//            UserBeansHistory bean = newCmClubDao.findLowOrder(order.getOrderID());
+//            if (bean != null) {
+//                //有扣豆子记录
+//                UserBeansHistory beansHistory = new UserBeansHistory();
+//                beansHistory.setUserId(order.getUserID());
+//                beansHistory.setOrderId(order.getOrderID());
+//                beansHistory.setBeansType(16);
+//                beansHistory.setType(1);
+//                beansHistory.setNum(500);
+//                beansHistory.setPushStatus(0);
+//                beansHistory.setAddTime(new Date());
+//                newCmClubDao.insertBeansHistory(beansHistory);
+//                int beans = cmUserDao.findUserBeans(order.getUserID()) + 500;
+//                cmUserDao.updateUserBeans(order.getUserID(), beans);
+//            }
+//        }
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String current = dateFormat.format(new Date());
         MessageCenter messageCenter = new MessageCenter();
@@ -2395,6 +2396,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 order.setShopName(shopOrders.get(0).getShopName());
             }
             int count = 0;
+            String shopOrderNoAndId = "";
             for (NewShopOrder shopOrder : order.getNewShopOrders()) {
                 shopOrder.setOrderID(order.getOrderID());
                 shopOrder.setOrderNo(order.getOrderNo());
@@ -2411,6 +2413,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 //通过子订单ID查询子订单信息
                 NewShopOrder newShopOrder = newShopOrderDao.get(String.valueOf(shopOrderID));
                 if (null != newShopOrder) {
+                    shopOrderNoAndId += "<b style=\"font-size: 17px;\">"+newShopOrder.getShopOrderID()+"</b>"+"("+newShopOrder.getShopOrderNo()+")<br>";
                     shopOrder.setFee(newShopOrder.getFee());
                     shopOrder.setShouldPayProduct(newShopOrder.getShouldPayProduct());
                     List<NewOrderProduct> pList = newOrderProductDao.findListByShopOrderID(shopOrderID);
@@ -2425,6 +2428,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                     shopOrder.setShouldPayProduct(0d);
                 }
             }
+            order.setShopOrderNoAndId(shopOrderNoAndId);
             //一个子订单只有一个商品时,不可拆分
             if (order.getProductCount() == null) {
                 order.setProductCount(1);

+ 87 - 35
src/main/java/com/caimei/modules/order/service/NewShopOrderService.java

@@ -277,6 +277,20 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         return page;
     }
 
+
+    @Transactional(readOnly = false)
+    public Page<NewShopOrder> payThirdParties(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.payThirdParties(shopOrder);
+        page.setList(payOrderList);
+        setValue(payOrderList);
+        return page;
+    }
+
     public void setValue(List<NewShopOrder> payOrderList) {
         for (NewShopOrder so : payOrderList) {
             Integer onlineFlag = newOrderDao.findOnlinePay(so.getOrderID()) > 0 ? 1 : 0;
@@ -294,10 +308,41 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
             } else {
                 so.setReceiptStatus("1");
             }
+            // 主订单已收金额
             double receiptTotalFee = cmReceiptOrderRelationDao.findPayFeeByOrderID(so.getOrderID().toString());
-
             so.setReceiptTotalFee(receiptTotalFee);
-
+            // 子订单已收金额
+            Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+            so.setReceiptAmount(receiptAmount);
+            // 子订单已付金额
+            Double shopAmountShopOrderId = newShopOrderDao.payShopAmountShopOrderId(so.getShopOrderID());
+            so.setPayShopAmount(shopAmountShopOrderId);
+            // 已结金额
+            Double settleAmountByShopOrderId = newShopOrderDao.settleAmountByShopOrderId(so.getShopOrderID());
+            so.setSettleAmount(settleAmountByShopOrderId);
+            // 退款金额
+            Double returnedPurchaseFeeByShopOrderId = newShopOrderDao.returnedPurchaseFeeByShopOrderId(so.getShopOrderID());
+            so.setCanRefundAmount(returnedPurchaseFeeByShopOrderId);
+            //结算记录
+            List<SettleRecord> settleRecord = newShopOrderDao.findSettleRecord(so.getShopOrderID().toString());
+            Integer num = null == settleRecord ? 0 : settleRecord.size();
+            so.setSettleRecordNum(num);
+            //分账记录数
+            Integer splitCount = newShopOrderDao.findSplitCount(so.getShopOrderID());
+            so.setSplitCount(splitCount);
+            // 订单收款路径 线上、 线下
+            Integer discernPayWay = cmReceiptOrderRelationDao.getDiscernPayWay(so.getOrderID());
+            if (null != discernPayWay && 1 != discernPayWay) {
+                // 线下收款,结算金额设置为已付金额
+                so.setSettleAmount(shopAmountShopOrderId);
+                if ( so.getSettleAmount() > 0 && (MathUtil.sub(so.getShouldPayShopAmount(), so.getShopOtherFee()).doubleValue()) == so.getSettleAmount()) {
+                    so.setSettleStatus(3);
+                } else if(so.getSettleAmount() > 0 &&  (MathUtil.sub(so.getShouldPayShopAmount(), so.getShopOtherFee()).doubleValue()) > so.getSettleAmount()) {
+                    so.setSettleStatus(2);
+                } else {
+                    so.setSettleStatus(1);
+                }
+            }
             //第一次收款收款时间
             Date receiptDate = cmReceiptOrderRelationDao.findOnlinePayment(so.getOrderID());
             if (receiptDate != null) {
@@ -315,6 +360,15 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                 returnNum = returnNum == null ? 0 : returnNum;
                 p.setReturnedNum(returnNum);
+                // 还原下单时商品成本
+                /*Double newCostPrice = 0d;
+                newCostPrice = p.getCostPrice();
+                p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100),100)).doubleValue());
+                p.setNewCostPrice(newCostPrice);*/
+                p.setOldDiscountPrice(p.getDiscountPrice());
+                if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                    p.setDiscountPrice(MathUtil.div(p.getDiscountPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+                }
             }
             if (so.getShopPostFee() == null) so.setShopPostFee(0D);
             if (so.getShopTaxFee() == null) so.setShopTaxFee(0D);
@@ -434,16 +488,17 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         }
     }
 
-    public Page<NewOrder> findPaymentOrderList(Page<NewOrder> page, NewOrder newOrder) {
-        newOrder.setPage(page);
-        if (newOrder.getPayStatus() != null && newOrder.getPayStatus() != "") {
-            String[] split = newOrder.getPayStatus().split(",");
-            newOrder.setPs(split);
+    public Page<NewShopOrder> findPaymentOrderList(Page<NewShopOrder> page, NewShopOrder shopOrder) {
+        shopOrder.setPage(page);
+        if (StringUtils.isNotBlank(shopOrder.getPayStatus())) {
+            String[] split = shopOrder.getPayStatus().split(",");
+            shopOrder.setPs(split);
         }
-        List<NewOrder> orderList = newOrderDao.findOrderList(newOrder);
-        page.setList(orderList);
-
-        List<Integer> oId = orderList.stream().map(NewOrder::getOrderID).collect(Collectors.toList());
+        // List<NewOrder> orderList = newOrderDao.findOrderList(newOrder);
+        List<NewShopOrder> payOrderList = newShopOrderDao.findShopOrderList(shopOrder);
+        page.setList(payOrderList);
+        setValue(payOrderList);
+        /*List<Integer> oId = orderList.stream().map(NewOrder::getOrderID).collect(Collectors.toList());
         //看看这些订单有哪些是返佣订单 返回他们的orderID
         List<Integer> orderIds = null;
         if (CollectionUtils.isNotEmpty(oId)) {
@@ -509,7 +564,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 if (newShopOrder.getShopID() != 998) {
                     //统计子订单下的商品信息
                     List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(newShopOrder.getShopOrderID());
-                    /* 退货数量 */
+                     // 退货数量
                     for (NewOrderProduct p : orderProductList) {
                         Integer count = newOrderProductDao.CountReturnedPurchaseProduct(newShopOrder.getShopOrderID(), p.getOrderProductID());
                         p.setReturnedNum(count == null ? 0 : count);
@@ -518,6 +573,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                     list.add(newShopOrder);
                 }
             }
+            order.setShopOrderID(shopOrders.get(0).getShopOrderID());
             //退款(退货)总金额
             Double returnedPurchaseFee = cmReturnedPurchaseDao.refundTotalMoney(order.getOrderID());
             Double returnValue = 0d;   //退货价值
@@ -542,31 +598,27 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 String name = heHeNewOrderDao.findHeUser(order.getUserID());
                 order.setClubName(name);
             }
-        }
+        }*/
         return page;
     }
 
-    public NewOrder findRefundRecord(Integer orderID) {
-        NewOrder order = newOrderDao.get(orderID.toString());
-        CmReceiptOrderRelation receiptOrderRelations = cmReceiptOrderRelationDao.findOrderRelation(orderID);
+    public NewShopOrder findRefundRecord(Integer shopOrderId) {
+        // NewOrder order = newOrderDao.get(orderID.toString());
+        NewShopOrder shopOrder = newShopOrderDao.get(shopOrderId.toString());
+        CmReceiptOrderRelation receiptOrderRelations = cmReceiptOrderRelationDao.findOrderRelation(shopOrder.getOrderID(), shopOrderId);
         if (receiptOrderRelations != null && receiptOrderRelations.getRelationType().equals("1")) {
-            order.setRebateOrder("1");
-            order.setReceiptStatus("4");
-            order.setAlreadyReceipt("----");
-            order.setPayStatus("4");
-            order.setPaid("----");
+            shopOrder.setRebateOrder("1");
+            shopOrder.setReceiptStatus("4");
+            shopOrder.setAlreadyReceipt("----");
+            shopOrder.setPayStatus("4");
+            shopOrder.setPaid("----");
         } else {
-            order.setRebateOrder("0");
-            //统计该主订单的收款金额
-            Double receiptTotalFee = cmReceiptOrderRelationDao.findPayFeeByOrderID(orderID.toString());
-            if (receiptTotalFee == null) receiptTotalFee = 0d;
-            order.setAlreadyReceipt(String.valueOf(receiptTotalFee));
-            //统计该主订单的付款金额
-            Double paid = newOrderDao.findPaidOrderID(order.getOrderID());
-            if (paid == null) paid = 0d;
-            order.setPaid(String.valueOf(paid));
-        }
-        if (order.getTotalDiscount() == null) order.setTotalDiscount(0d);
+            shopOrder.setRebateOrder("0");
+        }
+        ArrayList<NewShopOrder> newShopOrders = new ArrayList<>();
+        newShopOrders.add(shopOrder);
+        setValue(newShopOrders);
+        /*if (order.getTotalDiscount() == null) order.setTotalDiscount(0d);
         List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(orderID);
         List<NewShopOrder> list = new ArrayList();
         //统计所有子订单付供应商金额之和
@@ -585,7 +637,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
             if (newShopOrder.getShopID() != 998) {
                 //统计子订单下的商品信息
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(newShopOrder.getShopOrderID());
-                /* 退货数量 */
+                // 退货数量
                 for (NewOrderProduct p : orderProductList) {
                     Integer count = newOrderProductDao.CountReturnedPurchaseProduct(newShopOrder.getShopOrderID(), p.getOrderProductID());
                     p.setReturnedNum(count == null ? 0 : count);
@@ -611,8 +663,8 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         returnedFreightFlag = returnedFreightNum == null ? false : returnedFreightNum > 0 ? true : false;
         order.setReturnedFreightFlag(returnedFreightFlag);
         order.setShouldPayShopAmount(shouldPayShopAmount);
-        order.setNewShopOrders(list);
-        return order;
+        order.setNewShopOrders(list);*/
+        return newShopOrders.get(0);
     }
 
     @Transactional(readOnly = false)

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

@@ -21,6 +21,8 @@ import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 
 @Service
@@ -40,344 +42,310 @@ public class SplitAccountService extends BaseService {
     private NewShopOrderDao newShopOrderDao;
 
     @Transactional(readOnly = false, rollbackFor = Exception.class)
-    public void SplitAccount(String shopOrderIds) {
+    public void SplitAccount(String[] shopOrderIds) {
         logger.info("【手动分账开始】>>>>>>>>>>手动分账");
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(new Date());
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String currentTime = format.format(calendar.getTime());
-        // 查询未分账已支付收款
-        List<OrderReceiptRelationPo> orderRelations = newOrderDao.getUndividedPaidReceipt(currentTime, shopOrderIds);
-        if (null != orderRelations && orderRelations.size() > 0) {
+        List<String> ids = new ArrayList<>();
+        ids = Arrays.stream(shopOrderIds).collect(Collectors.toList());
+
+        ids.forEach(i -> {
+            // 查询未分账已支付收款
+            List<OrderReceiptRelationPo> orderRelations = newOrderDao.getUndividedPaidReceipt(currentTime, i);
+            List<SplitAccountPo> splitBillDetail = new ArrayList<>();
+            AtomicReference<Double> costPrice = new AtomicReference<Double>(0d);
+            AtomicReference<Double> cmCostPrice = new AtomicReference<Double>(0d);
+            AtomicReference<Double> organizeCostPrice = new AtomicReference<Double>(0d);
+            AtomicReference<Double> total = new AtomicReference<Double>(0d);
+            // 收款对应的订单信息
+            ShopOrderVo shopOrder = newOrderDao.getShopOrderListByOrderId(Integer.valueOf(i));
             for (OrderReceiptRelationPo orderRelation : orderRelations) {
                 logger.info("【分账】>>>>>>>>>>子订单id:" + orderRelation.getShopOrderId() + "进入分账");
-                // 收款对应的订单信息
-                ShopOrderVo shopOrder = newOrderDao.getShopOrderListByOrderId(orderRelation.getShopOrderId());
-                PayParamBo payParam = new PayParamBo();
-                //支付金额
-                payParam.setAllPay(orderRelation.getAssociateAmount());
-                if (12 == orderRelation.getPayType()) {
-                    // 网银支付
-                    payParam.setPayWay("UNIONPAY");
-                }
-                if (17 == orderRelation.getPayType()) {
-                    //b2c网银
-                    payParam.setPayWay("B2C");
-                }
-                //微信0.65%手续费
-                if (8 == orderRelation.getPayType() || 13 == orderRelation.getPayType() || 15 == orderRelation.getPayType()) {
-                    payParam.setPayWay("WX");
+                setSplitAccountDetail(costPrice, organizeCostPrice, cmCostPrice, total, shopOrder, orderRelation);
+            }
+            if (MathUtil.compare(total, MathUtil.add(MathUtil.add(costPrice, cmCostPrice), organizeCostPrice)) <= 0) {
+                logger.info("收款总金额不足分帐------------->total: " + total.get()
+                        + "costPrice: " + costPrice.get() + "----------"
+                        + "cmCostPrice: " + cmCostPrice.get() + "-------------"
+                        + "organizeCostPrice: " + organizeCostPrice.get() + "---------------");
+                return;
+            }
+            /**
+             *   线上订单,付第三方如果不为0,需要从供应商成本中支付
+             */
+            double payOther = newOrderDao.findPayOther(Integer.valueOf(i));
+            if (MathUtil.compare(payOther, 0) > 0) {
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setSplitAccount(payOther);
+                splitAccount.setProductType(6);
+                splitAccount.setType(6);
+                splitAccount.setSubUserNo(Constant.CUSTOMERNUM3);
+                logger.info("付第三方分账参数------------->" + splitAccount);
+                splitBillDetail.add(splitAccount);
+                // 当前版本付第三方从供应商成本支出
+                costPrice.updateAndGet(v -> MathUtil.sub(v, payOther).doubleValue());
+            }
+            if (costPrice.get() > 0) {
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setSplitAccount(costPrice.get());
+                splitAccount.setProductType(1);
+                // 该商品设置了商户号
+                splitAccount.setType(4);
+                splitAccount.setSubUserNo(shopOrder.getSplitCode());
+                logger.info("成本分账参数------------->" + splitAccount.toString());
+                splitBillDetail.add(splitAccount);
+            }
+            /** 成本分完,金额未尽,有组织佣金的情况,优先组织佣金
+             *  当前版本,采美供应商上架丽格商城,会存在三成本均>0的情况
+             *  若无组织佣金,所有剩余金额归于采美佣金
+             */
+            if (organizeCostPrice.get() > 0) {
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setSplitAccount(organizeCostPrice.get());
+                splitAccount.setProductType(5);
+                // 该商品设置了商户号
+                splitAccount.setType(4);
+                String code = newOrderDao.findSplitCodeByOrganize(shopOrder.getOrganizeId());
+                if (StringUtils.isBlank(code)) {
+                    logger.info("组织的分帐号未空,无法分帐组织佣金!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+                    return;
                 }
-                //快捷支付 借记卡支付29,贷记卡支付30
-                if (29 == orderRelation.getPayType()) {
-                    payParam.setPayWay("DEBIT");
+                splitAccount.setSubUserNo(code);
+                logger.info("组织佣金分账参数------------->" + splitAccount.toString());
+                splitBillDetail.add(splitAccount);
+            }
+            /**  当前版本还要考虑分组织/集团佣金
+             *   如果还有钱则为佣金,分到网络
+             */
+            if (cmCostPrice.get() > 0) {
+                // 此处不考虑手续费,外部计算总额
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setSplitAccount(cmCostPrice.get());
+                splitAccount.setProductType(3);
+                splitAccount.setType(5);
+                splitAccount.setSubUserNo(Constant.CUSTOMERNUM2);
+                logger.info("佣金分账参数------------->" + splitAccount);
+                splitBillDetail.add(splitAccount);
+            }
+
+            HashMap<String, BigDecimal> sbm = new HashMap<>();
+            for (SplitAccountPo splitAccountPo : splitBillDetail) {
+                String subUserNo = splitAccountPo.getSubUserNo();
+                // 计算当前商户号总分账金额
+                if (sbm.containsKey(subUserNo)) {
+                    BigDecimal v = MathUtil.add(sbm.get(subUserNo), splitAccountPo.getSplitAccount());
+                    sbm.put(subUserNo, v);
+                } else {
+                    sbm.put(subUserNo, BigDecimal.valueOf(splitAccountPo.getSplitAccount()));
                 }
-                if (30 == orderRelation.getPayType()) {
-                    payParam.setPayWay("CREDIT");
+                // splitcode相同的收款的时候已经是成本已分帐
+                if (subUserNo.equals(shopOrder.getSplitCode())) {
+                    // 供应商自己收款,此部分金额留在自己商户号,作为成本分账
+                    splitAccountPo.setPayStatus(1);
+                    // 保存分账详情
+                    newOrderDao.insertSplitAccount(splitAccountPo);
                 }
-                List<SplitAccountPo> splitBillDetail = setSplitAccountDetail(shopOrder, payParam);
-                HashMap<String, BigDecimal> sbm = new HashMap<>();
-                for (SplitAccountPo splitAccountPo : splitBillDetail) {
-                    String subUserNo = splitAccountPo.getSubUserNo();
-                    // 计算当前商户号总分账金额
-                    if (sbm.containsKey(subUserNo)) {
-                        BigDecimal v = MathUtil.add(sbm.get(subUserNo), splitAccountPo.getSplitAccount());
-                        sbm.put(subUserNo, v);
-                    } else {
-                        sbm.put(subUserNo, BigDecimal.valueOf(splitAccountPo.getSplitAccount()));
-                    }
-                    // splitcode相同的收款的时候已经是成本已分帐
-                    if (subUserNo.equals(shopOrder.getSplitCode())) {
-                        splitAccountPo.setMbOrderId(orderRelation.getMbOrderId());
-                        splitAccountPo.setOrderRequestNo(orderRelation.getOrderRequestNo());
-                        // 供应商自己收款,此部分金额留在自己商户号,作为成本分账
-                        splitAccountPo.setPayStatus(1);
-                        // 保存分账详情
-                        newOrderDao.insertSplitAccount(splitAccountPo);
+            }
+            ArrayList<AccountPayOrder.AccountPayOrderExt.SplitBillRule> splitBillRules = new ArrayList<>();
+            sbm.forEach((key, value) -> {
+                /**
+                 *   不是自己的splitcode分走,是自己的不动
+                 *   把成本之外的金额加入splitRule分账参数,延续上面逻辑,供应商自己的成本由自己的商户号收款,
+                 *   自己成本部分不需要加入分账参数,仅需在else中做业务表参数处理
+                 */
+                if (!key.equals(shopOrder.getSplitCode())) {
+                    // 佣金
+                    AccountPayOrder.AccountPayOrderExt.SplitBillRule splitBillRule = new AccountPayOrder.AccountPayOrderExt.SplitBillRule();
+                    // 分账计算的时候未处理手续费,总额处理手续费   x + x * 0.1% = value
+                    BigDecimal div = MathUtil.div(value, 1.001, 2);
+                    if (MathUtil.sub(value, div).doubleValue() < 0.01) {
+                        // 如果手续费小于最低手续费,取0.01
+                        div = MathUtil.round(MathUtil.sub(value, 0.01), 2);
                     }
-                }
-                ArrayList<AccountPayOrder.AccountPayOrderExt.SplitBillRule> splitBillRules = new ArrayList<>();
-                sbm.forEach((key, value) -> {
-                    /**
-                     *   不是自己的splitcode分走,是自己的不动
-                     *   把成本之外的金额加入splitRule分账参数,延续上面逻辑,供应商自己的成本由自己的商户号收款,
-                     *   自己成本部分不需要加入分账参数,仅需在else中做业务表参数处理
-                     */
-                    if (!key.equals(shopOrder.getSplitCode())) {
-                        // 佣金
-                        AccountPayOrder.AccountPayOrderExt.SplitBillRule splitBillRule = new AccountPayOrder.AccountPayOrderExt.SplitBillRule();
-                        // 分账计算的时候未处理手续费,总额处理手续费   x + x * 0.1% = value
-                        BigDecimal div = MathUtil.div(value, 1.001, 2);
-                        if (MathUtil.sub(value, div).doubleValue() < 0.01) {
-                            // 如果手续费小于最低手续费,取0.01
-                            div = MathUtil.round(MathUtil.sub(value, 0.01), 2);
+                    splitBillRule.setSplitBillAmount(div);
+                    splitBillRule.setSplitBillMerchantNo(key);
+                    splitBillRules.add(splitBillRule);
+                } else {
+                    // 修改子订单付款状态及付款金额
+                    newOrderDao.updateShopOrderByPayStatus(Integer.valueOf(i), value.doubleValue(), shopOrder.getPayStatus());
+                    SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    String currentTime2 = format2.format(new Date());
+                    // 保存付款单表
+                    PayShopPo payShop = new PayShopPo();
+                    payShop.setShopId(shopOrder.getShopId());
+                    payShop.setName("线上支付分账");
+                    payShop.setTotalAmount(value.doubleValue());
+                    payShop.setWipePayment(0d);
+                    payShop.setPayType(6);
+                    payShop.setStatus(1);
+                    payShop.setDelFlag(0);
+                    payShop.setApplyTime(currentTime2);
+                    payShop.setReviewTime(currentTime2);
+                    payShop.setPayTime(currentTime2);
+                    newOrderDao.insertPayShop(payShop);
+                    // 保存 付供应商记录
+                    PayShopRecordPo shopRecord = new PayShopRecordPo();
+                    shopRecord.setShopId(shopOrder.getShopId());
+                    shopRecord.setShopOrderId(shopOrder.getShopOrderId());
+                    shopRecord.setShopOrderNo(shopOrder.getShopOrderNo());
+                    shopRecord.setPayAmount(value.doubleValue());
+                    shopRecord.setWipePayment(0d);
+                    shopRecord.setPayType(6);
+                    shopRecord.setPayTime(currentTime2);
+                    shopRecord.setPayShopId(payShop.getId());
+                    shopRecord.setStatus(1);
+                    shopRecord.setDelFlag(0);
+                    newOrderDao.insertPayShopRecord(shopRecord);
+                    // 子订单是否全部付款
+                    List<String> payStatus = newShopOrderDao.findPayStatusByOrderID(shopOrder.getOrderId());
+                    boolean isPay = true;
+                    for (String shops : payStatus) {
+                        if (!"3".equals(shops)) {
+                            isPay = false;
+                            break;
                         }
-                        splitBillRule.setSplitBillAmount(div);
-                        splitBillRule.setSplitBillMerchantNo(key);
-                        splitBillRules.add(splitBillRule);
+                    }
+                    // 修改主订单付款状态
+                    if (isPay) {
+                        newOrderDao.updateOrderByPayStatus(shopOrder.getOrderId(), 3);
                     } else {
-                        /**
-                         *  成本分账处理
-                         *  子订单的splitcode和分账对象的splitcode一样的是留在账户里的钱,实际在付款完成后,付款状态就为已付款,分账状态就为已分账
-                         *  为维持业务完整性,保持原来的分账流程不变
-                         */
-                        List<SplitAccountPo> splitAccountList = newOrderDao.getSplitAccountList(orderRelation.getMbOrderId());
-                        if (splitAccountList != null && splitAccountList.size() > 0) {
-                            Integer orderId = splitAccountList.get(0).getOrderId();
-                            List<ShopOrderVo> shopOrderList = newOrderDao.getShopOrderByOrderId(orderId);
-                            Integer shopOrderId = null;
-                            String shopOrderNo = "";
-                            for (SplitAccountPo account : splitAccountList) {
-                                // 本次付供应商金额(分账金额)
-                                Double splitAmount = account.getSplitAccount();
-                                orderId = account.getOrderId();
-                                Integer shopId = account.getShopId();
-                                for (ShopOrderVo shop : shopOrderList) {
-                                    if (shopId.equals(shop.getShopId())) {
-                                        shopOrderId = shop.getShopOrderId();
-                                        shopOrderNo = shop.getShopOrderNo();
-                                        // 已付供应商金额
-                                        Double paidAmount = newOrderDao.getPaidShopAmount(shopOrderId);
-                                        Double paidShop = MathUtil.add(paidAmount, splitAmount).doubleValue();
-                                        shopOrder.setPayedShopAmount(paidShop);
-                                        if (MathUtil.compare(shopOrder.getShouldPayShopAmount(), paidShop) == 0) {
-                                            shopOrder.setPayStatus(3);
-                                        } else {
-                                            shopOrder.setPayStatus(2);
-                                        }
-                                        // 修改子订单付款状态及付款金额
-                                        newOrderDao.updateShopOrderByPayStatus(shopOrderId, paidShop, shopOrder.getPayStatus());
-                                    }
-                                }
-                                SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                                String currentTime2 = format2.format(new Date());
-                                // 保存付款单表
-                                PayShopPo payShop = new PayShopPo();
-                                payShop.setShopId(shopId);
-                                payShop.setName("线上支付分账");
-                                payShop.setTotalAmount(splitAmount);
-                                payShop.setWipePayment(0d);
-                                payShop.setPayType(6);
-                                payShop.setStatus(1);
-                                payShop.setDelFlag(0);
-                                payShop.setApplyTime(currentTime2);
-                                payShop.setReviewTime(currentTime2);
-                                payShop.setPayTime(currentTime2);
-                                newOrderDao.insertPayShop(payShop);
-                                // 保存 付供应商记录
-                                PayShopRecordPo shopRecord = new PayShopRecordPo();
-                                shopRecord.setShopId(shopId);
-                                shopRecord.setShopOrderId(shopOrderId);
-                                shopRecord.setShopOrderNo(shopOrderNo);
-                                shopRecord.setPayAmount(splitAmount);
-                                shopRecord.setWipePayment(0d);
-                                shopRecord.setPayType(6);
-                                shopRecord.setPayTime(currentTime2);
-                                shopRecord.setPayShopId(payShop.getId());
-                                shopRecord.setStatus(1);
-                                shopRecord.setDelFlag(0);
-                                newOrderDao.insertPayShopRecord(shopRecord);
-                            }
-                            // 子订单是否全部付款
-                            List<String> payStatus = newShopOrderDao.findPayStatusByOrderID(orderRelation.getOrderId());
-                            boolean isPay = true;
-                            for (String shops : payStatus) {
-                                if (!"3".equals(shops)) {
-                                    isPay = false;
-                                    break;
-                                }
-                            }
-                            // 修改主订单付款状态
-                            if (isPay) {
-                                newOrderDao.updateOrderByPayStatus(orderId, 3);
-                            } else {
-                                newOrderDao.updateOrderByPayStatus(orderId, 2);
-                            }
-                        }
+                        newOrderDao.updateOrderByPayStatus(shopOrder.getOrderId(), 2);
                     }
-                });
-                /**
-                 *  在上述else代码逻辑中已完成成本的业务表参数处理,在分账详情中排除成本,剩余佣金部分在分账结束收到
-                 *  成功返回码时处理(成本不参与分账)
-                 */
-                splitBillDetail.removeIf(s -> s.getSubUserNo().equals(shopOrder.getSplitCode()));
-                if (null != splitBillRules && splitBillRules.size() > 0) {
-                    //第三方分账接口
-                    try {
-                        AccountPayOrder accountPayOrder = new AccountPayOrder();
-                        accountPayOrder.setP1_bizType("AccountPaySub");
-                        accountPayOrder.setP2_signType("MD5");
-                        String format1 = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
-                        accountPayOrder.setP3_timestamp(format1);
-                        String substring = format1.substring(20);
-                        // fz+当前微秒时间+原唯一订单号
-                        accountPayOrder.setP4_orderId("FZ" + substring + orderRelation.getOrderRequestNo());
-                        //付款账户子订单绑定商户号
-                        accountPayOrder.setP5_customerNumber(shopOrder.getSplitCode());
-                        AccountPayOrder.AccountPayOrderExt accountPayOrderExt = new AccountPayOrder.AccountPayOrderExt();
-                        //收款账户商编  填写splitBillRules时候不填写MerchantNo,Amount并且即使填写这两个参数不生效!!
-                        //accountPayOrderExt.setInMerchantNo(splitMoneyVo.getName());
-                        //accountPayOrderExt.setAmount(splitMoneyVo.getSplitMoney());
-                        accountPayOrderExt.setOrderType(AccountPayOrderType.TRANSFER);
-                        accountPayOrderExt.setServerCallbackUrl(Constant.prodSplit);
-                        accountPayOrderExt.setGoodsName("分账");
-                        if (null != splitBillRules && splitBillRules.size() > 0) {
-                            accountPayOrderExt.setSplitBillRules(splitBillRules);
-                        }
-                        String ext = JSON.toJSONString(accountPayOrderExt);
-                        logger.info("分账规则串json串:" + ext);
-                        accountPayOrder.setP6_ext(ext);
-                        // 生成签名
-                        StringBuilder builder = new StringBuilder();
-                        builder.append(Constant.SPLIT)
-                                .append(accountPayOrder.getP1_bizType()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP2_signType()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP3_timestamp()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP4_orderId()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP5_customerNumber()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP6_ext()).append(Constant.SPLIT)
-                                .append(Constant.XUNI);
-                        String sign = Disguiser.disguiseMD5(builder.toString().trim());
-                        Map<String, String> bean = convertBean(accountPayOrder);
-                        logger.info("--------------------> 发送分账参数:  " + bean);
-                        Map<String, String> map = postForm(bean, Constant.FZ, sign, Map.class);
-                        logger.info("----------------分账返回数据: " + map.toString());
-                        if (map != null) {
-                            String code = map.get("rt5_retCode");
-                            if (!"0000".equals(code)) {
-                                String msg = map.get("rt6_retMsg");
-                                logger.info("【手动分账】>>>>>>>>>>手动分账失败>>>>>>>msg:" + msg);
-                            } else {
-                                for (SplitAccountPo splitAccount : splitBillDetail) {
-                                    splitAccount.setMbOrderId(orderRelation.getMbOrderId());
-                                    splitAccount.setOrderRequestNo(orderRelation.getOrderRequestNo());
-                                    splitAccount.setPayStatus(1);
-                                    // 保存分账详情
-                                    newOrderDao.insertSplitAccount(splitAccount);
-                                }
-                                redisService.remove("XSFZMDS");
-                                logger.info("【手动分账】>>>>>>>>>>此订单分账结束");
+                }
+            });
+            /**
+             *  在上述else代码逻辑中已完成成本的业务表参数处理,在分账详情中排除成本,剩余佣金部分在分账结束收到
+             *  成功返回码时处理(成本不参与分账)
+             */
+            splitBillDetail.removeIf(s -> s.getSubUserNo().equals(shopOrder.getSplitCode()));
+            if (null != splitBillRules && splitBillRules.size() > 0) {
+                //第三方分账接口
+                try {
+                    AccountPayOrder accountPayOrder = new AccountPayOrder();
+                    accountPayOrder.setP1_bizType("AccountPaySub");
+                    accountPayOrder.setP2_signType("MD5");
+                    String format1 = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
+                    accountPayOrder.setP3_timestamp(format1);
+                    String substring = format1.substring(20);
+                    // fz+当前微秒时间+原唯一订单号
+                    accountPayOrder.setP4_orderId("FZ" + substring + shopOrder.getShopOrderId());
+                    //付款账户子订单绑定商户号
+                    accountPayOrder.setP5_customerNumber(shopOrder.getSplitCode());
+                    AccountPayOrder.AccountPayOrderExt accountPayOrderExt = new AccountPayOrder.AccountPayOrderExt();
+                    //收款账户商编  填写splitBillRules时候不填写MerchantNo,Amount并且即使填写这两个参数不生效!!
+                    //accountPayOrderExt.setInMerchantNo(splitMoneyVo.getName());
+                    //accountPayOrderExt.setAmount(splitMoneyVo.getSplitMoney());
+                    accountPayOrderExt.setOrderType(AccountPayOrderType.TRANSFER);
+                    accountPayOrderExt.setServerCallbackUrl(Constant.prodSplit);
+                    accountPayOrderExt.setGoodsName("分账");
+                    if (null != splitBillRules && splitBillRules.size() > 0) {
+                        accountPayOrderExt.setSplitBillRules(splitBillRules);
+                    }
+                    String ext = JSON.toJSONString(accountPayOrderExt);
+                    logger.info("分账规则串json串:" + ext);
+                    accountPayOrder.setP6_ext(ext);
+                    // 生成签名
+                    StringBuilder builder = new StringBuilder();
+                    builder.append(Constant.SPLIT)
+                            .append(accountPayOrder.getP1_bizType()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP2_signType()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP3_timestamp()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP4_orderId()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP5_customerNumber()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP6_ext()).append(Constant.SPLIT)
+                            .append(Constant.XUNI);
+                    String sign = Disguiser.disguiseMD5(builder.toString().trim());
+                    Map<String, String> bean = convertBean(accountPayOrder);
+                    logger.info("--------------------> 发送分账参数:  " + bean);
+                    Map<String, String> map = postForm(bean, Constant.FZ, sign, Map.class);
+                    logger.info("----------------分账返回数据: " + map.toString());
+                    if (map != null) {
+                        String code = map.get("rt5_retCode");
+                        if (!"0000".equals(code)) {
+                            String msg = map.get("rt6_retMsg");
+                            logger.info("【手动分账】>>>>>>>>>>手动分账失败>>>>>>>msg:" + msg);
+                        } else {
+                            for (SplitAccountPo splitAccount : splitBillDetail) {
+                                splitAccount.setPayStatus(1);
+                                // 保存分账详情
+                                newOrderDao.insertSplitAccount(splitAccount);
                             }
+                            redisService.remove("XSFZMDS");
+                            logger.info("【手动分账】>>>>>>>>>>此订单分账结束");
                         }
-                    } catch (Exception e) {
-                        logger.error("【手动分账】>>>>>>>>>>错误信息", e);
                     }
-                } else {
-                    // 没有佣金分账,全是成本,本笔交易已分帐
-                    newOrderDao.updateBySplitStatus(orderRelation.getMbOrderId());
-                    //没有佣金分账也解锁
-                    redisService.remove("XSFZMDS");
+                } catch (Exception e) {
+                    logger.error("【手动分账】>>>>>>>>>>错误信息", e);
                 }
             }
-        }
+        });
     }
 
 
-    public List<SplitAccountPo> setSplitAccountDetail(ShopOrderVo shopOrder, PayParamBo payParam) {
-        List<SplitAccountPo> list = new ArrayList<>();
-        // 本次支付金额,单位/元
-        double payAmount = payParam.getAllPay();
+    public void setSplitAccountDetail(AtomicReference<Double> costPrice, AtomicReference<Double> organizePrice,
+                                      AtomicReference<Double> cmCostPrice, AtomicReference<Double> total,
+                                      ShopOrderVo shopOrder, OrderReceiptRelationPo orderRelation) {
         // 待分账总金额
-        double splitAmount = payAmount;
+        double splitAmount = orderRelation.getAssociateAmount();
+        total.updateAndGet(v -> MathUtil.add(v, splitAmount).doubleValue());
         // 总手续费
         double procedureFee;
-        if ("UNIONPAY".equals(payParam.getPayWay())) {
+        if (12 == orderRelation.getPayType()) {
             procedureFee = 10.00;
-        } else if ("B2C".equals(payParam.getPayWay())) {
+        } else if (17 == orderRelation.getPayType()) {
             //b2c 0.2%
-            procedureFee = MathUtil.mul(payAmount, 0.002, 2).doubleValue();
+            procedureFee = MathUtil.mul(splitAmount, 0.002, 2).doubleValue();
             //b2c最低手续费0.1
             if (procedureFee < 0.1) {
                 procedureFee = 0.1;
             }
-        } else if ("WX".equals(payParam.getPayWay())) {
+        } else if (13 == orderRelation.getPayType() || 15 == orderRelation.getPayType()) {
             //微信0.65%
-            procedureFee = MathUtil.mul(payAmount, 0.0065, 2).doubleValue();
-        } else if ("DEBIT".equals(payParam.getPayWay())) {
-            procedureFee = MathUtil.mul(payAmount, 0.003, 2).doubleValue();
+            procedureFee = MathUtil.mul(splitAmount, 0.0065, 2).doubleValue();
+        } else if (29 == orderRelation.getPayType()) {
+            procedureFee = MathUtil.mul(splitAmount, 0.003, 2).doubleValue();
             if (procedureFee < 0.1) {
                 procedureFee = 0.1;
             }
-        } else if ("CREDIT".equals(payParam.getPayWay())) {
-            procedureFee = MathUtil.mul(payAmount, 0.006, 2).doubleValue();
+        } else if (30 == orderRelation.getPayType()) {
+            procedureFee = MathUtil.mul(splitAmount, 0.006, 2).doubleValue();
             if (procedureFee < 0.1) {
                 procedureFee = 0.1;
             }
         } else {
             //手续费 其他0.25%
-            procedureFee = MathUtil.mul(payAmount, 0.0025, 2).doubleValue();
+            procedureFee = MathUtil.mul(splitAmount, 0.0025, 2).doubleValue();
         }
         if (MathUtil.compare(procedureFee, 0.01) <= 0) {
             procedureFee = 0.01;
         }
-        //手续费承担方 线上支付手续费:默认1采美承担,2供应商承担
-        Integer supportFlag = newOrderDao.findSupport(shopOrder.getShopOrderId());
-        //减去收款手续费
-        splitAmount = MathUtil.sub(splitAmount, procedureFee).doubleValue();
-
         // 商品数据
         List<OrderProductVo> orderProductList = newOrderDao.getOrderProductByShopOrderId(shopOrder.getShopOrderId());
-
         for (OrderProductVo orderProduct : orderProductList) {
-            // 价格 * 数量 * 供应商成本比例/100
-            double costPrice = MathUtil.mul(orderProduct.getTotalAmount(), orderProduct.getShopPercent() / 100, 2).doubleValue();
-            if (2 == supportFlag) {
-                //供应商自己承担手续费
-                costPrice = MathUtil.sub(costPrice, procedureFee).doubleValue();
-            }
-            /**
-             * todo
-             * 出于兼容性考虑,且多次支付手续费不同,分账方式为循环每次支付记录,
-             * 当前业务满足子订单支付完成才进行分账,可以循环子订单统计支付金额,
-             * 进行一次性分账,在当前模式下如果用户分多次支付,精度损失问题较为常见。
+            /**   价格 * 数量
+             *    前版本为全比例成本,当前版本重新加回固定成本,新增字段cmCostPrice(平台服务费,分帐分采美),organizeCostPrice(组织/集团成本。分帐分组织)
+             *    在此规则下,分帐方式取cop固定成本值。因存在成本修改,不能取cm_sku实时更新成本!
              */
-            // 判断是否支付过
-            Double paidAmount = newOrderDao.getOrderProductPaidAmount(orderProduct.getOrderProductId());
-            // 支付过金额大于0
-            if (null != paidAmount && MathUtil.compare(paidAmount, 0) > 0) {
-                //已付>0,成本-已付
-                costPrice = MathUtil.sub(costPrice, paidAmount).doubleValue();
-            }
-            // 待分账金额>成本
-            if (MathUtil.compare(splitAmount, costPrice) > 0) {
-                // 待分账金额-成本
-                splitAmount = MathUtil.sub(splitAmount, costPrice).doubleValue();
-            } else {
-                costPrice = splitAmount;
-                splitAmount = 0.00;
-            }
-            if (costPrice > 0) {
-                SplitAccountPo splitAccount = new SplitAccountPo();
-                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
-                splitAccount.setOrderId(shopOrder.getOrderId());
-                splitAccount.setOrderProductId(orderProduct.getOrderProductId());
-                splitAccount.setShopId(orderProduct.getShopId());
-                splitAccount.setSplitAccount(costPrice);
-                splitAccount.setProductType(1);
-                // 该商品设置了商户号
-                splitAccount.setType(4);
-                splitAccount.setSubUserNo(shopOrder.getSplitCode());
-                logger.info("成本分账参数------------->" + splitAccount.toString());
-                list.add(splitAccount);
-            }
-            if (MathUtil.compare(splitAmount, 0) == 0) {
-                break;
-            }
+            costPrice.updateAndGet(v -> MathUtil.add(v, MathUtil.mul(orderProduct.getCostPrice(), orderProduct.getNum(), 2)).doubleValue());
+            organizePrice.updateAndGet(v -> MathUtil.add(v, MathUtil.mul(orderProduct.getOrganizeCostPrice(), orderProduct.getNum(), 2)).doubleValue());
+            cmCostPrice.updateAndGet(v -> MathUtil.add(v, MathUtil.mul(orderProduct.getCmCostPrice(), orderProduct.getNum(), 2)).doubleValue());
         }
-        // 如果还有钱则为佣金,分到网络
-        if (MathUtil.compare(splitAmount, 0) > 0) {
-            // 此处不考虑手续费,外部计算总额
-            SplitAccountPo splitAccount = new SplitAccountPo();
-            splitAccount.setOrderId(shopOrder.getOrderId());
-            splitAccount.setShopOrderId(shopOrder.getShopOrderId());
-            splitAccount.setSplitAccount(splitAmount);
-            splitAccount.setProductType(3);
-            splitAccount.setType(5);
-            splitAccount.setSubUserNo(Constant.CUSTOMERNUM2);
-            logger.info("佣金分账参数------------->" + splitAccount);
-            list.add(splitAccount);
+        //手续费承担方 线上支付手续费:默认1采美承担,2供应商承担
+        Integer supportFlag = newOrderDao.findSupport(shopOrder.getShopOrderId());
+        if (2 == supportFlag) {
+            //供应商自己承担手续费
+            costPrice.set(costPrice.get() - procedureFee);
         }
-        return list;
     }
 
     public <T> T postForm(Map<String, String> params, String url, String sign, Class<T> clazz) {

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

@@ -8,11 +8,9 @@ import com.caimei.modules.order.dao.NewOrderDao;
 import com.caimei.modules.order.dao.NewOrderProductDao;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.*;
-import com.caimei.modules.order.utils.OrderUtil;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.user.entity.CmUserOrganize;
 import com.caimei.modules.user.service.CmUserOrganizeService;
-import com.caimei.redis.RedisService;
 import com.caimei.utils.MathUtil;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
@@ -20,7 +18,6 @@ import com.thinkgem.jeesite.common.utils.Encodes;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.thinkgem.jeesite.common.web.BaseController;
 import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -33,12 +30,12 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
-import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 /**
  * 付款单表Controller
@@ -49,9 +46,6 @@ import java.util.concurrent.atomic.AtomicReference;
 @Controller
 @RequestMapping(value = "${adminPath}/order/cmPayShop")
 public class CmPayShopController extends BaseController {
-    
-    @Resource
-    private RedisService redisService;
     @Resource
     private CmPayShopService cmPayShopService;
     @Resource
@@ -299,16 +293,23 @@ public class CmPayShopController extends BaseController {
         //如果子订单填写了成本方式,那么页面上传过来的成本方式必须和数据库相同
         //子订单的成本方式第一次填写以后就不能修改了
         // 固定成本
-        if ("1".equals(costType)) {
+        //if ("1".equals(costType)) {
             // List<CmReturnedPurchaseProduct> rL = cmReturnedPurchaseProductService.findReturnedByShopOrderID(Integer.parseInt(shopOrderID));
             for (NewOrderProduct product : newOrderProducts) {
                 Integer orderProductID = product.getOrderProductID();
                 Double costPrice = product.getCostPrice() == null ? 0d : product.getCostPrice();
+                Double organizeCostPrice = product.getOrganizeCostPrice() == null ? 0d : product.getOrganizeCostPrice();
+                Double cmCostPrice = product.getCmCostPrice() == null ? 0d : product.getCmCostPrice();
                 if (soZeroCostFlag && costPrice > 0) {
                     soZeroCostFlag = false;
                 }
+                // 在订单商品含税的情况下, 成本计算税费
+                if ("0".equals(product.getIncludedTax()) && null != product.getTaxRate() && product.getTaxRate() > 0d) {
+                    costPrice = MathUtil.add(costPrice, MathUtil.div(MathUtil.mul(costPrice, product.getTaxRate()), 100)).doubleValue();
+                }
+                // product.setSingleShouldPayTotalTax(MathUtil.div(MathUtil.mul(MathUtil.div(product.getCostPrice(), MathUtil.div(MathUtil.add(product.getTaxRate(), 100),100)), product.getSupplierTaxRate()), 100).doubleValue());
                 Double singleShouldPayTotalTax = product.getSingleShouldPayTotalTax() == null ? 0d : product.getSingleShouldPayTotalTax();
-                Double supplierTaxRate = product.getSupplierTaxRate() == null ? 0d : product.getSupplierTaxRate();
+                Double supplierTaxRate = product.getTaxRate() == null ? 0d : product.getTaxRate();
                 // 获取已被退款的商品数量
                 Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(Integer.parseInt(shopOrderID), orderProductID);
                 returnNum = returnNum == null ? 0 : returnNum;
@@ -328,14 +329,19 @@ public class CmPayShopController extends BaseController {
                     cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
                     cmChangePayShopProduct.setOrderProductId(orderProductID);
                     cmChangePayShopProduct.setOrderProductName(product.getName());
-                    cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
+                    // 同步使用机构税率 作为供应商税率
+                    cmChangePayShopProduct.setSupplierTaxRate(product.getTaxRate());
                     cmChangePayShopProduct.setCostPrice(orderProduct.getNewCostPrice());
                     cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
                     cmChangePayShopProductService.save(cmChangePayShopProduct);
                 }
 
                 orderProduct.setCostPrice(costPrice);
+                orderProduct.setOrganizeCostPrice(organizeCostPrice);
+                orderProduct.setCmCostPrice(cmCostPrice);
+                // 同步使用机构税率 作为供应商税率
                 orderProduct.setSupplierTaxRate(supplierTaxRate);
+                orderProduct.setTaxRate(product.getTaxRate());
                 orderProduct.setSingleShouldPayTotalTax(singleShouldPayTotalTax);
                 orderProducts.add(orderProduct);
                 int num = orderProduct.getNum() == null ? 0 : orderProduct.getNum();
@@ -357,42 +363,97 @@ public class CmPayShopController extends BaseController {
             }
             shopOrder.setShopTaxFee(totalTaxesFee); //总税费
             shopOrder.setShopProductAmount(totalCostFee); //商品费
-        }
+        //}
         // 比例成本
-        if ("2".equals(costType)) {
-            // 保存修改之前的记录
-            List<NewOrderProduct> orderProductList = newOrderProductService.getListByShopOrderID(Integer.parseInt(shopOrderID));
-            if (CollectionUtils.isNotEmpty(orderProductList)) {
-                for (NewOrderProduct orderProduct : orderProductList) {
-                    // 修改前
-                    if (StringUtils.isEmpty(dbcostType)) {
-                        CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
-                        cmChangePayShopProduct.setRecondType("1");
-                        cmChangePayShopProduct.setChangeType("1");
-                        cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
-                        cmChangePayShopProduct.setOrderProductId(orderProduct.getOrderProductID());
-                        cmChangePayShopProduct.setOrderProductName(orderProduct.getName());
-                        cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
-                        cmChangePayShopProduct.setCostPrice(orderProduct.getCostPrice());
-                        cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
-                        cmChangePayShopProductService.save(cmChangePayShopProduct);
-                    }
-                    //售价
-                    Double price = orderProduct.getTouchPrice() == null ? orderProduct.getDiscountPrice() : orderProduct.getTouchPrice();
-                    orderProduct.setCostPrice(price * proportional / 100);
-                    orderProducts.add(orderProduct);
-                    if (soZeroCostFlag && orderProduct.getCostPrice() <= 0) {
-                        soZeroCostFlag = false;
-                    }
+        /*if ("2".equals(costType)) {
+            for (NewOrderProduct product : newOrderProducts) {
+                Integer orderProductID = product.getOrderProductID();
+                Double costPrice = product.getCostPrice() == null ? 0d : product.getCostPrice();
+                if (soZeroCostFlag && costPrice > 0) {
+                    soZeroCostFlag = false;
+                }
+                Double singleShouldPayTotalTax = product.getSingleShouldPayTotalTax() == null ? 0d : product.getSingleShouldPayTotalTax();
+                Double supplierTaxRate = product.getSupplierTaxRate() == null ? 0d : product.getSupplierTaxRate();
+                // 获取已被退款的商品数量
+                Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(Integer.parseInt(shopOrderID), orderProductID);
+                returnNum = returnNum == null ? 0 : returnNum;
+                NewOrderProduct orderProduct = newOrderProductService.get(String.valueOf(orderProductID));
+                // 修改前
+                if (StringUtils.isEmpty(dbcostType)) {
+                    CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
+                    cmChangePayShopProduct.setRecondType("1");
+                    cmChangePayShopProduct.setChangeType("1");
+                    cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
+                    cmChangePayShopProduct.setOrderProductId(orderProductID);
+                    cmChangePayShopProduct.setOrderProductName(product.getName());
+                    cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
+                    cmChangePayShopProduct.setCostPrice(orderProduct.getNewCostPrice());
+                    cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
+                    cmChangePayShopProductService.save(cmChangePayShopProduct);
                 }
+                // 设置比例
+                orderProduct.setShopPercent(product.getShopPercent());
+                orderProduct.setOrganizePercent(product.getOrganizePercent());
+                orderProduct.setCmPercent(product.getCmPercent());
+                //售价
+                Double price = orderProduct.getTouchPrice() == null ? orderProduct.getDiscountPrice() : orderProduct.getTouchPrice();
+                // 成本 = 售价 * 供应商比例
+                orderProduct.setCostPrice(price * product.getShopPercent() / 100);
+                orderProduct.setSupplierTaxRate(supplierTaxRate);
+                orderProduct.setSingleShouldPayTotalTax(singleShouldPayTotalTax);
+                int num = orderProduct.getNum() == null ? 0 : orderProduct.getNum();
+                int presentNum = orderProduct.getPresentNum() == null ? 0 : orderProduct.getPresentNum();
+                totalCostFee += (num + presentNum - returnNum) * costPrice;
+                orderProduct.setShouldPayTotalTax(singleShouldPayTotalTax * (num + presentNum - returnNum));
+                totalTaxesFee += singleShouldPayTotalTax * (num + presentNum - returnNum);
+                orderProducts.add(orderProduct);
+                // 修改后
+                CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
+                cmChangePayShopProduct.setRecondType("2");
+                cmChangePayShopProduct.setChangeType(costType);
+                cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId2));
+                cmChangePayShopProduct.setOrderProductId(orderProductID);
+                cmChangePayShopProduct.setOrderProductName(product.getName());
+                cmChangePayShopProduct.setSupplierTaxRate(supplierTaxRate);
+                cmChangePayShopProduct.setCostPrice(product.getCostPrice());
+                cmChangePayShopProduct.setSingleShouldPayTotalTax(product.getSingleShouldPayTotalTax());
+                cmChangePayShopProductService.save(cmChangePayShopProduct);
             }
+            shopOrder.setShopTaxFee(totalTaxesFee); //总税费
+            shopOrder.setShopProductAmount(totalCostFee); //商品费
+//            // 保存修改之前的记录
+//            List<NewOrderProduct> orderProductList = newOrderProductService.getListByShopOrderID(Integer.parseInt(shopOrderID));
+//            if (CollectionUtils.isNotEmpty(orderProductList)) {
+//                for (NewOrderProduct orderProduct : orderProductList) {
+//                    // 修改前
+//                    if (StringUtils.isEmpty(dbcostType)) {
+//                        CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
+//                        cmChangePayShopProduct.setRecondType("1");
+//                        cmChangePayShopProduct.setChangeType("1");
+//                        cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
+//                        cmChangePayShopProduct.setOrderProductId(orderProduct.getOrderProductID());
+//                        cmChangePayShopProduct.setOrderProductName(orderProduct.getName());
+//                        cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
+//                        cmChangePayShopProduct.setCostPrice(orderProduct.getCostPrice());
+//                        cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
+//                        cmChangePayShopProductService.save(cmChangePayShopProduct);
+//                    }
+//                    //售价
+//                    Double price = orderProduct.getTouchPrice() == null ? orderProduct.getDiscountPrice() : orderProduct.getTouchPrice();
+//                    orderProduct.setCostPrice(price * proportional / 100);
+//                    orderProducts.add(orderProduct);
+//                    if (soZeroCostFlag && orderProduct.getCostPrice() <= 0) {
+//                        soZeroCostFlag = false;
+//                    }
+//                }
+//            }
+//
+//            shopOrder.setProportional(proportional);
+//            shopOrder.setShopTaxFee(0D); //总税费
+//            Double productAmount = shopOrder.getProductAmount();//子订单金额
+//            shopOrder.setShopProductAmount(productAmount * proportional / 100); //商品费
 
-            shopOrder.setProportional(proportional);
-            shopOrder.setShopTaxFee(0D); //总税费
-            Double productAmount = shopOrder.getProductAmount();//子订单金额
-            shopOrder.setShopProductAmount(productAmount * proportional / 100); //商品费
-
-        }
+        }*/
         shopOrder.setPayStatus(soZeroCostFlag ? "3" : "1");
         shopOrder.setZeroCostFlag(soZeroCostFlag ? 1 : 0);
         //当子订单0成本时,若主订单中其他子订单(除了运费子订单)都为0成本,设主订单为已付款,否则设为部分付款
@@ -438,7 +499,7 @@ public class CmPayShopController extends BaseController {
         shopOrder.setModifyShouldPayNote(modifyShouldPayNote);  //备注
         shopOrder.setModifyShouldPayUserID(UserUtils.getUser().getId());  //修改人的用户id
         shopOrder.setModifyShouldPayDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));  //修改时间
-        double shouldPayShopAmount = shopOrder.getShopProductAmount() + shopOrder.getShopPostFee() + shopOrder.getShopTaxFee();
+        double shouldPayShopAmount = shopOrder.getShopProductAmount() + shopOrder.getShopPostFee(); // + shopOrder.getShopTaxFee();
         if (shopOrder.getPayedShopAmount() != null && shouldPayShopAmount == shopOrder.getPayedShopAmount())
             shopOrder.setPayStatus("3");
         shopOrder.setShouldPayShopAmount(shouldPayShopAmount);
@@ -614,23 +675,26 @@ public class CmPayShopController extends BaseController {
 
     @RequestMapping("settleTime")
     @ResponseBody
-    public Map<String, Object> settleTime(@RequestParam("shopOrderId") Integer shopOrderId) {
+    public Map<String, Object> settleTime(@RequestParam("shopOrderIds") String[] shopOrderIds) {
+        List<String> ids = Arrays.stream(shopOrderIds).collect(Collectors.toList());
         Map<String, Object> map = new HashMap<>();
         Calendar instance = Calendar.getInstance();
-        int flag = 0;
+        AtomicInteger flag = new AtomicInteger(0);
         int weekIdx = instance.get(Calendar.DAY_OF_WEEK) - 1;
         String format = new SimpleDateFormat("HH:mm:ss").format(new Date());
         Integer substring = Integer.valueOf(format.substring(0, 2));
-        //当前时间周五下午到周日都返回1不能结算,其他时间看够不够24小时
-        if ((5 == weekIdx && substring > 14) || 6 == weekIdx || 7 == weekIdx) {
-            flag = 1;
-        } else {
-            Integer val = newOrderDao.getSplitTime(shopOrderId);
-            if (val <= 0) {
-                flag = 1;
+        ids.forEach(i->{
+            //当前时间周五下午到周日都返回1不能结算,其他时间看够不够24小时
+            if ((5 == weekIdx && substring > 14) || 6 == weekIdx || 7 == weekIdx) {
+                flag.set(1);
+            } else {
+                Integer val = newOrderDao.getSplitTime(i);
+                if (val <= 0) {
+                    flag.set(1);
+                }
             }
-        }
-        map.put("flag", flag);
+        });
+        map.put("flag", flag.get());
         map.put("msg", "添加成功");
         return map;
     }
@@ -673,13 +737,10 @@ public class CmPayShopController extends BaseController {
 
     @RequestMapping("splitEdit")
     public String splitEdit(String[] shopOrderIDs, RedirectAttributes redirectAttributes, Model model) {
-        splitAccountService.SplitAccount(shopOrderIDs[0]);
 
-//        Page<NewShopOrder> page = newShopOrderService.findSplitList(new Page<NewShopOrder>(),new NewShopOrder());
-//        model.addAttribute("page", page);
+        splitAccountService.SplitAccount(shopOrderIDs);
         addMessage(redirectAttributes, "分账成功!");
         return "redirect:" + Global.getAdminPath() + "/shopOrder/splitList";
-//        return "modules/order/cmSplitAccountList";
     }
 
     /**
@@ -819,25 +880,21 @@ public class CmPayShopController extends BaseController {
      * @return
      */
     @RequestMapping("settlement")
-    public String settlement(Double settleAmount, String shopOrderId, RedirectAttributes redirectAttributes) throws Exception {
-        Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
-        Double settleSum = newOrderDao.findSettleSum(shopOrderId);
-        if (settleSum >= shouldPayShopAmount) {
-            addMessage(redirectAttributes, "此订单已结算完毕!");
-            return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
-        }
-        Integer SDJSS = (Integer) redisService.get("SDJSS");
-        //验锁
-        if (null != SDJSS && SDJSS > 0) {
-            addMessage(redirectAttributes, "请勿短时间内重复结算,等待支付公司返回结算结果!");
-            return "redirect:" + Global.getAdminPath() + "/shopOrder/splitList/?repage";
-        }
-        cmPayShopService.settlement(shopOrderId, settleAmount);
+    public String settlement(String[] shopOrderIds, RedirectAttributes redirectAttributes) throws Exception {
+        List<String> ids = Arrays.stream(shopOrderIds).collect(Collectors.toList());
+        for (String shopOrderId : ids) {
+            Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
+            Double settleSum = newOrderDao.findSettleSum(shopOrderId);
+            if (settleSum >= shouldPayShopAmount) {
+                addMessage(redirectAttributes, "此订单已结算完毕!");
+                return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
+            }
+            cmPayShopService.settlement(shopOrderId);
+        }
         return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
     }
 
 
-    ////applyPayWipe
     @RequiresPermissions("order:cmPayShop:edit")
     @RequestMapping("applyPayWipe")
     public String applyPayWipe(CmPayShop cmPayShop, Model model, RedirectAttributes redirectAttributes) {
@@ -954,7 +1011,7 @@ public class CmPayShopController extends BaseController {
      * 付第三方数据回显
      */
     @RequestMapping("shopOtherFeeForm")
-    public String shopOtherFeeForm(Integer shopOrderId, Model model) {
+    public String shopOtherFeeForm(Integer shopOrderId,Integer payType, Model model) {
         ChangePayShopOther payShopOther = cmPayShopService.shopOtherFeeForm(shopOrderId);
         payShopOther.setShopOrderId(shopOrderId);
         NewShopOrder shopOrder = newShopOrderService.findByShopOrderID(shopOrderId);
@@ -964,6 +1021,7 @@ public class CmPayShopController extends BaseController {
         brokerage = brokerage == null ? 0d : brokerage;
         model.addAttribute("brokerage", brokerage);
         model.addAttribute("payShopOther", payShopOther);
+        model.addAttribute("payType", payType);
         return "modules/order/shopOtherFeeForm";
     }
 

+ 57 - 17
src/main/java/com/caimei/modules/order/web/CmShopOrderController.java

@@ -7,6 +7,7 @@ import com.caimei.modules.order.service.CmChangePayShopRecondService;
 import com.caimei.modules.order.service.NewShopOrderService;
 import com.caimei.modules.user.entity.CmUserOrganize;
 import com.caimei.modules.user.service.CmUserOrganizeService;
+import com.caimei.utils.MathUtil;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.utils.StringUtils;
@@ -88,6 +89,37 @@ public class CmShopOrderController extends BaseController {
         return "modules/order/cmPayShopList";
     }
 
+    /**
+     * 申请付第三方
+     * @param newShopOrder
+     * @param request
+     * @param response
+     * @param model
+     * @return
+     */
+    @RequiresPermissions("order:cmPayShop:view")
+    @RequestMapping("payThirdParties")
+    public String payThirdParties(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
+        if (null != newShopOrder.getStartTime() && !"".equals(newShopOrder.getStartTime()) && !newShopOrder.getStartTime().endsWith("00:00:00")) {
+            model.addAttribute("startTime", newShopOrder.getStartTime());
+            newShopOrder.setStartTime(newShopOrder.getStartTime().trim() + " 00:00:00");
+        }
+        if (null != newShopOrder.getEndTime() && !"".equals(newShopOrder.getEndTime()) && !newShopOrder.getEndTime().endsWith("23:59:59")) {
+            model.addAttribute("endTime", newShopOrder.getEndTime());
+            newShopOrder.setEndTime(newShopOrder.getEndTime().trim() + " 23:59:59");
+        }
+        Page<NewShopOrder> page = newShopOrderService.payThirdParties(new Page<>(request, response), newShopOrder);
+
+        //获取组织列表
+        List<CmUserOrganize> cmUserOrganizeList = cmUserOrganizeService.findOrganize();
+        model.addAttribute("cmUserOrganizeList", cmUserOrganizeList);
+        model.addAttribute("page", page);
+        model.addAttribute("operatingMode", newShopOrder.getOperatingMode());
+
+        //申请付第三方
+        return "modules/order/payThirdParties";
+    }
+
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping("refundRecordList")
     public String refundRecordList(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
@@ -164,6 +196,14 @@ public class CmShopOrderController extends BaseController {
         if (CollectionUtils.isNotEmpty(list) && list.size() == 1) {
             dbCostType = list.get(0).getCostType();
         }
+        for (NewOrderProduct p : list.get(0).getNewOrderProducts()) {
+            Double newCostPrice = 0d;
+            newCostPrice = p.getCostPrice();
+            if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+            }
+            p.setNewCostPrice(newCostPrice);
+        }
         BigDecimal payShopOtherFee = cmPayShopRecordDao.findPayShopOtherFee(newShopOrder.getShopOrderID());
         model.addAttribute("payShopOtherFee", payShopOtherFee);
         model.addAttribute("dbCostType", dbCostType);
@@ -213,16 +253,16 @@ public class CmShopOrderController extends BaseController {
 
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping("checkPaymentOrder")
-    public String checkPaymentOrder(NewOrder newOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
-        if (null != newOrder.getStartTime() && !"".equals(newOrder.getStartTime()) && !newOrder.getStartTime().endsWith("00:00:00")) {
-            model.addAttribute("startTime", newOrder.getStartTime());
-            newOrder.setStartTime(newOrder.getStartTime().trim() + " 00:00:00");
+    public String checkPaymentOrder(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
+        if (null != newShopOrder.getStartTime() && !"".equals(newShopOrder.getStartTime()) && !newShopOrder.getStartTime().endsWith("00:00:00")) {
+            model.addAttribute("startTime", newShopOrder.getStartTime());
+            newShopOrder.setStartTime(newShopOrder.getStartTime().trim() + " 00:00:00");
         }
-        if (null != newOrder.getEndTime() && !"".equals(newOrder.getEndTime()) && !newOrder.getEndTime().endsWith("23:59:59")) {
-            model.addAttribute("endTime", newOrder.getEndTime());
-            newOrder.setEndTime(newOrder.getEndTime().trim() + " 23:59:59");
+        if (null != newShopOrder.getEndTime() && !"".equals(newShopOrder.getEndTime()) && !newShopOrder.getEndTime().endsWith("23:59:59")) {
+            model.addAttribute("endTime", newShopOrder.getEndTime());
+            newShopOrder.setEndTime(newShopOrder.getEndTime().trim() + " 23:59:59");
         }
-        Page<NewOrder> page = newShopOrderService.findPaymentOrderList(new Page<NewOrder>(request, response), newOrder);
+        Page<NewShopOrder> page = newShopOrderService.findPaymentOrderList(new Page<NewShopOrder>(request, response), newShopOrder);
         List<CmUserOrganize> organizeList = cmUserOrganizeService.findOrganize();
         model.addAttribute("page", page);
         model.addAttribute("organizeList", organizeList);
@@ -235,23 +275,23 @@ public class CmShopOrderController extends BaseController {
      */
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping("refundRecord")
-    public String refundRecord(Integer orderID, Model model) {
-        NewOrder order = newShopOrderService.findRefundRecord(orderID);
-        List<Integer> shopOrderIDs = newShopOrderService.findIDsByOrderID(orderID);
+    public String refundRecord(Integer shopOrderId, Model model) {
+        NewShopOrder shopOrder = newShopOrderService.findRefundRecord(shopOrderId);
+        // List<Integer> shopOrderIDs = newShopOrderService.findIDsByOrderID(orderID);
         List<CmPayShopRecord> pr = new ArrayList<>();
         List<CmRefundShopRecord> rr = new ArrayList<>();
         List<CmDiscernReceipt> receipts = new ArrayList<>();
-        for (Integer shopOrderID : shopOrderIDs) {
-            List<CmPayShopRecord> payShopRecordList = newShopOrderService.getPayedRecords(shopOrderID.toString());
+        // for (Integer shopOrderID : shopOrderIDs) {
+            List<CmPayShopRecord> payShopRecordList = newShopOrderService.getPayedRecords(shopOrderId.toString());
             pr.addAll(payShopRecordList);
-            List<CmRefundShopRecord> refundShopRecordList = newShopOrderService.getRefundedRecords(shopOrderID.toString());
+            List<CmRefundShopRecord> refundShopRecordList = newShopOrderService.getRefundedRecords(shopOrderId.toString());
             rr.addAll(refundShopRecordList);
-            List<CmDiscernReceipt> receiptList = newShopOrderService.getDiscernReceipts(shopOrderID);
+            List<CmDiscernReceipt> receiptList = newShopOrderService.getDiscernReceipts(shopOrderId);
             receipts.addAll(receiptList);
-        }
+        // }
         model.addAttribute("pr", pr);
         model.addAttribute("rr", rr);
-        model.addAttribute("order", order);
+        model.addAttribute("shopOrder", shopOrder);
         model.addAttribute("receipts", receipts);
         return "modules/order/refundRecord";
     }

+ 2 - 2
src/main/java/com/caimei/modules/product/dao/CmOrganizeProductInfoMapper.java

@@ -74,8 +74,8 @@ public interface CmOrganizeProductInfoMapper extends CrudDao<CmOrganizeProductIn
     /**
      * 批量修改商品组织信息(采购平台独立字段)
      *
-     * @param organizeIds 需要删除的数据主键集合
+     * @param organizeId
      * @return 结果
      */
-    public int updateNotCmOrganizeProductInfos(@Param("organizeIds") Integer[] organizeIds,  @Param("productId")Integer productId,@Param("validFlag")Integer validFlag);
+    int updateNotCmOrganizeProductInfos(@Param("organizeId") Integer organizeId,  @Param("productId")Integer productId,@Param("costCheckFlag") Integer costCheckFlag,@Param("validFlag")Integer validFlag);
 }

+ 2 - 0
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -196,6 +196,8 @@ public interface ProductDao extends CrudDao<Product> {
 
     List<CmSku> findSkuList(Integer productID);
 
+    Integer getCostCheckFlag(@Param("productId") Integer productId,@Param("organizeId") Integer organizeId);
+
     List<CmSku> findSkuListProduct(Integer productID);
 
     List<CmSku> findSkuOrganizeList(Integer productID);

+ 12 - 0
src/main/java/com/caimei/modules/product/entity/CmOrganizeProductInfo.java

@@ -28,6 +28,10 @@ public class CmOrganizeProductInfo  extends DataEntity<CmOrganizeProductInfo> im
      * 商品id
      */
     private Integer productId;
+    /**
+     * 成本类型:1固定成本 2比例成本
+     */
+    private Integer costCheckFlag;
     /**
      * 0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
      */
@@ -49,6 +53,14 @@ public class CmOrganizeProductInfo  extends DataEntity<CmOrganizeProductInfo> im
         this.productId = productId;
     }
 
+    public Integer getCostCheckFlag() {
+        return costCheckFlag;
+    }
+
+    public void setCostCheckFlag(Integer costCheckFlag) {
+        this.costCheckFlag = costCheckFlag;
+    }
+
     public Integer getValidFlag() {
         return validFlag;
     }

+ 19 - 1
src/main/java/com/caimei/modules/product/entity/CmSku.java

@@ -24,7 +24,9 @@ public class CmSku extends DataEntity<CmSku> {
     private String stock;        // 库存
     private Integer costCheckFlag;        // 成本价选中标志:1固定成本 2比例成本
     private Double shopPercent;        // 比例成本百分比
-    private Double costPrice;        // 成本价
+    private Double costPrice;        // 供应商成本价
+    private Double organizeCostPrice;        // 集团成本价
+    private Double cmCostPrice;        // 采美成本价
     private Double price;        // 机构价
     private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
     private Integer minBuyNumber;        // 无阶梯价起订量
@@ -156,6 +158,22 @@ public class CmSku extends DataEntity<CmSku> {
         this.costPrice = costPrice;
     }
 
+    public Double getOrganizeCostPrice() {
+        return organizeCostPrice;
+    }
+
+    public void setOrganizeCostPrice(Double organizeCostPrice) {
+        this.organizeCostPrice = organizeCostPrice;
+    }
+
+    public Double getCmCostPrice() {
+        return cmCostPrice;
+    }
+
+    public void setCmCostPrice(Double cmCostPrice) {
+        this.cmCostPrice = cmCostPrice;
+    }
+
     public Double getPrice() {
         return price;
     }

+ 9 - 0
src/main/java/com/caimei/modules/product/entity/Product.java

@@ -70,6 +70,7 @@ public class Product extends DataEntity<Product> {
     private String shopPercent;        // 比例成本百分比
     private Double sqlShopPercent;     //入数据库字段
     private String costCheckFlag;        // 成本价选中标志:1固定成本 2比例成
+    private String mallCostCheckFlag;        // 成本价选中标志:1固定成本 2比例成
     private String precisehKey;        // 精确关键字
     private String giftFlag;//是否可以参加赠送(0:无法参加,1:可以参加赠送,2:已参加过赠送)
     private String beginTimeStr;//活动开始时间串
@@ -1033,6 +1034,14 @@ public class Product extends DataEntity<Product> {
         this.costCheckFlag = costCheckFlag;
     }
 
+    public String getMallCostCheckFlag() {
+        return mallCostCheckFlag;
+    }
+
+    public void setMallCostCheckFlag(String mallCostCheckFlag) {
+        this.mallCostCheckFlag = mallCostCheckFlag;
+    }
+
     public String getPrecisehKey() {
         return precisehKey;
     }

+ 23 - 5
src/main/java/com/caimei/modules/product/service/ProductService.java

@@ -333,23 +333,39 @@ public class ProductService extends CrudService<ProductDao, Product> {
             listMall.sort(Comparator.naturalOrder());
             String strip = StringUtils.strip(listMall.toString(), "[]");
             product.setGroundMall(strip.replaceAll(",", "##").trim());
-            cmOrganizeProductInfoMapper.updateNotCmOrganizeProductInfos(listMall.toArray(new Integer[listMall.size()]),product.getProductID(),3);
             listMall.forEach(s -> {
                 CmOrganizeProductInfo cmOrganizeProductInfoOrganizeId = new CmOrganizeProductInfo();
                 cmOrganizeProductInfoOrganizeId.setOrganizeId(s);
                 cmOrganizeProductInfoOrganizeId.setProductId(product.getProductID());
+                // 调整商品信息表
+                CmOrganizeProductInfo cmOrganizeProductInfo = new CmOrganizeProductInfo();
+                if (0 == s) {
+                    cmOrganizeProductInfo.setCostCheckFlag(Integer.parseInt(product.getCostCheckFlag()));
+                } else if (4 == s){
+                    cmOrganizeProductInfo.setCostCheckFlag(Integer.parseInt(product.getMallCostCheckFlag()));
+                }
                 if ( null == cmOrganizeProductInfoMapper.getByCmOrganizeProductInfo(cmOrganizeProductInfoOrganizeId)){
-                    CmOrganizeProductInfo cmOrganizeProductInfo = new CmOrganizeProductInfo();
                     cmOrganizeProductInfo.setOrganizeId(s);
                     cmOrganizeProductInfo.setProductId(product.getProductID());
                     cmOrganizeProductInfo.setValidFlag(1);
                     cmOrganizeProductInfoMapper.addCmOrganizeProductInfo(cmOrganizeProductInfo);
+                } else {
+                    Integer validFlag = 0;
+                    if (!strip.contains(s.toString())) {
+                        validFlag = 3;
+                    } else {
+                        validFlag = 2;
+                    }
+                    cmOrganizeProductInfoMapper.updateNotCmOrganizeProductInfos(s, product.getProductID(), cmOrganizeProductInfo.getCostCheckFlag(), validFlag);
                 }
 
             });
         } else {
             product.setGroundMall("");
-            cmOrganizeProductInfoMapper.delCmOrganizeProductInfoByOrganizeIds(new Integer[]{0, 4},product.getProductID());
+            /**
+             * 即使不上架平台,商品状态也不能直接删除,将商品状态置为下架,删除状态
+             */
+            cmOrganizeProductInfoMapper.updateNotCmOrganizeProductInfos(999,product.getProductID(),999,10);
         }
         if (null != product.getShopType() && 2 == product.getShopType()) {
             product.setValidFlag("2");
@@ -671,8 +687,9 @@ public class ProductService extends CrudService<ProductDao, Product> {
 
     public List<CmSku> findSkuList(Integer productID) {
         List<CmSku> skus = productDao.findSkuListProduct(productID);
+        Integer costCheckFlag = productDao.getCostCheckFlag(productID, 0);
         skus.forEach(s -> {
-            s.setCostCheckFlag(2);
+            s.setCostCheckFlag(costCheckFlag);
             s.ladderPriceList(productDao.findLadderPriceBySku(s.skuId()));
         });
 
@@ -681,8 +698,9 @@ public class ProductService extends CrudService<ProductDao, Product> {
 
     public List<CmSku> findMallSkuList(Integer productID) {
         List<CmSku> skuOrganizeList = productDao.findSkuOrganizeList(productID);
+        Integer costCheckFlag = productDao.getCostCheckFlag(productID, 4);
         skuOrganizeList.forEach(o -> {
-            o.setCostCheckFlag(2);
+            o.setCostCheckFlag(costCheckFlag);
         });
         return skuOrganizeList;
     }

+ 11 - 4
src/main/java/com/caimei/modules/product/web/ProductNewController.java

@@ -483,9 +483,16 @@ public class ProductNewController extends BaseController {
                 searchKeyStr += "##";
             }
         }
-        if (null != product.getSkuList()) {
+        /*if (null != product.getSkuList()) {
             for (CmSku s : product.getSkuList()) {
-                if (null != s.getCostCheckFlag() && s.getCostCheckFlag() == 2) {
+                if (StringUtils.isNotBlank(product.getCostCheckFlag()) && "1".equals(product.getCostCheckFlag())) {
+                    double v = MathUtil.add(MathUtil.add(s.getCostPrice(), s.getOrganizeCostPrice()), s.getCmCostPrice()).doubleValue();
+                    if (v != s.getPrice()) {
+                        addMessage(redirectAttributes, "保存商品失败,sku固定成本之和需要等于机构价!");
+                        return "redirect:" + Global.getAdminPath() + "/product/new/productEdit?id="+product.getId();
+                    }
+                }
+                if (StringUtils.isNotBlank(product.getCostCheckFlag()) && "2".equals(product.getCostCheckFlag())) {
                     if (s.getShopPercent()==0) {
                         addMessage(redirectAttributes, "保存商品失败,供应商比例必须大于0");
                         return "redirect:" + Global.getAdminPath() + "/product/new/productEdit?id="+product.getId();
@@ -497,7 +504,7 @@ public class ProductNewController extends BaseController {
                     }
                 }
             }
-        }
+        }*/
         product.setSearchKey(searchKeyStr);
         productDetailInfo.setProductID(product.getProductID());
         productService.saveProduct(product, productDetailInfo);
@@ -825,7 +832,7 @@ public class ProductNewController extends BaseController {
 
     @RequestMapping("auditProduct")
     @ResponseBody
-    public Map<String, Object> auditProduct(String validFlag, Integer newvalidFlag, String showtime, Integer productID, String remarks) {
+    public synchronized Map<String, Object> auditProduct(String validFlag, Integer newvalidFlag, String showtime, Integer productID, String remarks) {
         Map<String, Object> map = Maps.newLinkedHashMap();
         try {
             if (StringUtils.isBlank(validFlag) || null == productID) {

+ 4 - 2
src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml

@@ -38,8 +38,10 @@
 
 	<select id="findSencondProductPage" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
 		SELECT b.name as shopName ,b.`shopID` as shopId,a.name purchaseProductName,
-		cs.price,a.`productID` as productId,a.productCode productNo,a.mainImage image
-		,cs.costCheckFlag,cs.costPrice,cs.shopPercent, cs.normalPrice
+		cs.price,a.`productID` as productId,a.productCode productNo,
+		a.mainImage image,
+		(SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
+		cs.costPrice,cs.shopPercent, cs.normalPrice
 		,a.productCategory as "productCategory",cshd.secondHandType as "secondHandType",cs.ladderPriceFlag
 		,a.includedTax
 		,a.invoiceType

+ 1 - 0
src/main/resources/mappings/modules/cmpage/CmPageCentreMapper.xml

@@ -203,6 +203,7 @@
 		  left join cm_hehe_product chp on a.productId = chp.productId
 		WHERE
 		  a.centreId = #{centreId}
+
           <if test="type != null and type == '8'">
               and chp.id is not null
           </if>

+ 1 - 1
src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml

@@ -301,7 +301,7 @@
                ifnull(cs.shopPercent, 0) as shopPercent,
                ifnull(cs.organizePercent, 0) as organizePercent,
                ifnull(cs.cmPercent, 0) as cmPercent,
-               ifnull(cs.costCheckFlag, 0)    as costType,
+               ifnull((SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ), 0)    as costType,
                ifnull(cs.costPrice, 0)        as costPrice
             ,cs.organizeId
         from cm_sku cs

+ 5 - 3
src/main/resources/mappings/modules/order/CmPayShopMapper.xml

@@ -70,6 +70,10 @@
 		LEFT JOIN cm_pay_shop_record psr ON psr.payShopID = a.id
 		LEFT JOIN cm_shop_order so ON so.shopOrderID = psr.shopOrderID
 		<where>
+			(a.shopId = 1161 OR s.AccountOwnership = 0 OR so.splitCode = 'E1807059160' or so.ordertype = 2)
+			and a.delFlag = '0'
+			and (so.organizeID!=4 or so.organizeID is null)
+			and a.shopID != 998
 			<if test="id != null and id != ''">
 				and a.id = #{id}
 			</if>
@@ -118,9 +122,6 @@
 			<if test="paymentType != null">
 				AND a.id IN(SELECT payShopID FROM cm_pay_shop_record WHERE paymentType = #{paymentType} AND delFlag = 0)
 			</if>
-			and a.delFlag = '0'
-			and (so.organizeID!=4 or so.organizeID is null)
-			and a.shopID != 998
 		</where>
 		GROUP BY a.id
 		<choose>
@@ -131,6 +132,7 @@
 				ORDER BY a.id desc
 			</otherwise>
 		</choose>
+
 	</select>
 
 	<select id="findAllList" resultType="CmPayShop">

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

@@ -157,6 +157,16 @@
           AND b.delFlag = '0'
     </select>
 
+    <select id="findReceiptByShopOrderId" resultType="java.lang.Double">
+        select IFNULL(sum(associateAmount), 0)
+        from cm_receipt_order_relation a
+                 left join cm_discern_receipt b on a.receiptID = b.id
+        where a.shopOrderId = #{shopOrderId}
+          AND b.receiptStatus = '3'
+          AND a.delFlag = '0'
+          AND b.delFlag = '0'
+    </select>
+
     <select id="toAudit" resultType="java.lang.Integer">
         SELECT cdr.id
         FROM `cm_receipt_order_relation` cror
@@ -170,11 +180,20 @@
     <select id="findOrderRelation" resultType="CmReceiptOrderRelation">
         SELECT *
         FROM cm_receipt_order_relation
-        WHERE orderID = #{orderID}
+        WHERE (orderID = #{orderId} or shopOrderId = #{shopOrderId})
           AND delFlag = '0'
         GROUP BY orderID
     </select>
 
+    <select id="getDiscernPayWay" resultType="java.lang.Integer">
+        SELECT cdr.payWay
+        FROM cm_receipt_order_relation cror
+                 LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        WHERE cror.orderID = #{orderID} and cror.delFlag = 0
+        ORDER BY cdr.payWay
+        LIMIT 1
+    </select>
+
     <select id="findOnlinePayment" resultType="date">
         SELECT cdr.receiptDate
         FROM cm_receipt_order_relation cror

+ 82 - 19
src/main/resources/mappings/modules/order/OrderMapper.xml

@@ -173,6 +173,12 @@
             <if test="orderNo != null and orderNo != ''">
                 AND co.orderNo = #{orderNo}
             </if>
+            <if test="shopOrderID != null and shopOrderID != ''">
+                AND cso.shopOrderID = #{shopOrderID}
+            </if>
+            <if test="shopOrderNo != null and shopOrderNo != ''">
+                AND cso.shopOrderNo = #{shopOrderNo}
+            </if>
             <if test="organizeID != null">
                 AND co.organizeID = #{organizeID}
             </if>
@@ -1132,14 +1138,6 @@
         ORDER BY cop.discountPrice DESC
     </select>
 
-    <select id="getOrderProductPaidAmount" resultType="java.lang.Double">
-        SELECT SUM(splitAccount)
-        FROM cm_split_account
-        WHERE orderProductId = #{orderProductId}
-          AND payStatus = 1
-          AND productType = 1
-    </select>
-
     <select id="getShopOrderListByOrderId" resultType="com.caimei.modules.order.entity.ShopOrderVo">
         SELECT shopOrderID AS shopOrderId,
                shopOrderNo,
@@ -1167,7 +1165,8 @@
                payStatus,
                sendOutStatus,
                splitFlag,
-               splitCode
+               splitCode,
+               organizeId
         FROM cm_shop_order
         WHERE delFlag = 0
           AND shopOrderID = #{shopOrderId}
@@ -1265,7 +1264,6 @@
                cop.productImage                                                   AS image,
                cop.price,
                cop.shopName,
-               IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
                cop.normalPrice,
                cop.ladderPriceFlag,
                cop.discountPrice,
@@ -1296,17 +1294,19 @@
                cop.notOutStore,
                cop.isActProduct                                                   AS actProduct,
                cop.productType,
-               p.productCategory                                                  as productCategory,
-               p.splitCode,
-               cs.shopPercent,
-               cs.cmPercent,
-               cs.organizePercent
+               p.productCategory                                                  AS productCategory,
+               cop.organizeId,
+#                当前版本采美豆抵运费未实装,且运费子订单已取消,运费金额并入子订单,取值不做操作
+#                IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
+               IFNULL(cop.costPrice,0)                                            AS costPrice,
+               IFNULL(cop.organizeCostPrice,0)                                    AS organizeCostPrice,
+               IFNULL(cop.cmCostPrice,0)                                          AS cmCostPrice,
+               p.splitCode
         FROM cm_order_product cop
-                 LEFT JOIN product p ON cop.productID = p.productID
-                 left join cm_order co on co.orderID = cop.orderID
-                 left join cm_sku cs on cop.skuId = cs.skuId and cop.organizeID=cs.organizeID
+        LEFT JOIN product p ON cop.productID = p.productID
+        left join cm_order co on co.orderID = cop.orderID
         WHERE cop.shopOrderID = #{shopOrderId}
-          AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
+#           AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
         group by p.productID
         ORDER BY cop.discountPrice DESC
     </select>
@@ -1455,6 +1455,13 @@
         from cm_voucher_image
         where voucherId = #{id}
     </select>
+    <select id="getPaidOrganizePrice" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 5
+    </select>
     <insert id="insertSplitAccount">
         INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId, vipRecordId,
                                       authVipRecordId, type, subUserNo, splitAccount,
@@ -2022,6 +2029,62 @@
         limit 0,1
     </select>
 
+    <select id="findSplitCodeByOrganize" resultType="java.lang.String">
+        select splitCode from cm_mall_organize where id = #{organizeId}
+    </select>
+
+    <select id="findPayOther" resultType="java.lang.Double">
+        SELECT IFNULL(SUM(payAmount),0)
+        FROM cm_pay_shop_record cpsr
+        LEFT JOIN cm_pay_shop cps ON cpsr.payShopID = cps.id
+        WHERE cpsr.delFLag = 0
+          AND cps.delFlag = 0
+          AND cpsr.paymentType = 3
+          AND cps.status = 1
+          AND cpsr.status = 1
+          AND cpsr.shopOrderId = #{shopOrderId}
+    </select>
+
+    <select id="getShopOrderPaidAmount" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 1
+    </select>
+
+    <select id="getOtherPaid" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 6
+          AND type = 6
+    </select>
+
+    <select id="findShopCost" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 1
+    </select>
+
+    <select id="findPayOrganize" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 5
+    </select>
+
+    <select id="findOrganizeSplitByShopOrder" resultType="java.lang.String">
+        select cmo.splitCode
+        from cm_mall_organize cmo
+        left join cm_shop_order cso on cmo.id = cso.organizeID
+        where cso.shopOrderID = #{shopOrderId}
+    </select>
+
     <insert id="addCmOrder" parameterType="com.caimei.modules.order.entity.NewOrder" useGeneratedKeys="true" keyProperty="orderID">
         insert into cm_order
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 15 - 2
src/main/resources/mappings/modules/order/OrderProductMapper.xml

@@ -81,7 +81,7 @@
 		a.`productImage` AS `productImage`,
 		a.`shopName` AS `shopName`,
 		cs.stock AS stock,
-		cs.costCheckFlag AS costCheckFlag,
+		(SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
 		cs.costPrice AS costPrice,
 		cs.organizeId AS organizeId,
 		cs.unit AS unit,
@@ -477,7 +477,13 @@
     <update id="updateProductFee">
         UPDATE cm_order_product
         SET costPrice               = #{costPrice},
+            organizeCostPrice       = #{organizeCostPrice},
+            cmCostPrice             = #{cmCostPrice},
+            shopPercent             = #{shopPercent},
+            organizePercent         = #{organizePercent},
+            cmPercent               = #{cmPercent},
             supplierTaxRate         = #{supplierTaxRate},
+            taxRate                 = #{taxRate},
             shouldPayTotalTax       = #{shouldPayTotalTax},
             singleShouldPayTotalTax = #{singleShouldPayTotalTax}
         WHERE orderProductID = #{orderProductID}
@@ -544,7 +550,6 @@
                cop.totalFee                AS totalFee,
                cop.shouldPayTotalTax       AS shouldPayTotalTax,
                cop.shopProductAmount       AS shopProductAmount,
-               cop.costPrice               AS costPrice,
                cop.singleShouldPayTotalTax AS singleShouldPayTotalTax,
                cop.taxRate                 AS taxRate,
                cop.supplierTaxRate         AS supplierTaxRate,
@@ -554,6 +559,14 @@
                cop.productType             AS productType,
                cop.totalAddedValueTax      AS totalAddedValueTax,
                cs.organizeId      AS organizeId,
+               cs.unit as productUnit,
+               (cop.discountPrice - cop.costPrice - cop.cmCostPrice) as brokerage,
+               cop.costPrice               AS costPrice,
+               ifnull(cop.organizeCostPrice, 0)       AS organizeCostPrice,
+               ifnull(cop.cmCostPrice, 0)             AS cmCostPrice,
+               cop.shopPercent,
+               cop.organizePercent,
+               cop.cmPercent,
                cpo.touchPrice              AS touchPrice
         from cm_order_product cop
                  left join cm_sku cs on cop.skuId = cs.skuId and cs.organizeId=cop.organizeId

File diff suppressed because it is too large
+ 766 - 490
src/main/resources/mappings/modules/order/ShopOrderMapper.xml


+ 7 - 4
src/main/resources/mappings/modules/product/CmOrganizeProductInfoMapper.xml

@@ -48,11 +48,13 @@
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="organizeId != null">organizeId,</if>
             <if test="productId != null">productId,</if>
+            <if test="costCheckFlag != null">costCheckFlag,</if>
             <if test="validFlag != null">validFlag,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="organizeId != null">#{organizeId},</if>
             <if test="productId != null">#{productId},</if>
+            <if test="costCheckFlag != null">#{costCheckFlag},</if>
             <if test="validFlag != null">#{validFlag},</if>
         </trim>
     </insert>
@@ -88,11 +90,12 @@
         update cm_organize_product_info
         <trim prefix="SET" suffixOverrides=",">
             <if test="validFlag != null">validFlag = #{validFlag},</if>
+            <if test="costCheckFlag != null and costCheckFlag != 999">costCheckFlag = #{costCheckFlag},</if>
         </trim>
-        where productId = #{productId} and organizeId not in
-        <foreach item="organizeId" collection="organizeIds" open="(" separator="," close=")">
-            #{organizeId}
-        </foreach>
+        where productId = #{productId}
+            <if test="organizeId != null and organizeId != 999">
+                and organizeId = #{organizeId}
+            </if>
     </update>
 
 </mapper>

+ 14 - 6
src/main/resources/mappings/modules/product/CmPromotionMapper.xml

@@ -140,7 +140,7 @@
                p.`productID`       productId,
                p.productCode       productNo,
                p.mainImage         image,
-               cs.costCheckFlag    costCheckFlag,
+               (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
                cs.costPrice        costPrice,
                cs.organizeId        organizeId,
                cs.shopPercent shopPercent,
@@ -461,9 +461,13 @@
     </select>
 
     <select id="getPromotionSkus" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT DISTINCT cs.unit, cs.costCheckFlag, cs.costPrice, cs.shopPercent, cps.touchPrice
-                               , cs.skuId
-                               , cs.organizeId
+        SELECT DISTINCT cs.unit,
+                        (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
+                        cs.costPrice,
+                        cs.shopPercent,
+                        cps.touchPrice,
+                        cs.skuId,
+                        cs.organizeId
         FROM cm_promotions cp
                  LEFT JOIN cm_promotions_product cpp ON cp.id = cpp.promotionsId
                  LEFT JOIN cm_sku cs ON cpp.productId = cs.productId
@@ -472,8 +476,12 @@
     </select>
 
     <select id="getPromotionSkusByProduct" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT cs.skuId,cs.unit, cs.costCheckFlag, cs.costPrice, cs.shopPercent, cps.touchPrice
-                      , cs.organizeId
+        SELECT cs.skuId,cs.unit,
+               (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
+               cs.costPrice,
+               cs.shopPercent,
+               cps.touchPrice,
+               cs.organizeId
         FROM cm_sku cs
                  LEFT JOIN cm_promotion_sku cps ON cs.skuId = cps.skuId
         WHERE cs.productId = #{productIds} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)

+ 1 - 1
src/main/resources/mappings/modules/product/CmSecondHandDetailMapper.xml

@@ -47,7 +47,7 @@
 		cs.stock AS "stock",
 		p.brandID AS "brandID",
 		cs.costPrice as "costPrice",
-		cs.costCheckFlag AS "costCheckFlag",
+		(SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
 		cs.shopPercent AS "shopPercent",
 		cs.organizeId AS "organizeId",
 		p.visibility AS "visibility",

+ 109 - 49
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -122,7 +122,9 @@
 
     <select id="get" resultType="Product">
         SELECT
-        <include refid="productColumns"/>
+        <include refid="productColumns"/>,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 0 ) as costCheckFlag,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 4 ) as mallCostCheckFlag
         FROM product a
         <include refid="productJoins"/>
         WHERE a.productID = #{id}
@@ -1051,12 +1053,25 @@
          normalPrice,
          price,
          ladderPriceFlag,
-         costCheckFlag,
-         costprice,
+         <if test="costPrice != null and costPrice != ''">
+            costprice,
+         </if>
+         <if test="organizeCostPrice != null and organizeCostPrice != ''">
+            organizeCostPrice,
+         </if>
+         <if test="cmCostPrice != null and cmCostPrice != ''">
+            cmCostPrice,
+         </if>
          stock,
-         shopPercent,
-         organizePercent,
-         cmPercent,
+         <if test="shopPercent != null and shopPercent != ''">
+            shopPercent,
+         </if>
+         <if test="organizePercent != null and organizePercent != ''">
+            organizePercent,
+         </if>
+         <if test="cmPercent != null and cmPercent != ''">
+            cmPercent,
+         </if>
          organizeId,
          minBuyNumber,
          unit)
@@ -1064,12 +1079,25 @@
                 #{normalPrice},
                 #{price},
                 #{ladderPriceFlag},
-                #{costCheckFlag},
-                #{costPrice},
+                <if test="costPrice != null and costPrice != ''">
+                    #{costPrice},
+                </if>
+                <if test="organizeCostPrice != null and organizeCostPrice != ''">
+                    #{organizeCostPrice},
+                </if>
+                <if test="cmCostPrice != null and cmCostPrice != ''">
+                    #{cmCostPrice},
+                </if>
                 #{stock},
-                #{shopPercent},
-                #{organizePercent},
-                #{cmPercent},
+                <if test="shopPercent != null and shopPercent != ''">
+                    #{shopPercent},
+                </if>
+                <if test="organizePercent != null and organizePercent != ''">
+                    #{organizePercent},
+                </if>
+                <if test="cmPercent != null and cmPercent != ''">
+                    #{cmPercent},
+                </if>
                 #{organizeId},
                 #{minBuyNumber},
                 #{unit})
@@ -1094,6 +1122,8 @@
                 #{stock},
                 #{minBuyNumber},
                 #{unit},
+                #{organizeCostPrice},
+                #{cmCostPrice},
                 #{organizePercent},
                 #{shopPercent},
                 #{cmPercent})
@@ -1710,11 +1740,24 @@
             normalPrice=#{normalPrice},
             price=#{price},
             organizeId=#{organizeId},
-            shopPercent=#{shopPercent},
-            organizePercent=#{organizePercent},
-            cmPercent=#{cmPercent},
-            costPrice=#{costPrice},
-            costCheckFlag=#{costCheckFlag},
+            <if test="shopPercent != null and shopPercent !=''">
+                shopPercent=#{shopPercent},
+            </if>
+            <if test="organizePercent != null and organizePercent !=''">
+                organizePercent=#{organizePercent},
+            </if>
+            <if test="cmPercent != null and cmPercent !=''">
+                cmPercent=#{cmPercent},
+            </if>
+            <if test="costPrice != null and costPrice !=''">
+                costPrice=#{costPrice},
+            </if>
+            <if test="organizeCostPrice != null and organizeCostPrice !=''">
+                organizeCostPrice = #{organizeCostPrice},
+            </if>
+            <if test="cmCostPrice != null and cmCostPrice !=''">
+                cmCostPrice = #{cmCostPrice},
+            </if>
             stock=#{stock},
             unit=#{unit},
             minBuyNumber=#{minBuyNumber}
@@ -1978,7 +2021,7 @@
                unit,
                normalPrice,
                stock,
-               costCheckFlag,
+               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
                shopPercent,
                costPrice,
                price,
@@ -1994,6 +2037,9 @@
         where cs.productId = #{productID}
           and  cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=#{productID})
     </select>
+    <select id="getCostCheckFlag" resultType="java.lang.Integer">
+        select costCheckFlag from cm_organize_product_info where productId = #{productId} and organizeId = #{organizeId}
+    </select>
     <select id="findSkuListProduct" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.skuId,
                cs.productId,
@@ -2001,11 +2047,13 @@
                unit,
                normalPrice,
                stock,
-               costCheckFlag,
+               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
                shopPercent,
                organizePercent,
                cmPercent,
                costPrice,
+               organizeCostPrice,
+               cmCostPrice,
                price,
                ladderPriceFlag,
                minBuyNumber,
@@ -2017,22 +2065,24 @@
         where cs.organizeId=0 and  cs.productId = #{productID}
     </select>
     <select id="findSkuOrganizeList" resultType="com.caimei.modules.product.entity.CmSku">
-        select skuId,
-               productId,
-               organizeId,
-               unit,
-               normalPrice,
-               stock,
-               "2" as costCheckFlag,
-               shopPercent as shopPercent,
-               costPrice,
-               price,
-               minBuyNumber,
-               organizePercent,
-               shopPercent,
-               cmPercent
-        from cm_sku
-        where organizeId=4  and productId = #{productID}
+        select cs.skuId,
+               cs.productId,
+               cs.organizeId,
+               cs.unit,
+               cs.normalPrice,
+               cs.stock,
+               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               cs.shopPercent as shopPercent,
+               cs.costPrice,
+               cs.organizeCostPrice,
+               cs.cmCostPrice,
+               cs.price,
+               cs.minBuyNumber,
+               cs.organizePercent,
+               cs.shopPercent,
+               cs.cmPercent
+        from cm_sku cs
+        where cs.organizeId = 4  and cs.productId = #{productID}
     </select>
     <select id="findLadderPriceBySku" resultType="com.caimei.modules.product.entity.CmLadderPrice">
         select skuId, productId, userType, ladderNum, buyNum, buyPrice, delFlag
@@ -2071,12 +2121,11 @@
                cs.organizeId,
                cs.unit,
                cs.stock,
-               cs.costCheckFlag,
+               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
                cs.costPrice,
                ifnull(cs.shopPercent, 0) as shopPercent,
                ifnull(cs.organizePercent, 0) as organizePercent,
                ifnull(cs.cmPercent, 0) as cmPercent,
-               ifnull(cs.costCheckFlag, 0)    as costType,
                chs.price
         from cm_sku cs
                  left join cm_hehe_sku chs on cs.skuId = chs.skuId
@@ -2089,29 +2138,40 @@
         where productId = #{productId}
     </select>
     <select id="findSku" resultType="com.caimei.modules.product.entity.CmSku">
-        select price, ifnull(costPrice, 0) as costPrice, costCheckFlag, shopPercent, normalPrice
+        select cs.price,
+               ifnull(cs.costPrice, 0) as costPrice,
+               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               cs.shopPercent,
+               cs.normalPrice
         from cm_sku cs
-        where productId = #{productId}
+        where cs.productId = #{productId}
           and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
-        order by price asc
+        order by cs.price asc
         limit 1
     </select>
     <select id="findOrganizeSku" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT price, ifnull(costPrice, 0),"1" AS costCheckFlag, shopPercent AS shopPercent
-                    , normalPrice
-                    , organizeId
+        SELECT cs.price,
+               ifnull(cs.costPrice, 0),
+               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               cs.shopPercent AS shopPercent,
+               cs.normalPrice,
+               cs.organizeId
         FROM cm_sku cs
-        WHERE productId = #{productId}
+        WHERE cs.productId = #{productId}
           and cs.organizeId=4
-        ORDER BY price ASC
+        ORDER BY cs.price ASC
         LIMIT 1
     </select>
     <select id="findSkuById" resultType="com.caimei.modules.product.entity.CmSku">
-        select skuId, price, costPrice, costCheckFlag, shopPercent
-                    , unit
-                    , organizeId
-        from cm_sku
-        where skuId = #{skuId}
+        select cs.skuId,
+               cs.price,
+               cs.costPrice,
+               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               cs.shopPercent,
+               cs.unit,
+               cs.organizeId
+        from cm_sku cs
+        where cs.skuId = #{skuId}
           and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
     </select>
     <select id="findSkuIdByPromotionsId" resultType="java.lang.Integer">

+ 8 - 2
src/main/resources/mappings/modules/product/ProductNewMapper.xml

@@ -121,7 +121,9 @@
     </sql>
     <select id="get" resultType="Product">
         SELECT
-        <include refid="productColumns"/>
+        <include refid="productColumns"/>,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 0 ) as costCheckFlag,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 4 ) as mallCostCheckFlag
         FROM product a
         <include refid="productJoins"/>
         WHERE a.productID = #{id}
@@ -140,7 +142,11 @@
         SELECT
         <include refid="productColumns"/>
         FROM product a
-        <include refid="productJoins"/>
+        LEFT JOIN shop s ON s.shopID = a.shopID
+        LEFT JOIN cm_second_hand_detail cshd ON cshd.productID = a.productID
+        LEFT JOIN cm_brand cb ON a.brandID = cb.id
+        LEFT JOIN cm_svip_product csp on a.productID = csp.productId
+        left join (select * from cm_organize_product_info ) copi on copi.productId = a.productID
         <where>
               copi.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=a.productID)
             <if test="id !=null and id !=''">

+ 1 - 1
src/main/resources/mappings/modules/product/RepeatPurchasePriceMapper.xml

@@ -64,7 +64,7 @@
 			IFNULL(c.registerUserTypeID,3) As "type",
 			b.name AS "productName",
 		  	cs.unit,
-            CASE   cs.costCheckFlag
+            CASE   (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId )
             WHEN  1 THEN cs.`costPrice`
             WHEN  2 THEN cs.`shopPercent` * cs.`price` / 100
             END   AS "costPrice"

+ 1 - 1
src/main/resources/mappings/modules/weisha/CmOrganizeProductMapper.xml

@@ -80,7 +80,7 @@
         cmps.price,
         cmps.stock,
         cmps.unit,
-        "2" as costCheckFlag,
+        (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cmps.productId AND organizeId = cmps.organizeId ) AS costCheckFlag,
         cmps.organizePercent,
         cmps.shopPercent,
         cmps.cmPercent

+ 144 - 187
src/main/webapp/WEB-INF/views/modules/order/checkPaymentOrder.jsp

@@ -331,13 +331,13 @@
     <li class="active tab-li"><a href="${ctx}/shopOrder/checkPaymentOrder">订单财务信息</a></li>
 </ul>
 
-<form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newOrder"
+<form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newShopOrder"
            action="${ctx}/shopOrder/checkPaymentOrder" 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="shopOrderIDs" htmlEscape="false" onkeyup="onlynum(this)" maxlength="8" class="input-medium"/>
+        <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>
@@ -368,18 +368,17 @@
                               htmlEscape="false"/>
             </form:select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
             <label>退款状态:</label>
-            <form:select path="refundType" class="select-ele input-medium required">
+            <form:select path="refundStatus" class="select-ele input-medium required">
                 <form:option value="" label="所有"/>
-                <form:option value="0" label="无退款"/>
-                <form:option value="1" label="部分退款"/>
-                <form:option value="2" label="已退款"/>
+                <form:option value="1" label="无退款"/>
+                <form:option value="3" label="有退款"/>
             </form:select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-            <label>返佣订单:</label>
+            <%--<label>返佣订单:</label>
             <form:select path="rebateOrder" class="select-ele input-medium required">
                 <form:option value="" label="请选择"/>
                 <form:option value="1" label="是"/>
                 <form:option value="0" label="否"/>
-            </form:select>
+            </form:select>--%>
         </div>
         <div class="pay-status">
             <label>组织:</label>
@@ -412,6 +411,7 @@
             <table class="table table-striped table-bordered table-condensed pay-table">
                 <tr class="t1">
                     <th class="item0">序号</th>
+                    <th colspan="2">子订单编号(ID)</th>
                     <th colspan="2">母订单编号(ID)</th>
                     <th>下单时间</th>
                     <th>订单金额</th>
@@ -427,56 +427,34 @@
                     <th>已结金额</th>
                     <th>退款状态</th>
                     <th>退款金额</th>
-                    <th>机构</th>
                     <th>优惠券</th>
                     <th>经理折扣</th>
-                    <th>机构运费</th>
-                    <th>是否返佣</th>
                 </tr>
                 <tr>
                     <td rowspan="0" class="item0">${(page.pageNo-1)*page.pageSize+sIndex.index+1}</td>
+                    <td colspan="2">${s.shopOrderNo}(${s.shopOrderID})</td>
                     <td colspan="2">${s.orderNo}(${s.orderID})</td>
                     <td>${s.orderTime}</td>
-                    <td><fmt:formatNumber value="${s.payTotalFee}" type="number" pattern="#,##0.00"/></td>
+                    <td><fmt:formatNumber value="${s.totalAmount}" type="number" pattern="#,##0.00"/></td>
                     <td>
-                        <c:if test="${s.status eq 11 || s.status eq 12 || s.status eq 13 ||s.status eq 21 ||s.status eq 22 ||
-				        s.status eq 23 || s.status eq 31 ||s.status eq 32 ||s.status eq 33}">交易中<br>(${fns:getDictLabel(s.status,"order_detail_status","" )})</c:if>
-                        <c:if test="${s.status eq 0 || s.status eq 4 || s.status eq 5 || s.status eq 6 || s.status eq 7}">${fns:getDictLabel(s.status,"order_detail_status","" )}</c:if>
-                        <c:if test="${s.status eq 6}">
-                            <br>${s.closeTime ne null?s.closeTime:''}
-                        </c:if>
+                        <c:if test="${s.status == 0}"><font color="red">待确认</font></c:if>
+                        <c:if test="${s.status == 1}"><font color="#ff8c00">已确认</font></c:if>
+                        <c:if test="${s.status == 2}"><font color="#ff8c00">交易完成</font></c:if>
+                        <c:if test="${s.status == 3}"><font color="green">订单完成</font></c:if>
+                        <c:if test="${s.status == 4}"><font color="green">已关闭</font></c:if>
+                        <c:if test="${s.status == 5}"><font color="green">交易全退</font></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>
-                            <c:if test="${s.receiptStatus == 4}">
-                                ----
-                            </c:if>
-                        </a>
+                        <c:if test="${s.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+                        <c:if test="${s.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                        <c:if test="${s.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
                     </td>
                     <td>
-                        <fmt:formatNumber value="${s.payableAmount}" type="number" pattern="#,##0.00"/>
-                        (余额抵扣:<fmt:formatNumber value="${s.balancePayFee}" type="number" pattern="#,##0.00"/>)
+                        <fmt:formatNumber value="${s.needPayAmount}" type="number" pattern="#,##0.00"/>
+                        (余额抵扣:<fmt:formatNumber value="${s.accountAmount}" type="number" pattern="#,##0.00"/>)
                     </td>
                     <td>
-                        <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
-                           style="text-decoration: underline">
-                            <c:if test="${s.alreadyReceipt eq '----'}">
-                                ${s.alreadyReceipt}
-                            </c:if>
-                            <c:if test="${s.alreadyReceipt ne '----'}">
-                                <fmt:formatNumber value="${s.alreadyReceipt}" type="number" pattern="#,##0.00"/>
-                            </c:if>
-                        </a>
+                        ${s.receiptAmount}
                     </td>
                     <td>
                         <c:if test="${s.payStatus == 1 || empty s.payStatus || s.payStatus == 0}"><font
@@ -484,7 +462,7 @@
                         <c:if test="${s.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
                         <c:if test="${s.payStatus == 3}"><font color="green">已付款</font>
                             <c:if test="${s.zeroCostFlag eq 1}">
-                                <a href="javascript:;" class="zeroCost"><span><img src="/static/images/info.jpg"
+                                <a href="javascript: void(0);" class="zeroCost"><span><img src="/static/images/info.jpg"
                                                                                    style="width: 15px;margin-bottom: 4px"></span>
                                     <div class="message">
                                         <span>商品成本为0,直接置为已付款,无需付款供应商</span>
@@ -494,162 +472,139 @@
                         </c:if>
                         <c:if test="${s.payStatus == 4}">----</c:if>
                     </td>
-                    <td><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></td>
+                    <td><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></td>
                     <td>
-                        <c:if test="${s.paid eq '----'}">
-                            ${s.alreadyReceipt}
-                        </c:if>
-                        <c:if test="${s.paid ne '----'}">
-                            <fmt:formatNumber value="${s.paid}" type="number" pattern="#,##0.00"/>
-                        </c:if>
+                        <fmt:formatNumber value="${s.payShopAmount}" type="number" pattern="#,##0.00"/>
                     </td>
                     <td>
-                        <c:if test="${s.onlinePayFlag eq 0}">
-                            <c:if test="${s.settleAmount < s.shouldPayShopAmount && s.settleAmount > 0}"><font color="#ff8c00">部分结算</font></c:if>
-                            <c:if test="${s.settleAmount eq s.shouldPayShopAmount && s.settleAmount > 0}"><font color="green">已结算</font></c:if>
-                            <c:if test="${s.settleAmount eq 0}"><font color="red">未结算</font></c:if>
-                        </c:if>
-                        <c:if test="${s.onlinePayFlag eq 1}">---</c:if>
+                        <c:if test="${s.settleStatus == 1}"><font color="#ff8c00">未结算</font></c:if>
+                        <c:if test="${s.settleStatus  == 2}"><font color="green">部分结算</font></c:if>
+                        <c:if test="${s.settleStatus == 3}"><font color="red">已结算</font></c:if>
                     </td>
                     <td>
-                        <c:if test="${s.onlinePayFlag eq 0}"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></c:if>
-                        <c:if test="${s.onlinePayFlag eq 1}">---</c:if>
+                        <fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
                     </td>
                     <td>
-                        <c:if test="${s.onlinePayFlag eq 0}"><fmt:formatNumber value="${s.settleAmount}" type="number" pattern="#,##0.00"/></c:if>
-                        <c:if test="${s.onlinePayFlag eq 1}">---</c:if>
+                        <fmt:formatNumber value="${s.settleAmount}" type="number" pattern="#,##0.00"/>
                     </td>
                     <td>
-                        <c:if test="${s.refundType == 1}">
-                            <font>部分退款</font>
-                        </c:if>
-                        <c:if test="${s.refundType == 2}">
-                            <font>已退款</font>
-                        </c:if>
-                        <c:if test="${s.refundType != 1 && s.refundType != 2}">
+                        <c:if test="${s.refundStatus == 1}">
                             <font>无退款</font>
                         </c:if>
-                    </td>
-                    <td><fmt:formatNumber value="${s.returnValue}" type="number" pattern="#,##0.00"/></td>
-                    <td>
-                        <c:if test="${s.organizeID == '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 test="${s.refundStatus == 3}">
+                            <font>有退款</font>
                         </c:if>
                     </td>
+                    <td><fmt:formatNumber value="${s.canRefundAmount}" type="number" pattern="#,##0.00"/></td>
                     <td>
-                            ${s.couponAmount}
+                        <fmt:formatNumber value="${s.couponAmount}" type="number" pattern="#,##0.00"/>
                     </td>
                     <td><fmt:formatNumber value="${s.discountFee}" type="number" pattern="#,##0.00"/></td>
+                </tr>
+                <tr class="t2">
+                    <th colspan="3">机构</th>
+                    <th colspan="3">供应商</th>
+                    <th colspan="2">商品费</th>
+                    <th colspan="2">已付供应商</th>
+                    <th>供应商退款</th>
+                    <th colspan="2">应付供应商</th>
+                    <th colspan="2">应付税费</th>
+                    <th colspan="2">机构运费</th>
+                    <th>供应商运费</th>
+                    <th colspan="2">付第三方</th>
+                </tr>
+                <tr class="t2">
+                    <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 == 4}"><font color="red">(丽格集采联盟)</font></c:if>
+                    </td>
+                    <td colspan="3">${s.shopName}</td>
+                    <td colspan="2" class="product-fee"><fmt:formatNumber value="${s.shopProductAmount}"
+                                                                          type="number" pattern="#,##0.00"/></td>
+                    <td colspan="2"><fmt:formatNumber value="${s.payedShopAmount}" type="number"
+                                                      pattern="#,##0.00"/></td>
                     <td>
-                        <c:if test="${s.freight == 0}">
+                        <fmt:formatNumber value="${s.refundAmount}" type="number" pattern="#,##0.00"/>
+                    </td>
+                    <td colspan="2">
+                        <c:if test="${s.differenceType ne 1 && s.differenceType ne 2 }">
+                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number"
+                                                                    pattern="#,##0.00"/></font>
+                        </c:if>
+                              <%--1少付2多付--%>
+                        <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount-s.shopOtherFee},已补差价:${s.differencePrice})</font>
+                        </c:if>
+                        <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount-s.shopOtherFee},已退差价:${s.differencePrice})</font>
+                        </c:if>
+
+                    </td>
+                    <td colspan="2"><fmt:formatNumber value="${s.shopTaxFee}" type="number"
+                                                      pattern="#,##0.00"/></td>
+                    <td colspan="2">
+                        <c:if test="${s.shopPostFlag == 0}">
                             包邮
                         </c:if>
-                        <c:if test="${s.freight == -1}">
+                        <c:if test="${s.shopPostFlag == 2}">
                             到付
                         </c:if>
-                        <c:if test="${s.freight == -2}">
+                        <c:if test="${s.shopPostFlag == -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.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+                            <fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
                             <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>
-                        <c:if test="${s.rebateOrder == '1'}">是</c:if>
-                        <c:if test="${s.rebateOrder == '0'}">否</c:if>
-                    </td>
+                    <td class="product-freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
+                                                                  pattern="#,##0.00"/></td>
+                    <td colspan="2"><fmt:formatNumber value="${s.shopOtherFee}" type="number" pattern="#,##0.00"/></td>
+
                 </tr>
-                <c:forEach items="${s.newShopOrders}" var="so" varStatus="soIndex">
-                    <tr class="t2">
-                        <th colspan="3">子订单编号(ID)</th>
-                        <th colspan="3">供应商</th>
-                        <th colspan="2">商品费</th>
-                        <th colspan="2">已付供应商</th>
-                        <th>供应商退款</th>
-                        <th colspan="2">应付供应商</th>
-                        <th colspan="3">应付税费</th>
-                        <th>供应商运费</th>
-                        <th colspan="2">付第三方</th>
-                        <th colspan="2">成本类型</th>
-                    </tr>
-                    <tr class="t2">
-                        <td colspan="3">${so.shopOrderNo}(${so.shopOrderID})</td>
-                        <td colspan="3">${so.shopName}</td>
-                        <td colspan="2" class="product-fee"><fmt:formatNumber value="${so.shopProductAmount}"
-                                                                              type="number" pattern="#,##0.00"/></td>
-                        <td colspan="2"><fmt:formatNumber value="${so.payedShopAmount}" type="number"
-                                                          pattern="#,##0.00"/></td>
-                        <td>
-                            <c:if test="${so.refundAmount > 0}">
-                                <fmt:formatNumber value="${so.refundAmount}" type="number" pattern="#,##0.00"/>
-                            </c:if>
+                <tr>
+                    <th colspan="3">商品名</th>
+                    <th>规格</th>
+                    <th>数量<%--(赠品)--%></th>
+                    <th>退货</th>
+                    <th colspan="2">单价</th>
+                    <th colspan="3">机构税率 / 单税费 / 总税费</th>
+                    <th colspan="2">总价</th>
+                    <th colspan="3">供应商税率 / 单税费 / 总税费</th>
+                    <th colspan="2">成本(单 + 税)</th>
+                    <th colspan="2">成本(总)</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" colspan="3">
+                            <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 colspan="2">
-                            <c:if test="${so.differenceType ne 1 && so.differenceType ne 2 }">
-                                <font color="#E15616"><fmt:formatNumber value="${so.shouldPayShopAmount}" type="number"
-                                                                        pattern="#,##0.00"/></font>
-                            </c:if>
-                                  <%--1少付2多付--%>
-                            <c:if test="${so.differenceType eq 1 && so.differencePrice > 0}">
-                                <font color="black"><fmt:formatNumber value="${so.shouldPayShopAmount+so.differencePrice}"/></font><font color="red">(原应付:${so.shouldPayShopAmount},已补差价:${so.differencePrice})</font>
-                            </c:if>
-                            <c:if test="${so.differenceType eq 2 && so.differencePrice > 0}">
-                                <font color="black"><fmt:formatNumber value="${so.shouldPayShopAmount-so.differencePrice}"/></font><font color="red">(原应付:${so.shouldPayShopAmount},已退差价:${so.differencePrice})</font>
+                        <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 colspan="3"><fmt:formatNumber value="${so.shopTaxFee}" type="number"
-                                                          pattern="#,##0.00"/></td>
-                        <td class="product-freight"><fmt:formatNumber value="${so.shopPostFee}" type="number"
-                                                                      pattern="#,##0.00"/></td>
-                        <td colspan="2"><fmt:formatNumber value="${so.shopOtherFee}" type="number" pattern="#,##0.00"/></td>
-                        <td colspan="2"><c:if test="${empty so.costType || so.costType == '1'}">固定成本</c:if><c:if
-                                test="${so.costType == '2'}">比例成本</c:if></td>
-                    </tr>
-                    <tr>
-                        <th colspan="3">商品名</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 colspan="4">成本(总)</th>
-                    </tr>
-                    <c:forEach items="${so.newOrderProducts}" var="p" varStatus="pIndex">
-                        <tr class="pay-product-item">
-                            <td colspan="3" class="product-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>
+                        <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>
@@ -658,13 +613,15 @@
                                             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: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>
@@ -673,13 +630,13 @@
                                             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><fmt:formatNumber value="${p.costPrice}" type="number" pattern="#,##0.00"/></td>
-                            <td colspan="4"><fmt:formatNumber
-                                    value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}" type="number"
-                                    pattern="#,##0.00"/></td>
-                        </tr>
-                    </c:forEach>
+                            </c:choose>
+                        </td>
+                        <td class="p-costprice" colspan="2"><fmt:formatNumber value="${p.costPrice}" type="number"
+                                                                  pattern="#,##0.00"/></td>
+                        <td colspan="2"><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}"
+                                              type="number" pattern="#,##0.00"/></td>
+                    </tr>
                 </c:forEach>
             </table>
             <div style="float:right">
@@ -689,9 +646,9 @@
                 <c:if test="${s.settleRecordNum>0}">
                 <a href="${ctx}/bulkpurchase/cmRefundsProduct/toSettleRecord?orderID=${s.orderID}&pageType=1">结算记录</a>
                 </c:if>
-                <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord?orderID=${s.orderID}&from=3">收付款记录</a>&nbsp;&nbsp;&nbsp;
+                <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord?orderID=${s.orderID}&shopOrderID=${s.shopOrderID}&from=3">收付款记录</a>&nbsp;&nbsp;&nbsp;
                 <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID?orderID=${s.orderID}&from=3">用户退款/货记录</a>&nbsp;&nbsp;&nbsp;
-                <a href="${ctx}/shopOrder/refundRecord?orderID=${s.orderID}">供应商退/付款记录</a>
+                <a href="${ctx}/shopOrder/refundRecord?shopOrderId=${s.shopOrderID}">供应商退/付款记录</a>
             </div>
         </div>
     </c:forEach>

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

@@ -39,14 +39,14 @@
 <body>
 	<ul class="nav nav-tabs">
 		<li class="active"><a href="${ctx}/order/cmPayShop/">付款列表</a></li>
-		<shiro:hasPermission name="order:cmPayShop:view">
+		<%--<shiro:hasPermission name="order:cmPayShop:view">
             <li onclick="sessionStorage.removeItem('checkedIndexArr')"><a href="${ctx}/shopOrder/payOrderList?operatingMode=1">申请付款</a></li>
 			<li onclick="sessionStorage.removeItem('checkedIndexArr')"><a href="${ctx}/shopOrder/payOrderList?operatingMode=3">已付款子订单</a></li>
 		</shiro:hasPermission>
 		<shiro:hasPermission name="order:cmPayShop:split">
 			<li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
 		</shiro:hasPermission>
-		<li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
+		<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}"/>

+ 447 - 320
src/main/webapp/WEB-INF/views/modules/order/cmPayShopChange.jsp

@@ -1,32 +1,43 @@
 <%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<%@ 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}
-		#searchForm {
-			white-space: nowrap;
-		}
-		.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;
-		}
-
-       .form-horizontal .controls {
+    <title>付款修改</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th {
+            text-align: center
+        }
+
+        .table td {
+            text-align: center
+        }
+
+        #searchForm {
+            white-space: nowrap;
+        }
+
+        .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;
+        }
+
+        .form-horizontal .controls {
             margin-left: 0;
         }
 
@@ -47,23 +58,29 @@
             text-align: center;
             white-space: nowrap;
         }
-        .controls{
+
+        .controls {
             font-size: 0;
         }
-        .controls .conList{
+
+        .controls .conList {
             display: inline-block;
             margin-right: 15px;
         }
-        .conList .btn:nth-of-type(1){
+
+        .conList .btn:nth-of-type(1) {
             margin-left: 25px;
         }
-        .select2-choice{
+
+        .select2-choice {
             width: 100px;
         }
+
         .upload-content {
             margin-top: -70px;
             display: inline-block;
         }
+
         .upload-content .conList .btn:nth-of-type(1) {
             width: 90px;
             height: 100px;
@@ -71,19 +88,23 @@
             background: #fff;
             position: relative;
         }
-        .upload-content .conList .btn:nth-of-type(1)>div {
+
+        .upload-content .conList .btn:nth-of-type(1) > div {
             position: absolute;
             top: 50%;
             left: 50%;
             transform: translate(-50%, -50%);
             color: #666;
         }
+
         .upload-content .conList .btn:nth-of-type(1) span {
             font-size: 35px;
         }
+
         .upload-content .conList .btn:nth-of-type(1) h5 {
             color: #666;
         }
+
         .cancel-upload {
             background: transparent;
             border: none;
@@ -94,7 +115,8 @@
             cursor: pointer;
             z-index: 100;
         }
-         .upload-content .conList ol li {
+
+        .upload-content .conList ol li {
             width: 114px;
             min-height: 80px;
             text-align: center;
@@ -103,46 +125,47 @@
             top: 120px;
             margin-left: 2px;
         }
+
         .hide-pic {
             display: none !important;
         }
-	</style>
-	<script type="text/javascript">
-        $(document).ready(function() {
-				$("#inputForm").validate({
-                ignore:"",
-                submitHandler: function(form){
-					var modifyShouldPayNote = $("#modifyShouldPayNote").val();//备注
-					if(null == modifyShouldPayNote || ""  == modifyShouldPayNote){
-						alertx("请填写备注内容");
-						return false;
-					}
-					var confirmProductNames = $("#confirmProductNames").val();//修改了成本的含税商品商品名
-					if (confirmProductNames != "") {
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $("#inputForm").validate({
+                ignore: "",
+                submitHandler: function (form) {
+                    var modifyShouldPayNote = $("#modifyShouldPayNote").val();//备注
+                    if (null == modifyShouldPayNote || "" == modifyShouldPayNote) {
+                        alertx("请填写备注内容");
+                        return false;
+                    }
+                    var confirmProductNames = $("#confirmProductNames").val();//修改了成本的含税商品商品名
+                    if (confirmProductNames != "") {
                         var products = confirmProductNames.substring(0, confirmProductNames.length - 1);
-						var msg = "["+products+"]为含税商品,\n" +
-								"\n" +
-								"您已修改了成本,请确认是否需要修改税率。\n" +
-								"\n" +
-								"若需要修改税率,请点击继续修改按钮后进行修改;\n" +
-								"\n" +
-								"若不需要修改税率,请点击直接确定按钮完成修改";
-						top.$.jBox.confirm(msg, '提示', function (v, h, f) {
-							if (v == true) {
-								loading('正在提交,请稍等...');
-								form.submit();
-							}
-							return;
-						}, {buttons: {'继续修改': false, '直接确定': true}});
-					}else {
+                        var msg = "[" + products + "]为含税商品,\n" +
+                            "\n" +
+                            "您已修改了成本,请确认是否需要修改税率。\n" +
+                            "\n" +
+                            "若需要修改税率,请点击继续修改按钮后进行修改;\n" +
+                            "\n" +
+                            "若不需要修改税率,请点击直接确定按钮完成修改";
+                        top.$.jBox.confirm(msg, '提示', function (v, h, f) {
+                            if (v == true) {
+                                loading('正在提交,请稍等...');
+                                form.submit();
+                            }
+                            return;
+                        }, {buttons: {'继续修改': false, '直接确定': true}});
+                    } else {
                         loading('正在提交,请稍等...');
                         form.submit();
                     }
                 },
                 errorContainer: "#messageBox",
-                errorPlacement: function(error, element) {
+                errorPlacement: function (error, element) {
                     $("#messageBox").text("输入有误,请先更正。");
-                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                         error.appendTo(element.parent().parent());
                     } else {
                         error.insertAfter(element);
@@ -150,7 +173,8 @@
                 }
             });
         });
-        function page(n,s){
+
+        function page(n, s) {
             $("#pageNo").val(n);
             $("#pageSize").val(s);
             $("#searchForm").submit();
@@ -159,310 +183,413 @@
 
         //初始化默认清除本地本地Item数据
 
-	</script>
+    </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 class="active"><a href="${ctx}/shopOrder/toChangePayShopAmount?costType=1&shopOrderID=${shopOrderId}">修改成本</a></li>
+    <%--		<li><a href="${ctx}/order/cmPayShop">付款列表</a></li>--%>
+    <li><a href="${ctx}/shopOrder/payOrderList?operatingMode=1">申请付款</a></li>
+    <li class="active"><a href="${ctx}/shopOrder/toChangePayShopAmount?costType=1&shopOrderID=${shopOrderId}">修改成本</a>
+    </li>
 </ul>
 <input type="hidden" id="confirmProductNames">
-<form:form id="inputForm" modelAttribute="newShopOrder" action="${ctx}/order/cmPayShop/saveChangePayShopAmount?id=${shopOrderId}&costType=1" method="post"
+<form:form id="inputForm" modelAttribute="newShopOrder"
+           action="${ctx}/order/cmPayShop/saveChangePayShopAmount?id=${shopOrderId}&costType=1" method="post"
            class="form-horizontal">
-		<ul class="nav nav-tabs" id="myTab">
-		<c:if test="${dbCostType eq 1 || empty dbCostType}">
-			<li class="active" id="li-fixed-cost"><a href="${ctx}/shopOrder/toChangePayShopAmount?costType=1&shopOrderID=${shopOrderId}">固定成本修改</a></li>
-		</c:if>
-		<c:if test="${dbCostType eq 2 || empty dbCostType}">
-				<li id="li-proportional-cost"><a href="${ctx}/shopOrder/toChangePayShopAmount?costType=2&shopOrderID=${shopOrderId}">销售比例成本修改</a></li>
-		</c:if>
-		</ul>
-		<c:forEach items="${page.list}" var="newShopOrder">
-		<div class="tab-content">
-			<div class="tab-pane active revise-content" id="fixed-cost">
-			<input id="shopOrderID" type="hidden"  name="shopOrderID" value="${newShopOrder.shopOrderID}">
-			<input id="orderID" type="hidden"  name="orderID" value="${newShopOrder.orderID}">
-			<input id="productAmount" type="hidden"  name="productAmount" value="${newShopOrder.productAmount}">
-				<label style="color:red">注意:计算成本时请注意,含税商品的成本包括税费,无需另外计算税费</label>
-				<table class="table table-striped table-bordered table-condensed"  style="width: 800px">
-					<tr>
-						<td>商品名</td>
-						<td>成本(单)</td>
-						<td>供应商税率</td>
-						<td>供应商税费(单)</td>
-					</tr>
-							<c:forEach items="${newShopOrder.newOrderProducts}" var="product" varStatus="index">
-									<tr class="orderProducts">
-										<td hidden><input id="num" name="newOrderProducts[${index.index}].num" value="${product.num - product.returnedNum}"></td>
-										<td hidden><input id="presentNum" name="newOrderProducts[${index.index}].presentNum" value="${product.presentNum}"></td>
-										<td hidden><input id="name" name="newOrderProducts[${index.index}].name" value="${product.name}"></td>
-										<td hidden><input id="orderProductID" name="newOrderProducts[${index.index}].orderProductID" value="${product.orderProductID}"></td>
-										<td hidden><input id="includedTax${index.index}" value="${product.includedTax}"></td>
-										<td hidden><input id="productID${index.index}" value="${product.productID}"></td>
-										<td width="40%" id="productName${index.index}">${product.name}</td>
-										<td width="30%"><input id="costPrice"  style="width: 80px;float: left" name="newOrderProducts[${index.index}].costPrice" value="${product.costPrice}" onchange="changeShouldPay(this,${index.index})" />
-											<c:if test="${product.includedTax != null and product.includedTax != '' and product.includedTax ne 2}">
-												<label style="color: red">
-													(${product.includedTax eq 1?'含税':(product.invoiceType eq 1 or product.invoiceType eq 2)?'不含税-能开票':'不含税-不能开票'})
-												</label>
-											</c:if>
-										</td>
-										<td width="20%">
-											<c:choose>
-												<c:when test="${product.includedTax ne '' and product.includedTax eq 0 and product.invoiceType ne 1 and product.invoiceType ne 2}">
-													<label style="text-align: center">-----</label>
-												</c:when>
-												<c:otherwise>
-													<input style="width: 120px;float: left" maxlength="5" id="supplierTaxRate" name="newOrderProducts[${index.index}].supplierTaxRate" value="${empty product.supplierTaxRate?0.0:product.supplierTaxRate}" onchange="changeShouldPay(this)" />%
-												</c:otherwise>
-											</c:choose>
-										</td>
-										<td width="10%">
-											<c:choose>
-												<c:when test="${product.includedTax ne '' and ((product.includedTax eq 0 and product.invoiceType ne 1 and product.invoiceType ne 2) or product.includedTax eq 1 )}">
-													<label id="singleShouldPayTotalTaxLabel" name="newOrderProducts[${index.index}].singleShouldPayTotalTaxLabel" style="text-align: center">-----</label>
-													<input type="hidden" id="singleShouldPayTotalTax" name="newOrderProducts[${index.index}].singleShouldPayTotalTax" value="${empty product.singleShouldPayTotalTax?0.0:product.singleShouldPayTotalTax}">
-												</c:when>
-												<c:otherwise>
-													<label id="singleShouldPayTotalTaxLabel" style="text-align: center" name="newOrderProducts[${index.index}].singleShouldPayTotalTaxLabel">${empty product.singleShouldPayTotalTax?0.0:product.singleShouldPayTotalTax}</label>
-													<input type="hidden" id="singleShouldPayTotalTax" name="newOrderProducts[${index.index}].singleShouldPayTotalTax" value="${empty product.singleShouldPayTotalTax?0.0:product.singleShouldPayTotalTax}">
-												</c:otherwise>
-											</c:choose>
-										</td>
-									</tr>
-							</c:forEach>
-				</table>
-			</div>
-			<table>
-				<tr>
-					<td>
-						<b>供应商运费:</b><input type="number" id="shopPostFee" name="shopPostFee"  onchange="changeShouldPay(this)"  value="${newShopOrder.shopPostFee}" style="margin-left: 20px"/>
-					</td>
-					<td>
-						<b>付第三方:</b><input type="number" id="shopOtherFee" name="shopOtherFee"  onchange="inputnum(this)"  value="${newShopOrder.shopOtherFee}" style="margin-left: 5px;" ${(!newShopOrder.payShopOtherFee || payShopOtherFee > 0) ? 'readonly="true"':""}/>
-					</td>
-				</tr>
-				<tr>
-					<td style="padding-top: 10px;">
-						<b>付供应商:</b><font color="red"><span id="div-supplier-fee">${newShopOrder.shouldPayShopAmount}</span></font>
-					</td>
-					<%--<td style="padding-top: 10px;">
-						<b>已付供应商:</b><font color="red"><span id="div-payedShopAmount">${newShopOrder.payedShopAmount}</span></font>
-					</td>--%>
-				</tr>
-			</table>
-			<div style="margin-top: 10px">
-				<div class="remark-title"><font color="red">*</font>备注内容:</div>
-				<textarea name="modifyShouldPayNote" id="modifyShouldPayNote" class="remark-textarea" maxlength="500" placeholder="建议填写修改原因和修改前后的金额对比,不超过500字" style="width: 600px;height: 150px;margin-left: 70px;margin-top: -20px"></textarea>
-			</div>
-		</div>
-
-		</c:forEach>
-
-		<div >
-			<div class="controls upload-content" style="margin: -91px 0px 0px 16px;" id="remarkImageBox">
-			        <label>图片:</label>
-                    <div class="conList">
-                        <form:hidden id="remarkImage1" path="remarkImage1" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage1" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList hide-pic">
-                        <form:hidden id="remarkImage2" path="remarkImage2" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage2" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList hide-pic">
-                        <form:hidden id="remarkImage3" path="remarkImage3" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage3" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList hide-pic">
-                        <form:hidden id="remarkImage4" path="remarkImage4" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage4" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList hide-pic">
-                        <form:hidden id="remarkImage5" path="remarkImage5" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage5" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList hide-pic">
-                        <form:hidden id="remarkImage6" path="remarkImage6" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage6" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList hide-pic">
-                        <form:hidden id="remarkImage7" path="remarkImage7" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage7" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList hide-pic">
-                        <form:hidden id="remarkImage8" path="remarkImage8" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage8" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList  hide-pic">
-                        <form:hidden id="remarkImage9" path="remarkImage9" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage9" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                    <div class="conList  hide-pic">
-                        <form:hidden id="remarkImage10" path="remarkImage10" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                        <sys:ckfinder input="remarkImage10" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-                    </div>
-                </div>
-		</div>
-		<div class="form-actions">
-                <input id="btnSubmit" class="btn btn-primary" type="submit" value="确认"/>
-                <input id="btnCancel" class="btn" type="button" value="返回" onclick="history.go(-1)"/>
+    <%--		<ul class="nav nav-tabs" id="myTab">--%>
+    <%--		<c:if test="${dbCostType eq 1 || empty dbCostType}">--%>
+    <%--			<li class="active" id="li-fixed-cost"><a href="${ctx}/shopOrder/toChangePayShopAmount?costType=1&shopOrderID=${shopOrderId}">固定成本修改</a></li>--%>
+    <%--		</c:if>--%>
+    <%--		<c:if test="${dbCostType eq 2 || empty dbCostType}">--%>
+    <%--				<li id="li-proportional-cost"><a href="${ctx}/shopOrder/toChangePayShopAmount?costType=2&shopOrderID=${shopOrderId}">销售比例成本修改</a></li>--%>
+    <%--		</c:if>--%>
+    <%--		</ul>--%>
+    <c:forEach items="${page.list}" var="newShopOrder">
+        <div class="tab-content">
+            <div class="tab-pane active revise-content" id="fixed-cost">
+                <input id="shopOrderID" type="hidden" name="shopOrderID" value="${newShopOrder.shopOrderID}">
+                <input id="orderID" type="hidden" name="orderID" value="${newShopOrder.orderID}">
+                <input id="productAmount" type="hidden" name="productAmount" value="${newShopOrder.productAmount}">
+                <label style="color:red">注意:计算成本时请注意,含税商品的成本包括税费,无需另外计算税费</label>
+                <table class="table table-striped table-bordered table-condensed" style="width: 70%">
+                    <tr>
+                        <td>商品名</td>
+                        <td>供应商成本(单)</td>
+                        <td>集团成本(单)</td>
+                        <td>平台服务费</td>
+                        <td>机构税率</td>
+                        <td>供应商税费(单)</td>
+                    </tr>
+                    <c:forEach items="${newShopOrder.newOrderProducts}" var="product" varStatus="index">
+                        <tr class="orderProducts">
+                            <td hidden><input id="num" name="newOrderProducts[${index.index}].num"
+                                              value="${product.num - product.returnedNum}"></td>
+                                <%--                            <td hidden><input id="taxRate" name="newOrderProducts[${index.index}].taxRate" value="${product.taxRate}"></td>--%>
+                            <td hidden><input id="presentNum" name="newOrderProducts[${index.index}].presentNum"
+                                              value="${product.presentNum}"></td>
+                            <td hidden><input id="name" name="newOrderProducts[${index.index}].name"
+                                              value="${product.name}"></td>
+                            <td hidden><input id="orderProductID" name="newOrderProducts[${index.index}].orderProductID"
+                                              value="${product.orderProductID}"></td>
+                            <td hidden><input id="includedTax${index.index}"
+                                              name="newOrderProducts[${index.index}].includedTax"
+                                              value="${product.includedTax}"></td>
+                            <td hidden><input id="productID${index.index}" value="${product.productID}"></td>
+                            <td width="40%" id="productName${index.index}">${product.name}</td>
+                            <td width="30%"><input id="costPrice" style="width: 80px;float: left"
+                                                   name="newOrderProducts[${index.index}].costPrice"
+                                                   value="${product.costPrice}"
+                                                   onchange="changeShouldPay(this,${index.index})"/>
+                                <c:if test="${product.includedTax != null and product.includedTax != '' and product.includedTax ne 2}">
+                                    <label style="color: red">
+                                        (${product.includedTax eq 1?'含税':(product.invoiceType eq 1 or product.invoiceType eq 2)?'不含税-能开票':'不含税-不能开票'})
+                                    </label>
+                                </c:if>
+                            </td>
+                            <td><input id="organizeCostPrice" style="width: 80px;float: left"
+                                       name="newOrderProducts[${index.index}].organizeCostPrice"
+                                       value="${product.organizeCostPrice}"/></td>
+                            <td><input id="cmCostPrice" style="width: 80px;float: left"
+                                       name="newOrderProducts[${index.index}].cmCostPrice"
+                                       value="${product.cmCostPrice}"/></td>
+                            <td width="20%">
+                                <c:choose>
+                                    <c:when test="${product.includedTax ne '' and product.includedTax eq 0 and product.invoiceType ne 1 and product.invoiceType ne 2}">
+                                        <label style="text-align: center">-----</label>
+                                    </c:when>
+                                    <c:otherwise>
+                                        <input style="width: 120px;float: left" maxlength="5" id="supplierTaxRate"
+                                               name="newOrderProducts[${index.index}].taxRate"
+                                               value="${empty product.taxRate?0.0:product.taxRate}"
+                                               onchange="changeShouldPay(this)"/>%
+                                    </c:otherwise>
+                                </c:choose>
+                            </td>
+                            <td width="10%">
+                                <c:choose>
+                                    <c:when test="${product.includedTax ne '' and ((product.includedTax eq 0 and product.invoiceType ne 1 and product.invoiceType ne 2) or product.includedTax eq 1 )}">
+                                        <label id="singleShouldPayTotalTaxLabel"
+                                               name="newOrderProducts[${index.index}].singleShouldPayTotalTaxLabel"
+                                               style="text-align: center">-----</label>
+                                        <input type="hidden" id="singleShouldPayTotalTax"
+                                               name="newOrderProducts[${index.index}].singleShouldPayTotalTax"
+                                               value="${empty product.singleShouldPayTotalTax?0.0:product.singleShouldPayTotalTax}">
+                                    </c:when>
+                                    <c:otherwise>
+                                        <label id="singleShouldPayTotalTaxLabel" style="text-align: center"
+                                               name="newOrderProducts[${index.index}].singleShouldPayTotalTaxLabel">${empty product.singleShouldPayTotalTax?0.0:product.singleShouldPayTotalTax}</label>
+                                        <input type="hidden" id="singleShouldPayTotalTax"
+                                               name="newOrderProducts[${index.index}].singleShouldPayTotalTax"
+                                               value="${empty product.singleShouldPayTotalTax?0.0:product.singleShouldPayTotalTax}">
+                                    </c:otherwise>
+                                </c:choose>
+                            </td>
+                        </tr>
+                    </c:forEach>
+                </table>
+            </div>
+            <table>
+                <tr>
+                    <td>
+                        <b>供应商运费:</b><input type="number" id="shopPostFee" name="shopPostFee"
+                                            onchange="changeShouldPay(this)" value="${newShopOrder.shopPostFee}"
+                                            style="margin-left: 20px"/>
+                    </td>
+                    <td>
+                        <b>付第三方:</b><input type="number" id="shopOtherFee" name="shopOtherFee" onchange="inputnum(this)"
+                                           value="${newShopOrder.shopOtherFee}"
+                                           style="margin-left: 5px;" ${(!newShopOrder.payShopOtherFee || payShopOtherFee > 0) ? 'readonly="true"':""}/>
+                    </td>
+                </tr>
+                <tr>
+                    <td style="padding-top: 10px;">
+                        <b>付供应商:</b><font color="red"><span
+                            id="div-supplier-fee">${newShopOrder.shouldPayShopAmount - newShopOrder.shopOtherFee}</span></font>
+                    </td>
+                    <input style="display: none" id="hidePayShop" value="${newShopOrder.shouldPayShopAmount}">
+                        <%--<td style="padding-top: 10px;">
+                            <b>已付供应商:</b><font color="red"><span id="div-payedShopAmount">${newShopOrder.payedShopAmount}</span></font>
+                        </td>--%>
+                </tr>
+            </table>
+            <div style="margin-top: 10px">
+                <div class="remark-title"><font color="red">*</font>备注内容:</div>
+                <textarea name="modifyShouldPayNote" id="modifyShouldPayNote" class="remark-textarea" maxlength="500"
+                          placeholder="建议填写修改原因和修改前后的金额对比,不超过500字"
+                          style="width: 600px;height: 150px;margin-left: 70px;margin-top: -20px"></textarea>
+            </div>
+        </div>
+
+    </c:forEach>
+
+    <div>
+        <div class="controls upload-content" style="margin: -91px 0px 0px 16px;" id="remarkImageBox">
+            <label>图片:</label>
+            <div class="conList">
+                <form:hidden id="remarkImage1" path="remarkImage1" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage1" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden id="remarkImage2" path="remarkImage2" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage2" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden id="remarkImage3" path="remarkImage3" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage3" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden id="remarkImage4" path="remarkImage4" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage4" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden id="remarkImage5" path="remarkImage5" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage5" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden id="remarkImage6" path="remarkImage6" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage6" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden id="remarkImage7" path="remarkImage7" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage7" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList hide-pic">
+                <form:hidden id="remarkImage8" path="remarkImage8" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage8" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList  hide-pic">
+                <form:hidden id="remarkImage9" path="remarkImage9" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage9" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
+            <div class="conList  hide-pic">
+                <form:hidden id="remarkImage10" path="remarkImage10" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage10" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
+            </div>
         </div>
+    </div>
+    <div class="form-actions">
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="确认"/>
+        <input id="btnCancel" class="btn" type="button" value="返回" onclick="history.go(-1)"/>
+    </div>
 </form:form>
 
 <script type="text/javascript">
 
-//图片初始化
-  $(function () {
+    //图片初始化
+    $(function () {
         $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
         $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
         $('.upload-content .conList').find('.cancel-upload').hide();
         var observeEle = document.getElementsByClassName('upload-content')[0];
         var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
-        var MutationObserverConfig={
+        var MutationObserverConfig = {
             childList: true,
             subtree: true,
             characterData: true
         };
-        var observer = new MutationObserver(function(mutations){
-            $.each(mutations, function(index,item) {
+        var observer = new MutationObserver(function (mutations) {
+            $.each(mutations, function (index, item) {
                 if (item.type === 'childList') {
                     // 在创建新的 element 时调用
                     var target = $(item.target),
                         thisWrapper = target.closest('.conList'),
                         nextEle = thisWrapper.next();
-                    thisWrapper.find('li').css('z-index',99);
+                    thisWrapper.find('li').css('z-index', 99);
                     thisWrapper.find('.cancel-upload').show();
-                    if(nextEle.hasClass('hide-pic')) {
+                    if (nextEle.hasClass('hide-pic')) {
                         nextEle.removeClass('hide-pic');
                     }
                 }
             })
         });
-        observer.observe(observeEle,MutationObserverConfig);
+        observer.observe(observeEle, MutationObserverConfig);
 
-        $('body').on('click','.upload-content li',function() {
+        $('body').on('click', '.upload-content li', function () {
             var index = $(this).closest('.conList').index() + 1,
-                str = 'remarkImage'+index+'FinderOpen';
-            eval(str+'()');
+                str = 'remarkImage' + index + 'FinderOpen';
+            eval(str + '()');
         });
-        $('body').on('click', '.cancel-upload',function() {
+        $('body').on('click', '.cancel-upload', function () {
             var wrapper = $(this).closest('.conList');
-            wrapper.find('li').css('z-index','-1');
+            wrapper.find('li').css('z-index', '-1');
             wrapper.find('input').val('');
             $(this).hide();
             if ($('.cancel-upload:visible').length < 9) {
                 wrapper.addClass("hide-pic");
-            }else{
+            } else {
                 wrapper.removeClass("hide-pic");
             }
             wrapper.parent().append(wrapper.clone());
             wrapper.remove();
-			$(".conList").each(function(i,ele){
-				if($(ele).find("input.input-xlarge").val()){
-					$(ele).next().removeClass("hide-pic")
-				}
-			})
+            $(".conList").each(function (i, ele) {
+                if ($(ele).find("input.input-xlarge").val()) {
+                    $(ele).next().removeClass("hide-pic")
+                }
+            })
+        });
+        $(window).on("load", function () {
+            setTimeout(function () {
+                $("#remarkImageBox").find("input.input-xlarge").each(function (i, ele) {
+                    if ($(ele).val()) {
+                        $(ele).next().find("li").css("z-index", "99");
+                        $(ele).parents(".conList").find(".cancel-upload").show();
+                        $(ele).parents(".conList").next().removeClass("hide-pic")
+                    }
+                })
+            }, 500);
         });
-		$(window).on("load", function(){
-			setTimeout(function(){
-				$("#remarkImageBox").find("input.input-xlarge").each(function(i,ele){
-					if($(ele).val()){
-						$(ele).next().find("li").css("z-index","99");
-						$(ele).parents(".conList").find(".cancel-upload").show();
-						$(ele).parents(".conList").next().removeClass("hide-pic")
-					}
-				})
-			},500);
-		});
     });
 
     // 输入框验证
-	function inputnum(obj){
-		obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
-		obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
-		obj.value = obj.value.replace(/\.{2,}/g,""); //只保留第一个, 清除多余的
-		obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
-		obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
-		if(obj.value == null || obj.value == "" ){
-			obj.value = 0;
-		}
-	}
-
-	// 修改成本价
-	var confirmProductNames = "";
-	var confirmProductIdArr = [];
-	function changeShouldPay(eleThis,index) {
-		var productName = $("#productName" + index).text();
-		var productId = $("#productID" + index).val();
-		var includedTax = $("#includedTax" + index).val();
-		var addFlag = true;
-		for (var i = 0 ;i<confirmProductIdArr.length;i++){
-			if (confirmProductIdArr[i] == productId) {
-				addFlag = false;
-			}
-		}
-		if (includedTax == '1' && addFlag) {
-			confirmProductIdArr.push(productId);
-			confirmProductNames += productName+",";
-			confirmProductNames.substring(0, confirmProductNames.length-1);
-			$("#confirmProductNames").val(confirmProductNames);
-		}
-		//修改不符合规则值
-		eleThis.value = eleThis.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
-		eleThis.value = eleThis.value.replace(/^\./g,""); //验证第一个字符是数字
-		eleThis.value = eleThis.value.replace(/\.{2,}/g,""); //只保留第一个, 清除多余的
-		eleThis.value = eleThis.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
-		eleThis.value = eleThis.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
-		if($(eleThis).val() == null || $(eleThis).val() == "" ){
-			$(eleThis).val(0);
-		}
-
-		var totalAmount = Number(0);
-		//获取供应商层信息
-		var shopPostFee = $("#shopPostFee").val();
-		var shopOtherFee = $("#shopOtherFee").val();
-		if(null == shopPostFee)shopPostFee = 0;
-		// if(null == shopOtherFee)shopOtherFee = 0;
-		/*var n = parseFloat(that.value);
-		that.value = n.toFixed(2)*/
-		// 计算所有商品的成本和税费
-		$(".orderProducts").each(function(i, ele){
-			// 商品层信息
-			var num = $(ele).find('input[id=num]').val();
-			var presentNum = $(ele).find('input[id=presentNum]').val();
-			var costPrice = $(ele).find('input[id=costPrice]').val();
-			var supplierTaxRate = $(ele).find('input[id=supplierTaxRate]').val();
-			var singleShouldPayTotalTax = $(ele).find('label[id=singleShouldPayTotalTaxLabel]').text();// 单个供应商是税费
-
-			console.log(num+" "+presentNum+" "+" "+costPrice+" "+supplierTaxRate+" "+singleShouldPayTotalTax)
-
-			// 校验参数
-			if(null == num)num = 0;
-			if(null == presentNum)presentNum = 0;
-			if(null == costPrice)costPrice = 0;
-			if(null == supplierTaxRate)supplierTaxRate = 0;
-			if(null == singleShouldPayTotalTax)singleShouldPayTotalTax = 0;
-			var productNum = Number(num) + Number(presentNum);
-
-			if (singleShouldPayTotalTax == '-----') {
-				singleShouldPayTotalTax = 0;
-				$(ele).find('input[id=singleShouldPayTotalTax]').val(0);
-			}else {
-				//计算供应商税费(单)
-				singleShouldPayTotalTax = (costPrice * supplierTaxRate * 0.01).toFixed(2);
-				$(ele).find('label[id=singleShouldPayTotalTaxLabel]').text(singleShouldPayTotalTax);
-				$(ele).find('input[id=singleShouldPayTotalTax]').val(singleShouldPayTotalTax);
-			}
-			//计算应付供应商
-			totalAmount += ((Number(productNum) * Number(costPrice)) + (Number(productNum) * Number(singleShouldPayTotalTax)));
-		});
-		totalAmount += Number(shopPostFee);
-		// 四舍五入
-		var s = totalAmount.toFixed(2);
-		$("#div-supplier-fee").text(s);
-	}
+    function inputnum(obj) {
+        obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+        obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+        obj.value = obj.value.replace(/\.{2,}/g, ""); //只保留第一个, 清除多余的
+        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+        if (obj.value == null || obj.value == "") {
+            obj.value = 0;
+        }
+        var of = $("#shopOtherFee").val();
+        console.log("of----------------" + of);
+        if (of > 0) {
+            var totalAmount = 0;
+            $(".orderProducts").each(function (i, ele) {
+                // 商品层信息
+                var num = $(ele).find('input[id=num]').val();
+                var presentNum = $(ele).find('input[id=presentNum]').val();
+                var costPrice = $(ele).find('input[id=costPrice]').val();
+                var supplierTaxRate = $(ele).find('input[id=supplierTaxRate]').val();
+                var singleShouldPayTotalTax = $(ele).find('label[id=singleShouldPayTotalTaxLabel]').text();// 单个供应商是税费
+
+                console.log(num + " " + presentNum + " " + " " + costPrice + " " + supplierTaxRate + " " + singleShouldPayTotalTax)
+
+                // 校验参数
+                if (null == num) num = 0;
+                if (null == presentNum) presentNum = 0;
+                if (null == costPrice) costPrice = 0;
+                if (null == supplierTaxRate) supplierTaxRate = 0;
+                if (null == singleShouldPayTotalTax) singleShouldPayTotalTax = 0;
+                var productNum = Number(num) + Number(presentNum);
+
+                if (singleShouldPayTotalTax == '-----') {
+                    singleShouldPayTotalTax = 0;
+                    $(ele).find('input[id=singleShouldPayTotalTax]').val(0);
+                } else {
+                    //计算供应商税费(单)
+                    singleShouldPayTotalTax = (costPrice * supplierTaxRate * 0.01).toFixed(2);
+                    $(ele).find('label[id=singleShouldPayTotalTaxLabel]').text(singleShouldPayTotalTax);
+                    $(ele).find('input[id=singleShouldPayTotalTax]').val(singleShouldPayTotalTax);
+                }
+                //计算应付供应商
+                totalAmount += ((Number(productNum) * Number(costPrice)) + (Number(productNum) * Number(singleShouldPayTotalTax)));
+                console.log("totalAmount--------------" + totalAmount);
+            });
+            var shopPostFee = $("#shopPostFee").val();
+            console.log("shopPostFee----------" + shopPostFee);
+            console.log("shopPostFee----------" + shopPostFee);
+            totalAmount += Number(shopPostFee);
+            totalAmount -= Number(of);
+            $("#div-supplier-fee").text(totalAmount);
+        }
+    }
+
+    // 修改成本价
+    var confirmProductNames = "";
+    var confirmProductIdArr = [];
+
+    function changeShouldPay(eleThis, index) {
+        var productName = $("#productName" + index).text();
+        var productId = $("#productID" + index).val();
+        var includedTax = $("#includedTax" + index).val();
+        var addFlag = true;
+        for (var i = 0; i < confirmProductIdArr.length; i++) {
+            if (confirmProductIdArr[i] == productId) {
+                addFlag = false;
+            }
+        }
+        if (includedTax == '1' && addFlag) {
+            confirmProductIdArr.push(productId);
+            confirmProductNames += productName + ",";
+            confirmProductNames.substring(0, confirmProductNames.length - 1);
+            $("#confirmProductNames").val(confirmProductNames);
+        }
+        //修改不符合规则值
+        eleThis.value = eleThis.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+        eleThis.value = eleThis.value.replace(/^\./g, ""); //验证第一个字符是数字
+        eleThis.value = eleThis.value.replace(/\.{2,}/g, ""); //只保留第一个, 清除多余的
+        eleThis.value = eleThis.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+        eleThis.value = eleThis.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+        if ($(eleThis).val() == null || $(eleThis).val() == "") {
+            $(eleThis).val(0);
+        }
+
+        var totalAmount = Number(0);
+        //获取供应商层信息
+        var shopPostFee = $("#shopPostFee").val();
+        var shopOtherFee = $("#shopOtherFee").val();
+        if (null == shopPostFee) shopPostFee = 0;
+        // if(null == shopOtherFee)shopOtherFee = 0;
+        /*var n = parseFloat(that.value);
+        that.value = n.toFixed(2)*/
+        // 计算所有商品的成本和税费
+        $(".orderProducts").each(function (i, ele) {
+            // 商品层信息
+            var num = $(ele).find('input[id=num]').val();
+            var presentNum = $(ele).find('input[id=presentNum]').val();
+            var costPrice = $(ele).find('input[id=costPrice]').val();
+            var supplierTaxRate = $(ele).find('input[id=supplierTaxRate]').val();
+            var singleShouldPayTotalTax = $(ele).find('label[id=singleShouldPayTotalTaxLabel]').text();// 单个供应商是税费
+
+            console.log(num + " " + presentNum + " " + " " + costPrice + " " + supplierTaxRate + " " + singleShouldPayTotalTax)
+
+            // 校验参数
+            if (null == num) num = 0;
+            if (null == presentNum) presentNum = 0;
+            if (null == costPrice) costPrice = 0;
+            if (null == supplierTaxRate) supplierTaxRate = 0;
+            if (null == singleShouldPayTotalTax) singleShouldPayTotalTax = 0;
+            var productNum = Number(num) + Number(presentNum);
+
+            if (singleShouldPayTotalTax == '-----') {
+                singleShouldPayTotalTax = 0;
+                $(ele).find('input[id=singleShouldPayTotalTax]').val(0);
+            } else {
+                //计算供应商税费(单)
+                singleShouldPayTotalTax = (costPrice * supplierTaxRate * 0.01).toFixed(2);
+                $(ele).find('label[id=singleShouldPayTotalTaxLabel]').text(singleShouldPayTotalTax);
+                $(ele).find('input[id=singleShouldPayTotalTax]').val(singleShouldPayTotalTax);
+            }
+            //计算应付供应商
+            totalAmount += ((Number(productNum) * Number(costPrice)) + (Number(productNum) * Number(singleShouldPayTotalTax))); /* + (Number(productNum) * Number(singleShouldPayTotalTax))*/
+        });
+        var of = $("#shopOtherFee").val();
+        totalAmount += Number(shopPostFee);
+        totalAmount -= Number(of);
+        // 四舍五入
+        var s = totalAmount.toFixed(2);
+        $("#div-supplier-fee").text(s);
+    }
 
 </script>
 </body>

+ 123 - 14
src/main/webapp/WEB-INF/views/modules/order/cmPayShopChange1.jsp

@@ -120,21 +120,54 @@
         }
 	</style>
 	<script type="text/javascript">
+        var orderProducts = new Array();
         $(document).ready(function() {
             $("#inputForm").validate({
                 ignore:"",
                 submitHandler: function(form){
-                var proportional = $("#proportional").val();// 子订单占比
-                var modifyShouldPayNote = $("#modifyShouldPayNote").val();//备注
-                if(null == proportional || ""  == proportional){
-                    alertx("比例不能为空");
-                    return false;
-                }
-                if(null == modifyShouldPayNote || ""  == modifyShouldPayNote){
-                    alertx("请填写备注内容");
-                    return false;
-                }
+                    var flag = setOrderProductInfo();
+                    // var proportional = $("#proportional").val();// 子订单占比
+                    var modifyShouldPayNote = $("#modifyShouldPayNote").val();//备注
+                    var shopPostFee = $("#shopPostFee").val();//供应商运费
+                    var shopOtherFee = $("#shopOtherFee").val();//付第三方
+                    /*if(null == proportional || ""  == proportional){
+                        alertx("比例不能为空");
+                        return false;
+                    }*/
+                    if(null == modifyShouldPayNote || ""  == modifyShouldPayNote){
+                        alertx("请填写备注内容");
+                        return false;
+                    }
+                    if (!flag) {
+                        top.$.jBox.confirm("每个商品三个比例之和需要等于100%", '提示');
+                        return false;
+                    }
+                    console.log('orderProducts',orderProducts)
                     loading('正在提交,请稍等...');
+                    <%--$.ajax({--%>
+                    <%--    url: '${ctx}/order/cmPayShop/saveChangePayShopAmount',--%>
+                    <%--    data: {--%>
+                    <%--        'id': ${shopOrderId},--%>
+                    <%--        'costType' : 2,--%>
+                    <%--        'modifyShouldPayNote' : modifyShouldPayNote,--%>
+                    <%--        'newOrderProducts' : orderProducts,--%>
+                    <%--        'shopPostFee' : shopPostFee,--%>
+                    <%--        'shopOtherFee' : shopOtherFee--%>
+                    <%--    },--%>
+                    <%--    type: 'POST',--%>
+                    <%--    async: false,--%>
+                    <%--    success: function (data) {--%>
+                    <%--        loading('修改比例成本失败');--%>
+                    <%--        setTimeout(function () {--%>
+                    <%--            window.location.href = "${ctx}/weisha/cmOrganizeProduct/?organizeId=${organizeId}&productName=${cmOrganizeProductFront.productName}&shopName=${cmOrganizeProductFront.shopName}&includedTax=${cmOrganizeProductFront.includedTax}&status=${cmOrganizeProduct.status}";--%>
+                    <%--        }, 1000);--%>
+                    <%--    },--%>
+                    <%--    error: function (json) {--%>
+                    <%--        alertx('输入有误,请先更正。', function () {--%>
+                    <%--            window.location.href = "${ctx}/shopOrder/toChangePayShopAmount?costType=2&shopOrderID=${shopOrderId}"--%>
+                    <%--        });--%>
+                    <%--    }--%>
+                    <%--})--%>
                     form.submit();
                 },
                 errorContainer: "#messageBox",
@@ -149,6 +182,43 @@
             });
 
         });
+        function setOrderProductInfo() {
+            var flag = true;
+            $('.tr_orderProduct').each(function (dom, index) {
+                var index = 0;
+                var that = $(this)
+                var num = that.find('.num').val()
+                num.attr('num', 'skuList[' + skuIndex + '].organizeId');
+                var presentNum = that.find('.presentNum').val()
+                var name = that.find('.name').val()
+                var orderProductID = that.find('.orderProductID').val()
+                var includedTax = that.find('.includedTax').val()
+                var productID = that.find('.productID').val()
+                var cmPercent = that.find('.cmPercent').val()
+                var organizePercent = that.find('.organizePercent').val()
+                var shopPercent = that.find('.shopPercent').val()
+                console.log('shopPercent'+shopPercent)
+                console.log('organizePercent'+organizePercent)
+                console.log('cmPercent'+cmPercent)
+                if (100 != (shopPercent*1 + organizePercent*1 + cmPercent*1)) {
+                    top.$.jBox.confirm("每个商品三个比例之和需要等于100%", '提示');
+                    flag = false;
+                    return;
+                }
+                orderProducts.push({
+                    'num': num,
+                    'presentNum': presentNum,
+                    'name': name,
+                    'includedTax': includedTax,
+                    'productID': productID,
+                    'orderProductID': orderProductID,
+                    'shopPercent': shopPercent,
+                    'organizePercent': organizePercent,
+                    'cmPercent': cmPercent,
+                })
+            })
+            return flag;
+        }
         function page(n,s){
             $("#pageNo").val(n);
             $("#pageSize").val(s);
@@ -162,7 +232,7 @@
 </head>
 <body>
 <ul class="nav nav-tabs">
-		<li><a href="${ctx}/order/cmPayShop">付款列表</a></li>
+		<%--<li><a href="${ctx}/order/cmPayShop">付款列表</a></li>--%>
 		<li><a href="${ctx}/shopOrder/payOrderList?operatingMode=1">申请付款</a></li>
 		<li class="active"><a href="${ctx}/shopOrder/toChangePayShopAmount?costType=2&shopOrderID=${shopOrderId}">修改应付</a></li>
 </ul>
@@ -182,8 +252,35 @@
                 <input id="shopOrderID" type="hidden"  name="shopOrderID" value="${newShopOrder.shopOrderID}">
                 <input id="orderID" type="hidden"  name="orderID" value="${newShopOrder.orderID}">
                 <input id="productAmount" type="hidden"  name="productAmount" value="${newShopOrder.productAmount}">
-                <table class="table table-striped table-bordered table-condensed" style="width: 450px">
-                    <tr>
+                <table class="table table-striped table-bordered table-condensed" style="width: 80%">
+                    <thead>
+                        <tr>
+                            <th hidden>订单商品Id</th>
+                            <th>商品名</th>
+                            <th>规格</th>
+                            <th>供应商比例</th>
+                            <th>集团比例</th>
+                            <th>采美比例</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        <c:forEach var="product" items="${newShopOrder.newOrderProducts}" varStatus="index">
+                            <tr class="tr_orderProduct">
+                                <td hidden><input id="num" name="newOrderProducts[${index.index}].num" class="num" value="${product.num - product.returnedNum}"></td>
+                                <td hidden><input id="presentNum" name="newOrderProducts[${index.index}].presentNum" class="presentNum" value="${product.presentNum}"></td>
+                                <td hidden><input id="name" name="newOrderProducts[${index.index}].name" class="name" value="${product.name}"></td>
+                                <td hidden><input id="orderProductID" name="newOrderProducts[${index.index}].orderProductID" class="orderProductID" value="${product.orderProductID}"></td>
+                                <td hidden><input id="includedTax${index.index}" class="includedTax" value="${product.includedTax}"></td>
+                                <td hidden><input id="productID${index.index}" class="productID" value="${product.productID}"></td>
+                                <td>${product.name}</td>
+                                <td>${product.productUnit}</td>
+                                <td><input id="shopPercent" type="number" name="newOrderProducts[${index.index}].shopPercent" class="shopPercent" value="${product.shopPercent}" style="width: 100px"/> %</td>
+                                <td><input id="organizePercent" type="number" name="newOrderProducts[${index.index}].organizePercent" class="organizePercent" value="${product.organizePercent}" style="width: 100px"/> %</td>
+                                <td><input id="cmPercent" type="number" name="newOrderProducts[${index.index}].cmPercent" class="cmPercent" value="${product.cmPercent}" style="width: 100px"/> %</td>
+                            </tr>
+                        </c:forEach>
+                    </tbody>
+                    <%--<tr>
                         <td colspan="2">
                         <input type="hidden" id="shopOrderAmount" name="shopOrderAmount" value="${newShopOrder.productAmount}">
                             <font color="#6495ed"><b>子订单金额:</b>${newShopOrder.productAmount}</font>
@@ -205,7 +302,7 @@
                         <td>
                             <input type="number" id="shopPostFee" name="shopPostFee"  onchange="changeShouldPay(this)"  value="${newShopOrder.shopPostFee}" style="margin-left: 20px"/>
                         </td>
-                    </tr>
+                    </tr>--%>
                     <%--<tr>
                         <td>
                            <b>付第三方:</b>
@@ -219,6 +316,18 @@
 			</div>
 
 			<table>
+                <td>
+                    <b>供应商运费:</b>
+                </td>
+                <td>
+                    <input type="number" id="shopPostFee" name="shopPostFee"  onchange="changeShouldPay(this)"  value="${newShopOrder.shopPostFee}" style="margin-left: 20px"/>
+                </td>
+                <td>
+                    <b>付第三方:</b>
+                </td>
+                <td>
+                    <input type="number" id="shopOtherFee" name="shopOtherFee"  onchange="changeShouldPay(this)"  value="${newShopOrder.shopOtherFee}" style="margin-left: 20px"/>
+                </td>
 				<tr>
 					<td style="padding-top: 10px;">
 						<b>付供应商:</b><font color="red"><span id="div-supplier-fee">${newShopOrder.shouldPayShopAmount}</span></font>

+ 5 - 5
src/main/webapp/WEB-INF/views/modules/order/cmPayShopCheck.jsp

@@ -469,7 +469,7 @@
 							,</span>
                             <span class="nowrap">已付:${s.payedShopAmount},</span></div>
                         <div><span class="nowrap">待付:<input type="number"
-                                                            value="<fmt:formatNumber value="${s.waitPayShop}" pattern="0.00"/>"
+                                                            value="<fmt:formatNumber value="${s.waitPayShop-s.shopOtherFee}" pattern="0.00"/>"
                                                             class="need-to-pay" data-type="${s.differenceType}"
                                                             data-difference="${s.differencePrice}"
                                                             data-pay="${s.shouldPayShopAmount}"
@@ -495,8 +495,8 @@
                     <th colspan="3">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th>总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>
@@ -539,11 +539,11 @@
                                 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}"
+                                value="${p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice}"
                                 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)}"
+                                value="${(p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice) * (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>

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

@@ -330,96 +330,101 @@
     </div>
     <div class="payment-form-content">
         <%--涛姐遍历下面这个table--%>
-        <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}
-                        <c:if test="${not empty s.rebateFee}">
-                            <span style="color: red">(含返佣服务费¥${s.rebateFee})</span>
-                        </c:if>
-                    </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" style="display: none">
-                            <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}">
+            <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="3">下单时间</th>
+                        <th colspan="2">子订单金额</th>
+                            <%--                        <th colspan="3">所有子订单</th>--%>
+                            <%--                        <th>订单总佣金</th>--%>
+                        <th colspan="4">总平台服务费</th>
+                            <%--                        <th>机构运费</th>--%>
+                        <th colspan="2">收款状态</th>
+                        <th colspan="3">收款金额</th>
+                        <th colspan="2">经理折扣</th>
+                        <th colspan="2">优惠券</th>
+                    <tr/>
+                    <tr>
+                            <%--                        <td> ${s.orderNo}(${s.orderID})</td>--%>
+                        <td>${s.shopOrderNo}(${s.shopOrderID})</td>
+                            <%--                        <td colspan="3"> ${s.buyer}</td>--%>
+                        <td colspan="3"> ${s.orderTime}</td>
+                        <td colspan="2">${s.totalAmount}</td>
+                            <%--                        <td colspan="3">--%>
+                            <%--                        <c:forEach items="${s.shopOrderNos}" var="cs">--%>
+                            <%--                            ${cs}<br/>--%>
+                            <%--                        </c:forEach>--%>
+                            <%--                        </td>--%>
+                            <%--                        <td>--%>
+                            <%--                                ${s.income}--%>
+                            <%--                            <c:if test="${not empty s.rebateFee}">--%>
+                            <%--                                    <span style="color: red">(含返佣服务费¥${s.rebateFee})</span>--%>
+                            <%--                            </c:if>--%>
+                            <%--                        </td>--%>
+                        <td colspan="4">${s.allServeAmount}</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 colspan="2">
+                            <%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
+                               style="text-decoration: underline">
+                                </a>--%>
+                            <c:if test="${s.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+                            <c:if test="${s.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                            <c:if test="${s.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
+                        </td>
+                        <td colspan="3">
+                            <%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline"></a>--%>
+                                ${s.receiptAmount}
+                                <c:if test="${s.accountAmount>0}">(余额抵扣 ¥${s.accountAmount})</c:if>
+                        </td>
+                        <td colspan="2">
+                            <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}">
@@ -429,48 +434,79 @@
                                         <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" colspan="2">${s.couponAmount} </td>
+                        <td class="eachDiscount" style="display: none">${s.eachDiscount}</td>
+                    <tr/>
+                    <tr>
+                        <th>客户</th>
+                        <th colspan="3"> 供应商</th>
+                        <th colspan="3">子订单利润</th>
+                        <th colspan="3">商品费</th>
+                        <th>应付税费</th>
+                        <th>机构运费</th>
+                        <th>供应商运费</th>
+                        <th>付款状态</th>
+                        <th colspan="3">付供应商</th>
+                        <th colspan="2">付第三方</th>
+                        <%--<th>成本类型</th>--%>
+                    </tr>
+                    <tr>
+                        <td> ${s.buyer}</td>
+                        <td colspan="3">${s.shopName}</td>
+                        <c:if test="${empty s.brokerage}"><td colspan="3" class="payCm-t"></td></c:if>
+                        <c:if test="${not empty s.brokerage}"><td colspan="3" class="">${s.brokerage}</td></c:if>
+                            <%-- 子订单佣金=商品总佣金+机构运费-付第三方-供应商运费-分摊优惠--%>
+                        <td colspan="3" class="product-fee">${s.shopProductAmount}</td>
+
+                        <td class="taxes">
+                            <fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/>
+                        </td>
+                        <td>
+                            <label class="clubFreight"  style="display: none">
+                                <c:choose>
+                                    <c:when test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2 && s.returnedFreightFlag ne true}">
+                                        <fmt:formatNumber value="${s.shopPostFee}"/>
+                                    </c:when>
+                                    <c:otherwise>
+                                        <fmt:formatNumber value="0"/>
+                                    </c:otherwise>
+                                </c:choose>
+                            </label>
+                            <c:if test="${s.shopPostFlag == 0}">
+                                包邮
+                            </c:if>
+                            <c:if test="${s.shopPostFlag == 2}">
+                                到付
+                            </c:if>
+                            <c:if test="${s.shopPostFlag == -2}">
+                                仪器到付-产品包邮
+                            </c:if>
+                            <c:if test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+                                <fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
+                                <c:if test="${s.returnedFreightFlag eq true}"><font color="red">(已退)</font></c:if>
                             </c:if>
-                        </c:if>
-                        <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
-                    </td>
-                    <td>${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})</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.payStatus == 1 || empty s.payStatus || s.payStatus == 0}"><font
-                                color="red">待付款</font></c:if>
-                        <c:if test="${s.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
-                        <c:if test="${s.payStatus == 3}"><font color="green">已付款</font></c:if>
-                    </td>
-
-                    <td colspan="3" class="supplier-fee">
-                        <div><span class="nowrap">
+                            <c:if test="${s.userBeans gt 0}">
+                                (采美豆抵用${s.userBeans})
+                            </c:if>
+                        </td>
+                        <td class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
+                                                              pattern="#,##0.00"/></td>
+
+                        <td>
+                            <c:if test="${s.payStatus == 1 || empty s.payStatus || s.payStatus == 0}"><font
+                                    color="red">待付款</font></c:if>
+                            <c:if test="${s.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
+                            <c:if test="${s.payStatus == 3}"><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"/>
+                                应付:<fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
                             </c:if>
 							<c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
                                 <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
@@ -479,105 +515,106 @@
                                 <font color="black"><fmt:formatNumber value="${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">
-                        <label class="wipeBtn"><input class="wipeFee" type="checkbox" value="0"><span>付款抹平:<em
-                                class="red wipeText">¥0.00</em></span></label>
-                    </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>
+                                <span class="nowrap">已付:${s.payedShopAmount},</span></div>
+                            <div><span class="nowrap">待付:<input type="number"
+                                                                value="<fmt:formatNumber value="${s.waitPayShop-s.shopOtherFee}" 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">
+                            <label class="wipeBtn"><input class="wipeFee" type="checkbox" value="0"><span>付款抹平:<em
+                                    class="red wipeText">¥0.00</em></span></label>
                         </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>
+
+                        <td colspan="2" 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="2">单价</th>
+                        <th colspan="3">机构税率 / 单税费 / 总税费</th>
+                        <th colspan="2">总价</th>
+                        <th>利润(单)</th>
+                        <th>利润(总)</th>
+                        <th>平台服务费(单)</th>
+                        <th colspan="3">供应商税率 / 单税费 / 总税费</th>
+                        <th>成本(单 + 税)</th>
+                        <th>成本(总)</th>
                     </tr>
-                </c:forEach>
-            </table>
-        </c:forEach>
+                    <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><fmt:formatNumber
+                                    value="${p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice}"
+                                    pattern="#,##0.00"/></td>
+
+                            <td class="payCm"><fmt:formatNumber
+                                    value="${(p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice) * (p.num + p.presentNum - p.returnedNum)}"
+                                    pattern="#,##0.00"/></td>
+                            <td><fmt:formatNumber value="${p.cmCostPrice}" 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>
+            </c:forEach>
     </div>
     <div class="payment-form-bottom">
         <div>

+ 119 - 78
src/main/webapp/WEB-INF/views/modules/order/cmPayShopEdit.jsp

@@ -83,70 +83,80 @@
             <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>子订单编号(ID)</th>
+                            <%--                        <th colspan="3">客户</th>--%>
+                        <th colspan="3">下单时间</th>
+                        <th colspan="2">子订单金额</th>
+                            <%--                        <th colspan="3">所有子订单</th>--%>
+                            <%--                        <th>订单总佣金</th>--%>
+                        <th colspan="4">总平台服务费</th>
+                            <%--                        <th>机构运费</th>--%>
+                        <th colspan="2">收款状态</th>
                         <th colspan="3">收款金额</th>
-                        <th>经理折扣</th>
-                        <th>优惠券</th>
+                        <th colspan="2">经理折扣</th>
+                        <th colspan="2">优惠券</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"
+                            <%--                        <td> ${s.orderNo}(${s.orderID})</td>--%>
+                        <td>${s.shopOrderNo}(${s.shopOrderID})</td>
+                            <%--                        <td colspan="3"> ${s.buyer}</td>--%>
+                        <td colspan="3"> ${s.orderTime}</td>
+                        <td colspan="2">${s.totalAmount}</td>
+                            <%--                        <td colspan="3">--%>
+                            <%--                        <c:forEach items="${s.shopOrderNos}" var="cs">--%>
+                            <%--                            ${cs}<br/>--%>
+                            <%--                        </c:forEach>--%>
+                            <%--                        </td>--%>
+                            <%--                        <td>--%>
+                            <%--                                ${s.income}--%>
+                            <%--                            <c:if test="${not empty s.rebateFee}">--%>
+                            <%--                                    <span style="color: red">(含返佣服务费¥${s.rebateFee})</span>--%>
+                            <%--                            </c:if>--%>
+                            <%--                        </td>--%>
+                        <td colspan="4">${s.allServeAmount}</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 colspan="2">
+                            <%--<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>
+                                </a>--%>
+                            <c:if test="${s.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+                            <c:if test="${s.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                            <c:if test="${s.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
                         </td>
                         <td colspan="3">
-                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
-                               style="text-decoration: underline">${s.receiptTotalFee}</a>
+                            <%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline"></a>--%>
+                            ${s.receiptAmount}
+                            <c:if test="${s.accountAmount>0}">(余额抵扣 ¥${s.accountAmount})</c:if>
                         </td>
-                        <td>
-                            <label class="discountFee"  style="display: none">
+                        <td colspan="2">
+                            <label class="discountFee">
                                 <c:choose>
                                     <c:when test="${s.discountTotalFee gt 0 && s.discountTotalFee gt s.returnedPurchaseTotalFee}">
                                         <fmt:formatNumber value="${s.discountTotalFee - s.returnedPurchaseTotalFee}"/>
@@ -178,31 +188,61 @@
                             </c:if>
                             <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
                         </td>
-                        <td>${s.couponAmount} </td>
+                        <td class="couponAmount" colspan="2">${s.couponAmount} </td>
                         <td class="eachDiscount" style="display: none">${s.eachDiscount}</td>
                     <tr/>
                     <tr>
-                        <th>子订单编号(ID)</th>
+                        <th>客户</th>
                         <th colspan="3"> 供应商</th>
-                        <th colspan="3">子订单佣金</th>
+                        <th colspan="3">子订单利润</th>
                         <th colspan="3">商品费</th>
                         <th>应付税费</th>
+                        <th>机构运费</th>
                         <th>供应商运费</th>
                         <th>付款状态</th>
                         <th colspan="3">付供应商</th>
-                        <th>付第三方</th>
-                        <th>成本类型</th>
+                        <th colspan="2">付第三方</th>
+                        <%--<th>成本类型</th>--%>
                     </tr>
                     <tr>
-                        <td>${s.shopOrderNo}(${s.shopOrderID})</td>
+                        <td> ${s.buyer}</td>
                         <td colspan="3">${s.shopName}</td>
-                        <td colspan="3" class="payCm-t">子订单佣金</td>
+                        <c:if test="${empty s.brokerage}"><td colspan="3" class="payCm-t"></td></c:if>
+                        <c:if test="${not empty s.brokerage}"><td colspan="3" class="">${s.brokerage}</td></c:if>
+                            <%-- 子订单佣金=商品总佣金+机构运费-付第三方-供应商运费-分摊优惠--%>
                         <td colspan="3" class="product-fee">${s.shopProductAmount}</td>
 
                         <td class="taxes">
                             <fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/>
                         </td>
-
+                        <td>
+                            <label class="clubFreight"  style="display: none">
+                                <c:choose>
+                                    <c:when test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2 && s.returnedFreightFlag ne true}">
+                                        <fmt:formatNumber value="${s.shopPostFee}"/>
+                                    </c:when>
+                                    <c:otherwise>
+                                        <fmt:formatNumber value="0"/>
+                                    </c:otherwise>
+                                </c:choose>
+                            </label>
+                            <c:if test="${s.shopPostFlag == 0}">
+                                包邮
+                            </c:if>
+                            <c:if test="${s.shopPostFlag == 2}">
+                                到付
+                            </c:if>
+                            <c:if test="${s.shopPostFlag == -2}">
+                                仪器到付-产品包邮
+                            </c:if>
+                            <c:if test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+                                <fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
+                                <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 class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
                                                               pattern="#,##0.00"/></td>
 
@@ -238,25 +278,26 @@
                                     class="red wipeText">¥0.00</em></span></label>
                         </td>
 
-                        <td class="third-party-fee">${s.shopOtherFee}</td>
+                        <td colspan="2" class="third-party-fee">${s.shopOtherFee}</td>
 
-                        <td>
+                        <%--<td>
                             <c:if test="${empty s.costType || s.costType == '1'}">固定成本</c:if>
                             <c:if test="${s.costType == '2'}">比例成本</c:if>
-                        </td>
+                        </td>--%>
                     </tr>
                     <tr>
                         <th>商品名</th>
                         <th>规格</th>
                         <th>数量<%--(赠品)--%></th>
                         <th>退货</th>
-                        <th colspan="3">单价</th>
+                        <th colspan="2">单价</th>
                         <th colspan="3">机构税率 / 单税费 / 总税费</th>
-                        <th>总价</th>
-                        <th>佣金(单)</th>
-                        <th>佣金(总)</th>
+                        <th colspan="2">总价</th>
+                        <th>利润(单)</th>
+                        <th>利润(总)</th>
+                        <th>平台服务费(单)</th>
                         <th colspan="3">供应商税率 / 单税费 / 总税费</th>
-                        <th>成本(单)</th>
+                        <th>成本(单 + 税)</th>
                         <th>成本(总)</th>
                     </tr>
                     <c:forEach items="${s.newOrderProducts}" var="p" varStatus="pIndex">
@@ -273,7 +314,7 @@
                                 <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}"
+                            <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">
@@ -293,17 +334,17 @@
                                             type="number" pattern="#,##0.00"/>
                                 </c:otherwise>
                             </c:choose></td>
-                            <td><fmt:formatNumber
+                            <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><fmt:formatNumber
-                                    value="${(empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax - p.costPrice - p.singleShouldPayTotalTax}"
+                                    value="${p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice}"
                                     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)}"
+                                    value="${(p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice) * (p.num + p.presentNum - p.returnedNum)}"
                                     pattern="#,##0.00"/></td>
-
+                            <td><fmt:formatNumber value="${p.cmCostPrice}" 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>

+ 91 - 57
src/main/webapp/WEB-INF/views/modules/order/cmPayShopForm.jsp

@@ -415,35 +415,38 @@
             <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>子订单编号(ID)</th>
+<%--                        <th colspan="3">客户</th>--%>
+                        <th colspan="3">下单时间</th>
+                        <th colspan="2">子订单金额</th>
+<%--                        <th colspan="3">所有子订单</th>--%>
+<%--                        <th>订单总佣金</th>--%>
+                        <th colspan="4">总平台服务费</th>
+<%--                        <th>机构运费</th>--%>
+                        <th colspan="2">收款状态</th>
                         <th colspan="3">收款金额</th>
-                        <th>经理折扣</th>
-                        <th>优惠券</th>
+                        <th colspan="2">经理折扣</th>
+                        <th colspan="2">优惠券</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}
-                            <c:if test="${not empty s.rebateFee}">
-                                    <span style="color: red">(含返佣服务费¥${s.rebateFee})</span>
-                            </c:if>
-                        </td>
-                        <td>
+<%--                        <td> ${s.orderNo}(${s.orderID})</td>--%>
+                        <td>${s.shopOrderNo}(${s.shopOrderID})</td>
+<%--                        <td colspan="3"> ${s.buyer}</td>--%>
+                        <td colspan="3"> ${s.orderTime}</td>
+                        <td colspan="2">${s.totalAmount}</td>
+<%--                        <td colspan="3">--%>
+<%--                        <c:forEach items="${s.shopOrderNos}" var="cs">--%>
+<%--                            ${cs}<br/>--%>
+<%--                        </c:forEach>--%>
+<%--                        </td>--%>
+<%--                        <td>--%>
+<%--                                ${s.income}--%>
+<%--                            <c:if test="${not empty s.rebateFee}">--%>
+<%--                                    <span style="color: red">(含返佣服务费¥${s.rebateFee})</span>--%>
+<%--                            </c:if>--%>
+<%--                        </td>--%>
+                        <td colspan="4">${s.allServeAmount}</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}">
@@ -470,19 +473,21 @@
                             <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"
+                        </td>--%>
+                        <td colspan="2">
+                            <%--<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>
+                                </a>--%>
+                            <c:if test="${s.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+                            <c:if test="${s.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                            <c:if test="${s.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
                         </td>
                         <td colspan="3">
-                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
-                               style="text-decoration: underline">${s.receiptTotalFee}</a>
+                            <%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline"></a>--%>
+                                ${s.receiptAmount}
+                                <c:if test="${s.accountAmount>0}">(余额抵扣 ¥${s.accountAmount})</c:if>
                         </td>
-                        <td>
+                        <td colspan="2">
                             <label class="discountFee">
                                 <c:choose>
                                     <c:when test="${s.discountTotalFee gt 0 && s.discountTotalFee gt s.returnedPurchaseTotalFee}">
@@ -515,23 +520,24 @@
                             </c:if>
                             <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
                         </td>
-                        <td class="couponAmount">${s.couponAmount} </td>
+                        <td class="couponAmount" colspan="2">${s.couponAmount} </td>
                         <td class="eachDiscount" style="display: none">${s.eachDiscount}</td>
                     <tr/>
                     <tr>
-                        <th>子订单编号(ID)</th>
+                        <th>客户</th>
                         <th colspan="3"> 供应商</th>
-                        <th colspan="3">子订单佣金</th>
+                        <th colspan="3">子订单利润</th>
                         <th colspan="3">商品费</th>
                         <th>应付税费</th>
+                        <th>机构运费</th>
                         <th>供应商运费</th>
                         <th>付款状态</th>
                         <th colspan="3">付供应商</th>
-                        <th>付第三方</th>
-                        <th>成本类型</th>
+                        <th colspan="2">付第三方</th>
+                        <%--<th>成本类型</th>--%>
                     </tr>
                     <tr>
-                        <td>${s.shopOrderNo}(${s.shopOrderID})</td>
+                        <td> ${s.buyer}</td>
                         <td colspan="3">${s.shopName}</td>
                         <c:if test="${empty s.brokerage}"><td colspan="3" class="payCm-t"></td></c:if>
                         <c:if test="${not empty s.brokerage}"><td colspan="3" class="">${s.brokerage}</td></c:if>
@@ -541,7 +547,34 @@
                         <td class="taxes">
                             <fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/>
                         </td>
-
+                        <td>
+                            <label class="clubFreight"  style="display: none">
+                                <c:choose>
+                                    <c:when test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2 && s.returnedFreightFlag ne true}">
+                                        <fmt:formatNumber value="${s.shopPostFee}"/>
+                                    </c:when>
+                                    <c:otherwise>
+                                        <fmt:formatNumber value="0"/>
+                                    </c:otherwise>
+                                </c:choose>
+                            </label>
+                            <c:if test="${s.shopPostFlag == 0}">
+                                包邮
+                            </c:if>
+                            <c:if test="${s.shopPostFlag == 2}">
+                                到付
+                            </c:if>
+                            <c:if test="${s.shopPostFlag == -2}">
+                                仪器到付-产品包邮
+                            </c:if>
+                            <c:if test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+                                <fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
+                                <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 class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
                                                               pattern="#,##0.00"/></td>
 
@@ -555,7 +588,7 @@
                         <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"/>
+                                应付:<fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
                             </c:if>
 							<c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
                                 <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
@@ -566,7 +599,7 @@
 							,</span>
                                 <span class="nowrap">已付:${s.payedShopAmount},</span></div>
                             <div><span class="nowrap">待付:<input type="number"
-                                                                value="<fmt:formatNumber value="${s.waitPayShop}" pattern="0.00"/>"
+                                                                value="<fmt:formatNumber value="${s.waitPayShop-s.shopOtherFee}" pattern="0.00"/>"
                                                                 class="need-to-pay" data-type="${s.differenceType}"
                                                                 data-difference="${s.differencePrice}"
                                                                 data-pay="${s.shouldPayShopAmount}"
@@ -577,25 +610,26 @@
                                     class="red wipeText">¥0.00</em></span></label>
                         </td>
 
-                        <td class="third-party-fee">${s.shopOtherFee}</td>
+                        <td colspan="2" class="third-party-fee">${s.shopOtherFee}</td>
 
-                        <td>
+                        <%--<td>
                             <c:if test="${empty s.costType || s.costType == '1'}">固定成本</c:if>
                             <c:if test="${s.costType == '2'}">比例成本</c:if>
-                        </td>
+                        </td>--%>
                     </tr>
                     <tr>
                         <th>商品名</th>
                         <th>规格</th>
                         <th>数量<%--(赠品)--%></th>
                         <th>退货</th>
-                        <th colspan="3">单价</th>
+                        <th colspan="2">单价</th>
                         <th colspan="3">机构税率 / 单税费 / 总税费</th>
-                        <th>总价</th>
-                        <th>佣金(单)</th>
-                        <th>佣金(总)</th>
+                        <th colspan="2">总价</th>
+                        <th>利润(单)</th>
+                        <th>利润(总)</th>
+                        <th>平台服务费(单)</th>
                         <th colspan="3">供应商税率 / 单税费 / 总税费</th>
-                        <th>成本(单)</th>
+                        <th>成本(单 + 税)</th>
                         <th>成本(总)</th>
                     </tr>
                     <c:forEach items="${s.newOrderProducts}" var="p" varStatus="pIndex">
@@ -612,7 +646,7 @@
                                 <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}"
+                            <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">
@@ -632,17 +666,17 @@
                                             type="number" pattern="#,##0.00"/>
                                 </c:otherwise>
                             </c:choose></td>
-                            <td><fmt:formatNumber
+                            <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><fmt:formatNumber
-                                    value="${(empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax - p.costPrice - p.singleShouldPayTotalTax}"
+                                    value="${p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice}"
                                     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)}"
+                                    value="${(p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice) * (p.num + p.presentNum - p.returnedNum)}"
                                     pattern="#,##0.00"/></td>
-
+                            <td><fmt:formatNumber value="${p.cmCostPrice}" 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>

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

@@ -293,18 +293,18 @@
 <body>
 <ul class="nav nav-tabs">
     <c:if test="${operatingMode == '1'}">
-        <li><a href="${ctx}/order/cmPayShop">付款列表</a></li>
+        <%--<li><a href="${ctx}/order/cmPayShop">付款列表</a></li>--%>
         <li class="active tab-li"><a href="${ctx}/shopOrder/payOrderList?operatingMode=1">申请付款</a></li>
-        <li><a href="${ctx}/shopOrder/payOrderList?operatingMode=3">已付款子订单</a></li>
+        <%--<li><a href="${ctx}/shopOrder/payOrderList?operatingMode=3">已付款子订单</a></li>--%>
     </c:if>
-    <c:if test="${operatingMode == '2'}">
+    <%--<c:if test="${operatingMode == '2'}">
         <li><a href="${ctx}/order/cmRefundShop/">退款列表</a></li>
         <li class="active tab-li"><a href="${ctx}/shopOrder/refundRecordList?operatingMode=2">记录退款</a></li>
     </c:if>
     <shiro:hasPermission name="order:cmPayShop:split">
         <li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
     </shiro:hasPermission>
-        <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
+        <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>--%>
 </ul>
 <form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newShopOrder"
            action="${ctx}/shopOrder/payOrderList?operatingMode=${operatingMode
@@ -405,26 +405,28 @@
                     </th>
                     <th>子订单编号(ID)</th>
                     <th colspan="3">订单编号(ID)</th>
-                    <th colspan="2">订单金额</th>
+                    <th colspan="2">订单金额</th>
                     <th colspan="3">下单时间</th>
                     <th>收款状态</th>
                     <th>收款金额</th>
                     <th colspan="3">经理折扣</th>
-                    <th>优惠券</th>
-                    <th>成本类型</th>
+                    <th colspan="2">优惠券</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="2"><fmt:formatNumber value="${s.totalAmount}" 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><%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline"></a>--%>
+                        <c:if test="${s.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+                        <c:if test="${s.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                        <c:if test="${s.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
                     </td>
-                    <td><a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline">${s.receiptTotalFee}</a></td>
+                    <td><%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1" style="text-decoration: underline"></a></td>--%>
+                        ${s.receiptAmount}
+                        <c:if test="${s.accountAmount>0}">(余额抵扣 ¥${s.accountAmount})</c:if>
                     <td colspan="3">
                         <c:if test="${s.discountTotalFee gt 0}">
                             <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
@@ -448,11 +450,11 @@
                         </c:if>
                         <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
                     </td>
-                    <td>
+                    <td colspan="2">
                             ${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><c:if test="${empty s.costType || s.costType == '1'}">固定成本</c:if><c:if
+                            test="${s.costType == '2'}">比例成本</c:if></td>--%>
                 </tr>
                 <tr>
                     <th>供应商</th>
@@ -471,20 +473,20 @@
                         <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>
+                        <c:if test="${s.organizeID == 4}"><font color="red">(丽格集采联盟)</font></c:if>
                     </td>
                     <td>
-                        <c:if test="${s.freight == 0}">
+                        <c:if test="${s.shopPostFlag == 0}">
                             包邮
                         </c:if>
-                        <c:if test="${s.freight == -1}">
+                        <c:if test="${s.shopPostFlag == 2}">
                             到付
                         </c:if>
-                        <c:if test="${s.freight == -2}">
+                        <c:if test="${s.shopPostFlag == -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.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+                            <fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
                             <c:if test="${s.returnedFreightFlag eq true}"><font color="red">(已退)</font></c:if>
                         </c:if>
                         <c:if test="${s.userBeans > 0}">
@@ -503,13 +505,13 @@
                                                                     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>
+                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font>
                         </c:if>
                         <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
                         </c:if>
                         <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}" type="number" pattern="#,##0.00"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                         </c:if>
                     </td>
                     <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">
@@ -529,7 +531,7 @@
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th colspan="2">总价</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
-                    <th>成本(单)</th>
+                    <th>成本(单 + 税)</th>
                     <th>成本(总)</th>
                 </tr>
                 <c:forEach items="${s.newOrderProducts}" var="p" varStatus="pIndex">
@@ -593,7 +595,7 @@
                 </c:forEach>
             </table>
             <div class="pay-more-func">
-                <a id="applyShopOtherFee" href="${ctx}/order/cmPayShop/shopOtherFeeForm?shopOrderId=${s.shopOrderID}">付第三方申请</a>
+                <a id="applyShopOtherFee" href="${ctx}/order/cmPayShop/shopOtherFeeForm?shopOrderId=${s.shopOrderID}&payType=1">付第三方申请</a>
                 <c:if test="${s.paying ne '1' and s.payStatus eq '1' and !s.modifyPayable}">
                     <shiro:hasPermission name="order:cmPayShop:modifyPay">
                         <a onclick="applypayWay(${s.shopReceiptStatus},${s.payWay})"  href="${ctx}/shopOrder/toChangePayShopAmount?shopOrderID=${s.shopOrderID}">修改成本</a>

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

@@ -507,8 +507,8 @@
                     <th colspan="3">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th>总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>

+ 51 - 29
src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherPrintDetail.jsp

@@ -489,29 +489,40 @@
             <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 colspan="3">下单时间</th>
-                    <th>收款状态</th>
-                    <th>收款金额</th>
+                    <th colspan="2">子订单金额</th>
+                        <%--                        <th colspan="3">所有子订单</th>--%>
+                        <%--                        <th>订单总佣金</th>--%>
+                    <th colspan="4">总平台服务费</th>
+                        <%--                        <th>机构运费</th>--%>
+                    <th colspan="2">收款状态</th>
+                    <th colspan="3">收款金额</th>
                     <th colspan="2">经理折扣</th>
-                    <th colspan="3">成本类型</th>
                     <th colspan="2">付第三方</th>
                 </tr>
                 <tr>
                     <td>${s.shopOrderNo}(${s.shopOrderID})</td>
-                    <td colspan="3">${s.orderNo}(${s.orderID})</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="3"> ${s.orderTime}</td>
+                    <td colspan="2">${s.totalAmount}</td>
+                    <td colspan="4">${s.allServeAmount}</td>
                     <td colspan="2">
+                        <c:if test="${s.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+                        <c:if test="${s.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                        <c:if test="${s.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
+                    </td>
+                    <td colspan="3">
+                            ${s.receiptAmount}
+                        <c:if test="${s.accountAmount>0}">(余额抵扣 ¥${s.accountAmount})</c:if>
+                    </td>
+                    <td colspan="2">
+                        <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:choose>
+                        </label>
                         <c:if test="${s.discountTotalFee gt 0}">
                             <c:if test="${s.discountTotalFee gt s.returnedPurchaseTotalFee}">
                                 <fmt:formatNumber value="${s.discountTotalFee - s.returnedPurchaseTotalFee}"
@@ -534,8 +545,6 @@
                         </c:if>
                         <c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
                     </td>
-                    <td colspan="3"><c:if test="${empty s.costType || s.costType == '1'}">固定成本</c:if><c:if
-                            test="${s.costType == '2'}">比例成本</c:if></td>
                     <td colspan="2" class="third-party-fee"><fmt:formatNumber value="${s.shopOtherFee}" type="number"
                                                                               pattern="#,##0.00"/></td>
                 </tr>
@@ -558,19 +567,32 @@
                         <c:if test="${s.organizeID == 3}"></c:if>
                     </td>
                     <td>
-                        <c:if test="${s.freight == 0}">
+                        <label class="clubFreight"  style="display: none">
+                            <c:choose>
+                                <c:when test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2 && s.returnedFreightFlag ne true}">
+                                    <fmt:formatNumber value="${s.shopPostFee}"/>
+                                </c:when>
+                                <c:otherwise>
+                                    <fmt:formatNumber value="0"/>
+                                </c:otherwise>
+                            </c:choose>
+                        </label>
+                        <c:if test="${s.shopPostFlag == 0}">
                             包邮
                         </c:if>
-                        <c:if test="${s.freight == -1}">
+                        <c:if test="${s.shopPostFlag == 2}">
                             到付
                         </c:if>
-                        <c:if test="${s.freight == -2}">
+                        <c:if test="${s.shopPostFlag == -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.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+                            <fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
                             <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 class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
                                                           pattern="#,##0.00"/></td>
@@ -587,13 +609,13 @@
                     <td colspan="2" class="supplier-fee">
                         <div>
                             <c:if test="${s.differenceType ne 1 && s.differenceType ne 2}">应付:<fmt:formatNumber
-                                    value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/>
+                                    value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
                             </c:if>
                             <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
-                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount-s.shopOtherFee},已补差价:${s.differencePrice})</font>
                             </c:if>
                             <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount-s.shopOtherFee},已退差价:${s.differencePrice})</font>
                             </c:if>,
                             已付:<fmt:formatNumber value="${s.payedShopAmount}" type="number" pattern="#,##0.00"/>
                         </div>
@@ -603,7 +625,7 @@
                                                                              pattern="#,##0.00"/></span>,
                             </c:if>
                             待付: <fmt:formatNumber
-                                value="${s.wipePayment > 0 ? 0 : (s.differenceType eq 1 ? (s.differencePrice + s.waitPayShop):(s.waitPayShop - s.differencePrice))}"
+                                value="${s.wipePayment > 0 ? 0 : (s.differenceType eq 1 ? (s.differencePrice + s.waitPayShop-s.shopOtherFee):(s.waitPayShop - s.differencePrice-s.shopOtherFee))}"
                                 type="number" pattern="#,##0.00"/>
                         </div>
                         <c:if test="${s.wipePayment > 0}">
@@ -621,8 +643,8 @@
                     <th colspan="2">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th colspan="2">总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>

+ 26 - 12
src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherPrintDetails.jsp

@@ -386,19 +386,32 @@
                     <td>${s.shopName}</td>
                     <td colspan="3">${s.buyer}<c:if test="${s.organizeID == 3}"></c:if></td>
                     <td>
-                        <c:if test="${s.freight == 0}">
+                        <label class="clubFreight"  style="display: none">
+                            <c:choose>
+                                <c:when test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2 && s.returnedFreightFlag ne true}">
+                                    <fmt:formatNumber value="${s.shopPostFee}"/>
+                                </c:when>
+                                <c:otherwise>
+                                    <fmt:formatNumber value="0"/>
+                                </c:otherwise>
+                            </c:choose>
+                        </label>
+                        <c:if test="${s.shopPostFlag == 0}">
                             包邮
                         </c:if>
-                        <c:if test="${s.freight == -1}">
+                        <c:if test="${s.shopPostFlag == 2}">
                             到付
                         </c:if>
-                        <c:if test="${s.freight == -2}">
+                        <c:if test="${s.shopPostFlag == -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.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+                            <fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
                             <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 class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
                                                           pattern="#,##0.00"/></td>
@@ -411,23 +424,24 @@
                     <td class="supplier-fee">
                         <div>
                             <c:if test="${s.differenceType ne 1 && s.differenceType ne 2}">应付:<fmt:formatNumber
-                                    value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/>
+                                    value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
                             </c:if>
                             <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
-                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount-s.shopOtherFee},已补差价:${s.differencePrice})</font>
                             </c:if>
                             <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
-                            </c:if>
-                            已付:<fmt:formatNumber value="${s.payedShopAmount}" type="number" pattern="#,##0.00"/>
+                                <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount-s.shopOtherFee},已退差价:${s.differencePrice})</font>
+                            </c:if>
+                            已付:<fmt:formatNumber value="${s.payedShopAmount}" type="number" pattern="#,##0.00"/>
                         </div>
                         <div>
                             <c:if test="${s.refundAmount > 0}">
                                 <span style="color:red">退款:<fmt:formatNumber value="${s.refundAmount}" type="number"
                                                                              pattern="#,##0.00"/></span>,
                             </c:if>
-                            待付:<fmt:formatNumber value="${s.wipePayment>0 ? 0 : s.waitPayShop}" type="number"
-                                                 pattern="#,##0.00"/>
+                            待付: <fmt:formatNumber
+                                value="${s.wipePayment > 0 ? 0 : (s.differenceType eq 1 ? (s.differencePrice + s.waitPayShop-s.shopOtherFee):(s.waitPayShop - s.differencePrice-s.shopOtherFee))}"
+                                type="number" pattern="#,##0.00"/>
                         </div>
                         <c:if test="${s.wipePayment > 0}">
                             <div>

+ 260 - 218
src/main/webapp/WEB-INF/views/modules/order/cmPayShopPrintDetail.jsp

@@ -93,92 +93,102 @@
 		</div>
 		<div class="payment-form-content">
             <%--涛姐遍历下面这个table--%>
-			<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" style="display: none">
-								<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}">
+				<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="3">下单时间</th>
+							<th colspan="2">子订单金额</th>
+								<%--                        <th colspan="3">所有子订单</th>--%>
+								<%--                        <th>订单总佣金</th>--%>
+							<th colspan="4">总平台服务费</th>
+								<%--                        <th>机构运费</th>--%>
+							<th colspan="2">收款状态</th>
+							<th colspan="3">收款金额</th>
+							<th colspan="2">经理折扣</th>
+							<th colspan="2">优惠券</th>
+						<tr/>
+						<tr>
+								<%--                        <td> ${s.orderNo}(${s.orderID})</td>--%>
+							<td>${s.shopOrderNo}(${s.shopOrderID})</td>
+								<%--                        <td colspan="3"> ${s.buyer}</td>--%>
+							<td colspan="3"> ${s.orderTime}</td>
+							<td colspan="2">${s.totalAmount}</td>
+								<%--                        <td colspan="3">--%>
+								<%--                        <c:forEach items="${s.shopOrderNos}" var="cs">--%>
+								<%--                            ${cs}<br/>--%>
+								<%--                        </c:forEach>--%>
+								<%--                        </td>--%>
+								<%--                        <td>--%>
+								<%--                                ${s.income}--%>
+								<%--                            <c:if test="${not empty s.rebateFee}">--%>
+								<%--                                    <span style="color: red">(含返佣服务费¥${s.rebateFee})</span>--%>
+								<%--                            </c:if>--%>
+								<%--                        </td>--%>
+							<td colspan="4">${s.allServeAmount}</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 colspan="2">
+								<%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
+								   style="text-decoration: underline">
+									</a>--%>
+								<c:if test="${s.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+								<c:if test="${s.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+								<c:if test="${s.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
+							</td>
+							<td colspan="3">
+								<%--<a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${s.orderID}&from=1"
+								   style="text-decoration: underline"></a>--%>
+									${s.receiptAmount}
+									<c:if test="${s.accountAmount>0}">(余额抵扣 ¥${s.accountAmount})</c:if>
+							</td>
+							<td colspan="2">
+								<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}">
@@ -188,48 +198,79 @@
 										<fmt:formatNumber value="${s.discountTotalFee}" type="currency"/>
 									</c:if>)
                                 </span>
+									</c:if>
 								</c:if>
-							</c:if>
-							<c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
-						</td>
-						<td>${s.couponAmount} </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 colspan="2">付第三方</th>
-						<th colspan="2">成本类型</th>
-					</tr>
-					<tr>
-						<td>${s.shopOrderNo}(${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>
+								<c:if test="${s.discountTotalFee le 0}">¥0.00</c:if>
+							</td>
+							<td class="couponAmount" colspan="2">${s.couponAmount} </td>
+							<td class="eachDiscount" style="display: none">${s.eachDiscount}</td>
+						<tr/>
+						<tr>
+							<th>客户</th>
+							<th colspan="3"> 供应商</th>
+							<th colspan="3">子订单利润</th>
+							<th colspan="3">商品费</th>
+							<th>应付税费</th>
+							<th>机构运费</th>
+							<th>供应商运费</th>
+							<th>付款状态</th>
+							<th colspan="3">付供应商</th>
+							<th colspan="2">付第三方</th>
+							<%--<th>成本类型</th>--%>
+						</tr>
+						<tr>
+							<td> ${s.buyer}</td>
+							<td colspan="3">${s.shopName}</td>
+							<c:if test="${empty s.brokerage}"><td colspan="3" class="payCm-t"></td></c:if>
+							<c:if test="${not empty s.brokerage}"><td colspan="3" class="">${s.brokerage}</td></c:if>
+								<%-- 子订单佣金=商品总佣金+机构运费-付第三方-供应商运费-分摊优惠--%>
+							<td colspan="3" class="product-fee">${s.shopProductAmount}</td>
 
-						<td class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
-															  pattern="#,##0.00"/></td>
+							<td class="taxes">
+								<fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/>
+							</td>
+							<td>
+								<label class="clubFreight"  style="display: none">
+									<c:choose>
+										<c:when test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2 && s.returnedFreightFlag ne true}">
+											<fmt:formatNumber value="${s.shopPostFee}"/>
+										</c:when>
+										<c:otherwise>
+											<fmt:formatNumber value="0"/>
+										</c:otherwise>
+									</c:choose>
+								</label>
+								<c:if test="${s.shopPostFlag == 0}">
+									包邮
+								</c:if>
+								<c:if test="${s.shopPostFlag == 2}">
+									到付
+								</c:if>
+								<c:if test="${s.shopPostFlag == -2}">
+									仪器到付-产品包邮
+								</c:if>
+								<c:if test="${s.shopPostFlag != 2 && s.shopPostFlag != 0 && s.shopPostFlag != -2}">
+									<fmt:formatNumber value="${s.shopPostFee}" type="number" pattern="#,##0.00"/>
+									<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 class="freight"><fmt:formatNumber value="${s.shopPostFee}" type="number"
+																  pattern="#,##0.00"/></td>
 
-						<td>
-							<c:if test="${s.payStatus == 1 || empty s.payStatus || s.payStatus == 0}"><font
-									color="red">待付款</font></c:if>
-							<c:if test="${s.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
-							<c:if test="${s.payStatus == 3}"><font color="green">已付款</font></c:if>
-						</td>
+							<td>
+								<c:if test="${s.payStatus == 1 || empty s.payStatus || s.payStatus == 0}"><font
+										color="red">待付款</font></c:if>
+								<c:if test="${s.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
+								<c:if test="${s.payStatus == 3}"><font color="green">已付款</font></c:if>
+							</td>
 
-						<td colspan="3" class="supplier-fee">
-							<div><span class="nowrap">
+							<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"/>
+								应付:<fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
 							</c:if>
 							<c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
 								<font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
@@ -238,105 +279,106 @@
 								<font color="black"><fmt:formatNumber value="${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">
-							<label class="wipeBtn"><input class="wipeFee" type="checkbox" value="0"><span>付款抹平:<em
-									class="red wipeText">¥0.00</em></span></label>
-						</td>
-
-						<td colspan="2" class="third-party-fee">${s.shopOtherFee}</td>
-
-						<td colspan="2">
-							<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="6">供应商税率 / 单税费 / 总税费</th>
-						<th colspan="3">成本(单)</th>
-						<th colspan="4">成本(总)</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}
+									<span class="nowrap">已付:${s.payedShopAmount},</span></div>
+								<div><span class="nowrap">待付:<input type="number"
+																	value="<fmt:formatNumber value="${s.waitPayShop-s.shopOtherFee}" 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">
+								<label class="wipeBtn"><input class="wipeFee" type="checkbox" value="0"><span>付款抹平:<em
+										class="red wipeText">¥0.00</em></span></label>
 							</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 colspan="2" class="third-party-fee">${s.shopOtherFee}</td>
 
-							<td colspan="2" 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 colspan="2" 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 colspan="2" 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 colspan="3" class="p-costprice"><fmt:formatNumber value="${p.costPrice}" type="number"
-																	  pattern="#,##0.00"/></td>
-							<td colspan="4"><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}"
-												  type="number" pattern="#,##0.00"/></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="2">单价</th>
+							<th colspan="3">机构税率 / 单税费 / 总税费</th>
+							<th colspan="2">总价</th>
+							<th>利润(单)</th>
+							<th>利润(总)</th>
+							<th>平台服务费(单)</th>
+							<th colspan="3">供应商税率 / 单税费 / 总税费</th>
+							<th>成本(单 + 税)</th>
+							<th>成本(总)</th>
 						</tr>
-					</c:forEach>
-			</table>
-			</c:forEach>
+						<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><fmt:formatNumber
+										value="${p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice}"
+										pattern="#,##0.00"/></td>
+
+								<td class="payCm"><fmt:formatNumber
+										value="${(p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice) * (p.num + p.presentNum - p.returnedNum)}"
+										pattern="#,##0.00"/></td>
+								<td><fmt:formatNumber value="${p.cmCostPrice}" 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>
+				</c:forEach>
 		</div>
 		<div class="payment-form-bottom">
 			<div>

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

@@ -268,7 +268,7 @@
 							</c:if>
 						</c:if></td>
 					<td colspan="3" class="taxes"><fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/></td>
-					<td class="supplier-fee"><font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></font></td>
+					<td class="supplier-fee"><font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font></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}">

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

@@ -234,8 +234,8 @@
                     <th colspan="3">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th>总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>

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

@@ -76,7 +76,7 @@
 <body>
 <ul class="nav nav-tabs">
 	<li><a href="${ctx}/order/cmRefundShop/">退款列表</a></li>
-	<li class="active"><a href="${ctx}/order/cmRefundShop/form">提交退款</a></li>
+	<li class="active"><a href="${ctx}/order/cmRefundShop/toRefund?&shopOrderIDs=${cmRefundShop.shopOrderIDs}">提交退款</a></li>
 </ul><br/>
 <div class="refund-form">
 	<div class="refund-form-top">
@@ -219,7 +219,7 @@
 							<c:if test="${s.payStatus == 3}"><font color="green">已付款</font></c:if>
 						</td>
 						<td colspan="3" class="supplier-fee">
-							<div>应付:${s.shouldPayShopAmount}, 已付:${s.payedShopAmount}
+							<div>应付:${s.shouldPayShopAmount-s.shopOtherFee}, 已付:${s.payedShopAmount}
 								<c:if test="${s.wipePayment > 0}"><font color="red">(付款抹平¥${s.wipePayment})</font></c:if>
 							</div>
 							<div>已退:${s.refundsAmount}<%--, 待退:<span class="need-refund"><fmt:formatNumber value="${s.payedShopAmount-s.refundsAmount-s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></span>--%></div>
@@ -241,8 +241,8 @@
 						<th colspan="3">单价</th>
 						<th colspan="3">机构税率 / 单税费 / 总税费</th>
 						<th>总价</th>
-						<th>佣金(单)</th>
-						<th>佣金(总)</th>
+						<th>利润(单)</th>
+						<th>利润(总)</th>
 						<th colspan="3">供应商税率 / 单税费 / 总税费</th>
 						<th>成本(单)</th>
 						<th>成本(总)</th>
@@ -316,8 +316,8 @@
 					欠款账簿
 					<input type="number" name="refundBalanceAmount" id="refundBalanceAmount" class="refund-amount" value="0">
 					<br>
-					虚拟银行
-					<input type="number" name="refundAmount" id="refundAmount" class="refund-amount" value="0">
+					<%--虚拟银行--%>
+					<input type="hidden" name="refundAmount" id="refundAmount" class="refund-amount" value="0">
 				</div>
 				<%--<div class="refund-wrapper">
                     <select name="refundType" id="">

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

@@ -560,8 +560,8 @@
                         <th colspan="3">单价</th>
                         <th colspan="3">机构税率 / 单税费 / 总税费</th>
                         <th>总价</th>
-                        <th>佣金(单)</th>
-                        <th>佣金(总)</th>
+                        <th>利润(单)</th>
+                        <th>利润(总)</th>
                         <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                         <th>成本(单)</th>
                         <th>成本(总)</th>

+ 24 - 22
src/main/webapp/WEB-INF/views/modules/order/cmSettlementList.jsp

@@ -292,9 +292,10 @@
 </head>
 <body>
 <ul class="nav nav-tabs">
-    <li><a href="${ctx}/order/cmPayShop">付款列表</a></li>
+    <%--<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>
+    <li><a href="${ctx}/shopOrder/payOrderList?operatingMode=3">已付款子订单</a></li>--%>
+    <li><a href="${ctx}/shopOrder/payThirdParties">申请付第三方</a></li>
     <shiro:hasPermission name="order:cmPayShop:split">
         <li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
     </shiro:hasPermission>
@@ -324,13 +325,13 @@
         <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>
+<%--            <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>
@@ -446,13 +447,13 @@
                                                                     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>
+                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font>
                         </c:if>
                         <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
                         </c:if>
                         <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                         </c:if>
                     </td>
                     <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">
@@ -535,9 +536,9 @@
                     </tr>
                 </c:forEach>
             </table>
-            <div class="pay-more-func">
-                <a href="${ctx}/shopOrder/settleRecord?shopOrderID=${s.shopOrderID}">结算记录</a>
-            </div>
+<%--            <div class="pay-more-func">--%>
+<%--                <a href="${ctx}/shopOrder/settleRecord?shopOrderID=${s.shopOrderID}">结算记录</a>--%>
+<%--            </div>--%>
         </div>
     </c:forEach>
 </div>
@@ -824,21 +825,21 @@
             var checked = $('.pay-wrapper input[type=checkbox]:checked'), params = '?';
             for (var i = 0; i < checked.length; i++) {
                 shopOrderId = $(checked[i]).attr('data-shoporderid');
-                params += ('&shopOrderIDs=' + shopOrderId);
+                params += ('&shopOrderIds=' + shopOrderId);
             }
             if (checked.length < 1 || params == '?') {
                 alertx('请至少选择一个订单');
                 return false;
             }
-            if (checked.length > 1) {
-                alertx('每次只能选择一个子订单进行结算申请');
-                return false;
-            }
+            // if (checked.length > 1) {
+            //     alertx('每次只能选择一个子订单进行结算申请');
+            //     return false;
+            // }
             var flag=0;
             debugger;
             $.ajax({
                 url: "${ctx}/order/cmPayShop/settleTime",
-                data: {"shopOrderId":shopOrderId},
+                data: {"shopOrderIds":shopOrderId},
                 type: "POST",
                 async: false,
                 success: function(data){
@@ -849,7 +850,8 @@
                 alertx('该子订单暂未到结算时间,请于T+1后的工作日再申请结算(T指子订单分账时间)');
                 return false;
             }
-            window.location.href = '${ctx}/order/cmPayShop/settleEdit' + params;
+            window.location.href = '${ctx}/order/cmPayShop/settlement'+ params;
+            <%--window.location.href = '${ctx}/order/cmPayShop/settleEdit' + params;--%>
         });
 
         //付第三方

+ 36 - 50
src/main/webapp/WEB-INF/views/modules/order/cmSplitAccountList.jsp

@@ -292,9 +292,10 @@
 </head>
 <body>
 <ul class="nav nav-tabs">
-     <li><a href="${ctx}/order/cmPayShop">付款列表</a></li>
+     <%--<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>
+     <li><a href="${ctx}/shopOrder/payOrderList?operatingMode=3">已付款子订单</a></li>--%>
+     <li><a href="${ctx}/shopOrder/payThirdParties">申请付第三方</a></li>
      <shiro:hasPermission name="order:cmPayShop:split">
          <li class="active tab-li"><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
      </shiro:hasPermission>
@@ -419,13 +420,13 @@
                                                                     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>
+                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font>
                         </c:if>
                         <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
                         </c:if>
                         <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                         </c:if>
                     </td>
                     <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">
@@ -506,27 +507,12 @@
                         <td><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}"
                                               type="number" pattern="#,##0.00"/></td>
                     </tr>
+                    <div class="pay-more-func">
+                        <a id="applyShopOtherFee" href="${ctx}/order/cmPayShop/shopOtherFeeForm?shopOrderId=${s.shopOrderID}&payType=2">付第三方申请</a>
+                    </div>
                 </c:forEach>
             </table>
-<%--            <div class="pay-more-func">--%>
-<%--                <c:if test="${s.paying ne '1' and s.payStatus eq '1' and !s.modifyPayable}">--%>
-<%--                    <shiro:hasPermission name="order:cmPayShop:modifyPay">--%>
-<%--                        <a href="${ctx}/shopOrder/toChangePayShopAmount?shopOrderID=${s.shopOrderID}">修改成本</a>--%>
-<%--                    </shiro:hasPermission>--%>
-<%--                </c:if>--%>
-<%--                <c:if test="${(s.modifyPayable and s.paying ne '1') || s.payStatus eq '2'}">--%>
-<%--                    <a href="${ctx}/order/cmPayShop/differencePriceForm?shopOrderId=${s.shopOrderID}">供应商差价</a>--%>
-<%--                </c:if>--%>
-<%--                <c:if test="${s.paying ne '1' and s.payStatus eq '2'}">--%>
-<%--                    <c:if test="${!s.modifyPayable || s.receiptStatus eq '3'}">--%>
-<%--                        <shiro:hasPermission name="order:cmPayShop:modifyPay">--%>
-<%--                            <a href="${ctx}/shopOrder/toApplyPayWipe?shopOrderID=${s.shopOrderID}">付款抹平</a>--%>
-<%--                        </shiro:hasPermission>--%>
-<%--                    </c:if>--%>
-<%--                </c:if>--%>
-<%--                <a href="${ctx}/shopOrder/payShopRemark?shopOrderId=${s.shopOrderID}">应付备注</a>--%>
-<%--                <a href="${ctx}/shopOrder/payedAndRefundRecordList?shopOrderID=${s.shopOrderID}&operatingMode=${operatingMode}">退/付款记录</a>--%>
-<%--            </div>--%>
+
         </div>
     </c:forEach>
 </div>
@@ -616,12 +602,12 @@
 <script>
     function changeCheck(el){
         var checked = $('input[type=checkbox]:checked');
-        if (checked.length > 1) {
-            // $(".checkShop").attr('disabled','true');
-            alertx("请最多选择一个子订单进行分账");
-            $(el).prop('checked',false);
-            return false;
-        }
+        // if (checked.length > 1) {
+        //     // $(".checkShop").attr('disabled','true');
+        //     alertx("请最多选择一个子订单进行分账");
+        //     $(el).prop('checked',false);
+        //     return false;
+        // }
     }
 
     (function () {
@@ -837,26 +823,26 @@
 
         });
 
-        //付第三方
-        $('#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;
-        });
+        <%--//付第三方--%>
+        <%--$('#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 = '?';

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

@@ -502,7 +502,7 @@
     }
 
     function showInfo() {
-        debugger
+        // debugger
         var type = $("input[name='type']:checked").val();
         var ShopReceiptStatus=$('#ShopReceiptStatus').val();
         console.log(ShopReceiptStatus)

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

@@ -80,6 +80,14 @@
                 <label>订单号:</label>
                 <form:input path="orderNo" htmlEscape="false" maxlength="30" class="input-medium"/>
             </div>
+            <div class="item">
+                <label>子订单ID:</label>
+                <form:input path="shopOrderID" id="shipOrderID" htmlEscape="false" maxlength="30" class="input-medium"/>
+            </div>
+            <div class="item">
+                <label>子订单号:</label>
+                <form:input path="shopOrderNo" htmlEscape="false" maxlength="30" class="input-medium"/>
+            </div>
             <div class="item">
                 <label>机构:</label>
                 <form:input path="buyer" maxlength="20" class="input-medium"/>
@@ -221,8 +229,8 @@
 <fmt:formatDate value="<%=new Date()%>" var="monthFirst" pattern="yyyy-MM-01"/>
 <div class="data-title">
     <ul>
-        <li>订单ID</li>
-        <li>订单编号</li>
+        <li style="width: 190px; ">订单ID(订单编号)</li>
+        <li style="width: 195px; ">子订单ID(子订单编号)</li>
         <li>订单类型</li>
         <li>返佣订单</li>
 <%--        <li>二手订单</li>--%>
@@ -244,9 +252,8 @@
     <c:forEach items="${page.list}" var="order">
         <%--颜色区分分期不分期订单以及终止订单--%>
         <ul class="spileOrder" data-id="${order.orderNo}">
-            <li>${order.orderID}</li>
-            <li style="position: relative">${order.orderNo}
-            </li>
+            <li><b style="font-size: 17px;">${order.orderID}</b>(${order.orderNo})</li>
+            <li style="position: relative">${order.shopOrderNoAndId}</li>
             <li>
                 <c:if test="${order.orderType == 1}">
                     自主订单

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

@@ -405,34 +405,34 @@
 <table class="order-details-heading">
     <tr>
         <td>下单时间: ${order.orderTime}</td>
-        <td>订单号(ID): ${order.orderNo}(${order.orderID})</td>
+        <td>订单ID(订单编号): <b style="font-size: 17px;">${order.orderID}</b>(${order.orderNo})</td>
         <td>返佣订单: ${(order.rebateOrder ne '0' || order.rebateFlag eq '1')?'是':'否'}</td>
     </tr>
     <tr>
         <td>订单类型: <c:if test="${order.orderType == 1}">自主订单</c:if><c:if test="${order.orderType == 0}">协销订单</c:if></td>
         <td>订单来源: ${fns:getDictLabel(order.orderSource,"bp_orderSource","" )}</td>
-        <td>订单状态:
-            <c:if test="${order.status eq 11 || order.status eq 12 || order.status eq 13 ||order.status eq 21 ||order.status eq 22 ||
-				order.status eq 23 || order.status eq 31 ||order.status eq 32 ||order.status eq 33}">
-                交易中
-            </c:if>
-            <c:if test="${order.status eq 0 || order.status eq 4 || order.status eq 5 || order.status eq 6 || order.status eq 7}">
-                ${fns:getDictLabel(order.status,"order_status","" )}
-                <c:if test="${order.status eq 0}">
-                    <span id="time" style="color: red"></span>
-                </c:if>
-                <c:if test="${order.status eq 6}">
-                    <font color="red">(
-                            <c:if test="${order.closeTime ne null}">
-                                ${order.closeTime}
-                            </c:if>
-                            <c:if test="${order.closeReason ne null}">
-                                , ${order.closeReason}
-                            </c:if>
-                    )</font>
-                </c:if>
-            </c:if>
-        </td>
+<%--        <td>订单状态:--%>
+<%--            <c:if test="${order.status eq 11 || order.status eq 12 || order.status eq 13 ||order.status eq 21 ||order.status eq 22 ||--%>
+<%--				order.status eq 23 || order.status eq 31 ||order.status eq 32 ||order.status eq 33}">--%>
+<%--                交易中--%>
+<%--            </c:if>--%>
+<%--            <c:if test="${order.status eq 0 || order.status eq 4 || order.status eq 5 || order.status eq 6 || order.status eq 7}">--%>
+<%--                ${fns:getDictLabel(order.status,"order_status","" )}--%>
+<%--                <c:if test="${order.status eq 0}">--%>
+<%--                    <span id="time" style="color: red"></span>--%>
+<%--                </c:if>--%>
+<%--                <c:if test="${order.status eq 6}">--%>
+<%--                    <font color="red">(--%>
+<%--                            <c:if test="${order.closeTime ne null}">--%>
+<%--                                ${order.closeTime}--%>
+<%--                            </c:if>--%>
+<%--                            <c:if test="${order.closeReason ne null}">--%>
+<%--                                , ${order.closeReason}--%>
+<%--                            </c:if>--%>
+<%--                    )</font>--%>
+<%--                </c:if>--%>
+<%--            </c:if>--%>
+<%--        </td>--%>
     </tr>
     <tr>
         <c:if test="${order.status ne 0}">
@@ -827,7 +827,7 @@
 <c:forEach items="${order.newShopOrders}" var="shopOrder">
     <div class="order-rows">
         <span><label>下单时间:</label>${order.orderTime}</span>
-        <span><label>子订单号(ID):</label>${shopOrder.shopOrderNo}(${shopOrder.shopOrderID})</span>
+        <span><label>子订单ID(子订单编号):</label><b style="font-size: 17px;">${shopOrder.shopOrderID}</b>(${shopOrder.shopOrderNo})</span>
         <span><label>子订单金额:</label><fmt:formatNumber
                 value="${order.onlinePayFlag eq 0?shopOrder.realPay:shopOrder.needPayAmount}" type="currency"/></span>
         <td style="position: relative;"><a class="operation-btn btn"

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

@@ -249,13 +249,13 @@
 </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}/order/cmPayShop">付款列表</a></li>
+    <li><a href="${ctx}/shopOrder/payOrderList?operatingMode=1">申请付款</a></li>--%>
     <li class="active tab-li"><a href="${ctx}/shopOrder/payOrderList?operatingMode=3">已付款子订单</a></li>
-    <shiro:hasPermission name="order:cmPayShop:split">
+    <%--<shiro:hasPermission name="order:cmPayShop:split">
     <li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
     </shiro:hasPermission>
-    <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
+    <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>--%>
 </ul>
 <form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newShopOrder"
            action="${ctx}/shopOrder/payOrderList?operatingMode=${operatingMode
@@ -409,14 +409,14 @@
                                                                     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"
+                        <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number"
                                                                 pattern="#,##0.00"/></font>
                         </c:if>
                         <c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
                         </c:if>
                         <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                         </c:if>
                     </td>
                     <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">

+ 594 - 0
src/main/webapp/WEB-INF/views/modules/order/payThirdParties.jsp

@@ -0,0 +1,594 @@
+<%@ 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: 120px;
+            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
+        }
+
+        .tips-input-wrapper {
+            width: 100px
+        }
+
+        .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 class="active tab-li"><a href="${ctx}/shopOrder/payThirdParties">申请付第三方</a></li>
+    <shiro:hasPermission name="order:cmPayShop:split">
+        <li><a href="${ctx}/shopOrder/splitList">子订单手动分账</a></li>
+    </shiro:hasPermission>
+    <li><a href="${ctx}/shopOrder/settlement">子订单手动结算</a></li>
+</ul>
+<form:form id="searchForm" onsubmit="submitFunc()" modelAttribute="newShopOrder"
+           action="${ctx}/shopOrder/payOrderList?operatingMode=${operatingMode
+}" method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <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">
+            <label>组织:</label>
+            <form:select path="organizeID" class="input-medium">
+                <form:option value="" label="请选择"/>
+                <form:option value="0" label="采美"/>
+                <form:option value="9999" label="呵呵商城"/>
+                <c:forEach items="${cmUserOrganizeList}" var="organize">
+                    <c:if test="${organize.id!=4}">
+                        <form:option value="${organize.id}" label="${organize.organizeName}"/>
+                    </c:if>
+                </c:forEach>
+            </form:select>
+            <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="applyShopOtherFee" 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" ${s.status eq 7 ?'disabled':''} 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 colspan="2"><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}"><em class="weishaIcon">维沙</em></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.payStatus == 1 || empty s.payStatus || s.payStatus == 0}"><font
+                            color="red">待付款</font></c:if>
+                        <c:if test="${s.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
+                        <c:if test="${s.payStatus == 3}"><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"><fmt:formatNumber value="${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"><fmt:formatNumber value="${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/payShopRemark?shopOrderId=${s.shopOrderID}">应付备注</a>
+                <a href="${ctx}/shopOrder/payedAndRefundRecordList?shopOrderID=${s.shopOrderID}&operatingMode=${operatingMode}">退/付款记录</a>
+            </div>
+        </div>
+    </c:forEach>
+</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);
+        });
+
+        $('.tab-li').on('click', function () {
+            if (getCheckedArr) {
+                sessionStorage.removeItem('checkedIndexArr');
+            }
+        });
+
+        //付第三方
+        $('#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+'&payType=2';
+        });
+
+        //供应商差价申请
+        $('#applyDifferencePrice').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 shopOrderId = $(checked[0]).attr('data-shoporderid');
+            window.location.href = '${ctx}/order/cmPayShop/differencePriceForm?shopOrderId=' + shopOrderId;
+        });
+
+    })();
+
+    /**
+     * @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>

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

@@ -88,13 +88,14 @@
 <body>
 <ul class="nav nav-tabs">
     <li><a href="${ctx}/shopOrder/checkPaymentOrder">订单财务信息</a></li>
-    <li class="active tab-li"><a href="${ctx}/shopOrder/refundRecord?orderID=${order.orderID}">供应商退/付款记录</a></li>
+    <li class="active tab-li"><a href="${ctx}/shopOrder/refundRecord?shopOrderId=${shopOrder.shopOrderID}">供应商退/付款记录</a></li>
 </ul>
 <sys:message content="${message}"/>
 <div class="pay-wrapper">
     <div class="pay-list-item">
         <table class="table table-striped table-bordered table-condensed pay-table">
             <tr class="t1">
+                <th colspan="2">子订单编号(ID)</th>
                 <th colspan="2">母订单编号(ID)</th>
                 <th>下单时间</th>
                 <th>订单金额</th>
@@ -105,208 +106,224 @@
                 <th>付款状态</th>
                 <th>应付金额</th>
                 <th>已付金额</th>
+                <th>结算状态</th>
+                <th>应结金额</th>
+                <th>已结金额</th>
                 <th>退款状态</th>
                 <th>退款金额</th>
-                <th colspan="2">机构</th>
                 <th>优惠券</th>
                 <th>经理折扣</th>
-                <th>机构运费</th>
-                <th>是否返佣</th>
             </tr>
             <tr>
-                <td colspan="2">${order.orderNo}(${order.orderID})</td>
-                <td>${order.orderTime}</td>
-                <td><fmt:formatNumber value="${order.payTotalFee}" type="number" pattern="#,##0.00"/></td>
+                <td colspan="2">${shopOrder.shopOrderNo}(${shopOrder.shopOrderID})</td>
+                <td colspan="2">${shopOrder.orderNo}(${shopOrder.orderID})</td>
+                <td>${shopOrder.orderTime}</td>
+                <td><fmt:formatNumber value="${shopOrder.totalAmount}" type="number" pattern="#,##0.00"/></td>
                 <td>
-                    <c:if test="${order.status eq 11 || order.status eq 12 || order.status eq 13 ||order.status eq 21 ||order.status eq 22 ||
-                    order.status eq 23 || order.status eq 31 ||order.status eq 32 ||order.status eq 33}">交易中<br>(${fns:getDictLabel(order.status,"order_detail_status","" )})</c:if>
-                    <c:if test="${order.status eq 0 || order.status eq 4 || order.status eq 5 || order.status eq 6 || order.status eq 7}">${fns:getDictLabel(order.status,"order_detail_status","" )}</c:if>
+                    <c:if test="${shopOrder.status == 0}"><font color="red">待确认</font></c:if>
+                    <c:if test="${shopOrder.status == 1}"><font color="#ff8c00">已确认</font></c:if>
+                    <c:if test="${shopOrder.status == 2}"><font color="#ff8c00">交易完成</font></c:if>
+                    <c:if test="${shopOrder.status == 3}"><font color="green">订单完成</font></c:if>
+                    <c:if test="${shopOrder.status == 4}"><font color="green">已关闭</font></c:if>
+                    <c:if test="${shopOrder.status == 5}"><font color="green">交易全退</font></c:if>
                 </td>
                 <td>
-                    <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${order.orderID}&from=1"  style="text-decoration: underline">
-                        <c:if test="${order.receiptStatus == 1}">
-                            <font color="red">待收款</font>
-                        </c:if>
-                        <c:if test="${order.receiptStatus == 2}">
-                            <font color="#ff8c00">部分收款</font>
-                        </c:if>
-                        <c:if test="${order.receiptStatus == 3}">
-                            <font color="green">已收款</font>
-                        </c:if>
-                        <c:if test="${order.receiptStatus == 4}">
-                            ----
-                        </c:if>
-                    </a>
+                    <c:if test="${shopOrder.shopReceiptStatus == 1}"><font color="red">待收款</font></c:if>
+                    <c:if test="${shopOrder.shopReceiptStatus == 2}"><font color="#ff8c00">部分收款</font></c:if>
+                    <c:if test="${shopOrder.shopReceiptStatus == 3}"><font color="green">已收款</font></c:if>
                 </td>
                 <td>
-                    <fmt:formatNumber value="${order.payableAmount}" type="number" pattern="#,##0.00"/>
-                    (余额抵扣:<fmt:formatNumber value="${order.balancePayFee}" type="number" pattern="#,##0.00"/>)
+                    <fmt:formatNumber value="${shopOrder.needPayAmount}" type="number" pattern="#,##0.00"/>
+                    (余额抵扣:<fmt:formatNumber value="${shopOrder.accountAmount}" type="number" pattern="#,##0.00"/>)
                 </td>
                 <td>
-                    <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${order.orderID}&from=1"  style="text-decoration: underline">
-                        <c:if test="${order.alreadyReceipt eq '----'}">
-                            ${order.alreadyReceipt}
-                        </c:if>
-                        <c:if test="${order.alreadyReceipt ne '----'}">
-                            <fmt:formatNumber value="${order.alreadyReceipt}" type="number" pattern="#,##0.00"/>
-                        </c:if>
-                    </a>
+                    ${shopOrder.receiptAmount}
                 </td>
                 <td>
-                    <c:if test="${order.payStatus == 1 || empty order.payStatus || order.payStatus == 0}"><font
+                    <c:if test="${shopOrder.payStatus == 1 || empty shopOrder.payStatus || shopOrder.payStatus == 0}"><font
                             color="red">待付款</font></c:if>
-                    <c:if test="${order.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
-                    <c:if test="${order.payStatus == 3}"><font color="green">已付款</font>
-                        <c:if test="${order.zeroCostFlag eq 1}">
-                            <a href="javascript:;" class="zeroCost"><span><img src="/static/images/info.jpg" style="width: 15px;margin-bottom: 4px"></span>
+                    <c:if test="${shopOrder.payStatus == 2}"><font color="#ff8c00">部分付款</font></c:if>
+                    <c:if test="${shopOrder.payStatus == 3}"><font color="green">已付款</font>
+                        <c:if test="${shopOrder.zeroCostFlag eq 1}">
+                            <a href="javascript: void(0);" class="zeroCost"><span><img src="/static/images/info.jpg"
+                                                                                       style="width: 15px;margin-bottom: 4px"></span>
                                 <div class="message">
                                     <span>商品成本为0,直接置为已付款,无需付款供应商</span>
                                 </div>
                             </a>
                         </c:if>
                     </c:if>
-                    <c:if test="${order.payStatus == 4}">----</c:if>
+                    <c:if test="${shopOrder.payStatus == 4}">----</c:if>
                 </td>
-                <td><fmt:formatNumber value="${order.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></td>
+                <td><fmt:formatNumber value="${shopOrder.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></td>
                 <td>
-                    <c:if test="${order.paid eq '----'}">
-                        ${order.alreadyReceipt}
-                    </c:if>
-                    <c:if test="${order.paid ne '----'}">
-                        <fmt:formatNumber value="${order.paid}" type="number" pattern="#,##0.00"/>
-                    </c:if>
+                    <fmt:formatNumber value="${shopOrder.payShopAmount}" type="number" pattern="#,##0.00"/>
                 </td>
                 <td>
-                    <c:if test="${order.refundType == 1}">
-                          <font color="#ff8c00">部分退款</font>
-                    </c:if>
-                    <c:if test="${order.refundType == 2}">
-                         <font color="green">已退款</font>
+                    <c:if test="${shopOrder.settleStatus == 1}"><font color="#ff8c00">未结算</font></c:if>
+                    <c:if test="${shopOrder.settleStatus  == 2}"><font color="green">部分结算</font></c:if>
+                    <c:if test="${shopOrder.settleStatus == 3}"><font color="red">已结算</font></c:if>
+                </td>
+                <td>
+                    <fmt:formatNumber value="${shopOrder.shouldPayShopAmount}" type="number" pattern="#,##0.00"/>
+                </td>
+                <td>
+                    <fmt:formatNumber value="${shopOrder.settleAmount}" type="number" pattern="#,##0.00"/>
+                </td>
+                <td>
+                    <c:if test="${shopOrder.refundStatus == 1}">
+                        <font>无退款</font>
                     </c:if>
-                    <c:if test="${order.refundType != 1 && order.refundType != 2}">
-                         <font color="red">无退款</font>
+                    <c:if test="${shopOrder.refundStatus == 3}">
+                        <font>有退款</font>
                     </c:if>
                 </td>
-                <td><fmt:formatNumber value="${order.returnValue}" type="number" pattern="#,##0.00"/></td>
-                <td colspan="2">
-                    <c:if test="${order.organizeID == '1'}">
-                        <span class="org-note">星范</span>
-                    </c:if>
-                        ${order.buyer}<c:if test="${order.organizeID == 3}"></c:if>
+                <td><fmt:formatNumber value="${shopOrder.canRefundAmount}" type="number" pattern="#,##0.00"/></td>
+                <td>
+                    <fmt:formatNumber value="${shopOrder.couponAmount}" type="number" pattern="#,##0.00"/>
                 </td>
+                <td><fmt:formatNumber value="${shopOrder.discountFee}" type="number" pattern="#,##0.00"/></td>
+            </tr>
+            <tr class="t2">
+                <th colspan="3">机构</th>
+                <th colspan="3">供应商</th>
+                <th colspan="2">商品费</th>
+                <th colspan="2">已付供应商</th>
+                <th>供应商退款</th>
+                <th colspan="2">应付供应商</th>
+                <th colspan="2">应付税费</th>
+                <th>机构运费</th>
+                <th>供应商运费</th>
+                <th colspan="2">付第三方</th>
+                <th colspan="2">成本类型</th>
+            </tr>
+            <tr class="t2">
+                <td colspan="3">
+                    <c:if test="${shopOrder.organizeID eq 1}"><span class="org-note">星范</span></c:if>
+                    ${shopOrder.clubName}
+                    <c:if test="${shopOrder.orderType eq 2}"><font color="red">(呵呵商城)</font></c:if>
+                    <c:if test="${shopOrder.organizeID == 4}"><font color="red">(丽格集采联盟)</font></c:if>
+                </td>
+                <td colspan="3">${shopOrder.shopName}</td>
+                <td colspan="2" class="product-fee"><fmt:formatNumber value="${shopOrder.shopProductAmount}"
+                                                                      type="number" pattern="#,##0.00"/></td>
+                <td colspan="2"><fmt:formatNumber value="${shopOrder.payedShopAmount}" type="number"
+                                                  pattern="#,##0.00"/></td>
                 <td>
-                    ${order.couponAmount}
+                    <fmt:formatNumber value="${shopOrder.refundAmount}" type="number" pattern="#,##0.00"/>
                 </td>
-                <td><fmt:formatNumber value="${order.discountFee}" type="number" pattern="#,##0.00"/></td>
+                <td colspan="2">
+                    <c:if test="${shopOrder.differenceType ne 1 && shopOrder.differenceType ne 2 }">
+                        <font color="#E15616"><fmt:formatNumber value="${shopOrder.shouldPayShopAmount}" type="number"
+                                                                pattern="#,##0.00"/></font>
+                    </c:if>
+                    <%--1少付2多付--%>
+                    <c:if test="${shopOrder.differenceType eq 1 && shopOrder.differencePrice > 0}">
+                        <font color="black"><fmt:formatNumber value="${shopOrder.shouldPayShopAmount+shopOrder.differencePrice}"/></font><font color="red">(原应付:${shopOrder.shouldPayShopAmount},已补差价:${shopOrder.differencePrice})</font>
+                    </c:if>
+                    <c:if test="${shopOrder.differenceType eq 2 && shopOrder.differencePrice > 0}">
+                        <font color="black"><fmt:formatNumber value="${shopOrder.shouldPayShopAmount-shopOrder.differencePrice}"/></font><font color="red">(原应付:${shopOrder.shouldPayShopAmount},已退差价:${shopOrder.differencePrice})</font>
+                    </c:if>
+
+                </td>
+                <td colspan="2"><fmt:formatNumber value="${shopOrder.shopTaxFee}" type="number"
+                                                  pattern="#,##0.00"/></td>
                 <td>
-                    <c:if test="${order.freight == 0}">
+                    <c:if test="${shopOrder.shopPostFlag == 0}">
                         包邮
                     </c:if>
-                    <c:if test="${order.freight == -1}">
+                    <c:if test="${shopOrder.shopPostFlag == 2}">
                         到付
                     </c:if>
-                    <c:if test="${order.freight == -2}">
+                    <c:if test="${shopOrder.shopPostFlag == -2}">
                         仪器到付-产品包邮
                     </c:if>
-                    <c:if test="${order.freight != -1 && order.freight != 0 && order.freight != -2}">
-                        <fmt:formatNumber value="${order.freight}" type="currency"/>
-                        <c:if test="${order.returnedFreightFlag eq true}"><font color="red">(已退)</font></c:if>
+                    <c:if test="${shopOrder.shopPostFlag != 2 && shopOrder.shopPostFlag != 0 && shopOrder.shopPostFlag != -2}">
+                        <fmt:formatNumber value="${shopOrder.shopPostFee}" type="number" pattern="#,##0.00"/>
+                        <c:if test="${shopOrder.returnedFreightFlag eq true}"><font color="red">(已退)</font></c:if>
+                    </c:if>
+                    <c:if test="${shopOrder.userBeans > 0}">
+                        <br><font color="red">(采美豆抵用:${shopOrder.userBeans})</font>
                     </c:if>
                 </td>
-                <td>
-                    <c:if test="${order.rebateOrder == '1'}">是</c:if>
-                    <c:if test="${order.rebateOrder == '0'}">否</c:if>
-                </td>
+                <td class="product-freight"><fmt:formatNumber value="${shopOrder.shopPostFee}" type="number"
+                                                              pattern="#,##0.00"/></td>
+                <td colspan="2"><fmt:formatNumber value="${shopOrder.shopOtherFee}" type="number" pattern="#,##0.00"/></td>
+                <td colspan="2"><c:if test="${empty shopOrder.costType || shopOrder.costType == '1'}">固定成本</c:if><c:if
+                        test="${shopOrdercostType == '2'}">比例成本</c:if></td>
             </tr>
-            <c:forEach items="${order.newShopOrders}" var="so" varStatus="soIndex">
-                <tr class="t2">
-                    <th colspan="3">子订单编号(ID)</th>
-                    <th colspan="3">供应商</th>
-                    <th colspan="2">商品费</th>
-                    <th colspan="2">已付供应商</th>
-                    <th>供应商退款</th>
-                    <th colspan="2">应付供应商</th>
-                    <th colspan="3">应付税费</th>
-                    <th>供应商运费</th>
-                    <th>付第三方</th>
-                    <th>成本类型</th>
-                </tr>
-                <tr class="t2">
-                    <td colspan="3">${so.shopOrderNo}(${so.shopOrderID})</td>
-                    <td colspan="3">${so.shopName}</td>
-                    <td colspan="2" class="product-fee"><fmt:formatNumber value="${so.shopProductAmount}" type="number" pattern="#,##0.00"/></td>
-                    <td colspan="2"><fmt:formatNumber value="${so.payedShopAmount}" type="number" pattern="#,##0.00"/></td>
-                    <td>
-                        <c:if test="${so.refundAmount > 0}">
-                            <fmt:formatNumber value="${so.refundAmount}" type="number" pattern="#,##0.00"/>
-                        </c:if>
-                    </td>
-                    <td colspan="2"><fmt:formatNumber value="${so.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></td>
-                    <td colspan="3"><fmt:formatNumber value="${so.shopTaxFee}" type="number" pattern="#,##0.00"/></td>
-                    <td class="product-freight"><fmt:formatNumber value="${so.shopPostFee}" type="number" pattern="#,##0.00"/></td>
-                    <td><fmt:formatNumber value="${so.shopOtherFee}" type="number" pattern="#,##0.00"/></td>
-                    <td><c:if test="${empty so.costType || so.costType == '1'}">固定成本</c:if><c:if test="${so.costType == '2'}">比例成本</c:if></td>
-                </tr>
-                <tr>
-                    <th colspan="3">商品名</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 colspan="2">成本(总)</th>
-                </tr>
-                <c:forEach items="${so.newOrderProducts}" var="p" varStatus="pIndex">
-                    <tr class="pay-product-item">
-                        <td colspan="3" class="product-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>
+            <tr>
+                <th colspan="3">商品名</th>
+                <th>规格</th>
+                <th>数量<%--(赠品)--%></th>
+                <th>退货</th>
+                <th colspan="2">单价</th>
+                <th colspan="3">机构税率 / 单税费 / 总税费</th>
+                <th colspan="2">总价</th>
+                <th colspan="3">供应商税率 / 单税费 / 总税费</th>
+                <th colspan="2">成本(单)</th>
+                <th colspan="2">成本(总)</th>
+            </tr>
+            <c:forEach items="${shopOrder.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" colspan="3">
+                        <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}">
+                    </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: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"/>
+                                <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: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"/>
+                                <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><fmt:formatNumber value="${p.costPrice}" type="number" pattern="#,##0.00"/></td>
-                        <td colspan="2"><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}" type="number" pattern="#,##0.00"/></td>
-                    </tr>
-                </c:forEach>
+                        </c:choose>
+                    </td>
+                    <td class="p-costprice" colspan="2"><fmt:formatNumber value="${p.costPrice}" type="number"
+                                                                          pattern="#,##0.00"/></td>
+                    <td colspan="2"><fmt:formatNumber value="${p.costPrice * (p.num + p.presentNum - p.returnedNum)}"
+                                                      type="number" pattern="#,##0.00"/></td>
+                </tr>
             </c:forEach>
         </table>
-
     </div>
     <span style="font-weight:bold">付款记录</span>
     <table id="contentTable" class="payment" width="70%" border="1">

+ 129 - 91
src/main/webapp/WEB-INF/views/modules/order/shopOtherFeeForm.jsp

@@ -123,20 +123,25 @@
         .pay-status label:first-child {
             margin-left: 10px
         }
-        .controls{
+
+        .controls {
             font-size: 0;
         }
-        .controls .conList{
+
+        .controls .conList {
             display: inline-block;
             margin-right: 15px;
         }
-        .conList .btn:nth-of-type(1){
+
+        .conList .btn:nth-of-type(1) {
             margin-left: 25px;
         }
+
         .upload-content {
             margin-top: -70px;
             display: inline-block;
         }
+
         .upload-content .conList .btn:nth-of-type(1) {
             width: 90px;
             height: 100px;
@@ -144,19 +149,23 @@
             background: #fff;
             position: relative;
         }
-        .upload-content .conList .btn:nth-of-type(1)>div {
+
+        .upload-content .conList .btn:nth-of-type(1) > div {
             position: absolute;
             top: 50%;
             left: 50%;
             transform: translate(-50%, -50%);
             color: #666;
         }
+
         .upload-content .conList .btn:nth-of-type(1) span {
             font-size: 35px;
         }
+
         .upload-content .conList .btn:nth-of-type(1) h5 {
             color: #666;
         }
+
         .cancel-upload {
             background: transparent;
             border: none;
@@ -167,6 +176,7 @@
             cursor: pointer;
             z-index: 100;
         }
+
         .upload-content .conList ol li {
             width: 114px;
             min-height: 80px;
@@ -176,41 +186,42 @@
             top: 120px;
             margin-left: 2px;
         }
+
         .hide-pic {
             display: none !important;
         }
     </style>
     <script type="text/javascript">
-            $(document).ready(function() {
-                $("#inputForm").validate({
-                    ignore:"",
-                    submitHandler: function (form) {
-                        var shopOtherFee = $("#shopOtherFee").val();
-                        var brokerage = ${brokerage};
-                        if (brokerage < shopOtherFee) {
-                            top.$.jBox.confirm("付第三方的值不合理,导致佣金为负,确认继续吗?", '提示', function (v, h, f) {
-                                if (v == true) {
-                                    loading('正在提交,请稍等...');
-                                    form.submit();
-                                }
-                                return;
-                            }, {buttons: {'取消': false, '确定': true}});
-                        } else {
-                            loading('正在提交,请稍等...');
-                            form.submit();
-                        }
-                    },
-                    errorContainer: "#messageBox",
-                    errorPlacement: function(error, element) {
-                        $("#messageBox").text("输入有误,请先更正。");
-                        if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
-                            error.appendTo(element.parent().parent());
-                        } else {
-                            error.insertAfter(element);
-                        }
+        $(document).ready(function () {
+            $("#inputForm").validate({
+                ignore: "",
+                submitHandler: function (form) {
+                    var shopOtherFee = $("#shopOtherFee").val();
+                    var brokerage = ${brokerage};
+                    if (brokerage < shopOtherFee) {
+                        top.$.jBox.confirm("付第三方的值不合理,导致佣金为负,确认继续吗?", '提示', function (v, h, f) {
+                            if (v == true) {
+                                loading('正在提交,请稍等...');
+                                form.submit();
+                            }
+                            return;
+                        }, {buttons: {'取消': false, '确定': true}});
+                    } else {
+                        loading('正在提交,请稍等...');
+                        form.submit();
+                    }
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
                     }
-                });
+                }
             });
+        });
     </script>
 </head>
 <body>
@@ -218,10 +229,13 @@
     <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>
-    <li class="active"><a href="${ctx}/order/cmPayShop/shopOtherFeeForm?shopOrderId=${payShopOther.shopOrderId}">付第三方</a></li>
+    <li class="active"><a
+            href="${ctx}/order/cmPayShop/shopOtherFeeForm?shopOrderId=${payShopOther.shopOrderId}&payType=${payType}">付第三方</a></li>
 </ul>
-<form:form id="inputForm" modelAttribute="payShopOther" action="${ctx}/order/cmPayShop/saveShopOtherFee" method="post" class="form-horizontal">
+<form:form id="inputForm" modelAttribute="payShopOther" action="${ctx}/order/cmPayShop/saveShopOtherFee?payType=${payType}" method="post"
+           class="form-horizontal">
     <form:hidden path="shopOrderId"/>
+    <input style="display: none" name="payType" value="${payType}"/>
     <div class="control-group">
         <label class="control-label"><font color='red'>*</font>付款单名称:</label>
         <div class="controls">
@@ -231,72 +245,96 @@
     <div class="control-group">
         <label class="control-label"><font color='red'>*</font>付第三方金额:</label>
         <div class="controls">
-            <input type="number" id="shopOtherFee" required name="shopOtherFee" min="0" value="${payShopOther.shopOtherFee}" onchange="changeShouldPay(this)"/>
+            <input type="number" id="shopOtherFee" required name="shopOtherFee" min="0"
+                   value="${payShopOther.shopOtherFee}" onchange="changeShouldPay(this)"/>
         </div>
     </div>
-    <div class="control-group">
-        <label class="control-label"><font color='red'>*</font>开户名:</label>&nbsp;&nbsp;&nbsp;&nbsp;
-        <form:input path="bankAccountName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>&nbsp;&nbsp;&nbsp;&nbsp;
-        <label><font color='red'>*</font>账号:</label>
-        <form:input path="bankAccount" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
-    </div>
-    <div class="control-group">
-        <label class="control-label"><font color='red'>*</font>开户行:</label>&nbsp;&nbsp;&nbsp;&nbsp;
-        <form:input path="bankName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>&nbsp;&nbsp;&nbsp;&nbsp;
-        <label><font color='red'>*</font>账户类型:</label>
-        <form:select path="type" class="select-ele input-xlarge required">
-            <form:option value="0" label="公账"/>
-            <form:option value="1" label="私账"/>
-        </form:select>
-    </div>
+    <c:if test="${payType ne 2}">
+        <div class="control-group">
+            <label class="control-label"><font color='red'>*</font>开户名:</label>&nbsp;&nbsp;&nbsp;&nbsp;
+            <form:input path="bankAccountName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>&nbsp;&nbsp;&nbsp;&nbsp;
+            <label><font color='red'>*</font>账号:</label>
+            <form:input path="bankAccount" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
+        </div>
+        <div class="control-group">
+            <label class="control-label"><font color='red'>*</font>开户行:</label>&nbsp;&nbsp;&nbsp;&nbsp;
+            <form:input path="bankName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>&nbsp;&nbsp;&nbsp;&nbsp;
+            <label><font color='red'>*</font>账户类型:</label>
+            <form:select path="type" class="select-ele input-xlarge required">
+                <form:option value="0" label="公账"/>
+                <form:option value="1" label="私账"/>
+            </form:select>
+        </div>
+    </c:if>
     <div class="control-group">
         <label class="control-label"><font color='red'>*</font>备注内容:</label>
         <div class="controls">
-            <textarea type="text" name="remark" placeholder="请详细说明修改的原因,不超过500字" style="position: relative;height: 100px; width: 450px;" maxlength="500" required ></textarea>
+            <textarea type="text" name="remark" placeholder="请详细说明修改的原因,不超过500字"
+                      style="position: relative;height: 100px; width: 450px;" maxlength="500" required></textarea>
         </div>
     </div>
     <div class="control-group">
         <label class="control-label">图片:</label>
         <div class="controls upload-content" style="margin: -91px 0px 0px 16px;" id="remarkImageBox">
             <div class="conList">
-                <form:hidden id="remarkImage1" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage1" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage1" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage1" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList hide-pic">
-                <form:hidden id="remarkImage2" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage2" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage2" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage2" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList hide-pic">
-                <form:hidden id="remarkImage3" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage3" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage3" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage3" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList hide-pic">
-                <form:hidden id="remarkImage4" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage4" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage4" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage4" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList hide-pic">
-                <form:hidden id="remarkImage5" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage5" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage5" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage5" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList hide-pic">
-                <form:hidden id="remarkImage6" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage6" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage6" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage6" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList hide-pic">
-                <form:hidden id="remarkImage7" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage7" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage7" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage7" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList hide-pic">
-                <form:hidden id="remarkImage8" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage8" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage8" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage8" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList  hide-pic">
-                <form:hidden id="remarkImage9" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage9" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage9" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage9" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
             <div class="conList  hide-pic">
-                <form:hidden id="remarkImage10" path="remarkImages" htmlEscape="false" maxlength="255" class="input-xlarge"/>
-                <sys:ckfinder input="remarkImage10" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                <form:hidden id="remarkImage10" path="remarkImages" htmlEscape="false" maxlength="255"
+                             class="input-xlarge"/>
+                <sys:ckfinder input="remarkImage10" type="images" uploadPath="/photo" selectMultiple="false"
+                              maxWidth="100" maxHeight="100"/>
             </div>
         </div>
     </div>
@@ -315,61 +353,61 @@
         $('.upload-content .conList').find('.cancel-upload').hide();
         var observeEle = document.getElementsByClassName('upload-content')[0];
         var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
-        var MutationObserverConfig={
+        var MutationObserverConfig = {
             childList: true,
             subtree: true,
             characterData: true
         };
-        var observer = new MutationObserver(function(mutations){
-            $.each(mutations, function(index,item) {
+        var observer = new MutationObserver(function (mutations) {
+            $.each(mutations, function (index, item) {
                 if (item.type === 'childList') {
                     // 在创建新的 element 时调用
                     var target = $(item.target),
                         thisWrapper = target.closest('.conList'),
                         nextEle = thisWrapper.next();
-                    thisWrapper.find('li').css('z-index',99);
+                    thisWrapper.find('li').css('z-index', 99);
                     thisWrapper.find('.cancel-upload').show();
-                    if(nextEle.hasClass('hide-pic')) {
+                    if (nextEle.hasClass('hide-pic')) {
                         nextEle.removeClass('hide-pic');
                     }
                 }
             })
         });
-        observer.observe(observeEle,MutationObserverConfig);
+        observer.observe(observeEle, MutationObserverConfig);
 
-        $('body').on('click','.upload-content li',function() {
+        $('body').on('click', '.upload-content li', function () {
             var index = $(this).closest('.conList').index() + 1,
-                str = 'remarkImage'+index+'FinderOpen';
-            eval(str+'()');
+                str = 'remarkImage' + index + 'FinderOpen';
+            eval(str + '()');
         });
-        $('body').on('click', '.cancel-upload',function() {
+        $('body').on('click', '.cancel-upload', function () {
             var wrapper = $(this).closest('.conList');
-            wrapper.find('li').css('z-index','-1');
+            wrapper.find('li').css('z-index', '-1');
             wrapper.find('input').val('');
             $(this).hide();
             if ($('.cancel-upload:visible').length < 9) {
                 wrapper.addClass("hide-pic");
-            }else{
+            } else {
                 wrapper.removeClass("hide-pic");
             }
             wrapper.parent().append(wrapper.clone());
             wrapper.remove();
-            $(".conList").each(function(i,ele){
-                if($(ele).find("input.input-xlarge").val()){
+            $(".conList").each(function (i, ele) {
+                if ($(ele).find("input.input-xlarge").val()) {
                     $(ele).next().removeClass("hide-pic")
                 }
             })
         });
-        $(window).on("load", function(){
-            setTimeout(function(){
-                $("#remarkImageBox").find("input.input-xlarge").each(function(i,ele){
-                    if($(ele).val()){
-                        $(ele).next().find("li").css("z-index","99");
+        $(window).on("load", function () {
+            setTimeout(function () {
+                $("#remarkImageBox").find("input.input-xlarge").each(function (i, ele) {
+                    if ($(ele).val()) {
+                        $(ele).next().find("li").css("z-index", "99");
                         $(ele).parents(".conList").find(".cancel-upload").show();
                         $(ele).parents(".conList").next().removeClass("hide-pic")
                     }
                 })
-            },500);
+            }, 500);
         });
     });
 

+ 262 - 92
src/main/webapp/WEB-INF/views/modules/product-new/productEdit.jsp

@@ -314,6 +314,7 @@
            method="post" class="form-horizontal">
     <form:hidden path="id"/>
     <form:hidden path="searchName"/>
+    <form:hidden path="shopID" id="shopId" />
     <sys:message content="${message}"/>
     <table border="0" cellspacing="0" cellpadding="0" width="100%">
         <tr>
@@ -609,6 +610,7 @@
         </tr>
         <tr>
             <th><span class="red">*</span>上架平台:</th>
+
             <td>
                 <input id="caimei" type="checkbox" name="groundMall" value="0" >【采美】平台
                 <input id="bcc" type="checkbox" name="groundMall" value="4" >【丽格集采联盟】平台
@@ -618,6 +620,14 @@
             <th><span class="red">*</span>SKU种类:<br><span class="red">【采美】平台</span></th>
             <td>
                 <div><span><button class="addSku" onclick="return false">添加SKU</button></span></div>
+                <div class="sku-item sku-costCheckFlag" style="margin-top: 15px;">
+                    <span class="red">*</span>成本类型:
+                    <label><input type="radio" name="costCheckFlag" class="costCheckFlag" value="1"
+                        ${empty product.costCheckFlag || product.costCheckFlag == 1 ? "checked" : ""} />固定成本</label>
+                    <b class="line">|</b>
+                    <label><input type="radio" name="costCheckFlag" class="costCheckFlag" value="2"
+                        ${empty product.costCheckFlag || product.costCheckFlag == 2 ? "checked" : ""} />比例成本</label>
+                </div>
                     <%-- 插入html --%>
                 <div id="skus"></div>
             </td>
@@ -626,6 +636,14 @@
             <th><span class="red">*</span>SKU种类:<br><span class="red">【丽格集采联盟】平台</span></th>
             <td>
                 <div><span><button class="addMallSku" onclick="return false">添加SKU</button></span></div>
+                <div class="sku-item sku-costCheckFlag" style="margin-top: 15px;">
+                    <span class="red">*</span>成本类型:
+                    <label><input type="radio" name="mallCostCheckFlag" class="mallCostCheckFlag" value="1"
+                        ${empty product.mallCostCheckFlag || product.mallCostCheckFlag == 1 ? "checked" : ""} />固定成本</label>
+                    <b class="line">|</b>
+                    <label><input type="radio" name="mallCostCheckFlag" class="mallCostCheckFlag" value="2"
+                        ${empty product.mallCostCheckFlag || product.mallCostCheckFlag == 2 ? "checked" : ""} />比例成本</label>
+                </div>
                     <%-- 插入html --%>
                 <div id="mallSkus"></div>
             </td>
@@ -895,22 +913,24 @@
             </div>
         </div>
         <div class="sku-item-li">
-            <div class="sku-item sku-costCheckFlag">
-                <span class="red">*</span>成本:
-                <label><input type="radio" name="costCheckFlag" value="1" checked/>固定成本</label>
-                <b class="line">|</b>
-                <label><input type="radio" name="costCheckFlag" value="2"/>比例成本</label>
-            </div>
+<%--            <div class="sku-item sku-costCheckFlag">--%>
+<%--                <span class="red">*</span>成本类型--%>
+<%--                <label><input type="radio" name="costCheckFlag" value="1" checked/>固定成本</label>--%>
+<%--                <b class="line">|</b>--%>
+<%--                <label><input type="radio" name="costCheckFlag" value="2"/>比例成本</label>--%>
+<%--            </div>--%>
             <div class="sku-item sku-costPrice">
                 <span class="red">*</span>
                 <span class="costFlagText">成本价</span>:
-                <input style="width: 60px" name="costPrice" type="number" maxlength="11" class="short"/> 元
+                供应商:<input style="width: 60px" name="costPrice" type="number" maxlength="11" class="short costPrice"/>
+                集团:<input style="width: 60px" name="organizeCostPrice" type="number" maxlength="11" class="short organizeCostPrice"/>
+                采美:<input style="width: 60px" name="cmCostPrice" type="number" maxlength="11" class="short cmCostPrice"/>
             </div>
             <div class="sku-item sku-shopPercent" style="display: none;">
                 <span class="red">*</span>佣金比例:
-                供应商:<input style="width: 50px" name="shopPercent" type="number" maxlength="11" class="short"/>%
-                集团:<input style="width: 50px" name="organizePercent" type="number" maxlength="11" class="short"/>%
-                采美:<input style="width: 50px" name="cmPercent" type="number" maxlength="11" class="short"/>%
+                供应商:<input style="width: 50px" name="shopPercent" type="number" maxlength="11" class="short shopPercent"/>%
+                集团:<input style="width: 50px" name="organizePercent" type="number" maxlength="11" class="short organizePercent"/>%
+                采美:<input style="width: 50px" name="cmPercent" type="number" maxlength="11" class="short cmPercent"/>%
             </div>
         </div>
         <div class="sku-item-li sku-item-delete">
@@ -1054,7 +1074,83 @@
             $("#commodityDetailsFlag").prop("disabled", false);
         }
     }
+    $('.costCheckFlag').on('change', function () {
+        var skus = $("#skus")
+        if ($(this).val() == 1) {
+            skus.each(function() {
+                skus.find('.sku-shopPercent').hide();
+                skus.find('.sku-costPrice').show();
+            })
+            //shopPercent.parent('.sku-shopPercent').hide();
+            //costPrice.parent('.sku-costPrice').show();
+        } else {
+            skus.each(function() {
+                skus.find('.sku-shopPercent').show();
+                skus.find('.sku-costPrice').hide();
+            })
+            // shopPercent.parent('.sku-shopPercent').show();
+            // costPrice.parent('.sku-costPrice').hide();
+        }
+    })
+    $('.mallCostCheckFlag').on('change', function () {
+        console.log('333333')
+        var mallSkus = $("#mallSkus")
+        if ($(this).val() == 1) {
+            mallSkus.each(function() {
+                mallSkus.find('.sku-shopPercent').hide(); // shopPercent.parent('.sku-shopPercent').hide();
+                mallSkus.find('.sku-costPrice').show();
+            })
+        } else {
+            mallSkus.each(function() {
+                mallSkus.find('.sku-shopPercent').show(); // shopPercent.parent('.sku-shopPercent').hide();
+                mallSkus.find('.sku-costPrice').hide();
+            })
+            // shopPercent.parent('.sku-shopPercent').show();
+            // costPrice.parent('.sku-costPrice').hide();
+        }
+    })
+
+    //富文本框编辑
+    function checkInfo() {
+        // debugger
+
+        var productType = $("#productType").val();
+        var qualificationNo = $('#qualificationNo').val()
+        var productName = $("#productName").val();
+        var qualificationTime = $('#qualificationTime').val()
+        var qualificationLink = $("#qualificationLink").val();
+        if (productType == "2") {
+
+            if (qualificationNo == null || qualificationNo == "") {
+                alertx("请输入证书编号");
+                return false;
+            }
+            if (productName == null || productName == "") {
+                alertx("请输入产品名称");
+                return false;
+            }
+            if (qualificationTime == null || qualificationTime == "") {
+                alertx("请输入证书有效时间");
+                return false;
+            }
+            if (qualificationLink == null || qualificationLink == "") {
+                alertx("请输入证书有效链接");
+                return false;
+            }
+        }
 
+        var detailInfo = detailInfoEditor.getData();
+        $("#detailInfo").val(detailInfo);
+        var commonDetailInfo = detailInfoEditor2.getData();
+        $("#commonDetailInfo").val(commonDetailInfo);
+        console.log(detailInfo);
+        var orderInfo = orderInfoEditor.getData();
+        $("#orderInfo").val(orderInfo);
+        console.log(orderInfo);
+        var serviceInfo = serviceInfoEditor.getData();
+        $("#serviceInfo").val(serviceInfo);
+        console.log(serviceInfo);
+    }
 
     $(document).ready(function () {
 
@@ -1065,45 +1161,149 @@
         $("#inputForm").validate({
             ignore: "",
             submitHandler: function (form) {
+                var flag = true;
+                var shopId = $("#shopId").val()*1;
                 var commodityType = $("input[name='commodityType']:checked").val();
                 if (commodityType == '' || commodityType == null) {
                     alertx("请选择商品属性");
-                    return false;
+                    flag = false;
+                }
+                var groundMall = $("input[name='groundMall']:checked").val();
+                if (groundMall.length < 1) {
+                    alertx("请选中上架平台");
+                    flag = false;
                 }
                 var costCheckFlag = $("input[name='costCheckFlag']:checked").val();
-                if (costCheckFlag * 1 === 1) {
-                    if ($("#costPrice").val() == '') {
-                        alertx("请输入成本价");
-                        return false;
+                var skus = $("#skus .sku")
+                skus.each(function() {
+                    var cost = $(this)
+                    if (costCheckFlag * 1 === 1) {
+                        var costPrice = cost.find(".costPrice").val()
+                        var organizeCostPrice = cost.find(".organizeCostPrice").val()
+                        var cmCostPrice = cost.find(".cmCostPrice").val()
+                        var price = cost.find(".computedPrice").val()*1
+                        if (costPrice == '') {
+                            alertx("请输入供应商成本价");
+                            flag = false;
+                        }
+                        if (organizeCostPrice == '') {
+                            alertx("请输入集团成本价");
+                            flag = false;
+                        }
+                        if (cmCostPrice == '') {
+                            alertx("请输入采美成本价");
+                            flag = false;
+                        }
+                        const num = costPrice*1 + organizeCostPrice*1 + cmCostPrice*1
+                        if (shopId != 1161 ) {
+                            if (num != price) {
+                                alertx("采美国定成本和需为机构价")
+                                flag = false;
+                            }
+                        }else {
+                            if (num > price) {
+                                alertx("采美国定成本和不能大于机构价")
+                                flag = false;
+                            }
+                        }
+                    } else {
+                        var shopPercent = cost.find(".shopPercent").val()
+                        var organizePercent = cost.find(".organizePercent").val()
+                        var cmPercent = cost.find(".cmPercent").val()
+                        if (shopPercent == '') {
+                            alertx("请输入成本比例");
+                            flag = false;
+                        }
+                        if (organizePercent == '') {
+                            alertx("请输入集团比例");
+                            flag = false;
+                        }
+                        if (cmPercent == '') {
+                            alertx("请输入供应商比例");
+                            flag = false;
+                        }
+                        const num = shopPercent*1 + organizePercent*1 + cmPercent*1
+                        if (shopId != 1161 ) {
+                            if (num != 100) {
+                                alertx("采美佣金比例和需为100")
+                                flag = false;
+                            }
+                        }else {
+                            if (num > 100) {
+                                alertx("采美佣金比例和不能大于100")
+                                flag = false;
+                            }
+                        }
                     }
-                    ;
-                } else {
-                    var shopPercent = $("#shopPercent").val()
-                    var organizePercent = $("#organizePercent").val()
-                    var cmPercent = $("#cmPercent").val()
-                    if ($("#shopPercent").val() == '') {
-                        alertx("请输入成本比例");
-                        return false;
-                    };
-                    if ($("#organizePercent").val() == '') {
-                        alertx("请输入集团比例");
-                        return false;
-                    };
-                    if ($("#cmPercent").val() == '') {
-                        alertx("请输入供应商比例");
-                        return false;
-                    };
-                    /*const num = shopPercent*1 + organizePercent*1 + cmPercent*1
-                    if (num != 100) {
-                        alertx("佣金比例和需为100")
-                        return false;
-                    }*/
-                }
+                })
+                var mallCostCheckFlag = $("input[name='mallCostCheckFlag']:checked").val();
+                var mallSkus = $("#mallSkus")
+                mallSkus.each(function() {
+                    var mallCost = $(this)
+                    if (mallCostCheckFlag * 1 === 1) {
+                        var mallCostPrice = mallCost.find(".costPrice").val()
+                        var mallOrganizeCostPrice = mallCost.find(".organizeCostPrice").val()
+                        var mallCmCostPrice = mallCost.find(".cmCostPrice").val()
+                        var mallprice = mallCost.find(".computedPrice").val()*1
+                        if (mallCostPrice == '') {
+                            alertx("请输入供应商成本价");
+                            flag = false;
+                        }
+                        if (mallOrganizeCostPrice == '') {
+                            alertx("请输入集团成本价");
+                            flag = false;
+                        }
+                        if (mallCmCostPrice == '') {
+                            alertx("请输入采美成本价");
+                            flag = false;
+                        }
+                        const num = mallCostPrice*1 + mallOrganizeCostPrice*1 + mallCmCostPrice*1
+                        if (shopId != 1161 ) {
+                            if (num != mallprice) {
+                                alertx("丽格国定成本和需为机构价");
+                                flag = false;
+                            }
+                        } else {
+                            if (num > mallprice) {
+                                alertx("丽格国定成本和不能大于机构价")
+                                flag = false;
+                            }
+                        }
+                    } else {
+                        var mallShopPercent = mallCost.find(".shopPercent").val()
+                        var mallOrganizePercent = mallCost.find(".organizePercent").val()
+                        var mallCmPercent = mallCost.find(".cmPercent").val()
+                        if (mallShopPercent == '') {
+                            alertx("请输入成本比例");
+                            flag = false;
+                        }
+                        if (mallOrganizePercent == '') {
+                            alertx("请输入集团比例");
+                            flag = false;
+                        }
+                        if (mallCmPercent == '') {
+                            alertx("请输入供应商比例");
+                            flag = false;
+                        }
+                        const num = mallShopPercent*1 + mallOrganizePercent*1 + cmPercent*1
+                        if (shopId != 1161 ) {
+                            if (num != 100) {
+                                alertx("丽格佣金比例和需为100");
+                                flag = false;
+                            }
+                        } else {
+                            if (num > 100) {
+                                alertx("丽格佣金比例和不能大于100")
+                                flag = false;
+                            }
+                        }
+                    }
+                })
                 if ($('#minBuyNumber:visible').length > 0) {
                     var minBuyNumber = $('#minBuyNumber').val();
                     if (minBuyNumber <= 0 || minBuyNumber == '') {
                         alertx("请输入起订量");
-                        return false;
+                        flag = false;
                     }
                 }
                 if ($('input[name="ladderPriceList[0].buyNum"]:visible').length > 0) {
@@ -1111,7 +1311,7 @@
                     var buyPrice = $('input[name="ladderPriceList[0].buyPrice"]').val();
                     if (buyNum <= 0 || buyNum == '' || buyPrice <= 0 || buyPrice == '') {
                         alertx("请输入正确的阶梯价格");
-                        return false;
+                        flag = false;
                     }
                 }
                 if ($('input[name="ladderPriceList[1].buyNum"]:visible').length > 0) {
@@ -1119,7 +1319,7 @@
                     var buyPrice1 = $('input[name="ladderPriceList[1].buyPrice"]').val();
                     if (buyNum1 <= 0 || buyNum1 == '' || buyPrice1 <= 0 || buyPrice1 == '') {
                         alertx("请输入正确的阶梯价格");
-                        return false;
+                        flag = false;
                     }
                 }
                 if ($('input[name="ladderPriceList[2].buyNum"]:visible').length > 0) {
@@ -1127,18 +1327,18 @@
                     var buyPrice2 = $('input[name="ladderPriceList[2].buyPrice"]').val();
                     if (buyNum2 <= 0 || buyNum2 == '' || buyPrice2 <= 0 || buyPrice2 == '') {
                         alertx("请输入正确的阶梯价格");
-                        return false;
+                        flag = false;
                     }
                 }
                 var detailInfo = detailInfoEditor.getData();
                 if (detailInfo == '') {
                     alertx("请输入商品详细信息");
-                    return false;
+                    flag = false;
                 }
                 var includedTax = $("input[name='includedTax']:checked").val();
                 if (includedTax == '' || includedTax == null) {
                     alertx("请选择是否含税");
-                    return false;
+                    flag = false;
                 }
                 var invoiceType = $("input[name='invoiceType']:checked").val();
                 if ((includedTax == 0 || includedTax == 1) && (invoiceType == 1 || invoiceType == 2)) {
@@ -1146,11 +1346,11 @@
                     var supplierTaxPoint = $("#supplierTaxPoint").val();
                     if (taxPoint == '' || taxPoint == null) {
                         alertx("请输入机构税率");
-                        return false;
+                        flag = false;
                     }
                     if (supplierTaxPoint == '' || supplierTaxPoint == null) {
                         alertx("请输入供应商税率");
-                        return false;
+                        flag = false;
                     }
                 }
                 if (includedTax != ${product.includedTax} || invoiceType != ${product.invoiceType}) {
@@ -1163,8 +1363,10 @@
                                 $("#groundSkuBcc").remove()
                             }
                             // 提交订单
-                            loading('正在提交,请稍等...');
-                            form.submit();
+                            if (flag) {
+                                loading('正在提交,请稍等...');
+                                form.submit();
+                            }
                         }
                     }, {
                         buttonsFocus: 1, closed: function () {
@@ -1180,8 +1382,10 @@
                     if(!$('#bcc').prop('checked')){
                         $("#groundSkuBcc").remove()
                     }
-                    loading('正在提交,请稍等...');
-                    form.submit();
+                    if (flag) {
+                        loading('正在提交,请稍等...');
+                        form.submit();
+                    }
                 }
             },
             errorContainer: "#messageBox",
@@ -1533,48 +1737,6 @@
         });
     });
 
-    //富文本框编辑
-    function checkInfo() {
-        // debugger
-
-        var productType = $("#productType").val();
-        var qualificationNo = $('#qualificationNo').val()
-        var productName = $("#productName").val();
-        var qualificationTime = $('#qualificationTime').val()
-        var qualificationLink = $("#qualificationLink").val();
-        if (productType == "2") {
-
-            if (qualificationNo == null || qualificationNo == "") {
-                alertx("请输入证书编号");
-                return false;
-            }
-            if (productName == null || productName == "") {
-                alertx("请输入产品名称");
-                return false;
-            }
-            if (qualificationTime == null || qualificationTime == "") {
-                alertx("请输入证书有效时间");
-                return false;
-            }
-            if (qualificationLink == null || qualificationLink == "") {
-                alertx("请输入证书有效链接");
-                return false;
-            }
-        }
-
-        var detailInfo = detailInfoEditor.getData();
-        $("#detailInfo").val(detailInfo);
-        var commonDetailInfo = detailInfoEditor2.getData();
-        $("#commonDetailInfo").val(commonDetailInfo);
-        console.log(detailInfo);
-        var orderInfo = orderInfoEditor.getData();
-        $("#orderInfo").val(orderInfo);
-        console.log(orderInfo);
-        var serviceInfo = serviceInfoEditor.getData();
-        $("#serviceInfo").val(serviceInfo);
-        console.log(serviceInfo);
-    }
-
 
     // $("#ladderPrice1").on("click", ".addBtn", function () {
     //     $("#ladderPrice2").removeClass("hide");
@@ -2141,6 +2303,14 @@
         var costPrice = el.find('input[name$="costPrice"]');
         costPrice.val(product.costPrice)
         costPrice.attr('name', 'skuList[' + skuIndex + '].costPrice');
+        // 成本价
+        var organizeCostPrice = el.find('input[name$="organizeCostPrice"]');
+        organizeCostPrice.val(product.organizeCostPrice)
+        organizeCostPrice.attr('name', 'skuList[' + skuIndex + '].organizeCostPrice');
+        // 成本价
+        var cmCostPrice = el.find('input[name$="cmCostPrice"]');
+        cmCostPrice.val(product.cmCostPrice)
+        cmCostPrice.attr('name', 'skuList[' + skuIndex + '].cmCostPrice');
         // 比例成本百分比
         var shopPercent = el.find('input[name$="shopPercent"]');
         shopPercent.val(product.shopPercent)

Some files were not shown because too many files changed in this diff