Sfoglia il codice sorgente

贸易对账单功能测试与修复问题

xucaiqin 2 anni fa
parent
commit
afdcf0346d
22 ha cambiato i file con 600 aggiunte e 327 eliminazioni
  1. 20 9
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java
  2. 6 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  3. 23 26
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerLogistics.java
  4. 25 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTrade.java
  5. 15 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LedgerEnum.java
  6. 16 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LogisticsUnitType.java
  7. 22 42
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerLogisticsDto.java
  8. 28 55
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerTradeDto.java
  9. 6 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java
  10. 4 8
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java
  11. 6 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java
  12. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java
  13. 32 13
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsVo.java
  14. 64 92
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerTradeVo.java
  15. 18 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/AbsLedger.java
  16. 18 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsOrderService.java
  17. 115 57
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  18. 10 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsTrackService.java
  19. 30 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsUnitService.java
  20. 104 14
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  21. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeTrackService.java
  22. 36 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

+ 20 - 9
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java

@@ -5,7 +5,7 @@ import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.payment.model.dto.LedgerTradeDto;
 import com.sckw.payment.model.vo.req.*;
-import com.sckw.payment.model.vo.res.LedgerLogisticsVo;
+import com.sckw.payment.model.vo.res.LedgerTradeVo;
 import com.sckw.payment.service.KwpLedgerTradeService;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletResponse;
@@ -61,6 +61,11 @@ public class KwpLedgerTradeController {
         return HttpResult.ok(kwpLedgerTradeService.pageList(tradeReq));
     }
 
