xucaiqin 2 лет назад
Родитель
Сommit
cdff31b257
18 измененных файлов с 1145 добавлено и 123 удалено
  1. 5 0
      sckw-modules/sckw-payment/pom.xml
  2. 149 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java
  3. 7 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  4. 21 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerLogistics.java
  5. 46 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTrade.java
  6. 34 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementLogistics.java
  7. 36 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LedgerLicEnum.java
  8. 148 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerLogisticsDto.java
  9. 21 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerReq.java
  10. 24 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java
  11. 31 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsConfirmReq.java
  12. 29 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsReq.java
  13. 105 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java
  14. 8 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogVo.java
  15. 166 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsVo.java
  16. 172 29
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  17. 135 54
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  18. 8 2
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

+ 5 - 0
sckw-modules/sckw-payment/pom.xml

@@ -54,6 +54,11 @@
             <artifactId>sckw-system-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-excel</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 149 - 6
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java

@@ -1,13 +1,156 @@
 package com.sckw.payment.controller;
+
+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.dto.LedgerLogisticsDto;
+import com.sckw.payment.model.vo.req.*;
+import com.sckw.payment.model.vo.res.LedgerLogisticsVo;
+import com.sckw.payment.service.KwpLedgerLogisticsService;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
-* 对账-物流订单
-*
-* @author xucaiqin
-*/
+ * 对账-物流订单
+ *
+ * @author xucaiqin
+ */
 @RestController
-@RequestMapping("/kwp_ledger_logistics")
+@RequestMapping("/kwpLedger")
 public class KwpLedgerLogisticsController {
-    
+    @Resource
+    private KwpLedgerLogisticsService kwpLedgerLogisticsService;
+
+    /**
+     * 物流对账单-发起对账(保存草稿)
+     *
+     * @param logisticsReq
+     * @return
+     */
+    @PostMapping("logistics/sendDraft")
+    public HttpResult sendDraft(@RequestBody @Valid LogisticsSendReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.sendLedgerDraft(logisticsReq));
+    }
+
+    /**
+     * 物流对账单-发起对账
+     *
+     * @param logisticsReq
+     * @return
+     */
+    @PostMapping("logistics/send")
+    public HttpResult send(@RequestBody @Valid LogisticsSendReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.sendLedger(logisticsReq));
+    }
+
+    /**
+     * 物流对账单列表查询
+     *
+     * @param logisticsReq
+     * @return
+     */
+    @PostMapping("logistics/pageList")
+    public HttpResult pageList(@RequestBody @Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.pageList(logisticsReq));
+    }
+
+    /**
+     * 删除对账单
+     *
+     * @param id
+     * @return
+     */
+    @DeleteMapping("logistics/delete")
+    public HttpResult delete(@RequestParam("id") Long id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.remove(id));
+    }
+
+    /**
+     * 物流对账单-撤回对账
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("logistics/back")
+    public HttpResult back(@RequestParam("id") Long id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.backOrder(id));
+    }
+
+    /**
+     * 物流对账单-对账确认
+     *
+     * @param confirmReq
+     * @return
+     */
+    @PostMapping("logistics/confirm")
+    public HttpResult confirm(@RequestBody @Valid LogisticsConfirmReq confirmReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.confirmOrder(confirmReq));
+    }
+
+    /**
+     * 物流对账单-驳回查询
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("logistics/queryBack")
+    public HttpResult queryBack(@RequestParam("id") Long id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryBack(id));
+    }
+
+    /**
+     * 物流对账单-驳回
+     *
+     * @param ledgerReq
+     * @return
+     */
+    @PostMapping("logistics/doBack")
+    public HttpResult doBack(@RequestBody @Valid LedgerReq ledgerReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.doBack(ledgerReq));
+    }
+
+    /**
+     * 物流对账单-对账完成
+     * <p>
+     * 生成结算单
+     * </p>
+     *
+     * @param ledgerReq
+     * @return
+     */
+    @PostMapping("logistics/success")
+    public HttpResult orderSuccess(@RequestBody @Valid LedgerSuccessReq ledgerReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.orderSuccess(ledgerReq));
+    }
+
+    /**
+     * 导出
+     *
+     * @param response
+     * @param logisticsReq
+     * @return
+     */
+    @PostMapping("logistics/export")
+    public HttpResult export(HttpServletResponse response, @RequestBody LogisticsReq logisticsReq) {
+        PageRes<LedgerLogisticsDto> pageResult = kwpLedgerLogisticsService.pageList(logisticsReq);
+        List<LedgerLogisticsDto> list = pageResult.getList();
+        if (CollectionUtils.isEmpty(list)) {
+            return HttpResult.error("没有可导出的数据");
+        }
+        List<LedgerLogisticsVo> collect = list.stream().map(a -> {
+            LedgerLogisticsVo ledgerLogisticsVo = new LedgerLogisticsVo();
+            BeanUtils.copyProperties(a, ledgerLogisticsVo);
+            return ledgerLogisticsVo;
+        }).collect(Collectors.toList());
+
+        ExcelUtil.download(response, LedgerLogisticsVo.class, collect);
+        return null;
+    }
 }

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

