Преглед на файлове

对账功能优化,扩展详情接口

xucaiqin преди 2 години
родител
ревизия
1628266496
променени са 24 файла, в които са добавени 839 реда и са изтрити 399 реда
  1. 24 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/base/TimeBase.java
  2. 23 21
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java
  3. 15 14
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java
  4. 3 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  5. 1 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  6. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LogisticsUnitType.java
  7. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementEnum.java
  8. 36 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ISettlement.java
  9. 80 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementPurchaseDto.java
  10. 137 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementSellDto.java
  11. 27 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java
  12. 2 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerReq.java
  13. 2 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java
  14. 0 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java
  15. 49 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java
  16. 98 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementTradeReq.java
  17. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java
  18. 0 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java
  19. 39 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/SettlementSumVo.java
  20. 19 19
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  21. 15 16
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  22. 42 142
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  23. 85 145
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  24. 138 29
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

+ 24 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/base/TimeBase.java

@@ -0,0 +1,24 @@
+package com.sckw.core.model.base;
+
+import com.sckw.core.utils.StringTimeUtil;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-27 19:30:53
+ */
+public interface TimeBase {
+    default String getStartDateTime(String time) {
+        if (StringUtils.isBlank(time)) {
+            return null;
+        }
+        return StringTimeUtil.fillStart(time);
+    }
+
+    default String getEndDateTime(String time) {
+        if (StringUtils.isBlank(time)) {
+            return null;
+        }
+        return StringTimeUtil.fillEnd(time);
+    }
+}

+ 23 - 21
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java

@@ -1,9 +1,9 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.dto.ILedger;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.LedgerLogisticsVo;
@@ -29,34 +29,25 @@ public class KwpLedgerLogisticsController {
     @Resource
     private KwpLedgerLogisticsService kwpLedgerLogisticsService;
 
-    private void fill(LogisticsSendReq logisticsSendReq) {
-        if (CollectionUtils.isEmpty(logisticsSendReq.getIdList())) {
-            throw new BusinessException("物流订单不能为空");
-        }
-        logisticsSendReq.setOrders(logisticsSendReq.getIdList());
-    }
-
     /**
-     * 物流对账单-发起对账(保存草稿)
+     * 物流对账单-发起对账(保存草稿)(承运方)
      *
      * @param logisticsReq
      * @return
      */
     @PostMapping("sendDraft")
     public HttpResult sendDraft(@RequestBody @Valid LogisticsSendReq logisticsReq) {
-        fill(logisticsReq);
         return HttpResult.ok(kwpLedgerLogisticsService.sendLedgerDraft(logisticsReq));
     }
 
     /**
-     * 物流对账单-发起对账
+     * 物流对账单-发起对账(承运方)
      *
      * @param logisticsReq
      * @return
      */
     @PostMapping("send")
     public HttpResult send(@RequestBody @Valid LogisticsSendReq logisticsReq) {
-        fill(logisticsReq);
         return HttpResult.ok(kwpLedgerLogisticsService.sendLedger(logisticsReq));
     }
 
@@ -72,7 +63,7 @@ public class KwpLedgerLogisticsController {
     }
 
     /**
-     * 承运方物流对账单列表查询
+     * 承运方物流对账单列表查询(物流公司、收钱方)
      *
      * @param logisticsReq
      * @return
@@ -83,18 +74,29 @@ public class KwpLedgerLogisticsController {
     }
 
     /**
-     * 查询物流对账单详情
+     * 承运方-查询物流对账单详情
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("queryCarrierDetail")
+    public HttpResult queryCarrierDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id), LogisticsUnitType.SHIPPER));
+    }
+
+    /**
+     * 托运方-查询物流对账单详情
      *
      * @param id
      * @return
      */
-    @GetMapping("queryDetail")
+    @GetMapping("queryShipperDetail")
     public HttpResult queryDetail(@RequestParam("id") String id) {
-        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id)));
+        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id), LogisticsUnitType.CARRIER));
     }
 
     /**
-     * 修改物流对账单详情(修改物流对账单接口使用)
+     * 修改物流对账单详情(修改物流对账单接口使用) 仅发起对账方支持修改
      *
      * @param id
      * @return
@@ -110,8 +112,8 @@ public class KwpLedgerLogisticsController {
      * @return
      */
     @GetMapping("shipperCount")
-    public HttpResult shipperCount() {
-        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(1));
+    public HttpResult shipperCount(@Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 1));
     }
 
     /**
@@ -120,8 +122,8 @@ public class KwpLedgerLogisticsController {
      * @return
      */
     @GetMapping("carrierCount")
-    public HttpResult carrierCount() {
-        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(2));
+    public HttpResult carrierCount(@Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 2));
     }
 
     /**

+ 15 - 14
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java

@@ -1,9 +1,9 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.dto.ILedger;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.LedgerTradeVo;
@@ -32,12 +32,6 @@ public class KwpLedgerTradeController {
     @Resource
     private KwpLedgerTradeService kwpLedgerTradeService;
 
-    private void fill(TradeSendReq tradeSendReq) {
-        if (CollectionUtils.isEmpty(tradeSendReq.getIdList())) {
-            throw new BusinessException("销售订单不能为空");
-        }
-        tradeSendReq.setOrders(tradeSendReq.getIdList());
-    }
 
     /**
      * 贸易对账单-发起对账(保存草稿)
@@ -47,7 +41,6 @@ public class KwpLedgerTradeController {
      */
     @PostMapping("sendDraft")
     public HttpResult sendDraft(@RequestBody @Valid TradeSendReq tradeSendReq) {
-        fill(tradeSendReq);
         return HttpResult.ok(kwpLedgerTradeService.sendLedgerDraft(tradeSendReq));
     }
 