+    /**
+     * 贸易订单数分类统计
+     *
+     * @return
+     */
     @GetMapping("count")
     public HttpResult count() {
         return HttpResult.ok(kwpLedgerTradeService.orderCount());
@@ -143,18 +148,24 @@ public class KwpLedgerTradeController {
      * @return
      */
     @PostMapping("export")
-    public HttpResult export(HttpServletResponse response, @RequestBody TradeReq tradeReq) {
-        PageRes<LedgerTradeDto> pageResult = kwpLedgerTradeService.pageList(tradeReq);
-        List<LedgerTradeDto> list = pageResult.getList();
+    public HttpResult export(HttpServletResponse response, @RequestBody @Valid TradeReq tradeReq) {
+        List<LedgerTradeDto> list;
+        if (CollectionUtils.isEmpty(tradeReq.getIds())) {
+            PageRes<LedgerTradeDto> pageResult = kwpLedgerTradeService.pageList(tradeReq);
+            list = pageResult.getList();
+        } else {
+            list = kwpLedgerTradeService.selectList(tradeReq.getIds());
+        }
+
         if (CollectionUtils.isEmpty(list)) {
             return HttpResult.error("没有可导出的数据");
         }
-        List<LedgerLogisticsVo> collect = list.stream().map(a -> {
-            LedgerLogisticsVo ledgerLogisticsVo = new LedgerLogisticsVo();
-            BeanUtils.copyProperties(a, ledgerLogisticsVo);
-            return ledgerLogisticsVo;
+        List<LedgerTradeVo> collect = list.stream().map(a -> {
+            LedgerTradeVo ledgerTradeVo = new LedgerTradeVo();
+            BeanUtils.copyProperties(a, ledgerTradeVo);
+            return ledgerTradeVo;
         }).collect(Collectors.toList());
-        ExcelUtil.downData(response, LedgerLogisticsVo.class, collect);
+        ExcelUtil.downData(response, LedgerTradeVo.class, collect);
         return null;
     }
 }

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

@@ -8,13 +8,18 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author xucaiqin
- * @date 2023-07-14 10:12:40
+ * @date 2023-07-17 15:34:43
  */
 
 @Mapper
 public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
     List<LedgerTradeDto> pageSelect(@Param("tradeReq") TradeReq tradeReq);
+
+    Map<String, Long> countOrder();
+
+    List<LedgerTradeDto> selectIds(@Param("ids") List<Long> ids);
 }

+ 23 - 26
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerLogistics.java

@@ -12,9 +12,12 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
- * 对账-物流订单
  * @author xucaiqin
- * @date 2023-07-14 09:08:11
+ * @date 2023-07-17 15:34:39
+ */
+
+/**
+ * 对账-物流订单
  */
 @Getter
 @Setter
@@ -69,36 +72,18 @@ public class KwpLedgerLogistics {
     @TableField(value = "trading")
     private Integer trading;
 
-    /**
-     * 卸货量
-     */
-    @TableField(value = "unload_amount")
-    private BigDecimal unloadAmount;
-
-    /**
-     * 装货量
-     */
-    @TableField(value = "load_amount")
-    private BigDecimal loadAmount;
-
-    /**
-     * 亏损量
-     */
-    @TableField(value = "deficit_amount")
-    private BigDecimal deficitAmount;
-
-    /**
-     * 合理损耗量
-     */
-    @TableField(value = "lose_amount")
-    private BigDecimal loseAmount;
-
     /**
      * 总应收/元
      */
     @TableField(value = "total_price")
     private BigDecimal totalPrice;
 
+    /**
+     * 不含税金额
+     */
+    @TableField(value = "ex_tax_price")
+    private BigDecimal exTaxPrice;
+
     /**
      * 实际结算金额
      */
@@ -135,6 +120,18 @@ public class KwpLedgerLogistics {
     @TableField(value = "generate_time")
     private LocalDateTime generateTime;
 
+    /**
+     * 预计收款日期
+     */
+    @TableField(value = "receipt_time")
+    private LocalDateTime receiptTime;
+
+    /**
+     * 订单数量
+     */
+    @TableField(value = "order_count")
+    private Integer orderCount;
+
     /**
      * 备注
      */

+ 25 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTrade.java

@@ -12,9 +12,12 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
- * 对账-交易订单
  * @author xucaiqin
- * @date 2023-07-14 10:12:40
+ * @date 2023-07-17 15:34:43
+ */
+
+/**
+ * 对账-交易订单
  */
 @Getter
 @Setter
@@ -67,7 +70,7 @@ public class KwpLedgerTrade {
      * 交易方式(预付款、货到付款)
      */
     @TableField(value = "trading")
-    private Long trading;
+    private Integer trading;
 
     /**
      * 总应收/元
@@ -75,6 +78,12 @@ public class KwpLedgerTrade {
     @TableField(value = "total_price")
     private BigDecimal totalPrice;
 
+    /**
+     * 不含税金额
+     */
+    @TableField(value = "ex_tax_price")
+    private BigDecimal exTaxPrice;
+
     /**
      * 实际计算金额
      */
@@ -105,12 +114,24 @@ public class KwpLedgerTrade {
     @TableField(value = "generate_time")
     private LocalDateTime generateTime;
 
+    /**
+     * 预计收款日期
+     */
+    @TableField(value = "receipt_time")
+    private LocalDateTime receiptTime;
+
     /**
      * 对账清单凭证
      */
     @TableField(value = "url")
     private String url;
 
+    /**
+     * 订单数量
+     */
+    @TableField(value = "order_count")
+    private Integer orderCount;
+
     /**
      * 备注
      */
@@ -118,7 +139,7 @@ public class KwpLedgerTrade {
     private String remark;
 
     /**
-     * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
+     * 状态(1-已保存、2-待对账、3-已对账、4-已完成、5-已退回)
      */
     @TableField(value = "`status`")
     private Integer status;

+ 15 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LedgerEnum.java

@@ -1,5 +1,7 @@
 package com.sckw.payment.model.constant;
 
+import java.util.Objects;
+
 /**
  * 物流、贸易
  * 对账单状态枚举
@@ -8,6 +10,7 @@ package com.sckw.payment.model.constant;
  * @date 2023-07-11 12:00:52
  */
 public enum LedgerEnum {
+    ALL(0, "全部"),
     SAVE(1, "已保存"),
     TO_LEDGER(2, "待对账"),
     LEDGERED(3, "已对账"),
@@ -21,6 +24,18 @@ public enum LedgerEnum {
         this.desc = desc;
     }
 
+    public static String getDesc(Integer status) {
+        if (Objects.isNull(status)) {
+            return "";
+        }
+        for (LedgerEnum value : values()) {
+            if (status == value.getStatus()) {
+                return value.getDesc();
+            }
+        }
+        return "";
+    }
+
     public int getStatus() {
         return status;
     }

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

@@ -0,0 +1,16 @@
+package com.sckw.payment.model.constant;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-14 09:26:16
+ */
+public interface LogisticsUnitType {
+    /**
+     * 托运方(客户单位)
+     */
+    Integer SHIPPER = 1;
+    /**
+     * 承运方
+     */
+    Integer CARRIER = 2;
+}

+ 22 - 42
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerLogisticsDto.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -48,17 +49,15 @@ public class LedgerLogisticsDto {
     /**
      * 开始日期
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime startTime;
 
     /**
      * 结束日期
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime endTime;
 
-    /**
-     * 对账金额
-     */
-    private BigDecimal price;
 
     /**
      * 发票税率(%)
@@ -70,30 +69,15 @@ public class LedgerLogisticsDto {
      */
     private String trading;
 
-    /**
-     * 卸货量
-     */
-    private BigDecimal unloadAmount;
-
-    /**
-     * 装货量
-     */
-    private BigDecimal loadAmount;
-
-    /**
-     * 亏损量
-     */
-    private BigDecimal deficitAmount;
-
-    /**
-     * 合理损耗量
-     */
-    private BigDecimal loseAmount;
 
     /**
      * 总应收/元
      */
     private BigDecimal totalPrice;
+    /**
+     * 不含税金额
+     */
+    private BigDecimal exTaxPrice;
 
     /**
      * 实际结算金额
@@ -106,19 +90,19 @@ public class LedgerLogisticsDto {
     private BigDecimal actualPrice;
 
     /**
-     * 对账审核人电话
+     * 对账清单凭证
      */
-    private String auditPhone;
-
+    private String url;
     /**
-     * 对账审核人名称
+     * 生成时间
      */
-    private String auditUser;
-
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime generateTime;
     /**
-     * 对账清单凭证
+     * 预计收款时间
      */
-    private String url;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime receiptTime;
 
     /**
      * 备注
@@ -129,20 +113,16 @@ public class LedgerLogisticsDto {
      * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
      */
     private Integer status;
-
-    private Long createBy;
-
-    private LocalDateTime createTime;
-
-    private Long updateBy;
-
     /**
-     * 更新时间
+     * 客户联系人
      */
-    private LocalDateTime updateTime;
-
+    private String contacts;
+    /**
+     * 客户联系人电话
+     */
+    private String phone;
     /**
      * 订单数量
      */
-    private Long orderCount;
+    private Integer orderCount;
 }

+ 28 - 55
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerTradeDto.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -20,80 +21,49 @@ public class LedgerTradeDto {
      */
     private Long id;
     /**
-     * 物流对账单编号
+     * 贸易对账单编号
      */
-    private String lLedgerNo;
+    private String tLedgerNo;
 
     /**
      * 对账单名称
      */
     private String name;
 
-    /**
-     * 企业id
-     */
-    private Long entId;
-
-    /**
-     * 托运单位
-     */
-    private Long checkEntId;
-
-    /**
-     * 承运单位
-     */
-    private Long carrierEntId;
-
 
     /**
      * 开始日期
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime startTime;
 
     /**
      * 结束日期
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime endTime;
 
-    /**
-     * 对账金额
-     */
-    private BigDecimal price;
-
     /**
      * 发票税率(%)
      */
-    private BigDecimal taxRate;
+    private Integer taxRate;
+    private String taxRateLabel;
 
     /**
      * 交易方式(预付款、货到付款)
      */
-    private String trading;
+    private Integer trading;
+    private String tradingLabel;
 
-    /**
-     * 卸货量
-     */
-    private BigDecimal unloadAmount;
-
-    /**
-     * 装货量
-     */
-    private BigDecimal loadAmount;
-
-    /**
-     * 亏损量
-     */
-    private BigDecimal deficitAmount;
-
-    /**
-     * 合理损耗量
-     */
-    private BigDecimal loseAmount;
 
     /**
      * 总应收/元
      */
     private BigDecimal totalPrice;
+    /**
+     * 不含税金额
+     */
+    private BigDecimal exTaxPrice;
 
     /**
      * 实际结算金额
@@ -119,6 +89,16 @@ public class LedgerTradeDto {
      * 对账清单凭证
      */
     private String url;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime generateTime;
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime receiptTime;
 
     /**
      * 备注
@@ -129,20 +109,13 @@ public class LedgerTradeDto {
      * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
      */
     private Integer status;
-
-    private Long createBy;
-
-    private LocalDateTime createTime;
-
-    private Long updateBy;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
+    private String statusLabel;
+    private String contacts;
+    private String phone;
+    private String firmName;
 
     /**
      * 订单数量
      */
-    private Long orderCount;
+    private Integer orderCount;
 }

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

@@ -1,10 +1,13 @@
 package com.sckw.payment.model.vo.req;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.time.LocalDateTime;
+
 /**
  * 对账完成
  *
@@ -18,6 +21,9 @@ public class LedgerSuccessReq {
     private Long id;
     @NotBlank(message = "财务联系人不能为空")
     private String successUser;
+    @NotNull(message = "预计收款日期不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime receiptTime;
     @NotBlank(message = "财务联系电话不能为空")
     private String successPhone;
 

+ 4 - 8
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java

@@ -1,10 +1,7 @@
 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 jakarta.validation.constraints.*;
 import lombok.Getter;
 import lombok.Setter;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -28,10 +25,6 @@ public class LogisticsSendReq {
     @NotNull(message = "客户单位不能为空")
     private Long checkEntId;
 
-    /**
-     * 承运单位
-     */
-    private Long carrierEntId;
     /**
      * 名称
      */
@@ -101,5 +94,8 @@ public class LogisticsSendReq {
     /**
      * 承运订单
      */
+    @NotEmpty(message = "承运订单不能为空")
     private List<Long> ids;
+    private LocalDateTime generateTime;
+
 }

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

@@ -1,7 +1,9 @@
 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.LedgerEnum;
+import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,7 +20,11 @@ import java.util.List;
 public class TradeReq extends BasePara {
     @Serial
     private static final long serialVersionUID = 5328731681168692784L;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @NotNull(message = "生成开始时间不能为空")
     private LocalDateTime startCreateTime;
+    @NotNull(message = "生成结束时间不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime endCreateTime;
     private Integer trading;
     /**

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

@@ -80,4 +80,5 @@ public class TradeSendReq {
     private List<Long> ids;
 
     private LocalDateTime generateTime;
+    private Integer status;
 }

+ 32 - 13
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsVo.java

@@ -28,31 +28,31 @@ public class LedgerLogisticsVo {
     /**
      * 物流对账单编号
      */
-    //@ExcelProperty(value = "物流对账单编号")
+    @ExcelProperty(value = "物流对账单编号")
     private String lLedgerNo;
 
     /**
      * 对账单名称
      */
-    //@ExcelProperty(value = "对账单名称")
+    @ExcelProperty(value = "对账单名称")
     private String name;
 
     /**
      * 企业id
      */
-    //@ExcelProperty(value = "企业id")
+    @ExcelProperty(value = "企业id")
     private Long entId;
 
     /**
      * 托运单位
      */
-    //@ExcelProperty(value = "托运单位")
+    @ExcelProperty(value = "托运单位")
     private Long checkEntId;
 
     /**
      * 承运单位
      */
-    //@ExcelProperty(value = "承运单位")
+    @ExcelProperty(value = "承运单位")
     private Long carrierEntId;
 
 
@@ -75,87 +75,103 @@ public class LedgerLogisticsVo {
     /**
      * 对账金额
      */
-    //@ExcelProperty(value = "对账金额")
+    @ExcelProperty(value = "对账金额")
     private BigDecimal price;
 
     /**
      * 发票税率(%)
      */
-    //@ExcelProperty(value = "发票税率(%)")
+    @ExcelProperty(value = "发票税率(%)")
     private BigDecimal taxRate;
 
     /**
      * 交易方式(预付款、货到付款)
      */
-    //@ExcelProperty(value = "交易方式")
+    @ExcelProperty(value = "交易方式")
     private String trading;
 
     /**
      * 卸货量
      */
-    //@ExcelProperty(value = "卸货量")
+    @ExcelProperty(value = "卸货量")
     private BigDecimal unloadAmount;
 
     /**
      * 装货量
      */
-    //@ExcelProperty(value = "装货量")
+    @ExcelProperty(value = "装货量")
     private BigDecimal loadAmount;
 
     /**
      * 亏损量
      */
-    //@ExcelProperty(value = "亏损量")
+    @ExcelProperty(value = "亏损量")
     private BigDecimal deficitAmount;
 
     /**
      * 合理损耗量
      */
-    //@ExcelProperty(value = "合理损耗量")
+    @ExcelProperty(value = "合理损耗量")
     private BigDecimal loseAmount;
 
     /**
      * 总应收/元
      */
+    @ExcelProperty(value = "总应收/元")
     private BigDecimal totalPrice;
 
     /**
      * 实际结算金额
      */
+    @ExcelProperty(value = "实际结算金额")
     private BigDecimal settlePrice;
 
     /**
      * 已收款/元
      */
+    @ExcelProperty(value = "已收款/元")
     private BigDecimal actualPrice;
 
     /**
      * 对账审核人电话
      */
+    @ExcelProperty(value = "对账审核人电话")
     private String auditPhone;
 
     /**
      * 对账审核人名称
      */
+    @ExcelProperty(value = "对账审核人名称")
     private String auditUser;
 
     /**
      * 对账清单凭证
      */
+    @ExcelProperty(value = "对账清单凭证")
     private String url;
+    /**
+     * 生成时间
+     */
+    @ExcelProperty(value = "生成时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime generateTime;
 
     /**
      * 备注
      */
+    @ExcelProperty(value = "备注")
     private String remark;
 
     /**
      * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
      */
+    @ExcelProperty(value = "状态")
     private Integer status;
 
     private Long createBy;
-
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime createTime;
 
     private Long updateBy;
@@ -163,10 +179,13 @@ public class LedgerLogisticsVo {
     /**
      * 更新时间
      */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;
 
     /**
      * 订单数量
      */
+    @ExcelProperty(value = "订单数量")
     private Long orderCount;
 }

+ 64 - 92
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerTradeVo.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.vo.res;
 
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.sckw.excel.annotation.ExcelContext;
 import lombok.Getter;
 import lombok.Setter;
@@ -21,146 +22,117 @@ public class LedgerTradeVo {
     /**
      * 主键
      */
-    @ExcelProperty(value = "id")
+    @ExcelProperty(value = "序号")
     private Long id;
+    /**
+     * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
+     */
+    @ExcelProperty(value = "状态")
+    private String statusLabel;
+
     /**
      * 贸易对账单编号
      */
-    //@ExcelProperty(value = "贸易对账单编号")
+    @ExcelProperty(value = "贸易对账单编号")
     private String tLedgerNo;
 
     /**
      * 对账单名称
      */
-    //@ExcelProperty(value = "对账单名称")
+    @ExcelProperty(value = "对账单名称")
     private String name;
 
     /**
-     * 企业id
+     * 客户单位
      */
-    //@ExcelProperty(value = "企业id")
-    private Long entId;
-
+    @ExcelProperty(value = "客户单位")
+    private String firmName;
     /**
-     * 托运单位
-     */
-    //@ExcelProperty(value = "托运单位")
-    private Long checkEntId;
-
-    /**
-     * 承运单位
-     */
-    //@ExcelProperty(value = "承运单位")
-    private Long carrierEntId;
-
-
-    /**
-     * 开始日期
+     * 订单数量
      */
-    //@ExcelProperty(value = "开始日期")
-    private LocalDateTime startTime;
+    @ExcelProperty(value = "订单数量")
+    private Long orderCount;
 
-    /**
-     * 结束日期
-     */
-    //@ExcelProperty(value = "结束日期")
-    private LocalDateTime endTime;
 
+//    /**
+//     * 开始日期
+//     */
+//    @ExcelProperty(value = "开始日期")
+//    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+//    private LocalDateTime startTime;
+//
+//    /**
+//     * 结束日期
+//     */
+//    @ExcelProperty(value = "结束日期")
+//    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+//    private LocalDateTime endTime;
     /**
-     * 对账金额
+     * 付款方式(预付款、货到付款)
      */
-    //@ExcelProperty(value = "对账金额")
-    private BigDecimal price;
+    @ExcelProperty(value = "付款方式")
+    private String tradingLabel;
 
     /**
      * 发票税率(%)
      */
-    //@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;
+    @ExcelProperty(value = "发票税率(%)")
+    private String taxRateLabel;
 
     /**
      * 总应收/元
      */
+    @ExcelProperty(value = "总应收/元")
     private BigDecimal totalPrice;
 
-    /**
-     * 实际结算金额
-     */
-    private BigDecimal settlePrice;
+//    /**
+//     * 实际结算金额
+//     */
+//    @ExcelProperty(value = "实际结算金额")
+//    private BigDecimal settlePrice;
 
     /**
      * 已收款/元
      */
+    @ExcelProperty(value = "已收款/元")
     private BigDecimal actualPrice;
 
+//    /**
+//     * 对账审核人电话
+//     */
+//    @ExcelProperty(value = "对账审核人电话")
+//    private String auditPhone;
     /**
-     * 对账审核人电话
-     */
-    private String auditPhone;
-
-    /**
-     * 对账审核人名称
+     * 客户联系人
      */
-    private String auditUser;
-
+    @ExcelProperty(value = "客户联系人")
+    private String contacts;
     /**
-     * 对账清单凭证
+     * 联系方式
      */
-    private String url;
+    @ExcelProperty(value = "联系方式")
+    private String phone;
 
     /**
-     * 备注
+     * 预计收款日期
      */
-    private String remark;
-
+    @ExcelProperty(value = "预计收款日期")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime receiptTime;
     /**
-     * 状态(待对账、对账中、已对账、已完成、已取消、已退回)
+     * 对账审核人名称
      */
-    private Integer status;
-
-    private Long createBy;
+    @ExcelProperty(value = "提交人")
+    private String auditUser;
 
-    private LocalDateTime createTime;
 
-    private Long updateBy;
 
     /**
-     * 更新时间
+     * 生成时间
      */
-    private LocalDateTime updateTime;
+    @ExcelProperty(value = "生成时间")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime generateTime;
+
 
-    /**
-     * 订单数量
-     */
-    private Long orderCount;
 }

+ 18 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/AbsLedger.java

@@ -5,25 +5,39 @@ import com.sckw.core.exception.BusinessException;
 import com.sckw.payment.model.constant.LedgerEnum;
 
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @author xucaiqin
  * @date 2023-07-13 15:40:37
  */
 public abstract class AbsLedger {
-    public void deleteCheck(Integer status){
+    public void backCheck(Integer status) {
+        if (Objects.nonNull(status) && LedgerEnum.TO_LEDGER.getStatus() != status) {
+            throw new BusinessException("只有【待对账】的单据才支持对账驳回!");
+        }
+    }
+
+    public void confirmCheck(Integer status) {
+        if (Objects.nonNull(status) && LedgerEnum.TO_LEDGER.getStatus() != status) {
+            throw new BusinessException("只有【待对账】的单据才支持对账确认!");
+        }
+    }
+
+    public void deleteCheck(Integer status) {
         List<Integer> objects = Lists.newArrayList(LedgerEnum.BACK.getStatus(), LedgerEnum.SAVE.getStatus());
-        if (!objects.contains(status)) {
+        if (Objects.nonNull(status) && !objects.contains(status)) {
             throw new BusinessException("只有【已保存】和【已退回】的单据才支持删除!");
         }
     }
+
     /**
      * 撤回订单校验
      *
      * @param status
      */
     public void revokeCheck(Integer status) {
-        if (LedgerEnum.TO_LEDGER.getStatus() != status) {
+        if (Objects.nonNull(status) && LedgerEnum.TO_LEDGER.getStatus() != status) {
             throw new BusinessException("只有【待对账】的单据才支持撤销!");
         }
     }
@@ -34,7 +48,7 @@ public abstract class AbsLedger {
      * @param status
      */
     public void successCheck(Integer status) {
-        if (LedgerEnum.LEDGERED.getStatus() != status) {
+        if (Objects.nonNull(status) && LedgerEnum.LEDGERED.getStatus() != status) {
             throw new BusinessException("只有【已对账】的订单支持完成对账!");
         }
     }

+ 18 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsOrderService.java

@@ -1,11 +1,29 @@
 package com.sckw.payment.service;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.sckw.payment.dao.KwpLedgerLogisticsOrderMapper;
+import com.sckw.payment.model.KwpLedgerLogisticsOrder;
+import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
 /**
  * @author xucaiqin
  * @date 2023-07-10 16:38:36
  */
 @Service
+@AllArgsConstructor
 public class KwpLedgerLogisticsOrderService {
+    private final KwpLedgerLogisticsOrderMapper logisticsOrderMapper;
 
+    public void remove(Long lLedgerId) {
+        KwpLedgerLogisticsOrder logisticsOrder = new KwpLedgerLogisticsOrder();
+        logisticsOrder.setDelFlag(1);
+        logisticsOrder.setUpdateTime(LocalDateTime.now());
+        LambdaUpdateWrapper<KwpLedgerLogisticsOrder> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(KwpLedgerLogisticsOrder::getLLedgerId, lLedgerId);
+        wrapper.eq(KwpLedgerLogisticsOrder::getDelFlag, 0);
+        logisticsOrderMapper.update(logisticsOrder, wrapper);
+    }
 }

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

@@ -5,24 +5,28 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.OrderGenerateUtils;
 import com.sckw.payment.dao.KwpLedgerLogisticsMapper;
-import com.sckw.payment.dao.KwpLedgerLogisticsOrderMapper;
 import com.sckw.payment.model.KwpLedgerLogistics;
-import com.sckw.payment.model.KwpLedgerLogisticsOrder;
 import com.sckw.payment.model.KwpLedgerLogisticsTrack;
+import com.sckw.payment.model.KwpLedgerLogisticsUnit;
 import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.payment.model.constant.LedgerEnum;
 import com.sckw.payment.model.constant.LedgerTrackEnum;
+import com.sckw.payment.model.constant.LogisticsUnitType;
+import com.sckw.payment.model.dto.LedgerCountVo;
 import com.sckw.payment.model.dto.LedgerLogisticsDto;
 import com.sckw.payment.model.vo.req.*;
 import lombok.AllArgsConstructor;
-import org.apache.commons.lang3.StringUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 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.Map;
 import java.util.Objects;
 
 /**
@@ -31,11 +35,13 @@ import java.util.Objects;
  */
 @Service
 @AllArgsConstructor
+@Slf4j
 public class KwpLedgerLogisticsService extends AbsLedger {
     private final KwpLedgerLogisticsTrackService logisticsTrackService;
     private final KwpSettlementLogisticsService settlementLogisticsService;
+    private final KwpLedgerLogisticsUnitService logisticsUnitService;
+    private final KwpLedgerLogisticsOrderService logisticsOrderService;
     private final KwpLedgerLogisticsMapper logisticsMapper;
-    private final KwpLedgerLogisticsOrderMapper logisticsOrderMapper;
 
     /**
      * 分页查询物流对账单列表
@@ -44,13 +50,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      * @return
      */
     public PageRes<LedgerLogisticsDto> pageList(LogisticsReq logisticsReq) {
-        //todo 查询缓存,获取客户企业id
-        String keywords = logisticsReq.getKeywords();
-        if (StringUtils.isNotBlank(keywords)) {
-
-        }
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
-
         List<LedgerLogisticsDto> kwpLedgerLogisticsList = logisticsMapper.pageSelect(logisticsReq, new ArrayList<>());
 
         return new PageRes<>(new PageInfo<>(kwpLedgerLogisticsList));
@@ -67,62 +67,101 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         Long id = logisticsReq.getId();
         if (Objects.isNull(id)) {
             //新增
+            logisticsReq.setGenerateTime(LocalDateTime.now());
+            Long aLong = saveDraft(logisticsReq);
+            logisticsTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
         } else {
-            //修改
+            removeDraft(id);
+            logisticsReq.setGenerateTime(LocalDateTime.now());
+            Long aLong = saveDraft(logisticsReq);
+            logisticsTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
+
         }
-        return "新增对账单成功";
+        return "保存对账单成功";
     }
 
-    /**
-     * 保存物流对账单草稿
-     *
-     * @param logisticsReq
-     * @return
-     */
-    @Transactional(rollbackFor = Exception.class)
-    public String sendLedgerDraft(LogisticsSendReq logisticsReq) {
-        /*插入物流对账单*/
+    private void removeDraft(Long id) {
+        //删除 kwp_ledger_logistics_order
+        logisticsOrderService.remove(id);
+        //删除 kwp_ledger_logistics_track
+        logisticsTrackService.remove(id);
+        //删除 kwp_ledger_logistics_unit
+        logisticsUnitService.remove(id);
+    }
+
+    private Long saveDraft(LogisticsSendReq logisticsSendReq) {
         KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
-        kwpLedgerLogistics.setId(new IdWorker(1).nextId());
-        kwpLedgerLogistics.setEntId(0L);//todo
-        kwpLedgerLogistics.setLLedgerNo("");//todo
-        kwpLedgerLogistics.setName(logisticsReq.getName());
-        kwpLedgerLogistics.setStartTime(logisticsReq.getStartTime());
-        kwpLedgerLogistics.setEndTime(logisticsReq.getEndTime());
-        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.setActualPrice(new BigDecimal("0"));
-        kwpLedgerLogistics.setGenerateTime(null);
+        kwpLedgerLogistics.setId(Objects.isNull(logisticsSendReq.getId()) ? new IdWorker(1).nextId() : logisticsSendReq.getId());
+        kwpLedgerLogistics.setEntId(0L);
+        kwpLedgerLogistics.setLLedgerNo("");
+        kwpLedgerLogistics.setName("");
+        kwpLedgerLogistics.setStartTime(logisticsSendReq.getStartTime());
+        kwpLedgerLogistics.setEndTime(logisticsSendReq.getEndTime());
+        kwpLedgerLogistics.setTaxRate(logisticsSendReq.getTaxRate());
+        kwpLedgerLogistics.setTrading(logisticsSendReq.getTrading());
+        kwpLedgerLogistics.setTotalPrice(logisticsSendReq.getTotalPrice());
+        kwpLedgerLogistics.setExTaxPrice(logisticsSendReq.getTotalPrice());//todo 不含税金额计算方式:订单含税金额总和/1.13(税率)
+        kwpLedgerLogistics.setSettlePrice(logisticsSendReq.getSettlePrice());
+        kwpLedgerLogistics.setActualPrice(new BigDecimal("0.0"));
+        kwpLedgerLogistics.setAuditUser("");
+        kwpLedgerLogistics.setAuditPhone("");
+        kwpLedgerLogistics.setReceiptTime(null);
+        kwpLedgerLogistics.setOrderCount(logisticsSendReq.getIds().size());
         kwpLedgerLogistics.setUrl("");
-        kwpLedgerLogistics.setRemark(logisticsReq.getRemark());
+        kwpLedgerLogistics.setGenerateTime(logisticsSendReq.getGenerateTime());
+        kwpLedgerLogistics.setRemark("");
         kwpLedgerLogistics.setStatus(LedgerEnum.SAVE.getStatus());
-        kwpLedgerLogistics.setCreateBy(0L);//todo
+        kwpLedgerLogistics.setCreateBy(0L);
         kwpLedgerLogistics.setCreateTime(LocalDateTime.now());
         kwpLedgerLogistics.setUpdateBy(0L);
         kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
         kwpLedgerLogistics.setDelFlag(0);
-        logisticsMapper.insert(kwpLedgerLogistics);
-        /*插入对账关联物流运单*/
-        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);
+        if (Objects.isNull(logisticsSendReq.getId())) {
+            logisticsMapper.insert(kwpLedgerLogistics);
+        } else {
+            logisticsMapper.updateById(kwpLedgerLogistics);
         }
-        logisticsTrackService.saveTrack(kwpLedgerLogistics.getId(), "", LedgerTrackEnum.SAVE);
-        return "保存成功";
+        /*报错物流订单关联数据*/
+        List<Long> ids = logisticsSendReq.getIds();
+        /*保存企业相关信息*/
+        Long checkEntId = logisticsSendReq.getCheckEntId();
+
+        List<KwpLedgerLogisticsUnit> logisticsUnits = new ArrayList<>();
+        KwpLedgerLogisticsUnit kwpLedgerLogisticsUnit = new KwpLedgerLogisticsUnit();
+        kwpLedgerLogisticsUnit.setId(new IdWorker(1).nextId());
+        kwpLedgerLogisticsUnit.setLLedgerId(kwpLedgerLogistics.getId());
+        kwpLedgerLogisticsUnit.setLLedgerNo("");
+        kwpLedgerLogisticsUnit.setUnitType(LogisticsUnitType.SHIPPER);
+        kwpLedgerLogisticsUnit.setEntId(checkEntId);
+        kwpLedgerLogisticsUnit.setTopEntId(checkEntId);//todo
+        kwpLedgerLogisticsUnit.setFirmName("");
+        kwpLedgerLogisticsUnit.setContacts("");
+        kwpLedgerLogisticsUnit.setPhone("");
+        kwpLedgerLogisticsUnit.setRemark("");
+        kwpLedgerLogisticsUnit.setStatus(0);
+        kwpLedgerLogisticsUnit.setCreateBy(0L);
+        kwpLedgerLogisticsUnit.setCreateTime(LocalDateTime.now());
+        kwpLedgerLogisticsUnit.setUpdateBy(0L);
+        kwpLedgerLogisticsUnit.setUpdateTime(LocalDateTime.now());
+        kwpLedgerLogisticsUnit.setDelFlag(0);
+
+        logisticsUnits.add(kwpLedgerLogisticsUnit);
+        logisticsUnitService.saveList(logisticsUnits);
+        return kwpLedgerLogistics.getId();
+    }
+
+    /**
+     * 保存物流对账单草稿
+     *
+     * @param logisticsReq
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public String sendLedgerDraft(LogisticsSendReq logisticsReq) {
+        logisticsReq.setGenerateTime(null);
+        Long aLong = saveDraft(logisticsReq);
+        logisticsTrackService.saveTrack(aLong, "", LedgerTrackEnum.SAVE);
+        return "草稿保存成功";
     }
 
     /**
@@ -181,6 +220,11 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         if (Objects.isNull(kwpLedgerLogistics)) {
             throw new BusinessException("对账单不存在!");
         }
+        backCheck(kwpLedgerLogistics.getStatus());
+        backCheck(kwpLedgerLogistics.getStatus());
+        kwpLedgerLogistics.setStatus(LedgerEnum.BACK.getStatus());
+        kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
+        logisticsMapper.updateById(kwpLedgerLogistics);
         return logisticsTrackService.saveTrack(ledgerReq.getId(), ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
     }
 
@@ -218,7 +262,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
             throw new BusinessException("对账单不存在!");
         }
         successCheck(kwpLedgerLogistics.getStatus());
-
+        kwpLedgerLogistics.setReceiptTime(ledgerReq.getReceiptTime());
         kwpLedgerLogistics.setStatus(LedgerEnum.SUCCESS.getStatus());
         kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
         logisticsMapper.updateById(kwpLedgerLogistics);
@@ -227,16 +271,16 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpSettlementLogistics.setId(new IdWorker(1).nextId());
         kwpSettlementLogistics.setEntId(0L);//todo
         kwpSettlementLogistics.setLLedgerId(kwpLedgerLogistics.getId());
-        kwpSettlementLogistics.setSlOrderNo(String.valueOf(new IdWorker(1).nextId()));//todo
+        kwpSettlementLogistics.setSlOrderNo(OrderGenerateUtils.generateOrderNo("SL"));
         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.setReceiptTime(ledgerReq.getReceiptTime());
         kwpSettlementLogistics.setStatus(0);
         kwpSettlementLogistics.setCreateBy(0L);
         kwpSettlementLogistics.setCreateTime(LocalDateTime.now());
@@ -249,4 +293,18 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         logisticsTrackService.saveTrack(ledgerReq.getId(), "", LedgerTrackEnum.SUCCESS);
         return "对账完成";
     }
+
+    public List<LedgerCountVo> orderCount() {
+        Map<String, Long> map = logisticsMapper.countOrder();
+        LedgerCountVo ledgerCountVo;
+        List<LedgerCountVo> res = new ArrayList<>();
+        for (LedgerEnum value : LedgerEnum.values()) {
+            ledgerCountVo = new LedgerCountVo();
+            ledgerCountVo.setCount(map.get(String.valueOf(value.getStatus())));
+            ledgerCountVo.setLabel(value.getDesc());
+            ledgerCountVo.setStatus(value.getStatus());
+            res.add(ledgerCountVo);
+        }
+        return res;
+    }
 }

+ 10 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsTrackService.java

@@ -9,6 +9,7 @@ import jakarta.validation.constraints.NotNull;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Objects;
 
@@ -53,4 +54,13 @@ public class KwpLedgerLogisticsTrackService {
     }
 
 
+    public void remove(Long lLedgerId) {
+        LambdaQueryWrapper<KwpLedgerLogisticsTrack> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpLedgerLogisticsTrack::getLLedgerId, lLedgerId);
+        wrapper.eq(KwpLedgerLogisticsTrack::getDelFlag, 0);
+        KwpLedgerLogisticsTrack logisticsTrack = new KwpLedgerLogisticsTrack();
+        logisticsTrack.setUpdateTime(LocalDateTime.now());
+        logisticsTrack.setDelFlag(1);
+        logisticsTrackMapper.update(logisticsTrack, wrapper);
+    }
 }

+ 30 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsUnitService.java

@@ -1,11 +1,40 @@
 package com.sckw.payment.service;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.sckw.payment.dao.KwpLedgerLogisticsUnitMapper;
+import com.sckw.payment.model.KwpLedgerLogisticsUnit;
+import com.sckw.payment.model.KwpLedgerTradeUnit;
+import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
 /**
  * @author xucaiqin
  * @date 2023-07-13 17:32:34
  */
 @Service
-public class KwpLedgerLogisticsUnitService  {
+@AllArgsConstructor
+public class KwpLedgerLogisticsUnitService {
+    private final KwpLedgerLogisticsUnitMapper logisticsUnitMapper;
+
+    public void saveList(List<KwpLedgerLogisticsUnit> logisticsUnits) {
+        if (!CollectionUtils.isEmpty(logisticsUnits)) {
+            for (KwpLedgerLogisticsUnit logisticsUnit : logisticsUnits) {
+                logisticsUnitMapper.insert(logisticsUnit);
+            }
+        }
+    }
 
+    public void remove(Long lLedgerId) {
+        KwpLedgerLogisticsUnit logisticsUnit = new KwpLedgerLogisticsUnit();
+        logisticsUnit.setDelFlag(1);
+        logisticsUnit.setUpdateTime(LocalDateTime.now());
+        LambdaUpdateWrapper<KwpLedgerLogisticsUnit> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(KwpLedgerLogisticsUnit::getLLedgerId, lLedgerId);
+        wrapper.eq(KwpLedgerLogisticsUnit::getDelFlag, 0);
+        logisticsUnitMapper.update(logisticsUnit, wrapper);
+    }
 }

+ 104 - 14
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -5,7 +5,9 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.OrderGenerateUtils;
 import com.sckw.payment.dao.KwpLedgerTradeMapper;
 import com.sckw.payment.model.KwpLedgerTrade;
 import com.sckw.payment.model.KwpLedgerTradeTrack;
@@ -14,18 +16,21 @@ import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.constant.LedgerEnum;
 import com.sckw.payment.model.constant.LedgerTrackEnum;
 import com.sckw.payment.model.constant.TradeUnitType;
+import com.sckw.payment.model.dto.LedgerCountVo;
 import com.sckw.payment.model.dto.LedgerTradeDto;
 import com.sckw.payment.model.vo.req.*;
-import lombok.AllArgsConstructor;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.SysDictResDto;
+import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 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;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author xucaiqin
@@ -33,14 +38,42 @@ import java.util.Objects;
  */
 
 @Service
-@AllArgsConstructor
 @Slf4j
 public class KwpLedgerTradeService extends AbsLedger {
-    private final KwpLedgerTradeMapper tradeMapper;
-    private final KwpLedgerTradeTrackService tradeTrackService;
-    private final KwpLedgerTradeOrderService tradeOrderService;
-    private final KwpSettlementTradeService settlementTradeService;
-    private final KwpLedgerTradeUnitService tradeUnitService;
+    @Resource
+    private KwpLedgerTradeMapper tradeMapper;
+    @Resource
+    private KwpLedgerTradeTrackService tradeTrackService;
+    @Resource
+    private KwpLedgerTradeOrderService tradeOrderService;
+    @Resource
+    private KwpSettlementTradeService settlementTradeService;
+    @Resource
+    private KwpLedgerTradeUnitService tradeUnitService;
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+
+    private void changeDict(List<LedgerTradeDto> list) {
+        List<SysDictResDto> taxRateDict = remoteSystemService.queryDictByType("taxRate");//todo
+        Map<String, String> taxRateMap = new HashMap<>();
+        Map<String, String> tradingMap = new HashMap<>();
+
+        if (!CollectionUtils.isEmpty(taxRateDict)) {
+            taxRateMap = taxRateDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
+        }
+        List<SysDictResDto> tradingDict = remoteSystemService.queryDictByType("trade_type");//todo
+        if (!CollectionUtils.isEmpty(tradingDict)) {
+            tradingMap = tradingDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
+        }
+        for (LedgerTradeDto tradeDto : list) {
+            Integer trading = tradeDto.getTrading();
+            tradeDto.setTradingLabel(tradingMap.get(String.valueOf(trading)));
+            Integer taxRate = tradeDto.getTaxRate();
+            tradeDto.setTaxRateLabel(taxRateMap.get(String.valueOf(taxRate)));
+
+            tradeDto.setStatusLabel(LedgerEnum.getDesc(tradeDto.getStatus()));
+        }
+    }
 
     /**
      * 分页查询对账单列表
@@ -51,6 +84,10 @@ public class KwpLedgerTradeService extends AbsLedger {
     public PageRes<LedgerTradeDto> pageList(TradeReq tradeReq) {
         PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
         List<LedgerTradeDto> ledgerTradeDto = tradeMapper.pageSelect(tradeReq);
+        //字典转换
+        if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
+            changeDict(ledgerTradeDto);
+        }
         return new PageRes<>(new PageInfo<>(ledgerTradeDto));
     }
 
@@ -67,27 +104,30 @@ public class KwpLedgerTradeService extends AbsLedger {
         KwpLedgerTrade kwpLedgerTrade = new KwpLedgerTrade();
         kwpLedgerTrade.setId(Objects.isNull(tradeSendReq.getId()) ? new IdWorker(1).nextId() : tradeSendReq.getId());
         kwpLedgerTrade.setEntId(0L);//todo
-        kwpLedgerTrade.setTLedgerNo("");
         kwpLedgerTrade.setName(tradeSendReq.getName());
         kwpLedgerTrade.setStartTime(tradeSendReq.getStartTime());
         kwpLedgerTrade.setEndTime(tradeSendReq.getEndTime());
         kwpLedgerTrade.setTaxRate(tradeSendReq.getTaxRate());
-        kwpLedgerTrade.setTrading(0L);
+        kwpLedgerTrade.setTrading(tradeSendReq.getTrading());
         kwpLedgerTrade.setTotalPrice(tradeSendReq.getTotalPrice());
+        kwpLedgerTrade.setExTaxPrice(tradeSendReq.getTotalPrice());//todo 不含税金额计算方式:订单含税金额总和/1.13(税率)
         kwpLedgerTrade.setSettlePrice(tradeSendReq.getSettlePrice());
         kwpLedgerTrade.setActualPrice(new BigDecimal("0.0"));
         kwpLedgerTrade.setAuditUser("");
         kwpLedgerTrade.setAuditPhone("");
         kwpLedgerTrade.setGenerateTime(tradeSendReq.getGenerateTime());
+        kwpLedgerTrade.setReceiptTime(null);
+        kwpLedgerTrade.setOrderCount(tradeSendReq.getIds().size());
         kwpLedgerTrade.setUrl("");
         kwpLedgerTrade.setRemark("");
-        kwpLedgerTrade.setStatus(LedgerEnum.SAVE.getStatus());
+        kwpLedgerTrade.setStatus(tradeSendReq.getStatus());
         kwpLedgerTrade.setCreateBy(0L);
         kwpLedgerTrade.setCreateTime(LocalDateTime.now());
         kwpLedgerTrade.setUpdateBy(0L);
         kwpLedgerTrade.setUpdateTime(LocalDateTime.now());
         kwpLedgerTrade.setDelFlag(0);
         if (Objects.isNull(tradeSendReq.getId())) {
+            kwpLedgerTrade.setTLedgerNo(OrderGenerateUtils.generateOrderNo("TL"));
             tradeMapper.insert(kwpLedgerTrade);
         } else {
             tradeMapper.updateById(kwpLedgerTrade);
@@ -119,6 +159,26 @@ public class KwpLedgerTradeService extends AbsLedger {
         kwpLedgerTradeUnit.setDelFlag(0);
 
         list.add(kwpLedgerTradeUnit);
+        //非客户企业方,通过登录用户获取顶级企业
+        KwpLedgerTradeUnit sellLedgerTradeUnit = new KwpLedgerTradeUnit();
+        sellLedgerTradeUnit.setId(new IdWorker(1).nextId());
+        sellLedgerTradeUnit.setTLedgerId(kwpLedgerTrade.getId());
+        sellLedgerTradeUnit.setTLedgerNo(kwpLedgerTrade.getTLedgerNo());
+        sellLedgerTradeUnit.setUnitType(TradeUnitType.SELL);
+        sellLedgerTradeUnit.setEntId(purchaseEntId);//todo
+        sellLedgerTradeUnit.setTopEntId(0L);
+        sellLedgerTradeUnit.setFirmName("");
+        sellLedgerTradeUnit.setContacts("");
+        sellLedgerTradeUnit.setPhone("");
+        sellLedgerTradeUnit.setRemark("");
+        sellLedgerTradeUnit.setStatus(0);
+        sellLedgerTradeUnit.setCreateBy(0L);
+        sellLedgerTradeUnit.setCreateTime(LocalDateTime.now());
+        sellLedgerTradeUnit.setUpdateBy(0L);
+        sellLedgerTradeUnit.setUpdateTime(LocalDateTime.now());
+        sellLedgerTradeUnit.setDelFlag(0);
+        list.add(sellLedgerTradeUnit);
+
         tradeUnitService.saveList(list);
         return kwpLedgerTrade.getId();
     }
@@ -131,10 +191,12 @@ public class KwpLedgerTradeService extends AbsLedger {
      */
     @Transactional(rollbackFor = Exception.class)
     public String sendLedger(TradeSendReq tradeSendReq) {
+        log.info("保存对账单入参:{}", JSONObject.toJSONString(tradeSendReq));
         Long id = tradeSendReq.getId();
         if (Objects.isNull(id)) {
             //新增
             tradeSendReq.setGenerateTime(LocalDateTime.now());
+            tradeSendReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
             Long aLong = saveDraft(tradeSendReq);
             tradeTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
         } else {
@@ -142,6 +204,7 @@ public class KwpLedgerTradeService extends AbsLedger {
             removeDraft(id);
             //在新增
             tradeSendReq.setGenerateTime(LocalDateTime.now());
+            tradeSendReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
             Long aLong = saveDraft(tradeSendReq);
             tradeTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
 
@@ -159,6 +222,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     public String sendLedgerDraft(TradeSendReq tradeSendReq) {
         log.info("贸易对账单保存草稿:{}", JSONObject.toJSONString(tradeSendReq));
         tradeSendReq.setGenerateTime(null);
+        tradeSendReq.setStatus(LedgerEnum.SAVE.getStatus());
         Long aLong = saveDraft(tradeSendReq);
         tradeTrackService.saveTrack(aLong, "", LedgerTrackEnum.SAVE);
         return "草稿保存成功";
@@ -172,6 +236,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         }
         deleteCheck(kwpLedgerTrade.getStatus());
         kwpLedgerTrade.setDelFlag(1);
+        kwpLedgerTrade.setUpdateTime(LocalDateTime.now());
         tradeMapper.updateById(kwpLedgerTrade);
         tradeTrackService.saveTrack(kwpLedgerTrade.getId(), "", LedgerTrackEnum.DELETE);
         return "删除成功";
@@ -203,7 +268,6 @@ public class KwpLedgerTradeService extends AbsLedger {
      */
     public List<KwpLedgerTradeTrack> queryBack(Long id) {
         return tradeTrackService.selectList(id, LedgerTrackEnum.REJECT);
-
     }
 
     /**
@@ -217,6 +281,10 @@ public class KwpLedgerTradeService extends AbsLedger {
         if (Objects.isNull(kwpLedgerTrade)) {
             throw new BusinessException("对账单不存在!");
         }
+        backCheck(kwpLedgerTrade.getStatus());
+        kwpLedgerTrade.setStatus(LedgerEnum.BACK.getStatus());
+        kwpLedgerTrade.setUpdateTime(LocalDateTime.now());
+        tradeMapper.updateById(kwpLedgerTrade);
         return tradeTrackService.saveTrack(ledgerReq.getId(), ledgerReq.getRemark(), LedgerTrackEnum.REJECT);
     }
 
@@ -231,6 +299,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         if (Objects.isNull(kwpLedgerTrade)) {
             throw new BusinessException("对账单不存在!");
         }
+        confirmCheck(kwpLedgerTrade.getStatus());
         kwpLedgerTrade.setStatus(LedgerEnum.LEDGERED.getStatus());
         kwpLedgerTrade.setAuditPhone(confirmReq.getAuditPhone());
         kwpLedgerTrade.setAuditUser(confirmReq.getAuditUser());
@@ -278,4 +347,25 @@ public class KwpLedgerTradeService extends AbsLedger {
         tradeTrackService.saveTrack(ledgerReq.getId(), "", LedgerTrackEnum.SUCCESS);
         return "对账完成";
     }
+
+    public List<LedgerCountVo> orderCount() {
+        Map<String, Long> map = tradeMapper.countOrder();
+        LedgerCountVo ledgerCountVo;
+        List<LedgerCountVo> res = new ArrayList<>();
+        for (LedgerEnum value : LedgerEnum.values()) {
+            ledgerCountVo = new LedgerCountVo();
+            ledgerCountVo.setCount(map.get(String.valueOf(value.getStatus())));
+            ledgerCountVo.setLabel(value.getDesc());
+            ledgerCountVo.setStatus(value.getStatus());
+            res.add(ledgerCountVo);
+        }
+        return res;
+    }
+
+    public List<LedgerTradeDto> selectList(List<Long> ids) {
+        List<LedgerTradeDto> ledgerTradeDto = tradeMapper.selectIds(ids);
+        changeDict(ledgerTradeDto);
+        return ledgerTradeDto;
+    }
+
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeTrackService.java

@@ -48,7 +48,7 @@ public class KwpLedgerTradeTrackService {
      */
     public List<KwpLedgerTradeTrack> selectList(@NotNull Long id, LedgerTrackEnum status) {
         LambdaQueryWrapper<KwpLedgerTradeTrack> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpLedgerTradeTrack::getId, id);
+        wrapper.eq(KwpLedgerTradeTrack::getTLedgerId, id);
         wrapper.eq(Objects.nonNull(status), KwpLedgerTradeTrack::getStatus, status.getStatus());
         wrapper.eq(KwpLedgerTradeTrack::getDelFlag, 0);
         return tradeTrackMapper.selectList(wrapper);

+ 36 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -118,4 +118,40 @@
         FROM `kwp_ledger_trade`
         WHERE del_flag = 0;
     </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>
 </mapper>