@@ -11,10 +11,15 @@ import java.util.List;
 
 /**
  * @author xucaiqin
- * @date 2023-07-11 13:41:43
+ * @date 2023-07-11 15:17:12
  */
 
 @Mapper
 public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics> {
-    List<LedgerLogisticsDto> pageSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
+    /**
+     * @param logisticsReq
+     * @param ids          客户单位id
+     * @return
+     */
+    List<LedgerLogisticsDto> pageSelect(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("ids") List<Long> ids);
 }

+ 21 - 12
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerLogistics.java

@@ -11,13 +11,10 @@ import lombok.ToString;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
-/**
- * @author xucaiqin
- * @date 2023-07-11 13:41:43
- */
-
 /**
  * 对账-物流订单
+ * @author xucaiqin
+ * @date 2023-07-11 15:17:12
  */
 @Getter
 @Setter
@@ -76,7 +73,7 @@ public class KwpLedgerLogistics {
      * 发票税率(%)
      */
     @TableField(value = "tax_rate")
-    private BigDecimal taxRate;
+    private String taxRate;
 
     /**
      * 交易方式(预付款、货到付款)
@@ -126,6 +123,12 @@ public class KwpLedgerLogistics {
     @TableField(value = "actual_price")
     private BigDecimal actualPrice;
 
+    /**
+     * 托运方联系人
+     */
+    @TableField(value = "check_user")
+    private String checkUser;
+
     /**
      * 托运方电话
      */
@@ -133,10 +136,10 @@ public class KwpLedgerLogistics {
     private String checkPhone;
 
     /**
-     * 运方联系人
+     * 运方联系人
      */
-    @TableField(value = "check_user")
-    private String checkUser;
+    @TableField(value = "carrier_user")
+    private String carrierUser;
 
     /**
      * 承运方电话
@@ -145,10 +148,16 @@ public class KwpLedgerLogistics {
     private String carrierPhone;
 
     /**
-     * 承运方联系人
+     * 审核人联系方式(采购方)
      */
-    @TableField(value = "carrier_user")
-    private String carrierUser;
+    @TableField(value = "audit_user")
+    private String auditUser;
+
+    /**
+     * 审核人电话(采购方)
+     */
+    @TableField(value = "audit_phone")
+    private String auditPhone;
 
     /**
      * 对账清单凭证

+ 46 - 12
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTrade.java

@@ -4,19 +4,17 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
 
-/**
- * @author xucaiqin
- * @date 2023-07-10 16:42:20
- */
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
 
 /**
  * 对账-交易订单
+ * @author xucaiqin
+ * @date 2023-07-11 10:10:47
  */
 @Getter
 @Setter
@@ -47,6 +45,15 @@ public class KwpLedgerTrade {
     @TableField(value = "supply_ent_id")
     private Long supplyEntId;
 
+    /**
+     * 交易对账单编号
+     */
+    @TableField(value = "t_ledger_no")
+    private String tLedgerNo;
+
+    /**
+     * 对账单名称
+     */
     @TableField(value = "`name`")
     private String name;
 
@@ -62,12 +69,6 @@ public class KwpLedgerTrade {
     @TableField(value = "end_time")
     private LocalDateTime endTime;
 
-    /**
-     * 对账金额
-     */
-    @TableField(value = "price")
-    private BigDecimal price;
-
     /**
      * 发票税率(%)
      */
@@ -86,12 +87,42 @@ public class KwpLedgerTrade {
     @TableField(value = "total_price")
     private BigDecimal totalPrice;
 
+    /**
+     * 实际计算金额
+     */
+    @TableField(value = "settle_price")
+    private BigDecimal settlePrice;
+
     /**
      * 已收款/元
      */
     @TableField(value = "actual_price")
     private BigDecimal actualPrice;
 
+    /**
+     * 采购方联系人
+     */
+    @TableField(value = "procure_user")
+    private String procureUser;
+
+    /**
+     * 采购方联系电话
+     */
+    @TableField(value = "procure_phone")
+    private String procurePhone;
+
+    /**
+     * 供应方联系人
+     */
+    @TableField(value = "supply_user")
+    private String supplyUser;
+
+    /**
+     * 供应方联系电话
+     */
+    @TableField(value = "supply_phone")
+    private String supplyPhone;
+
     /**
      * 对账清单凭证
      */
@@ -113,6 +144,9 @@ public class KwpLedgerTrade {
     @TableField(value = "create_by")
     private Long createBy;
 
+    /**
+     * 创建时间
+     */
     @TableField(value = "create_time")
     private LocalDateTime createTime;
 

+ 34 - 6
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementLogistics.java

@@ -4,19 +4,17 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
 
-/**
- * @author xucaiqin
- * @date 2023-07-10 16:42:20
- */
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
 
 /**
  * 结算-物流订单
+ * @author xucaiqin
+ * @date 2023-07-10 16:42:20
  */
 @Getter
 @Setter
@@ -62,12 +60,42 @@ public class KwpSettlementLogistics {
     @TableField(value = "actual_price")
     private BigDecimal actualPrice;
 
+    /**
+     * 预计收款日期
+     */
+    @TableField(value = "receipt_time")
+    private LocalDateTime receiptTime;
+
     /**
      * 备注
      */
     @TableField(value = "remark")
     private String remark;
 
+    /**
+     * 对账审核人名称
+     */
+    @TableField(value = "audit_user")
+    private String auditUser;
+
+    /**
+     * 对账审核人电话
+     */
+    @TableField(value = "audit_phone")
+    private String auditPhone;
+
+    /**
+     * 对账完成人名称
+     */
+    @TableField(value = "success_user")
+    private String successUser;
+
+    /**
+     * 对账完成人电话
+     */
+    @TableField(value = "success_phone")
+    private String successPhone;
+
     /**
      * 状态(待回款、部分回款、全部回款、回退)
      */

+ 36 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LedgerLicEnum.java

@@ -0,0 +1,36 @@
+package com.sckw.payment.model.constant;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-11 12:00:52
+ */
+public enum LedgerLicEnum {
+    SAVE(1, "已保存"),
+    TO_LEDGER(2, "待对账"),
+    LEDGERED(3, "已对账"),
+    SUCCESS(4, "已完成"),
+    BACK(5, "已退回");
+    private int status;
+    private String desc;
+
+    LedgerLicEnum(int status, String desc) {
+        this.status = status;
+        this.desc = desc;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+}

+ 148 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerLogisticsDto.java

@@ -0,0 +1,148 @@
+package com.sckw.payment.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 对账-物流订单
+ *
+ * @author xucaiqin
+ * @date 2023-07-10 18:11:24
+ */
+@Getter
+@Setter
+public class LedgerLogisticsDto {
+    /**
+     * 主键
+     */
+    private Long id;
+    /**
+     * 物流对账单编号
+     */
+    private String lLedgerNo;
+
+    /**
+     * 对账单名称
+     */
+    private String name;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 托运单位
+     */
+    private Long checkEntId;
+
+    /**
+     * 承运单位
+     */
+    private Long carrierEntId;
+
+
+    /**
+     * 开始日期
+     */
+    private LocalDateTime startTime;
+
+    /**
+     * 结束日期
+     */
+    private LocalDateTime endTime;
+
+    /**
+     * 对账金额
+     */
+    private BigDecimal price;
+
+    /**
+     * 发票税率(%)
+     */
+    private BigDecimal taxRate;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    private String trading;
+
+    /**
+     * 卸货量
+     */
+    private BigDecimal unloadAmount;
+
+    /**
+     * 装货量
+     */
+    private BigDecimal loadAmount;
+
+    /**
+     * 亏损量
+     */
+    private BigDecimal deficitAmount;
+
+    /**
+     * 合理损耗量
+     */
+    private BigDecimal loseAmount;
+
+    /**
+     * 总应收/元
+     */
+    private BigDecimal totalPrice;
+
+    /**
+     * 实际结算金额
+     */
+    private BigDecimal settlePrice;
+
+    /**
+     * 已收款/元
+     */
+    private BigDecimal actualPrice;
+
+    /**
+     * 对账审核人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 对账审核人名称
+     */
+    private String auditUser;
+
+    /**
+     * 对账清单凭证
+     */
+    private String url;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
+     */
+    private Integer status;
+
+    private Long createBy;
+
+    private LocalDateTime createTime;
+
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 订单数量
+     */
+    private Long orderCount;
+}

+ 21 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerReq.java

@@ -0,0 +1,21 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-10 17:05:28
+ */
+@Getter
+@Setter
+public class LedgerReq {
+    @NotNull(message = "物流对账单id不能为空")
+    private Long id;
+    @NotBlank(message = "驳回原因不能为空")
+    @Size(max = 400, message = "最大不能超过400字符")
+    private String remark;
+}

+ 24 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java

@@ -0,0 +1,24 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 对账完成
+ *
+ * @author xucaiqin
+ * @date 2023-07-10 17:05:28
+ */
+@Getter
+@Setter
+public class LedgerSuccessReq {
+    @NotNull(message = "物流对账单id不能为空")
+    private Long id;
+    @NotBlank(message = "财务联系人不能为空")
+    private String successUser;
+    @NotBlank(message = "财务联系电话不能为空")
+    private String successPhone;
+
+}

+ 31 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsConfirmReq.java

@@ -0,0 +1,31 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 对账确认
+ *
+ * @author xucaiqin
+ * @date 2023-07-10 17:05:28
+ */
+@Getter
+@Setter
+public class LogisticsConfirmReq {
+    @NotNull(message = "id不能为空")
+    private Long id;
+    /**
+     * 对账审核人
+     */
+    @NotBlank(message = "对账审核人不能为空")
+    private String auditUser;
+    /**
+     * 对账审核人联系方式
+     */
+    @NotBlank(message = "对账审核人联系方式为空")
+    private String auditPhone;
+    @NotBlank(message = "对账清单凭证不能为空")
+    private String url;
+}

+ 29 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsReq.java

@@ -0,0 +1,29 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.core.model.vo.BasePara;
+import com.sckw.payment.model.constant.LedgerLicEnum;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-10 17:05:28
+ */
+@Getter
+@Setter
+public class LogisticsReq extends BasePara {
+    @Serial
+    private static final long serialVersionUID = 5328731681168692784L;
+    private LocalDateTime startCreateTime;
+    private LocalDateTime endCreateTime;
+    private Integer trading;
+    /**
+     * @see LedgerLicEnum
+     */
+    private Integer status;
+    private List<Long> ids;
+}

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

@@ -0,0 +1,105 @@
+package com.sckw.payment.model.vo.req;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.PositiveOrZero;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-10 17:05:28
+ */
+@Getter
+@Setter
+public class LogisticsSendReq {
+
+    private Long id;
+    /**
+     * 托运单位(客户单位)
+     */
+    @NotNull(message = "客户单位不能为空")
+    private Long checkEntId;
+
+    /**
+     * 承运单位
+     */
+    private Long carrierEntId;
+    /**
+     * 名称
+     */
+    @NotBlank(message = "对账表名称不能为空")
+    private String name;
+    /**
+     * 开始日期
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @NotNull(message = "计划开始日期不能为空")
+    private LocalDateTime startTime;
+    /**
+     * 结束日期
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @NotNull(message = "计划结束日期不能为空")
+    private LocalDateTime endTime;
+    /**
+     * 实际结算金额
+     */
+    @NotNull(message = "实际结算金额不能为空")
+    @PositiveOrZero(message = "实际结算金额必须大于等于0")
+    private BigDecimal settlePrice;
+    /**
+     * 发票税率(%)
+     */
+    @NotBlank(message = "发票税率(%)不能为空")
+    private String taxRate;
+    /**
+     * 交易方式
+     */
+    @NotNull(message = "付款方式不能为空")
+    private Integer trading;
+    /**
+     * 卸货量
+     */
+    private BigDecimal unloadAmount;
+    /**
+     * 装货量
+     */
+    private BigDecimal loadAmount;
+    /**
+     * 亏损量
+     */
+    private BigDecimal deficitAmount;
+    /**
+     * 合理损耗量
+     */
+    private BigDecimal loseAmount;
+    /**
+     * 总应收/元
+     */
+    @NotNull(message = "总应收不能为空")
+    @PositiveOrZero(message = "总应收必须大于等于0")
+    private BigDecimal totalPrice;
+    /**
+     * 已收款/元
+     */
+    private BigDecimal actualPrice;
+    /**
+     * 备注
+     */
+    @Size(max = 200, message = "备注不能超过200字")
+    private String remark;
+    /**
+     * 承运订单
+     */
+    private List<Long> ids;
+}

+ 8 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogVo.java

@@ -0,0 +1,8 @@
+package com.sckw.payment.model.vo.res;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-10 17:04:51
+ */
+public class LedgerLogVo {
+}

+ 166 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsVo.java

@@ -0,0 +1,166 @@
+package com.sckw.payment.model.vo.res;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 对账-物流订单
+ *
+ * @author xucaiqin
+ * @date 2023-07-11 15:17:12
+ */
+@Getter
+@Setter
+@ExcelContext(fileName = "物流对账单表", sheetName = "物流对账单表")
+public class LedgerLogisticsVo {
+    /**
+     * 主键
+     */
+    @ExcelProperty(value = "id")
+    private Long id;
+    /**
+     * 物流对账单编号
+     */
+    //@ExcelProperty(value = "物流对账单编号")
+    private String lLedgerNo;
+
+    /**
+     * 对账单名称
+     */
+    //@ExcelProperty(value = "对账单名称")
+    private String name;
+
+    /**
+     * 企业id
+     */
+    //@ExcelProperty(value = "企业id")
+    private Long entId;
+
+    /**
+     * 托运单位
+     */
+    //@ExcelProperty(value = "托运单位")
+    private Long checkEntId;
+
+    /**
+     * 承运单位
+     */
+    //@ExcelProperty(value = "承运单位")
+    private Long carrierEntId;
+
+
+    /**
+     * 开始日期
+     */
+    //@ExcelProperty(value = "开始日期")
+    private LocalDateTime startTime;
+
+    /**
+     * 结束日期
+     */
+    //@ExcelProperty(value = "结束日期")
+    private LocalDateTime endTime;
+
+    /**
+     * 对账金额
+     */
+    //@ExcelProperty(value = "对账金额")
+    private BigDecimal price;
+
+    /**
+     * 发票税率(%)
+     */
+    //@ExcelProperty(value = "发票税率(%)")
+    private BigDecimal taxRate;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    //@ExcelProperty(value = "交易方式")
+    private String trading;
+
+    /**
+     * 卸货量
+     */
+    //@ExcelProperty(value = "卸货量")
+    private BigDecimal unloadAmount;
+
+    /**
+     * 装货量
+     */
+    //@ExcelProperty(value = "装货量")
+    private BigDecimal loadAmount;
+
+    /**
+     * 亏损量
+     */
+    //@ExcelProperty(value = "亏损量")
+    private BigDecimal deficitAmount;
+
+    /**
+     * 合理损耗量
+     */
+    //@ExcelProperty(value = "合理损耗量")
+    private BigDecimal loseAmount;
+
+    /**
+     * 总应收/元
+     */
+    private BigDecimal totalPrice;
+
+    /**
+     * 实际结算金额
+     */
+    private BigDecimal settlePrice;
+
+    /**
+     * 已收款/元
+     */
+    private BigDecimal actualPrice;
+
+    /**
+     * 对账审核人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 对账审核人名称
+     */
+    private String auditUser;
+
+    /**
+     * 对账清单凭证
+     */
+    private String url;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
+     */
+    private Integer status;
+
+    private Long createBy;
+
+    private LocalDateTime createTime;
+
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 订单数量
+     */
+    private Long orderCount;
+}

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

@@ -1,22 +1,23 @@
 package com.sckw.payment.service;
 
+import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.sckw.core.model.page.PageHelperUtil;
-import com.sckw.core.model.page.PageResult;
+import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.payment.dao.KwpLedgerLogisticsMapper;
 import com.sckw.payment.dao.KwpLedgerLogisticsOrderMapper;
 import com.sckw.payment.dao.KwpLedgerLogisticsTrackMapper;
+import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
 import com.sckw.payment.model.KwpLedgerLogistics;
 import com.sckw.payment.model.KwpLedgerLogisticsOrder;
 import com.sckw.payment.model.KwpLedgerLogisticsTrack;
+import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.payment.model.constant.LedgerLicEnum;
 import com.sckw.payment.model.dto.LedgerLogisticsDto;
-import com.sckw.payment.model.vo.req.LedgerReq;
-import com.sckw.payment.model.vo.req.LogisticsReq;
-import com.sckw.payment.model.vo.req.LogisticsSendReq;
+import com.sckw.payment.model.vo.req.*;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
@@ -24,7 +25,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @author xucaiqin
@@ -37,8 +40,15 @@ public class KwpLedgerLogisticsService {
     private final KwpLedgerLogisticsMapper logisticsMapper;
     private final KwpLedgerLogisticsTrackMapper logisticsTrackMapper;
     private final KwpLedgerLogisticsOrderMapper logisticsOrderMapper;
+    private final KwpSettlementLogisticsMapper settlementLogisticsMapper;
 
-    public PageResult pageList(LogisticsReq logisticsReq) {
+    /**
+     * 分页查询物流对账单列表
+     *
+     * @param logisticsReq 查询参数
+     * @return
+     */
+    public PageRes<LedgerLogisticsDto> pageList(LogisticsReq logisticsReq) {
         //todo 查询缓存,获取客户企业id
         String keywords = logisticsReq.getKeywords();
         if (StringUtils.isNotBlank(keywords)) {
@@ -46,17 +56,36 @@ public class KwpLedgerLogisticsService {
         }
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
 
-        List<LedgerLogisticsDto> kwpLedgerLogisticsList = logisticsMapper.pageSelect(logisticsReq);
+        List<LedgerLogisticsDto> kwpLedgerLogisticsList = logisticsMapper.pageSelect(logisticsReq, new ArrayList<>());
 
-        return PageHelperUtil.getPageResult(new PageInfo<>(kwpLedgerLogisticsList));
+        return new PageRes<>(new PageInfo<>(kwpLedgerLogisticsList));
     }
 
-    public Object sendLedger(LogisticsSendReq logisticsReq) {
-        return null;
+    /**
+     * 保存物流对账单
+     *
+     * @param logisticsReq
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public String sendLedger(LogisticsSendReq logisticsReq) {
+        Long id = logisticsReq.getId();
+        if (Objects.isNull(id)) {
+            //新增
+        } else {
+            //修改
+        }
+        return "新增对账单成功";
     }
 
+    /**
+     * 保存物流对账单草稿
+     *
+     * @param logisticsReq
+     * @return
+     */
     @Transactional(rollbackFor = Exception.class)
-    public Object sendLedgerDraft(LogisticsSendReq logisticsReq) {
+    public String sendLedgerDraft(LogisticsSendReq logisticsReq) {
         /*插入物流对账单*/
         KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
         kwpLedgerLogistics.setId(new IdWorker(1).nextId());
@@ -67,49 +96,88 @@ public class KwpLedgerLogisticsService {
         kwpLedgerLogistics.setName(logisticsReq.getName());
         kwpLedgerLogistics.setStartTime(logisticsReq.getStartTime());
         kwpLedgerLogistics.setEndTime(logisticsReq.getEndTime());
-        kwpLedgerLogistics.setTaxRate(new BigDecimal("0"));//todo
-        kwpLedgerLogistics.setTrading(logisticsReq.getTrading());//todo
+        kwpLedgerLogistics.setTaxRate(logisticsReq.getTaxRate());//todo 发票税率数据库字段类型
+        kwpLedgerLogistics.setTrading(logisticsReq.getTrading());
+        kwpLedgerLogistics.setTotalPrice(logisticsReq.getTotalPrice());
+        kwpLedgerLogistics.setSettlePrice(logisticsReq.getSettlePrice());
         //todo 查询运单
 
         kwpLedgerLogistics.setUnloadAmount(new BigDecimal("0"));
         kwpLedgerLogistics.setLoadAmount(new BigDecimal("0"));
         kwpLedgerLogistics.setDeficitAmount(new BigDecimal("0"));
         kwpLedgerLogistics.setLoseAmount(new BigDecimal("0"));
-        kwpLedgerLogistics.setTotalPrice(logisticsReq.getTotalPrice());
-        kwpLedgerLogistics.setSettlePrice(logisticsReq.getSettlePrice());
         kwpLedgerLogistics.setActualPrice(new BigDecimal("0"));
-        kwpLedgerLogistics.setCheckPhone("");//取承运订单的第一条数据
+        kwpLedgerLogistics.setCheckPhone("");//todo 取配置的数据
         kwpLedgerLogistics.setCheckUser("");
         kwpLedgerLogistics.setCarrierPhone("");
         kwpLedgerLogistics.setCarrierUser("");
         kwpLedgerLogistics.setGenerateTime(null);
         kwpLedgerLogistics.setUrl("");
         kwpLedgerLogistics.setRemark(logisticsReq.getRemark());
-        kwpLedgerLogistics.setStatus(0);
-        kwpLedgerLogistics.setCreateBy(0L);
+        kwpLedgerLogistics.setStatus(LedgerLicEnum.SAVE.getStatus());
+        kwpLedgerLogistics.setCreateBy(0L);//todo
         kwpLedgerLogistics.setCreateTime(LocalDateTime.now());
         kwpLedgerLogistics.setUpdateBy(0L);
         kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
         kwpLedgerLogistics.setDelFlag(0);
         logisticsMapper.insert(kwpLedgerLogistics);
         /*插入对账关联物流运单*/
-        logisticsOrderMapper.insert(new KwpLedgerLogisticsOrder());
-        return null;
+        List<Long> ids = logisticsReq.getIds();
+        for (Long id : ids) {
+            KwpLedgerLogisticsOrder kwpLedgerLogisticsOrder = new KwpLedgerLogisticsOrder();
+            kwpLedgerLogisticsOrder.setId(new IdWorker(1).nextId());
+            kwpLedgerLogisticsOrder.setLLedgerId(kwpLedgerLogistics.getId());
+            kwpLedgerLogisticsOrder.setLOrderId(id);
+            kwpLedgerLogisticsOrder.setRemark("");
+            kwpLedgerLogisticsOrder.setStatus(0);
+            logisticsOrderMapper.insert(kwpLedgerLogisticsOrder);
+        }
+        return "保存成功";
     }
 
-
+    /**
+     * 删除物流对账单
+     *
+     * @param id 物流对账单id
+     * @return
+     */
     public Integer remove(Long id) {
-        return logisticsMapper.deleteById(id);
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        if (Objects.isNull(kwpLedgerLogistics)) {
+            throw new BusinessException("对账单不存在!");
+        }
+        List<Integer> objects = Lists.newArrayList(LedgerLicEnum.BACK.getStatus(), LedgerLicEnum.SAVE.getStatus());
+        if (!objects.contains(kwpLedgerLogistics.getStatus())) {
+            throw new BusinessException("只有【已保存】和【已退回】的单据才支持删除!");
+        }
+        kwpLedgerLogistics.setDelFlag(1);
+        return logisticsMapper.updateById(kwpLedgerLogistics);
     }
 
-    public String backOrder(Long id) {
-        KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
-        kwpLedgerLogistics.setId(id);
-        kwpLedgerLogistics.setStatus(LedgerLicEnum.CANCEL.getStatus());
-        logisticsMapper.updateById(kwpLedgerLogistics);
-        return null;
+    /**
+     * 撤回物流对账单
+     *
+     * @param id 物流对账单id
+     * @return
+     */
+    public Integer backOrder(Long id) {
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(id);
+        if (Objects.isNull(kwpLedgerLogistics)) {
+            throw new BusinessException("对账单不存在!");
+        }
+        if (LedgerLicEnum.TO_LEDGER.getStatus() != kwpLedgerLogistics.getStatus()) {
+            throw new BusinessException("只有【待对账】的单据才支持撤销!");
+        }
+        kwpLedgerLogistics.setStatus(LedgerLicEnum.BACK.getStatus());
+        return logisticsMapper.updateById(kwpLedgerLogistics);
     }
 
+    /**
+     * 查询物流对账单驳回记录
+     *
+     * @param id 物流对账单id
+     * @return 物流对账单驳回记录
+     */
     public List<KwpLedgerLogisticsTrack> queryBack(Long id) {
         LambdaQueryWrapper<KwpLedgerLogisticsTrack> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(KwpLedgerLogisticsTrack::getLLedgerId, id);
@@ -117,13 +185,88 @@ public class KwpLedgerLogisticsService {
         return logisticsTrackMapper.selectList(wrapper);
     }
 
+    /**
+     * 驳回物流对账单
+     *
+     * @param ledgerReq 驳回参数
+     * @return
+     */
     public Integer doBack(LedgerReq ledgerReq) {
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(ledgerReq.getId());
+        if (Objects.isNull(kwpLedgerLogistics)) {
+            throw new BusinessException("对账单不存在!");
+        }
         KwpLedgerLogisticsTrack kwpLedgerLogisticsTrack = new KwpLedgerLogisticsTrack();
         kwpLedgerLogisticsTrack.setId(new IdWorker(1).nextId());
         kwpLedgerLogisticsTrack.setLLedgerId(ledgerReq.getId());
         kwpLedgerLogisticsTrack.setRemark(ledgerReq.getRemark());
         kwpLedgerLogisticsTrack.setStatus(0);
-
         return logisticsTrackMapper.insert(kwpLedgerLogisticsTrack);
     }
+
+    /**
+     * 对账确认
+     * 订单变更为已对账
+     *
+     * @param confirmReq
+     * @return
+     */
+    public Integer confirmOrder(LogisticsConfirmReq confirmReq) {
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(confirmReq.getId());
+        if (Objects.isNull(kwpLedgerLogistics)) {
+            throw new BusinessException("对账单不存在!");
+        }
+        kwpLedgerLogistics.setStatus(LedgerLicEnum.LEDGERED.getStatus());
+        kwpLedgerLogistics.setAuditPhone(confirmReq.getAuditPhone());
+        kwpLedgerLogistics.setAuditUser(confirmReq.getAuditUser());
+        kwpLedgerLogistics.setUrl(confirmReq.getUrl());
+        kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
+        return logisticsMapper.updateById(kwpLedgerLogistics);
+    }
+
+    /**
+     * 对账完成
+     *
+     * @param ledgerReq
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public String orderSuccess(LedgerSuccessReq ledgerReq) {
+        KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(ledgerReq.getId());
+        if (Objects.isNull(kwpLedgerLogistics)) {
+            throw new BusinessException("对账单不存在!");
+        }
+        if (LedgerLicEnum.LEDGERED.getStatus() != kwpLedgerLogistics.getStatus()) {
+            throw new BusinessException("只有【已对账】的订单支持完成对账!");
+        }
+        kwpLedgerLogistics.setStatus(LedgerLicEnum.SUCCESS.getStatus());
+        kwpLedgerLogistics.setAuditPhone(ledgerReq.getSuccessPhone());
+        kwpLedgerLogistics.setAuditUser(ledgerReq.getSuccessUser());
+        kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
+        logisticsMapper.updateById(kwpLedgerLogistics);
+        //生成结算单
+        KwpSettlementLogistics kwpSettlementLogistics = new KwpSettlementLogistics();
+        kwpSettlementLogistics.setId(new IdWorker(1).nextId());
+        kwpSettlementLogistics.setEntId(0L);//todo
+        kwpSettlementLogistics.setLLedgerId(kwpLedgerLogistics.getId());
+        kwpSettlementLogistics.setSlOrderNo(String.valueOf(new IdWorker(1).nextId()));//todo
+        kwpSettlementLogistics.setName(kwpLedgerLogistics.getName());//取物流对账单名称
+        kwpSettlementLogistics.setTotalPrice(kwpLedgerLogistics.getTotalPrice());
+        kwpSettlementLogistics.setActualPrice(kwpLedgerLogistics.getActualPrice());
+        kwpSettlementLogistics.setReceiptTime(LocalDateTime.now());
+        kwpSettlementLogistics.setRemark("");
+        kwpSettlementLogistics.setAuditUser(kwpLedgerLogistics.getAuditUser());
+        kwpSettlementLogistics.setAuditPhone(kwpLedgerLogistics.getAuditPhone());
+        kwpSettlementLogistics.setSuccessUser(ledgerReq.getSuccessUser());
+        kwpSettlementLogistics.setSuccessPhone(ledgerReq.getSuccessPhone());
+        kwpSettlementLogistics.setStatus(0);
+        kwpSettlementLogistics.setCreateBy(0L);
+        kwpSettlementLogistics.setCreateTime(LocalDateTime.now());
+        kwpSettlementLogistics.setUpdateBy(0L);
+        kwpSettlementLogistics.setUpdateTime(LocalDateTime.now());
+        kwpSettlementLogistics.setDelFlag(0);
+
+        settlementLogisticsMapper.insert(kwpSettlementLogistics);
+        return "对账完成";
+    }
 }

+ 135 - 54
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -1,64 +1,145 @@
 <?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.KwpLedgerLogisticsMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpLedgerLogistics">
-    <!--@mbg.generated-->
-    <!--@Table kwp_ledger_logistics-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="ent_id" jdbcType="BIGINT" property="entId" />
-    <result column="check_ent_id" jdbcType="BIGINT" property="checkEntId" />
-    <result column="carrier_ent_id" jdbcType="BIGINT" property="carrierEntId" />
-    <result column="l_ledger_no" jdbcType="VARCHAR" property="lLedgerNo" />
-    <result column="name" jdbcType="VARCHAR" property="name" />
-    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
-    <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
-    <result column="tax_rate" jdbcType="DECIMAL" property="taxRate" />
-    <result column="trading" jdbcType="INTEGER" property="trading" />
-    <result column="unload_amount" jdbcType="DECIMAL" property="unloadAmount" />
-    <result column="load_amount" jdbcType="DECIMAL" property="loadAmount" />
-    <result column="deficit_amount" jdbcType="DECIMAL" property="deficitAmount" />
-    <result column="lose_amount" jdbcType="DECIMAL" property="loseAmount" />
-    <result column="total_price" jdbcType="DECIMAL" property="totalPrice" />
-    <result column="settle_price" jdbcType="DECIMAL" property="settlePrice" />
-    <result column="actual_price" jdbcType="DECIMAL" property="actualPrice" />
-    <result column="check_phone" jdbcType="VARCHAR" property="checkPhone" />
-    <result column="check_user" jdbcType="VARCHAR" property="checkUser" />
-    <result column="carrier_phone" jdbcType="VARCHAR" property="carrierPhone" />
-    <result column="carrier_user" jdbcType="VARCHAR" property="carrierUser" />
-    <result column="url" jdbcType="VARCHAR" property="url" />
-    <result column="generate_time" jdbcType="TIMESTAMP" property="generateTime" />
-    <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, check_ent_id, carrier_ent_id, l_ledger_no, `name`, start_time, end_time, 
-    tax_rate, trading, unload_amount, load_amount, deficit_amount, lose_amount, total_price, 
-    settle_price, actual_price, check_phone, check_user, carrier_phone, carrier_user, 
-    url, generate_time, remark, `status`, create_by, create_time, update_by, update_time, 
-    del_flag
-  </sql>
+    <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpLedgerLogistics">
+        <!--@mbg.generated-->
+        <!--@Table kwp_ledger_logistics-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="ent_id" jdbcType="BIGINT" property="entId"/>
+        <result column="check_ent_id" jdbcType="BIGINT" property="checkEntId"/>
+        <result column="carrier_ent_id" jdbcType="BIGINT" property="carrierEntId"/>
+        <result column="l_ledger_no" jdbcType="VARCHAR" property="lLedgerNo"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
+        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
+        <result column="tax_rate" jdbcType="DECIMAL" property="taxRate"/>
+        <result column="trading" jdbcType="INTEGER" property="trading"/>
+        <result column="unload_amount" jdbcType="DECIMAL" property="unloadAmount"/>
+        <result column="load_amount" jdbcType="DECIMAL" property="loadAmount"/>
+        <result column="deficit_amount" jdbcType="DECIMAL" property="deficitAmount"/>
+        <result column="lose_amount" jdbcType="DECIMAL" property="loseAmount"/>
+        <result column="total_price" jdbcType="DECIMAL" property="totalPrice"/>
+        <result column="settle_price" jdbcType="DECIMAL" property="settlePrice"/>
+        <result column="actual_price" jdbcType="DECIMAL" property="actualPrice"/>
+        <result column="check_user" jdbcType="VARCHAR" property="checkUser"/>
+        <result column="check_phone" jdbcType="VARCHAR" property="checkPhone"/>
+        <result column="carrier_user" jdbcType="VARCHAR" property="carrierUser"/>
+        <result column="carrier_phone" jdbcType="VARCHAR" property="carrierPhone"/>
+        <result column="audit_user" jdbcType="VARCHAR" property="auditUser"/>
+        <result column="audit_phone" jdbcType="VARCHAR" property="auditPhone"/>
+        <result column="url" jdbcType="VARCHAR" property="url"/>
+        <result column="generate_time" jdbcType="TIMESTAMP" property="generateTime"/>
+        <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,
+        check_ent_id,
+        carrier_ent_id,
+        l_ledger_no,
+        `name`,
+        start_time,
+        end_time,
+        tax_rate,
+        trading,
+        unload_amount,
+        load_amount,
+        deficit_amount,
+        lose_amount,
+        total_price,
+        settle_price,
+        actual_price,
+        check_user,
+        check_phone,
+        carrier_user,
+        carrier_phone,
+        audit_user,
+        audit_phone,
+        url,
+        generate_time,
+        remark,
+        `status`,
+        create_by,
+        create_time,
+        update_by,
+        update_time,
+        del_flag
+    </sql>
 
     <select id="pageSelect" resultType="com.sckw.payment.model.dto.LedgerLogisticsDto">
-        select *
+        select kll.id,
+               kll.check_ent_id   checkEntId,
+               kll.carrier_ent_id carrierEntId,
+               kll.l_ledger_no    lLedgerNo,
+               kll.name,
+               kll.start_time     startTime,
+               kll.end_time       endTime,
+               kll.tax_rate       taxRate,
+               kll.trading,
+               kll.unload_amount  unloadAmount,
+               kll.load_amount    loadAmount,
+               kll.deficit_amount deficitAmount,
+               kll.lose_amount    loseAmount,
+               kll.total_price    totalPrice,
+               kll.settle_price   settlePrice,
+               kll.actual_price   actualPrice,
+               kll.check_phone    checkPhone,
+               kll.check_user     checkUser,
+               kll.carrier_phone  carrierPhone,
+               kll.carrier_user   carrierUser,
+               kll.url,
+               kll.generate_time  generateTime,
+               kll.remark,
+               kll.status,
+               count(kllo.id)     orderCount
         from kwp_ledger_logistics kll
+                 inner join kwp_ledger_logistics_order kllo on kll.id = kllo.l_ledger_id
         <where>
-            kll.del_flag = 0
-            <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>
+            <choose>
+                <when test="ids != null and ids.size() != 0">
+                    kll.id in
+                    <foreach collection="ids" item="id" separator="," open="" close=")">
+                    #{id,jdbcType=BIGINT}
+                    </foreach>
+                </when>
+                <otherwise>
+                    kll.del_flag = 0
+                      and kllo.del_flag = 0
+                    <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}, '%')
+                            or kll.check_user like concat('%', #{logisticsReq.keywords}, '%')
+                        <if test="ids != null and ids.size() != 0">
+                            or kll.check_ent_id in
+                            <foreach close=")" collection="ids" item="item" open="(" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
+                        </if>
+                        )
+                    </if>
+                </otherwise>
+            </choose>
         </where>
-        order by kll.generate_time
+        group by kll.id, kll.check_ent_id, kll.carrier_ent_id, kll.l_ledger_no, kll.name, kll.start_time, kll.end_time,
+                 kll.tax_rate, kll.trading, kll.unload_amount, kll.load_amount, kll.deficit_amount, kll.lose_amount,
+                 kll.total_price, kll.settle_price, kll.actual_price, kll.check_phone, kll.check_user,
+                 kll.carrier_phone, kll.carrier_user, kll.url, kll.generate_time, kll.remark, kll.status
+        order by kll.generate_time desc
     </select>
 </mapper>

+ 8 - 2
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -11,7 +11,12 @@
     <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="remark" jdbcType="VARCHAR" property="remark" />
+    <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="status" jdbcType="INTEGER" property="status" />
     <result column="create_by" jdbcType="BIGINT" property="createBy" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
@@ -21,7 +26,8 @@
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, ent_id, l_ledger_id, sl_order_no, `name`, total_price, actual_price, remark, 
-    `status`, create_by, create_time, update_by, update_time, del_flag
+    id, ent_id, l_ledger_id, sl_order_no, `name`, total_price, actual_price, receipt_time, 
+    remark, audit_user, audit_phone, success_user, success_phone, `status`, create_by, 
+    create_time, update_by, update_time, del_flag
   </sql>
 </mapper>