@@ -59,7 +52,6 @@ public class KwpLedgerTradeController {
      */
     @PostMapping("send")
     public HttpResult send(@RequestBody @Valid TradeSendReq tradeSendReq) {
-        fill(tradeSendReq);
         return HttpResult.ok(kwpLedgerTradeService.sendLedger(tradeSendReq));
     }
 
@@ -86,16 +78,25 @@ public class KwpLedgerTradeController {
     }
 
     /**
-     * 查询贸易对账单详情
+     * 销售-查询贸易对账单详情
      *
      * @param id
      * @return
      */
-    @GetMapping("queryDetail")
-    public HttpResult queryDetail(@RequestParam("id") String id) {
-        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id)));
+    @GetMapping("querySellDetail")
+    public HttpResult querySellDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id), TradeUnitType.PURCHASE));
+    }
+    /**
+     * 采购-查询贸易对账单详情
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("queryPurchaseDetail")
+    public HttpResult queryPurchaseDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id),TradeUnitType.SELL));
     }
-
     /**
      * 修改贸易对账单详情(修改物流对账单接口使用)
      *

+ 3 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java

@@ -29,16 +29,16 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
     List<LedgerShipperDto> shipperSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
 
     /**
-     * 承运方
+     * 承运方 对账发起方,客户公司是托运方
      *
      * @param logisticsReq
      * @return
      */
     List<LedgerCarrierDto> carrierSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
 
-    Map<String, Long> countOrder(@Param("entId") Long entId, @Param("unitType") Integer unitType);
+    Map<String, Long> countOrder(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("unitType") Integer unitType);
 
-    LedgerLogisticsDto selectId(@Param("id") Long id);
+    LedgerLogisticsDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
 
     List<LedgerShipperDto> selectShipperIds(@Param("ids") List<Long> ids);

+ 1 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java

@@ -19,7 +19,6 @@ import java.util.Map;
 
 @Mapper
 public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
-    List<LedgerTradeDto> pageSelect(@Param("tradeReq") TradeReq tradeReq);
 
     List<LedgerSellDto> sellList(@Param("tradeReq") TradeReq tradeReq);
 
@@ -27,7 +26,7 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     Map<String, Long> countOrder(@Param("entId") Long entId, @Param("unitType") Integer unitType);
 
-    LedgerTradeDto selectId(@Param("id") Long id);
+    LedgerTradeDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
     List<LedgerSellDto> selectSellIds(@Param("ids") List<Long> ids);
 

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LogisticsUnitType.java

@@ -6,11 +6,11 @@ package com.sckw.payment.model.constant;
  */
 public interface LogisticsUnitType {
     /**
-     * 托运方(客户单位)
+     * 托运方 货物的委托人或发货人,即发送货物的一方
      */
     Integer SHIPPER = 1;
     /**
-     * 承运方
+     * 承运方 发起对账的一方
      */
     Integer CARRIER = 2;
 }

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementEnum.java

@@ -8,6 +8,7 @@ package com.sckw.payment.model.constant;
  * @date 2023-07-11 12:00:52
  */
 public enum SettlementEnum {
+    ALL(0, "全部"),
     WAITING_PAYMENT(1, "待结算"),
     PARTIAL_PAYMENT(2, "部分结算"),
     ALL_PAYMENT(3, "全部结算");

+ 36 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ISettlement.java

@@ -0,0 +1,36 @@
+package com.sckw.payment.model.dto;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.Objects;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-28 08:42:13
+ */
+public interface ISettlement {
+
+    void setTrading(Integer trading);
+
+    Integer getTrading();
+
+    void setTradingLabel(String tradingLabel);
+
+    void setStatus(Integer status);
+
+    Integer getStatus();
+
+    void setStatusLabel(String statusLabel);
+
+    private DecimalFormat df() {
+        return new DecimalFormat("0.00");
+    }
+
+    default String changePrice(BigDecimal price) {
+        if (Objects.isNull(price)) {
+            //金额为null时显示的金额
+            return "";
+        }
+        return df().format(price);
+    }
+}

+ 80 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementPurchaseDto.java

@@ -0,0 +1,80 @@
+package com.sckw.payment.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * 销售结算 采购方
+ *
+ * @author xucaiqin
+ * @date 2023-07-20 12:26
+ */
+@Getter
+@Setter
+public class SettlementPurchaseDto implements ISettlement {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 结算单编号
+     */
+    private String stOrderNo;
+
+    /**
+     * 结算单名称
+     */
+    private String name;
+
+    /**
+     * 总应收/元
+     */
+    private String totalPrice;
+
+    /**
+     * 已收款/元
+     */
+    private String actualPrice;
+    /**
+     * 剩余带回款金额
+     */
+    private String waitPrice;
+
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date receiptTime;
+
+    /**
+     * 对账销售财务联系人名称
+     */
+    private String successUser;
+
+    /**
+     * 对账销售财务联系人电话
+     */
+    private String successPhone;
+    /**
+     * 交易方式
+     */
+    private Integer trading;
+    private String tradingLabel;
+
+    /**
+     * 状态(待回款、部分回款、全部回款、回退)
+     */
+    private Integer status;
+    private String statusLabel;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+}

+ 137 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementSellDto.java

@@ -0,0 +1,137 @@
+package com.sckw.payment.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.Date;
+
+/**
+ * 销售结算 销售方
+ *
+ * @author Aick Spt
+ * @date 2023-07-20 12:26
+ */
+@Setter
+@ToString
+public class SettlementSellDto implements ISettlement {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 结算单编号
+     */
+    private String stOrderNo;
+
+    /**
+     * 结算单名称
+     */
+    private String name;
+
+    /**
+     * 总应收/元
+     */
+    private String totalPrice;
+
+    /**
+     * 已收款/元
+     */
+    private String actualPrice;
+    /**
+     * 剩余带回款金额
+     */
+    private String waitPrice;
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date receiptTime;
+
+    /**
+     * 对账采购财务联系人名称
+     */
+    private String auditUser;
+
+    /**
+     * 对账采购财务联系人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    private Integer trading;
+    private String tradingLabel;
+
+    /**
+     * 状态(待回款、部分回款、全部回款、回退)
+     */
+    private Integer status;
+    private String statusLabel;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getStOrderNo() {
+        return stOrderNo;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getTotalPrice() {
+        return totalPrice;
+    }
+
+    public String getActualPrice() {
+        return actualPrice;
+    }
+
+    public String getWaitPrice() {
+        return waitPrice;
+    }
+
+    public Date getReceiptTime() {
+        return receiptTime;
+    }
+
+    public String getAuditUser() {
+        return auditUser;
+    }
+
+    public String getAuditPhone() {
+        return auditPhone;
+    }
+
+    @Override
+    public Integer getTrading() {
+        return trading;
+    }
+
+    public String getTradingLabel() {
+        return tradingLabel;
+    }
+
+    @Override
+    public Integer getStatus() {
+        return status;
+    }
+
+    public String getStatusLabel() {
+        return statusLabel;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+}

+ 27 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java

@@ -3,17 +3,19 @@ package com.sckw.payment.model.dto;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 /**
  * 结算-交易订单
+ *
  * @author Aick Spt
  * @date 2023-07-20 12:26
  */
 @Getter
 @Setter
-public class SettlementTradeDto {
+public class SettlementTradeDto implements ISettlement {
 
     /**
      * 主键
@@ -49,6 +51,10 @@ public class SettlementTradeDto {
      * 已收款/元
      */
     private BigDecimal actualPrice;
+    /**
+     * 带回款金额(扩展的计算字段)
+     */
+    private BigDecimal waitPrice;
 
     /**
      * 预计收款日期
@@ -139,4 +145,24 @@ public class SettlementTradeDto {
                 ", delFlag=" + delFlag +
                 '}';
     }
+
+    @Override
+    public void setTrading(Integer trading) {
+
+    }
+
+    @Override
+    public Integer getTrading() {
+        return null;
+    }
+
+    @Override
+    public void setTradingLabel(String tradingLabel) {
+
+    }
+
+    @Override
+    public void setStatusLabel(String statusLabel) {
+
+    }
 }

+ 2 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerReq.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.model.vo.req;
 
+import com.sckw.core.model.base.IdsList;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
@@ -12,7 +13,7 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-public class LedgerReq {
+public class LedgerReq implements IdsList {
     @NotNull(message = "对账单id不能为空")
     private String id;
     @NotBlank(message = "驳回原因不能为空")

+ 2 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.vo.req;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.core.model.base.IdsList;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
@@ -17,7 +18,7 @@ import java.time.LocalDate;
  */
 @Getter
 @Setter
-public class LedgerSuccessReq {
+public class LedgerSuccessReq implements IdsList {
     @NotNull(message = "物流对账单id不能为空")
     private String id;
     @NotBlank(message = "财务联系人不能为空")

+ 0 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java

@@ -9,7 +9,6 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.List;
 
 /**
  * @author xucaiqin
@@ -83,7 +82,6 @@ public class LogisticsSendReq implements IdsList {
     @NotEmpty(message = "承运订单不能为空")
     private String ids;
 
-    private List<Long> orders;
     private LocalDateTime generateTime;
     private Integer status;
 

+ 49 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java

@@ -0,0 +1,49 @@
+package com.sckw.payment.model.vo.req;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.core.model.vo.BasePara;
+import com.sckw.payment.model.constant.SettlementEnum;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serial;
+import java.time.LocalDateTime;
+
+/**
+ * @author Aick Spt
+ * @date 2023-07-18 11:29
+ */
+@Getter
+@Setter
+public class SettlementOfflinePayReq extends BasePara {
+    @Serial
+    private static final long serialVersionUID = 6537008434516489423L;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "创建时间开始日期不能为空")
+    private LocalDateTime startCreateTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "创建时间结束日期不能为空")
+    private LocalDateTime endCreateTime;
+
+        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "预计回款开始日期不能为空")
+    private LocalDateTime startReceiptTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @NotNull(message = "预计回款结束日期不能为空")
+    private LocalDateTime endReceiptTime;
+
+    /**
+     * @see SettlementEnum
+     */
+    private Integer status;
+
+    private String ids;
+}

+ 98 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementTradeReq.java

@@ -0,0 +1,98 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.core.model.base.TimeBase;
+import com.sckw.core.model.vo.BasePara;
+import com.sckw.payment.model.constant.SettlementEnum;
+
+import java.io.Serial;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-18 11:29
+ */
+public class SettlementTradeReq extends BasePara implements TimeBase {
+    @Serial
+    private static final long serialVersionUID = -508783597831158781L;
+
+    private String startCreateTime;
+
+    private String endCreateTime;
+
+    private String startReceiptTime;
+
+    private String endReceiptTime;
+
+    /**
+     * @see SettlementEnum
+     */
+    private Integer status;
+    private Integer unitType;
+
+    private String ids;
+    private Long entId;
+
+    public Long getEntId() {
+        return entId;
+    }
+
+    public void setEntId(Long entId) {
+        this.entId = entId;
+    }
+
+    public Integer getUnitType() {
+        return unitType;
+    }
+
+    public void setUnitType(Integer unitType) {
+        this.unitType = unitType;
+    }
+
+    public String getStartCreateTime() {
+        return getStartDateTime(startCreateTime);
+    }
+
+    public void setStartCreateTime(String startCreateTime) {
+        this.startCreateTime = startCreateTime;
+    }
+
+    public String getEndCreateTime() {
+        return getEndDateTime(endCreateTime);
+    }
+
+    public void setEndCreateTime(String endCreateTime) {
+        this.endCreateTime = endCreateTime;
+    }
+
+    public String getStartReceiptTime() {
+        return getStartDateTime(startReceiptTime);
+    }
+
+    public void setStartReceiptTime(String startReceiptTime) {
+        this.startReceiptTime = startReceiptTime;
+    }
+
+    public String getEndReceiptTime() {
+        return getEndDateTime(endReceiptTime);
+    }
+
+    public void setEndReceiptTime(String endReceiptTime) {
+        this.endReceiptTime = endReceiptTime;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    @Override
+    public String getIds() {
+        return ids;
+    }
+
+    public void setIds(String ids) {
+        this.ids = ids;
+    }
+}

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java

@@ -25,5 +25,6 @@ public class TradeReq extends BasePara {
     private Integer status;
     private String ids;
     private Long entId;
+    private Integer unitType;
 
 }

+ 0 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java

@@ -84,7 +84,6 @@ public class TradeSendReq implements IdsList {
     @NotBlank(message = "销售订单不能为空")
     private String ids;
 
-    private List<Long> orders;
     private LocalDateTime generateTime;
     private Integer status;
 }

+ 39 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/SettlementSumVo.java

@@ -0,0 +1,39 @@
+package com.sckw.payment.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 表尾结算统计数据
+ *
+ * @author xucaiqin
+ * @date 2023-07-21 14:44
+ */
+@Getter
+@Setter
+public class SettlementSumVo {
+
+    /**
+     * 合计数量
+     */
+    public Long allCount;
+
+    /**
+     * 实际应收
+     */
+    public BigDecimal receiveAll;
+
+    /**
+     * 当前收款
+     */
+    public BigDecimal alreadyReceive;
+
+    /**
+     * 代收款
+     */
+    public BigDecimal waitReceive;
+
+
+}

+ 19 - 19
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java

@@ -98,6 +98,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
 
     public PageRes<ILedger> shipperList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
+        logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
         List<LedgerShipperDto> kwpLedgerLogisticsList = logisticsMapper.shipperSelect(logisticsReq);
         //字典转换
@@ -112,6 +113,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     public PageRes<ILedger> carrierList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
+        logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
         List<LedgerCarrierDto> kwpLedgerLogisticsList = logisticsMapper.carrierSelect(logisticsReq);
         //字典转换
         if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
@@ -159,7 +161,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
 
     private Long saveDraft(LogisticsSendReq logisticsSendReq) {
         KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
-        kwpLedgerLogistics.setId(StringUtils.isBlank(logisticsSendReq.getId()) ? new IdWorker(1).nextId() : Long.parseLong(logisticsSendReq.getId()));
+        kwpLedgerLogistics.setId(Objects.isNull(logisticsSendReq.getIdLong()) ? new IdWorker(1).nextId() : logisticsSendReq.getIdLong());
         kwpLedgerLogistics.setEntId(LoginUserHolder.getEntId());
         kwpLedgerLogistics.setName(logisticsSendReq.getName());
         if (StringUtils.isNotBlank(logisticsSendReq.getStartTime())) {
@@ -177,7 +179,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpLedgerLogistics.setAuditUser("");
         kwpLedgerLogistics.setAuditPhone("");
         kwpLedgerLogistics.setReceiptTime(null);
-        kwpLedgerLogistics.setOrderCount(logisticsSendReq.getOrders().size());
+        kwpLedgerLogistics.setOrderCount(logisticsSendReq.getIdList().size());
         kwpLedgerLogistics.setUrl("");
         kwpLedgerLogistics.setGenerateTime(logisticsSendReq.getGenerateTime());
         kwpLedgerLogistics.setRemark("");
@@ -191,7 +193,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
             kwpLedgerLogistics.setLLedgerNo(OrderGenerateUtils.generateOrderNo("LL"));
             logisticsMapper.insert(kwpLedgerLogistics);
         } else {
-            KwpLedgerLogistics ledgerLogistics = logisticsMapper.selectById(logisticsSendReq.getId());
+            KwpLedgerLogistics ledgerLogistics = logisticsMapper.selectById(logisticsSendReq.getIdLong());
             orderCheck(ledgerLogistics);
             updateCheck(ledgerLogistics.getStatus());
             kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
@@ -199,10 +201,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
             logisticsMapper.updateById(kwpLedgerLogistics);
         }
         /*保存物流订单关联数据*/
-        List<Long> ids = logisticsSendReq.getOrders();
+        List<Long> ids = logisticsSendReq.getIdList();
         //todo-xcq 校验当前订单是否已存在绑定的对账单
         logisticsOrderService.check(ids);
-        List<KwtLogisticsOrderVO> acceptCarriageOrderDetail = transportDubboService.getAcceptCarriageOrderDetail(ids.stream().map(a -> Long.toString(a)).toList());
+        List<KwtLogisticsOrderVO> acceptCarriageOrderDetail = transportDubboService.getAcceptCarriageOrderDetail(logisticsSendReq.getIdsList());
         if (CollectionUtils.isEmpty(acceptCarriageOrderDetail) || acceptCarriageOrderDetail.size() < ids.size()) {
             throw new BusinessException("未找到物流订单!");
         }
@@ -353,8 +355,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      * @return
      */
     public Integer doBack(LedgerReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
-        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(ledgerReq.getIdLong());
         if (Objects.isNull(kwpLedgerLogistics)) {
             throw new BusinessException("对账单不存在!");
         }
@@ -363,7 +364,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
         kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
         logisticsMapper.updateById(kwpLedgerLogistics);
-        return logisticsTrackService.saveTrack(id, ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
+        return logisticsTrackService.saveTrack(ledgerReq.getIdLong(), ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
     }
 
     /**
@@ -375,8 +376,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public Integer confirmOrder(LedgerConfirmReq confirmReq) {
-        Long id = Long.parseLong(confirmReq.getId());
-        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(confirmReq.getIdLong());
         orderCheck(kwpLedgerLogistics);
         confirmCheck(kwpLedgerLogistics.getStatus());
         kwpLedgerLogistics.setStatus(LedgerEnum.LEDGERED.getStatus());
@@ -386,7 +386,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
         kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
         logisticsMapper.updateById(kwpLedgerLogistics);
-        return logisticsTrackService.saveTrack(id, "", LedgerTrackEnum.CONFIRM);
+        return logisticsTrackService.saveTrack(confirmReq.getIdLong(), "", LedgerTrackEnum.CONFIRM);
     }
 
     /**
@@ -397,8 +397,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public String orderSuccess(LedgerSuccessReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
-        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(ledgerReq.getIdLong());
         orderCheck(kwpLedgerLogistics);
 
         successCheck(kwpLedgerLogistics.getStatus());
@@ -432,7 +431,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
 
         settlementLogisticsService.save(kwpSettlementLogistics);
 
-        logisticsTrackService.saveTrack(id, "", LedgerTrackEnum.SUCCESS);
+        logisticsTrackService.saveTrack(ledgerReq.getIdLong(), "", LedgerTrackEnum.SUCCESS);
         return "对账完成";
     }
 
@@ -440,8 +439,9 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      * @param unitType 1-托运方 2-承运方
      * @return
      */
-    public List<LedgerCountVo> orderCount(Integer unitType) {
-        Map<String, Long> map = logisticsMapper.countOrder(LoginUserHolder.getEntId(), unitType);
+    public List<LedgerCountVo> orderCount(LogisticsReq logisticsReq, Integer unitType) {
+        logisticsReq.setEntId(LoginUserHolder.getEntId());
+        Map<String, Long> map = logisticsMapper.countOrder(logisticsReq, unitType);
         LedgerCountVo ledgerCountVo;
         List<LedgerCountVo> res = new ArrayList<>();
         for (LedgerEnum value : LedgerEnum.values()) {
@@ -481,14 +481,14 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     }
 
     public LedgerLogisticsDetailVo queryUpdate(Long id) {
-        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id);
+        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id, LogisticsUnitType.SHIPPER);
         orderCheck(ledgerLogisticsDto);
         updateCheck(ledgerLogisticsDto.getStatus());
         return getLedgerLogisticsDetailVo(ledgerLogisticsDto);
     }
 
-    public LedgerLogisticsDetailVo queryDetail(Long id) {
-        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id);
+    public LedgerLogisticsDetailVo queryDetail(Long id, Integer unitType) {
+        LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id, unitType);
         orderCheck(ledgerLogisticsDto);
         return getLedgerLogisticsDetailVo(ledgerLogisticsDto);
     }

+ 15 - 16
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -101,6 +101,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     public PageRes<ILedger> sellList(TradeReq tradeReq) {
         fillPara(tradeReq);
         PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        tradeReq.setUnitType(TradeUnitType.PURCHASE);
         List<LedgerSellDto> ledgerTradeDto = tradeMapper.sellList(tradeReq);
         //字典转换
         if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
@@ -120,6 +121,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     public PageRes<ILedger> purchaseList(TradeReq tradeReq) {
         fillPara(tradeReq);
         PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        tradeReq.setUnitType(TradeUnitType.SELL);
         List<LedgerPurchaseDto> ledgerTradeDto = tradeMapper.purchaseList(tradeReq);
         //字典转换
         if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
@@ -141,7 +143,7 @@ public class KwpLedgerTradeService extends AbsLedger {
 
     private Long saveDraft(TradeSendReq tradeSendReq) {
         KwpLedgerTrade kwpLedgerTrade = new KwpLedgerTrade();
-        kwpLedgerTrade.setId(StringUtils.isBlank(tradeSendReq.getId()) ? new IdWorker(1).nextId() : Long.parseLong(tradeSendReq.getId()));
+        kwpLedgerTrade.setId(Objects.isNull(tradeSendReq.getId()) ? new IdWorker(1).nextId() : tradeSendReq.getIdLong());
         kwpLedgerTrade.setEntId(LoginUserHolder.getEntId());
         kwpLedgerTrade.setName(tradeSendReq.getName());
         if (StringUtils.isNotBlank(tradeSendReq.getStartTime())) {
@@ -160,7 +162,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         kwpLedgerTrade.setAuditPhone("");
         kwpLedgerTrade.setGenerateTime(tradeSendReq.getGenerateTime());
         kwpLedgerTrade.setReceiptTime(null);
-        kwpLedgerTrade.setOrderCount(tradeSendReq.getOrders().size());
+        kwpLedgerTrade.setOrderCount(tradeSendReq.getIdList().size());
         kwpLedgerTrade.setUrl("");
         kwpLedgerTrade.setRemark("");
         kwpLedgerTrade.setStatus(tradeSendReq.getStatus());
@@ -183,7 +185,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         }
 
         /*保存贸易订单关联数据*/
-        List<Long> ids = tradeSendReq.getOrders();
+        List<Long> ids = tradeSendReq.getIdList();
         //todo-xcq 校验当前订单是否已存在绑定的对账单
         tradeOrderService.check(ids);
         List<OrderDetailRes> resList = new ArrayList<>();
@@ -276,8 +278,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     @Transactional(rollbackFor = Exception.class)
     public String sendLedger(TradeSendReq tradeSendReq) {
         log.info("保存对账单入参:{}", JSONObject.toJSONString(tradeSendReq));
-        String id = tradeSendReq.getId();
-        if (StringUtils.isBlank(id)) {
+        if (Objects.isNull(tradeSendReq.getIdLong())) {
             //新增
             tradeSendReq.setGenerateTime(LocalDateTime.now());
             tradeSendReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
@@ -285,7 +286,7 @@ public class KwpLedgerTradeService extends AbsLedger {
             tradeTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
         } else {
             //先删除
-            removeDraft(Long.parseLong(id));
+            removeDraft(tradeSendReq.getIdLong());
             //在新增
             tradeSendReq.setGenerateTime(LocalDateTime.now());
             tradeSendReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
@@ -364,15 +365,14 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @return
      */
     public String doBack(LedgerReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
-        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(id);
+        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(ledgerReq.getIdLong());
         orderCheck(kwpLedgerTrade);
         backCheck(kwpLedgerTrade.getStatus());
         kwpLedgerTrade.setStatus(LedgerEnum.BACK.getStatus());
         kwpLedgerTrade.setUpdateBy(LoginUserHolder.getUserId());
         kwpLedgerTrade.setUpdateTime(LocalDateTime.now());
         tradeMapper.updateById(kwpLedgerTrade);
-        tradeTrackService.saveTrack(id, ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
+        tradeTrackService.saveTrack(ledgerReq.getIdLong(), ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
         return "驳回成功";
     }
 
@@ -384,8 +384,7 @@ public class KwpLedgerTradeService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public String confirmOrder(LedgerConfirmReq confirmReq) {
-        Long id = Long.parseLong(confirmReq.getId());
-        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(id);
+        KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(confirmReq.getIdLong());
         orderCheck(kwpLedgerTrade);
         confirmCheck(kwpLedgerTrade.getStatus());
         kwpLedgerTrade.setStatus(LedgerEnum.LEDGERED.getStatus());
@@ -395,7 +394,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         kwpLedgerTrade.setUpdateBy(LoginUserHolder.getUserId());
         kwpLedgerTrade.setUpdateTime(LocalDateTime.now());
         tradeMapper.updateById(kwpLedgerTrade);
-        tradeTrackService.saveTrack(id, "", LedgerTrackEnum.CONFIRM);
+        tradeTrackService.saveTrack(confirmReq.getIdLong(), "", LedgerTrackEnum.CONFIRM);
         return "对账确认成功";
     }
 
@@ -407,7 +406,7 @@ public class KwpLedgerTradeService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public String orderSuccess(LedgerSuccessReq ledgerReq) {
-        Long id = Long.parseLong(ledgerReq.getId());
+        Long id = ledgerReq.getIdLong();
 
         KwpLedgerTrade kwpLedgerTrade = tradeMapper.selectById(id);
         orderCheck(kwpLedgerTrade);
@@ -473,7 +472,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     }
 
     public LedgerTradeDetailVo queryUpdate(Long id) {
-        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id);
+        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id,TradeUnitType.PURCHASE);
         orderCheck(ledgerTradeDto);
         updateCheck(ledgerTradeDto.getStatus());
         List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(ledgerTradeDto.getId());
@@ -500,8 +499,8 @@ public class KwpLedgerTradeService extends AbsLedger {
         return ledgerTradeDetailVo;
     }
 
-    public LedgerTradeDetailVo queryDetail(Long id) {
-        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id);
+    public LedgerTradeDetailVo queryDetail(Long id, Integer unitType) {
+        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id,unitType);
         orderCheck(ledgerTradeDto);
 
         List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(ledgerTradeDto.getId());

+ 42 - 142
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -58,36 +58,39 @@
         update_time,
         del_flag
     </sql>
-
-    <select id="shipperSelect" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+    <sql id="list_col">
+        kll.id,
+        kll.l_ledger_no   lLedgerNo,
+        kll.name,
+        kll.start_time    startTime,
+        kll.end_time      endTime,
+        kll.tax_rate      taxRate,
+        kll.trading,
+        kll.total_price   totalPrice,
+        kll.ex_tax_price  exTaxPrice,
+        kll.settle_price  settlePrice,
+        kll.actual_price  actualPrice,
+        kll.audit_phone   auditPhone,
+        kll.audit_user    auditUser,
+        kll.url,
+        kll.generate_time generateTime,
+        kll.receipt_time  receiptTime,
+        kll.remark,
+        kll.status,
+        kllu.contacts,
+        kllu.phone,
+        kllu.firm_name    firmName,
+        kll.order_count   orderCount
+    </sql>
+    <sql id="pageList">
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
             kll.del_flag = 0
-              and kllu.unit_type = 1
-              and kllu.ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+              and kllu.unit_type = #{logisticsReq.unitType,jdbcType=INTEGER}
+              and kllu.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
             <if test="logisticsReq.status != null">
                 and kll.status = #{logisticsReq.status}
             </if>
@@ -107,55 +110,12 @@
             </if>
         </where>
         order by kll.generate_time desc
+    </sql>
+    <select id="shipperSelect" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
+        <include refid="pageList"/>
     </select>
     <select id="carrierSelect" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
-        from kwp_ledger_logistics kll
-                 inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
-        <where>
-            kll.del_flag = 0
-              and kllu.unit_type = 2
-              and kllu.ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
-            <if test="logisticsReq.status != null">
-                and kll.status = #{logisticsReq.status}
-            </if>
-            <if test="logisticsReq.trading != null">
-                and kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
-            </if>
-            <if test="logisticsReq.startCreateTime != null and logisticsReq.endCreateTime != null">
-                and kll.generate_time between #{logisticsReq.startCreateTime,jdbcType=TIMESTAMP}
-                    and #{logisticsReq.endCreateTime,jdbcType=TIMESTAMP}
-            </if>
-            <if test="logisticsReq.keywords != null and logisticsReq.keywords != ''">
-                and (
-                            kll.l_ledger_no like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kllu.firm_name like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
-                    )
-            </if>
-        </where>
-        order by kll.generate_time desc
+        <include refid="pageList"/>
     </select>
 
     <select id="countOrder" resultType="java.util.Map">
@@ -170,32 +130,12 @@
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         WHERE kll.del_flag = 0
           and kllu.unit_type = #{unitType,jdbcType=INTEGER}
-          and kllu.ent_id = #{entId,jdbcType=BIGINT}
+          and kllu.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
     </select>
 
     <select id="selectCarrierIds" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
@@ -209,33 +149,13 @@
         order by kll.generate_time desc
     </select>
     <select id="selectShipperIds" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
             kll.del_flag = 0
-              and kllu.unit_type = 1
+              and kllu.unit_type = 2
               and kll.id in
             <foreach collection="ids" item="id" close=")" open="(" separator=",">
                 #{id,jdbcType=BIGINT}
@@ -244,33 +164,13 @@
         order by kll.generate_time desc
     </select>
     <select id="selectId" resultType="com.sckw.payment.model.dto.LedgerLogisticsDto">
-        select kll.id,
-               kll.l_ledger_no   lLedgerNo,
-               kll.name,
-               kll.start_time    startTime,
-               kll.end_time      endTime,
-               kll.tax_rate      taxRate,
-               kll.trading,
-               kll.total_price   totalPrice,
-               kll.ex_tax_price  exTaxPrice,
-               kll.settle_price  settlePrice,
-               kll.actual_price  actualPrice,
-               kll.audit_phone   auditPhone,
-               kll.audit_user    auditUser,
-               kll.url,
-               kll.generate_time generateTime,
-               kll.receipt_time  receiptTime,
-               kll.remark,
-               kll.status,
-               kllu.contacts,
-               kllu.phone,
-               kllu.firm_name    firmName,
-               kll.order_count   orderCount
+        select
+        <include refid="list_col"/>
         from kwp_ledger_logistics kll
                  inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
         <where>
             kll.del_flag = 0
-              and kllu.unit_type = 1
+              and kllu.unit_type = #{unitType,jdbcType=INTEGER}
               and kll.id = #{id}
         </where>
     </select>

+ 85 - 145
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -58,83 +58,64 @@
         update_time,
         del_flag
     </sql>
-
-    <select id="pageSelect" resultType="com.sckw.payment.model.dto.LedgerTradeDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
-        from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
-        <where>
-            klt.del_flag = 0
-              and kltu.unit_type = 1
-            <if test="tradeReq.status != null">
-                and klt.status = #{tradeReq.status}
-            </if>
-            <if test="tradeReq.trading != null">
-                and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
-            </if>
-            <if test="tradeReq.startCreateTime != null and tradeReq.endCreateTime != null">
-                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP} and
-                    #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
-            </if>
-            <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
-                and (
-                            klt.t_ledger_no like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.firm_name like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.contacts like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                    )
-            </if>
-        </where>
-        order by klt.generate_time desc
-    </select>
+    <sql id="sell_col">
+         klt.id,
+        klt.t_ledger_no   tLedgerNo,
+        klt.name,
+        klt.start_time    startTime,
+        klt.end_time      endTime,
+        klt.tax_rate      taxRate,
+        klt.trading,
+        klt.total_price   totalPrice,
+        klt.ex_tax_price  exTaxPrice,
+        klt.settle_price  settlePrice,
+        klt.actual_price  actualPrice,
+        klt.audit_phone   auditPhone,
+        klt.audit_user    auditUser,
+        klt.url,
+        klt.generate_time generateTime,
+        klt.receipt_time  receiptTime,
+        klt.remark,
+        klt.status,
+        kltu.contacts,
+        kltu.phone,
+        kltu.firm_name    firmName,
+        klt.order_count   orderCount
+    </sql>
+    <sql id="purchase_col">
+        klt.id,
+        klt.t_ledger_no   tLedgerNo,
+        klt.name,
+        klt.start_time    startTime,
+        klt.end_time      endTime,
+        klt.tax_rate      taxRate,
+        klt.trading,
+        klt.total_price   totalPrice,
+        klt.ex_tax_price  exTaxPrice,
+        klt.settle_price  settlePrice,
+        klt.actual_price  actualPrice,
+        klt.audit_phone   auditPhone,
+        klt.audit_user    auditUser,
+        klt.url,
+        klt.generate_time generateTime,
+        klt.receipt_time  receiptTime,
+        klt.remark,
+        klt.status,
+        kltu.contacts,
+        kltu.phone,
+        kltu.firm_name    firmName,
+        klt.order_count   orderCount
+    </sql>
     <select id="sellList" resultType="com.sckw.payment.model.dto.LedgerSellDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
+        select
+        <include refid="sell_col"/>
         from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu
+        on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
         <where>
             klt.del_flag = 0
-              and kltu.unit_type = 2
+            and kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+            and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
             <if test="tradeReq.status != null">
                 and klt.status = #{tradeReq.status}
             </if>
@@ -142,63 +123,57 @@
                 and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
             </if>
             <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
-                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP} and
-                    #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
                 and (
-                            klt.t_ledger_no like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.firm_name like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.contacts like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
+                    klt.t_ledger_no like concat('%'
+                  , #{tradeReq.keywords,jdbcType=VARCHAR}
+                  , '%')
+                 or kltu.firm_name like concat('%'
+                  , #{tradeReq.keywords,jdbcType=VARCHAR}
+                  , '%')
+                 or kltu.contacts like concat('%'
+                  , #{tradeReq.keywords,jdbcType=VARCHAR}
+                  , '%')
                     )
             </if>
         </where>
         order by klt.generate_time desc
     </select>
     <select id="purchaseList" resultType="com.sckw.payment.model.dto.LedgerPurchaseDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
+        select
+        <include refid="purchase_col"/>
         from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        inner join kwp_ledger_trade_unit kltu
+        on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
         <where>
             klt.del_flag = 0
-              and kltu.unit_type = 1
+            and kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+            and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
             <if test="tradeReq.status != null">
                 and klt.status = #{tradeReq.status}
             </if>
             <if test="tradeReq.trading != null">
                 and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
             </if>
-            <if test="tradeReq.startCreateTime != null and tradeReq.endCreateTime != null">
-                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP} and
-                    #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+            <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
                 and (
-                            klt.t_ledger_no like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.firm_name like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                        or kltu.contacts like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
-                    )
+                klt.t_ledger_no like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                or kltu.firm_name like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                or kltu.contacts like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                )
             </if>
         </where>
         order by klt.generate_time desc
@@ -218,41 +193,6 @@
           and kltu.ent_id = #{entId,jdbcType=BIGINT}
     </select>
 
-    <select id="selectIds" resultType="com.sckw.payment.model.dto.LedgerTradeDto">
-        select klt.id,
-               klt.t_ledger_no   tLedgerNo,
-               klt.name,
-               klt.start_time    startTime,
-               klt.end_time      endTime,
-               klt.tax_rate      taxRate,
-               klt.trading,
-               klt.total_price   totalPrice,
-               klt.ex_tax_price  exTaxPrice,
-               klt.settle_price  settlePrice,
-               klt.actual_price  actualPrice,
-               klt.audit_phone   auditPhone,
-               klt.audit_user    auditUser,
-               klt.url,
-               klt.generate_time generateTime,
-               klt.receipt_time  receiptTime,
-               klt.remark,
-               klt.status,
-               kltu.contacts,
-               kltu.phone,
-               kltu.firm_name    firmName,
-               klt.order_count   orderCount
-        from kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
-        <where>
-            klt.del_flag = 0
-              and kltu.unit_type = 1
-              and klt.id in
-            <foreach collection="ids" item="id" close=")" open="(" separator=",">
-                #{id,jdbcType=BIGINT}
-            </foreach>
-        </where>
-        order by klt.generate_time desc
-    </select>
     <select id="selectSellIds" resultType="com.sckw.payment.model.dto.LedgerSellDto">
         select klt.id,
         klt.t_ledger_no   tLedgerNo,
@@ -350,7 +290,7 @@
                  inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
         <where>
             klt.del_flag = 0
-              and kltu.unit_type = 1
+              and kltu.unit_type = #{unitType,jdbcType=INTEGER}
               and klt.id = #{id,jdbcType=BIGINT}
         </where>
     </select>

+ 138 - 29
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -1,33 +1,142 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.payment.dao.KwpSettlementTradeMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementTrade">
-    <!--@mbg.generated-->
-    <!--@Table kwp_settlement_trade-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="ent_id" jdbcType="BIGINT" property="entId" />
-    <result column="t_ledger_id" jdbcType="BIGINT" property="tLedgerId" />
-    <result column="st_order_no" jdbcType="VARCHAR" property="stOrderNo" />
-    <result column="name" jdbcType="VARCHAR" property="name" />
-    <result column="total_price" jdbcType="DECIMAL" property="totalPrice" />
-    <result column="actual_price" jdbcType="DECIMAL" property="actualPrice" />
-    <result column="receipt_time" jdbcType="TIMESTAMP" property="receiptTime" />
-    <result column="audit_user" jdbcType="VARCHAR" property="auditUser" />
-    <result column="audit_phone" jdbcType="VARCHAR" property="auditPhone" />
-    <result column="success_user" jdbcType="VARCHAR" property="successUser" />
-    <result column="success_phone" jdbcType="VARCHAR" property="successPhone" />
-    <result column="remark" jdbcType="VARCHAR" property="remark" />
-    <result column="status" jdbcType="INTEGER" property="status" />
-    <result column="create_by" jdbcType="BIGINT" property="createBy" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
-    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, ent_id, t_ledger_id, st_order_no, `name`, total_price, actual_price, receipt_time, 
-    audit_user, audit_phone, success_user, success_phone, remark, `status`, create_by, 
-    create_time, update_by, update_time, del_flag
-  </sql>
+    <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementTrade">
+        <!--@mbg.generated-->
+        <!--@Table kwp_settlement_trade-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="ent_id" jdbcType="BIGINT" property="entId"/>
+        <result column="t_ledger_id" jdbcType="BIGINT" property="tLedgerId"/>
+        <result column="st_order_no" jdbcType="VARCHAR" property="stOrderNo"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="total_price" jdbcType="DECIMAL" property="totalPrice"/>
+        <result column="actual_price" jdbcType="DECIMAL" property="actualPrice"/>
+        <result column="receipt_time" jdbcType="TIMESTAMP" property="receiptTime"/>
+        <result column="audit_user" jdbcType="VARCHAR" property="auditUser"/>
+        <result column="audit_phone" jdbcType="VARCHAR" property="auditPhone"/>
+        <result column="success_user" jdbcType="VARCHAR" property="successUser"/>
+        <result column="success_phone" jdbcType="VARCHAR" property="successPhone"/>
+        <result column="remark" jdbcType="VARCHAR" property="remark"/>
+        <result column="status" jdbcType="INTEGER" property="status"/>
+        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id,
+        ent_id,
+        t_ledger_id,
+        st_order_no,
+        `name`,
+        total_price,
+        actual_price,
+        receipt_time,
+        audit_user,
+        audit_phone,
+        success_user,
+        success_phone,
+        remark,
+        `status`,
+        create_by,
+        create_time,
+        update_by,
+        update_time,
+        del_flag
+    </sql>
+    <sql id="query">
+        <where>
+            kst.del_flag = 0
+              and kltu.unit_type = #{settlementReq.unitType,jdbcType=INTEGER}
+            <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
+                and (
+                            klt.name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kltu.firm_name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+            <if test="settlementReq.status != null">
+                and kst.status = #{settlementReq.status,jdbcType=INTEGER}
+            </if>
+            <if test="settlementReq.startCreateTime != null and settlementReq.startCreateTime != '' and settlementReq.endCreateTime != null and settlementReq.endCreateTime != ''">
+                and kst.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="settlementReq.startReceiptTime != null and settlementReq.startReceiptTime != '' and settlementReq.endReceiptTime != null and settlementReq.endReceiptTime != ''">
+                and kst.receipt_time between #{settlementReq.startReceiptTime,jdbcType=TIMESTAMP} and #{settlementReq.endReceiptTime,jdbcType=TIMESTAMP}
+            </if>
+        </where>
+    </sql>
+    <select id="pageSelect" resultType="com.sckw.payment.model.dto.SettlementTradeDto">
+        select kst.id,
+               kst.status,
+               kst.st_order_no,
+               kst.create_time,
+               kst.receipt_time,
+               cast(kst.actual_price as char)                     actualPrice,
+               cast(kst.total_price as char)                      totalPrice,
+               cast((kst.total_price - kst.actual_price) as char) waitPrice,
+               kst.audit_user,
+               kst.audit_phone,
+               kst.success_user,
+               kst.success_phone,
+               kst.create_time,
+               klt.name,
+               klt.trading,
+               kltu.firm_name
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <include refid="query"/>
+        order by kst.create_time desc
+    </select>
+
+    <select id="sumMoney" resultType="com.sckw.payment.model.vo.res.SettlementSumVo">
+        select count(1)                                                allCount,
+               IFNULL(sum(kst.total_price), 0)                         receiveAll,
+               IFNULL(sum(kst.actual_price), 0)                        alreadyReceive,
+               IFNULL(sum(kst.total_price) - sum(kst.actual_price), 0) waitReceive
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <include refid="query"/>
+    </select>
+    <select id="countOrder" resultType="com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo">
+        select count(1)                           allCount,
+               count(if(kst.status = 3, 1, null)) allPaymentCount,
+               count(if(kst.status = 2, 1, null)) partialPaymentCount,
+               count(if(kst.status = 1, 1, null)) waitingPaymentCount
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <include refid="query"/>
+    </select>
+
+    <select id="selectByIds" resultType="com.sckw.payment.model.dto.SettlementTradeDto">
+        select kst.id,
+               kst.status,
+               kst.st_order_no,
+               kst.create_time,
+               kst.receipt_time,
+               cast(kst.actual_price as char)                     actualPrice,
+               cast(kst.total_price as char)                      totalPrice,
+               cast((kst.total_price - kst.actual_price) as char) waitPrice,
+               kst.audit_user,
+               kst.audit_phone,
+               kst.success_user,
+               kst.success_phone,
+               kst.create_time,
+               klt.name,
+               klt.trading,
+               kltu.firm_name
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <where>
+            kst.id in
+            <foreach collection="ids" open="(" close=")" item="item">
+                #{item,jdbcType=BIGINT}
+            </foreach>
+        </where>
+    </select>
 </mapper>