Răsfoiți Sursa

新增部分对账、结算 运营app端接口;提供给合作单位删除,查询关联对账单、结算单的dubbo校验接口

xucaiqin 2 ani în urmă
părinte
comite
f4424ed8ab
30 a modificat fișierele cu 1067 adăugiri și 297 ștergeri
  1. 25 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java
  2. 13 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/constant/OrderEnum.java
  3. 7 0
      sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java
  4. 4 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java
  5. 14 9
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java
  6. 0 7
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java
  7. 253 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpLedgerLogisticsController.java
  8. 216 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpLedgerTradeController.java
  9. 55 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpSettlementLogisticsController.java
  10. 87 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpSettlementTradeController.java
  11. 8 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  12. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  13. 6 229
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerCarrierDto.java
  14. 2 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerPurchaseDto.java
  15. 2 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerSellDto.java
  16. 4 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/OrderDto.java
  17. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LedgerSuccessReq.java
  18. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsReq.java
  19. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java
  20. 15 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerCountSumVo.java
  21. 2 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsDetailVo.java
  22. 60 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  23. 13 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsUnitService.java
  24. 89 34
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  25. 16 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeUnitService.java
  26. 22 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  27. 23 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  28. 52 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  29. 30 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  30. 38 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

+ 25 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java

@@ -0,0 +1,25 @@
+package com.sckw.payment.api.dubbo;
+
+import com.sckw.payment.api.model.constant.OrderEnum;
+
+import java.util.List;
+import java.util.Map;
+
+public interface PaymentDubboService {
+    /**
+     * 确认企业关联的对账单是否存在关联业务
+     *
+     * @param entId     企业id
+     * @return 关联的订单号
+     */
+    Map<OrderEnum,List<String>> checkLedger(Long entId);
+
+    /**
+     * 确认企业关联的结算单是否存在关联业务
+     *
+     * @param entId     企业id
+     * @return
+     */
+    Map<OrderEnum,List<String>> checkSettlement(Long entId);
+
+}

+ 13 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/constant/OrderEnum.java

@@ -0,0 +1,13 @@
+package com.sckw.payment.api.model.constant;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum OrderEnum {
+    LOGISTICS("1", "物流"),
+    TRADE("2", "贸易");
+    private final String code;
+    private final String value;
+}

+ 7 - 0
sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java

@@ -1,6 +1,7 @@
 package com.sckw.example.controller;
 
 import com.sckw.payment.api.dubbo.PayCenterDubboService;
+import com.sckw.payment.api.dubbo.PaymentDubboService;
 import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.dto.MemberDetail;
 import com.sckw.payment.api.model.dto.WalletDto;
@@ -20,6 +21,8 @@ import java.util.List;
 public class TestController {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private PayCenterDubboService payCenterDubboService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private PaymentDubboService paymentDubboService;
 
     @GetMapping("/detail")
     public R<MemberDetail> download(@RequestParam("uid") Long uid, String channel) {
@@ -30,5 +33,9 @@ public class TestController {
     public R<List<WalletDto>> wall(@RequestParam("uid") Long uid, String channel, Long filter) {
         return payCenterDubboService.wallet(uid, null, filter);
     }
+    @GetMapping("/test")
+    public R<Object> test(@RequestParam("entId") Long entId) {
+        return R.ok(paymentDubboService.checkSettlement(entId));
+    }
 
 }

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

@@ -64,7 +64,7 @@ public class KwpLedgerLogisticsController {
      * @return
      */
     @PostMapping("shipperList")
-    public HttpResult shipperList(@RequestBody @Valid LogisticsReq logisticsReq) {
+    public HttpResult shipperList(@RequestBody LogisticsReq logisticsReq) {
         return HttpResult.ok(kwpLedgerLogisticsService.shipperList(logisticsReq));
     }
 
@@ -86,7 +86,7 @@ public class KwpLedgerLogisticsController {
      * @return
      */
     @PostMapping("carrierList")
-    public HttpResult carrierList(@RequestBody @Valid LogisticsReq logisticsReq) {
+    public HttpResult carrierList(@RequestBody LogisticsReq logisticsReq) {
         return HttpResult.ok(kwpLedgerLogisticsService.carrierList(logisticsReq));
     }
 
@@ -141,7 +141,7 @@ public class KwpLedgerLogisticsController {
      * @return 物流对账单统计数据
      */
     @PostMapping("shipperCount")
-    public HttpResult shipperCount(@RequestBody @Valid LogisticsReq logisticsReq) {
+    public HttpResult shipperCount(@RequestBody LogisticsReq logisticsReq) {
         logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
         logisticsReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
         List<TableTop> tableTops = kwpLedgerLogisticsService.orderCount(logisticsReq);
@@ -159,7 +159,7 @@ public class KwpLedgerLogisticsController {
      * @return 物流对账单统计数据
      */
     @PostMapping("carrierCount")
-    public HttpResult carrierCount(@RequestBody @Valid LogisticsReq logisticsReq) {
+    public HttpResult carrierCount(@RequestBody  LogisticsReq logisticsReq) {
         logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
         logisticsReq.setUnitTypeTwo(LogisticsUnitType.CARRIER);
         return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq));

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

@@ -6,7 +6,8 @@ import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.payment.model.constant.LedgerEnum;
 import com.sckw.payment.model.constant.TradeUnitType;
-import com.sckw.payment.model.dto.ILedger;
+import com.sckw.payment.model.dto.LedgerPurchaseDto;
+import com.sckw.payment.model.dto.LedgerSellDto;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.LedgerTradeVo;
 import com.sckw.payment.service.KwpLedgerTradeService;
@@ -65,7 +66,7 @@ public class KwpLedgerTradeController {
      * @return
      */
     @PostMapping("sellList")
-    public HttpResult sellList(@RequestBody @Valid TradeReq tradeReq) {
+    public HttpResult sellList(@RequestBody TradeReq tradeReq) {
         return HttpResult.ok(kwpLedgerTradeService.sellList(tradeReq));
     }
 
@@ -87,7 +88,7 @@ public class KwpLedgerTradeController {
      * @return
      */
     @PostMapping("purchaseList")
-    public HttpResult purchaseList(@RequestBody @Valid TradeReq tradeReq) {
+    public HttpResult purchaseList(@RequestBody TradeReq tradeReq) {
         return HttpResult.ok(kwpLedgerTradeService.purchaseList(tradeReq));
     }
 
@@ -141,7 +142,7 @@ public class KwpLedgerTradeController {
      * @return
      */
     @PostMapping("sellCount")
-    public HttpResult sellCount(@RequestBody @Valid TradeReq tradeReq) {
+    public HttpResult sellCount(@RequestBody  TradeReq tradeReq) {
         tradeReq.setUnitType(TradeUnitType.PURCHASE);
         tradeReq.setUnitTypeTwo(TradeUnitType.SELL);
         return HttpResult.ok(kwpLedgerTradeService.orderCount(tradeReq));
@@ -153,7 +154,7 @@ public class KwpLedgerTradeController {
      * @return
      */
     @PostMapping("purchaseCount")
-    public HttpResult purchaseCount(@RequestBody @Valid TradeReq tradeReq) {
+    public HttpResult purchaseCount(@RequestBody  TradeReq tradeReq) {
         tradeReq.setUnitType(TradeUnitType.SELL);
         tradeReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
         List<TableTop> tableTops = kwpLedgerTradeService.orderCount(tradeReq);
@@ -242,10 +243,12 @@ public class KwpLedgerTradeController {
      */
     @PostMapping("sellExport")
     public HttpResult sellExport(HttpServletResponse response, @RequestBody @Valid TradeReq tradeReq) {
-        List<ILedger> list;
+        List<LedgerSellDto> list;
 
         if (CollectionUtils.isEmpty(tradeReq.getIdList())) {
-            PageRes<ILedger> pageResult = kwpLedgerTradeService.sellList(tradeReq);
+            tradeReq.setPage(0);
+            tradeReq.setPageSize(0);
+            PageRes<LedgerSellDto> pageResult = kwpLedgerTradeService.sellList(tradeReq);
             list = pageResult.getList();
         } else {
             list = kwpLedgerTradeService.selectSellList(tradeReq.getIdList());
@@ -272,9 +275,11 @@ public class KwpLedgerTradeController {
      */
     @PostMapping("purchaseExport")
     public HttpResult purchaseExport(HttpServletResponse response, @RequestBody @Valid TradeReq tradeReq) {
-        List<ILedger> list;
+        List<LedgerPurchaseDto> list;
         if (CollectionUtils.isEmpty(tradeReq.getIdList())) {
-            PageRes<ILedger> pageResult = kwpLedgerTradeService.purchaseList(tradeReq);
+            tradeReq.setPage(0);
+            tradeReq.setPageSize(0);
+            PageRes<LedgerPurchaseDto> pageResult = kwpLedgerTradeService.purchaseList(tradeReq);
             list = pageResult.getList();
         } else {
             list = kwpLedgerTradeService.selectPurchaseList(tradeReq.getIdList());

+ 0 - 7
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java

@@ -153,13 +153,6 @@ public class KwpSettlementTradeController {
         }
         return this.export(response, list);
     }
-
-    @GetMapping(name = "付款-采购结算订单详情", path = "detailPayment")
-    public HttpResult detailPayment(@RequestParam("id") Long id) {
-//        return HttpResult.ok(kwpSettlementTradeService.detailPayment(id));
-        return HttpResult.ok(null);
-    }
-
     /**
      * 导出
      *

+ 253 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpLedgerLogisticsController.java

@@ -0,0 +1,253 @@
+package com.sckw.payment.controller.app;
+
+import com.sckw.core.model.vo.TableTop;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.constant.LedgerEnum;
+import com.sckw.payment.model.constant.LogisticsUnitType;
+import com.sckw.payment.model.vo.req.*;
+import com.sckw.payment.service.KwpLedgerLogisticsService;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 对账-物流订单
+ *
+ * @author xucaiqin
+ */
+@Validated
+@RestController
+@RequestMapping("/appKwpLedgerLogistics")
+public class AppKwpLedgerLogisticsController {
+    @Resource
+    private KwpLedgerLogisticsService kwpLedgerLogisticsService;
+
+    /**
+     * 物流对账单-发起对账(保存草稿)(承运方)
+     *
+     * @param logisticsReq 保存物流对账单参数
+     * @return
+     */
+    @PostMapping("sendDraft")
+    public HttpResult sendDraft(@RequestBody @Valid LogisticsSendReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.sendLedgerDraft(logisticsReq));
+    }
+
+    /**
+     * 物流对账单-发起对账(承运方)
+     *
+     * @param logisticsReq 保存物流对账单参数
+     * @return
+     */
+    @PostMapping("send")
+    public HttpResult send(@RequestBody @Valid LogisticsSendReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.sendLedger(logisticsReq));
+    }
+
+    /**
+     * 托运方物流对账单列表查询
+     *
+     * @param logisticsReq 物流订单查询参数
+     * @return
+     */
+    @PostMapping("shipperList")
+    public HttpResult shipperList(@RequestBody @Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.shipperList(logisticsReq));
+    }
+
+    /**
+     * 托运方物流对账单统计
+     *
+     * @param logisticsReq 物流订单查询参数
+     * @return 对账单梳理、对账单金额
+     */
+    @PostMapping("shipperSum")
+    public HttpResult shipperSum(@RequestBody @Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.shipperSum(logisticsReq));
+    }
+
+    /**
+     * 托运方对账单关联订单
+     *
+     * @param ledgerListReq 对账单id
+     * @return
+     */
+    @GetMapping("shipperOrderList")
+    public HttpResult shipperOrderList(@Valid LedgerListReq ledgerListReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryOrderList(ledgerListReq));
+    }
+
+    /**
+     * 承运方物流对账单列表查询(物流公司、收钱方)
+     *
+     * @param logisticsReq 物流订单查询参数
+     * @return
+     */
+    @PostMapping("carrierList")
+    public HttpResult carrierList(@RequestBody @Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.carrierList(logisticsReq));
+    }
+
+
+    /**
+     * 承运方物流对账单统计
+     *
+     * @param logisticsReq
+     * @return 对账应收金额、对账单数量
+     */
+    @PostMapping("carrierSum")
+    public HttpResult carrierSum(@RequestBody @Valid LogisticsReq logisticsReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.carrierSum(logisticsReq));
+    }
+
+    /**
+     * 承运方对账单关联订单
+     *
+     * @param ledgerListReq 对账单id
+     * @return
+     */
+    @GetMapping("carrierOrderList")
+    public HttpResult carrierOrderList(@Valid LedgerListReq ledgerListReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryOrderList(ledgerListReq));
+    }
+
+    /**
+     * 承运方-查询物流对账单详情
+     *
+     * @param id 物流对账单id
+     * @return 物流对账单详情
+     */
+    @GetMapping("queryCarrierDetail")
+    public HttpResult queryCarrierDetail(@RequestParam("id") @NotBlank(message = "物流对账单id不能为空") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id), LogisticsUnitType.SHIPPER));
+    }
+
+    /**
+     * 托运方-查询物流对账单详情
+     *
+     * @param id 物流对账单id
+     * @return 物流对账单详情
+     */
+    @GetMapping("queryShipperDetail")
+    public HttpResult queryDetail(@RequestParam("id") @NotBlank(message = "物流对账单id不能为空") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryDetail(Long.valueOf(id), LogisticsUnitType.CARRIER));
+    }
+
+    /**
+     * 修改物流对账单详情(修改物流对账单接口使用) 仅发起对账方支持修改
+     *
+     * @param id 物流对账单id
+     * @return 物流对账单详情
+     */
+    @GetMapping("queryUpdate")
+    public HttpResult queryUpdate(@RequestParam("id") @NotBlank(message = "物流对账单id不能为空") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryUpdate(Long.valueOf(id)));
+    }
+
+    /**
+     * 托运方
+     *
+     * @param logisticsReq 物流订单查询参数
+     * @return 物流对账单统计数据
+     */
+    @PostMapping("shipperCount")
+    public HttpResult shipperCount(@RequestBody @Valid LogisticsReq logisticsReq) {
+        logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
+        List<TableTop> tableTops = kwpLedgerLogisticsService.orderCount(logisticsReq);
+        List<Integer> re = new ArrayList<>() {{
+            add(LedgerEnum.SAVE.getStatus());
+            add(LedgerEnum.REVOCATION.getStatus());
+        }};
+        return HttpResult.ok(tableTops.stream().filter(a -> !re.contains(a.getValue())).collect(Collectors.toList()));
+    }
+
+    /**
+     * 承运方
+     *
+     * @param logisticsReq 物流订单查询参数
+     * @return 物流对账单统计数据
+     */
+    @PostMapping("carrierCount")
+    public HttpResult carrierCount(@RequestBody @Valid LogisticsReq logisticsReq) {
+        logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.CARRIER);
+        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq));
+    }
+
+    /**
+     * 删除对账单
+     * 释放关联的订单(只有删除操作才释放订单)
+     *
+     * @param id 物流对账单id
+     * @return
+     */
+    @DeleteMapping("delete")
+    public HttpResult delete(@RequestParam("id") @NotBlank(message = "物流对账单id不能为空") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.remove(Long.valueOf(id)));
+    }
+
+    /**
+     * 物流对账单-撤回对账
+     *
+     * @param id 物流对账单id
+     * @return
+     */
+    @PostMapping("back")
+    public HttpResult back(@RequestParam("id") @NotBlank(message = "物流对账单id不能为空") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.backOrder(Long.valueOf(id)));
+    }
+
+    /**
+     * 物流对账单-对账确认
+     *
+     * @param confirmReq
+     * @return
+     */
+    @PostMapping("confirm")
+    public HttpResult confirm(@RequestBody @Valid LedgerConfirmReq confirmReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.confirmOrder(confirmReq));
+    }
+
+    /**
+     * 物流对账单-驳回查询
+     *
+     * @param id 物流对账单id
+     * @return
+     */
+    @GetMapping("queryBack")
+    public HttpResult queryBack(@RequestParam("id") @NotBlank(message = "物流对账单id不能为空") String id) {
+        return HttpResult.ok(kwpLedgerLogisticsService.queryBack(Long.valueOf(id)));
+    }
+
+    /**
+     * 物流对账单-驳回
+     *
+     * @param ledgerReq 驳回参数
+     * @return
+     */
+    @PostMapping("doBack")
+    public HttpResult doBack(@RequestBody @Valid LedgerReq ledgerReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.doBack(ledgerReq));
+    }
+
+    /**
+     * 物流对账单-对账完成
+     * <p>
+     * 生成结算单
+     * </p>
+     *
+     * @param ledgerReq 对账完成参数
+     * @return
+     */
+    @PostMapping("success")
+    public HttpResult orderSuccess(@RequestBody @Valid LedgerSuccessReq ledgerReq) {
+        return HttpResult.ok(kwpLedgerLogisticsService.orderSuccess(ledgerReq));
+    }
+}

+ 216 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpLedgerTradeController.java

@@ -0,0 +1,216 @@
+package com.sckw.payment.controller.app;
+
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.constant.TradeUnitType;
+import com.sckw.payment.model.vo.req.*;
+import com.sckw.payment.service.KwpLedgerTradeService;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * app端接口
+ * 对账-交易订单
+ *
+ * @author xucaiqin
+ */
+@RestController
+@RequestMapping("/appKwpLedgerTrade")
+@Validated
+public class AppKwpLedgerTradeController {
+    @Resource
+    private KwpLedgerTradeService kwpLedgerTradeService;
+
+
+    /**
+     * 贸易对账单-发起对账(保存草稿)
+     *
+     * @param tradeSendReq
+     * @return
+     */
+    @PostMapping("sendDraft")
+    public HttpResult sendDraft(@RequestBody @Valid TradeSendReq tradeSendReq) {
+        return HttpResult.ok(kwpLedgerTradeService.sendLedgerDraft(tradeSendReq));
+    }
+
+    /**
+     * 贸易对账单-发起对账
+     *
+     * @param tradeSendReq
+     * @return
+     */
+    @PostMapping("send")
+    public HttpResult send(@RequestBody @Valid TradeSendReq tradeSendReq) {
+        return HttpResult.ok(kwpLedgerTradeService.sendLedger(tradeSendReq));
+    }
+
+    /**
+     * 贸易对账单列表查询 销售方
+     *
+     * @param tradeReq
+     * @return
+     */
+    @PostMapping("sellList")
+    public HttpResult sellList(@RequestBody @Valid TradeReq tradeReq) {
+        return HttpResult.ok(kwpLedgerTradeService.sellList(tradeReq));
+    }
+
+    /**
+     * 贸易对账单统计数据 销售方
+     *
+     * @param tradeReq
+     * @return
+     */
+    @PostMapping("sellSum")
+    public HttpResult sellSum(@RequestBody @Valid TradeReq tradeReq) {
+        return HttpResult.ok(kwpLedgerTradeService.sellSum(tradeReq));
+    }
+
+    /**
+     * 销售方对账单关联订单
+     *
+     * @param ledgerListReq 对账单id
+     * @return
+     */
+    @GetMapping("sellOrderList")
+    public HttpResult sellOrderList(@Valid LedgerListReq ledgerListReq) {
+        return HttpResult.ok(kwpLedgerTradeService.queryOrderList(ledgerListReq));
+    }
+
+    /**
+     * 贸易对账单列表查询 采购方
+     *
+     * @param tradeReq
+     * @return
+     */
+    @PostMapping("purchaseList")
+    public HttpResult purchaseList(@RequestBody @Valid TradeReq tradeReq) {
+        return HttpResult.ok(kwpLedgerTradeService.purchaseList(tradeReq));
+    }
+    /**
+     * 贸易对账单统计 采购方
+     *
+     * @param tradeReq
+     * @return
+     */
+    @PostMapping("purchaseSum")
+    public HttpResult purchaseSum(@RequestBody @Valid TradeReq tradeReq) {
+        return HttpResult.ok(kwpLedgerTradeService.purchaseSum(tradeReq));
+    }
+    /**
+     * 对账单关联订单
+     *
+     * @param ledgerListReq 对账单id
+     * @return
+     */
+    @GetMapping("purchaseOrderList")
+    public HttpResult purchaseOrderList(@Valid LedgerListReq ledgerListReq) {
+        return HttpResult.ok(kwpLedgerTradeService.queryOrderList(ledgerListReq));
+    }
+
+    /**
+     * 销售-查询贸易对账单详情
+     *
+     * @param id 对账单id
+     * @return
+     */
+    @GetMapping("querySellDetail")
+    public HttpResult querySellDetail(@NotBlank(message = "id不能为空")@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id), TradeUnitType.PURCHASE));
+    }
+
+    /**
+     * 采购-查询贸易对账单详情
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("queryPurchaseDetail")
+    public HttpResult queryPurchaseDetail(@NotBlank(message = "id不能为空")@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id), TradeUnitType.SELL));
+    }
+
+    /**
+     * 修改贸易对账单详情(修改物流对账单接口使用)
+     *
+     * @param id 对账单id
+     * @return
+     */
+    @GetMapping("queryUpdate")
+    public HttpResult queryUpdate(@NotBlank(message = "id不能为空")@RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryUpdate(Long.valueOf(id)));
+    }
+
+
+    /**
+     * 删除对账单
+     *
+     * @param id
+     * @return
+     */
+    @DeleteMapping("delete")
+    public HttpResult delete(@NotBlank(message = "id不能为空") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.remove(Long.valueOf(id)));
+    }
+
+    /**
+     * 贸易对账单-撤回对账
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("back")
+    public HttpResult back(@NotBlank(message = "id不能为空") @RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.backOrder(Long.valueOf(id)));
+    }
+
+    /**
+     * 贸易对账单-对账确认
+     *
+     * @param confirmReq
+     * @return
+     */
+    @PostMapping("confirm")
+    public HttpResult confirm(@RequestBody @Valid LedgerConfirmReq confirmReq) {
+        return HttpResult.ok(kwpLedgerTradeService.confirmOrder(confirmReq));
+    }
+
+    /**
+     * 贸易对账单-驳回查询
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("queryBack")
+    public HttpResult queryBack(@NotBlank(message = "id不能为空") @RequestParam("id") String id) {
+        return HttpResult.ok(kwpLedgerTradeService.queryBack(Long.valueOf(id)));
+    }
+
+    /**
+     * 贸易对账单-驳回对账
+     *
+     * @param ledgerReq
+     * @return
+     */
+    @PostMapping("doBack")
+    public HttpResult doBack(@RequestBody @Valid LedgerReq ledgerReq) {
+        return HttpResult.ok(kwpLedgerTradeService.doBack(ledgerReq));
+    }
+
+    /**
+     * 贸易对账单-对账完成
+     * <p>
+     * 生成结算单
+     * </p>
+     *
+     * @param ledgerReq
+     * @return
+     */
+    @PostMapping("success")
+    public HttpResult orderSuccess(@RequestBody @Valid LedgerSuccessReq ledgerReq) {
+        return HttpResult.ok(kwpLedgerTradeService.orderSuccess(ledgerReq));
+    }
+
+}

+ 55 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpSettlementLogisticsController.java

@@ -0,0 +1,55 @@
+package com.sckw.payment.controller.app;
+
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.vo.req.SettlementReq;
+import com.sckw.payment.service.KwpSettlementLogisticsService;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 结算-物流订单
+ *
+ * @author Aick Spt
+ * @date 2023-07-18 16:34
+ */
+@RestController
+@RequestMapping("/appKwpSettlementLogistics")
+public class AppKwpSettlementLogisticsController {
+
+    @Resource
+    private KwpSettlementLogisticsService kwpSettlementLogisticsService;
+
+    //   ========= 运费收款 承运方 =========
+    @PostMapping(name = "运费收款-物流订单列表", path = "pageListCollection")
+    public HttpResult pageSelectCollection(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.pageSelectCollection(settlementReq));
+    }
+
+    @PostMapping(name = "运费收款-物流订单各状态列表总数", path = "getCountListCollection")
+    public HttpResult getCountListCollection(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.getCountListCollection(settlementReq));
+    }
+
+    @GetMapping(name = "运费收款-物流订单详情", path = "detailCollection")
+    public HttpResult detailCollection(@RequestParam("id") Long id) {
+        return HttpResult.ok(kwpSettlementLogisticsService.detailCollection(id));
+    }
+
+
+    //   ========= 运费付款 托运方 =========
+    @PostMapping(name = "运费付款-物流订单列表", path = "pageListPayment")
+    public HttpResult pageSelectPayment(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.pageSelectPayment(settlementReq));
+    }
+
+    @PostMapping(name = "运费付款-物流订单各状态列表总数", path = "getCountListPayment")
+    public HttpResult getCountListPayment(@RequestBody @Valid SettlementReq settlementReq) {
+        return HttpResult.ok(kwpSettlementLogisticsService.getCountListPayment(settlementReq));
+    }
+
+    @GetMapping(name = "物流订单详情", path = "detailPayment")
+    public HttpResult detailPayment(@RequestParam("id") Long id) {
+        return HttpResult.ok(kwpSettlementLogisticsService.detailPayment(id));
+    }
+}

+ 87 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpSettlementTradeController.java

@@ -0,0 +1,87 @@
+package com.sckw.payment.controller.app;
+
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.constant.TradeUnitType;
+import com.sckw.payment.model.vo.req.SettlementTradeReq;
+import com.sckw.payment.service.KwpSettlementTradeService;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 结算-交易订单
+ *
+ * @author xucaiqin
+ */
+@RestController
+@RequestMapping("/appKwpSettlementTrade")
+public class AppKwpSettlementTradeController {
+
+    @Resource
+    private KwpSettlementTradeService kwpSettlementTradeService;
+
+    //   ========= 收款 销售 =========
+
+    /**
+     * 销售分页列表
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-销售结算单列表", path = "pageSellList")
+    public HttpResult pageListCollection(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
+        settlementReq.check();
+        return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
+    }
+
+    /**
+     * 待结算、部分结算、全部结算
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表头统计数量", path = "getSellCount")
+    public HttpResult getCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+        settlementReq.check();
+        return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
+    }
+
+
+    //   ========= 付款 采购 =========
+
+    /**
+     * 采购分页列表
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "付款-采购结算单列表", path = "pagePurchaseList")
+    public HttpResult pageListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        settlementReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
+        return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
+    }
+
+    /**
+     * 待结算、部分结算、全部结算
+     *
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping(name = "收款-表头统计数量", path = "getPurchaseCount")
+    public HttpResult getPurchaseCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
+        settlementReq.setUnitType(TradeUnitType.SELL);
+        settlementReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+        return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
+    }
+
+}

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

@@ -6,6 +6,7 @@ import com.sckw.payment.model.dto.LedgerCarrierDto;
 import com.sckw.payment.model.dto.LedgerLogisticsDto;
 import com.sckw.payment.model.dto.LedgerShipperDto;
 import com.sckw.payment.model.vo.req.LogisticsReq;
+import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -58,5 +59,12 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     List<LedgerCarrierDto> selectCarrierIds(@Param("ids") List<Long> ids);
 
+    /**
+     * 统计对账金额、对账单数量
+     *
+     * @param logisticsReq
+     * @return
+     */
+    LedgerCountSumVo countSum(@Param("logisticsReq") LogisticsReq logisticsReq);
 
 }

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

@@ -6,6 +6,7 @@ import com.sckw.payment.model.dto.LedgerPurchaseDto;
 import com.sckw.payment.model.dto.LedgerSellDto;
 import com.sckw.payment.model.dto.LedgerTradeDto;
 import com.sckw.payment.model.vo.req.TradeReq;
+import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -31,4 +32,6 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
     List<LedgerSellDto> selectSellIds(@Param("ids") List<Long> ids);
 
     List<LedgerPurchaseDto> selectPurchaseIds(@Param("ids") List<Long> ids);
+
+    LedgerCountSumVo countSum(@Param("tradeReq") TradeReq tradeReq);
 }

+ 6 - 229
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerCarrierDto.java

@@ -1,6 +1,9 @@
 package com.sckw.payment.model.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.Setter;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -11,6 +14,8 @@ import java.time.LocalDateTime;
  * @author xucaiqin
  * @date 2023-07-10 18:11:24
  */
+@Getter
+@Setter
 public class LedgerCarrierDto implements ILedger {
 
     /**
@@ -20,6 +25,7 @@ public class LedgerCarrierDto implements ILedger {
     /**
      * 物流对账单编号
      */
+    @JsonProperty("lLedgerNo")
     private String lLedgerNo;
 
     /**
@@ -136,233 +142,4 @@ public class LedgerCarrierDto implements ILedger {
      * 订单数量
      */
     private Integer orderCount;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public String getlLedgerNo() {
-        return lLedgerNo;
-    }
-
-    public void setlLedgerNo(String lLedgerNo) {
-        this.lLedgerNo = lLedgerNo;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Long getEntId() {
-        return entId;
-    }
-
-    public void setEntId(Long entId) {
-        this.entId = entId;
-    }
-
-    public String getAuditPhone() {
-        return auditPhone;
-    }
-
-    public void setAuditPhone(String auditPhone) {
-        this.auditPhone = auditPhone;
-    }
-
-    public String getAuditUser() {
-        return auditUser;
-    }
-
-    public void setAuditUser(String auditUser) {
-        this.auditUser = auditUser;
-    }
-
-    public Long getCheckEntId() {
-        return checkEntId;
-    }
-
-    public void setCheckEntId(Long checkEntId) {
-        this.checkEntId = checkEntId;
-    }
-
-    public Long getCarrierEntId() {
-        return carrierEntId;
-    }
-
-    public void setCarrierEntId(Long carrierEntId) {
-        this.carrierEntId = carrierEntId;
-    }
-
-    public LocalDateTime getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(LocalDateTime startTime) {
-        this.startTime = startTime;
-    }
-
-    public LocalDateTime getEndTime() {
-        return endTime;
-    }
-
-    public void setEndTime(LocalDateTime endTime) {
-        this.endTime = endTime;
-    }
-
-    public String getTaxRateLabel() {
-        return taxRateLabel;
-    }
-
-    @Override
-    public void setTaxRateLabel(String taxRateLabel) {
-        this.taxRateLabel = taxRateLabel;
-    }
-
-    public Integer getTaxRate() {
-        return taxRate;
-    }
-
-    public void setTaxRate(Integer taxRate) {
-        this.taxRate = taxRate;
-    }
-
-    @Override
-    public String getTrading() {
-        return trading;
-    }
-
-    @Override
-    public void setTrading(String trading) {
-        this.trading = trading;
-    }
-
-    public String getTradingLabel() {
-        return tradingLabel;
-    }
-
-    @Override
-    public void setTradingLabel(String tradingLabel) {
-        this.tradingLabel = tradingLabel;
-    }
-
-    public BigDecimal getTotalPrice() {
-        return totalPrice;
-    }
-
-    public void setTotalPrice(BigDecimal totalPrice) {
-        this.totalPrice = totalPrice;
-    }
-
-    public BigDecimal getExTaxPrice() {
-        return exTaxPrice;
-    }
-
-    public void setExTaxPrice(BigDecimal exTaxPrice) {
-        this.exTaxPrice = exTaxPrice;
-    }
-
-    public BigDecimal getSettlePrice() {
-        return settlePrice;
-    }
-
-    public void setSettlePrice(BigDecimal settlePrice) {
-        this.settlePrice = settlePrice;
-    }
-
-    public BigDecimal getActualPrice() {
-        return actualPrice;
-    }
-
-    public void setActualPrice(BigDecimal actualPrice) {
-        this.actualPrice = actualPrice;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public LocalDateTime getGenerateTime() {
-        return generateTime;
-    }
-
-    public void setGenerateTime(LocalDateTime generateTime) {
-        this.generateTime = generateTime;
-    }
-
-    public LocalDateTime getReceiptTime() {
-        return receiptTime;
-    }
-
-    public void setReceiptTime(LocalDateTime receiptTime) {
-        this.receiptTime = receiptTime;
-    }
-
-    public String getRemark() {
-        return remark;
-    }
-
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
-
-    public Integer getStatus() {
-        return status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public String getStatusLabel() {
-        return statusLabel;
-    }
-
-    @Override
-    public void setStatusLabel(String statusLabel) {
-        this.statusLabel = statusLabel;
-    }
-
-    public String getContacts() {
-        return contacts;
-    }
-
-    public void setContacts(String contacts) {
-        this.contacts = contacts;
-    }
-
-    public String getPhone() {
-        return phone;
-    }
-
-    public void setPhone(String phone) {
-        this.phone = phone;
-    }
-
-    public String getFirmName() {
-        return firmName;
-    }
-
-    public void setFirmName(String firmName) {
-        this.firmName = firmName;
-    }
-
-    public Integer getOrderCount() {
-        return orderCount;
-    }
-
-    public void setOrderCount(Integer orderCount) {
-        this.orderCount = orderCount;
-    }
 }

+ 2 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerPurchaseDto.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -23,6 +24,7 @@ public class LedgerPurchaseDto implements ILedger {
     /**
      * 贸易对账单编号
      */
+    @JsonProperty("tLedgerNo")
     private String tLedgerNo;
 
     /**

+ 2 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerSellDto.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -23,6 +24,7 @@ public class LedgerSellDto implements ILedger {
     /**
      * 贸易对账单编号
      */
+    @JsonProperty("tLedgerNo")
     private String tLedgerNo;
 
     /**

+ 4 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/OrderDto.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -11,7 +12,9 @@ public class OrderDto {
     private Long entId;
     private String trading;
     private String tradingLabel;
-    private Long torderId;
+    @JsonProperty("tOrderId")
+    private Long tOrderId;
+    @JsonProperty("tOrderNo")
     private String tOrderNo;
     private String contractNo;
     private Long goodsId;

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

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

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

@@ -3,6 +3,7 @@ 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.NotBlank;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,8 +19,10 @@ public class LogisticsReq extends BasePara {
     @Serial
     private static final long serialVersionUID = 5328731681168692784L;
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @NotBlank(message = "创建开始时间不能为空")
     private String startCreateTime;
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @NotBlank(message = "创建结算时间不能为空")
     private String endCreateTime;
     private String trading;
     /**

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

@@ -2,6 +2,7 @@ package com.sckw.payment.model.vo.req;
 
 import com.sckw.core.model.vo.BasePara;
 import com.sckw.payment.model.constant.LedgerEnum;
+import jakarta.validation.constraints.NotBlank;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -16,7 +17,9 @@ import java.io.Serial;
 public class TradeReq extends BasePara {
     @Serial
     private static final long serialVersionUID = 5328731681168692784L;
+    @NotBlank(message = "创建开始时间不能为空")
     private String startCreateTime;
+    @NotBlank(message = "创建结束时间不能为空")
     private String endCreateTime;
     private String trading;
     /**

+ 15 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerCountSumVo.java

@@ -0,0 +1,15 @@
+package com.sckw.payment.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author xucaiqin
+ * @date 2023-08-17 14:03:38
+ */
+@Getter
+@Setter
+public class LedgerCountSumVo {
+    private String totalPrice;
+    private String ledgerCount;
+}

+ 2 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsDetailVo.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.vo.res;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.sckw.transport.api.model.dto.LogisticsOrderDTO;
 import lombok.Getter;
 import lombok.Setter;
@@ -20,6 +21,7 @@ import java.util.List;
 @Setter
 public class LedgerLogisticsDetailVo {
     private Long id;
+    @JsonProperty("lLedgerNo")
     private String lLedgerNo;
     private Long checkEntId;
     private String name;

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

@@ -1,5 +1,6 @@
 package com.sckw.payment.service;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.NumberConstant;
@@ -25,6 +26,7 @@ import com.sckw.payment.model.dto.LedgerCarrierDto;
 import com.sckw.payment.model.dto.LedgerLogisticsDto;
 import com.sckw.payment.model.dto.LedgerShipperDto;
 import com.sckw.payment.model.vo.req.*;
+import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import com.sckw.payment.model.vo.res.LedgerLogisticsDetailVo;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
@@ -100,6 +102,12 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         }
     }
 
+    /**
+     * 托运方物流对账单列表查询
+     *
+     * @param logisticsReq
+     * @return 托运方对账订单分页数据
+     */
     public PageRes<ILedger> shipperList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
         logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
@@ -115,6 +123,19 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         return new PageRes<>();
     }
 
+    /**
+     * 托运方 统计物流对账单
+     *
+     * @param logisticsReq
+     * @return
+     */
+    public LedgerCountSumVo shipperSum(LogisticsReq logisticsReq) {
+        fillPara(logisticsReq);
+        logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
+        return logisticsMapper.countSum(logisticsReq);
+    }
+
     public PageRes<ILedger> carrierList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
         logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
@@ -130,6 +151,13 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         return new PageRes<>();
     }
 
+    public LedgerCountSumVo carrierSum(LogisticsReq logisticsReq) {
+        fillPara(logisticsReq);
+        logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.CARRIER);
+        return logisticsMapper.countSum(logisticsReq);
+    }
+
     /**
      * 保存物流对账单
      *
@@ -138,6 +166,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      */
     @GlobalTransactional(name = "default_tx_group", rollbackFor = Exception.class)
     public String sendLedger(LogisticsSendReq logisticsReq) {
+        log.info("保存物流对账单:{}", JSONObject.toJSONString(logisticsReq));
         String id = logisticsReq.getId();
         if (StringUtils.isBlank(id)) {
             //新增
@@ -203,12 +232,12 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpLedgerLogistics.setStatus(logisticsSendReq.getStatus());
         kwpLedgerLogistics.setDelFlag(Global.UN_DELETED);
         //id为空,新增对账单
-        if (Objects.isNull(logisticsSendReq.getId())) {
+        if (Objects.isNull(logisticsSendReq.getIdLong())) {
             kwpLedgerLogistics.setCreateBy(LoginUserHolder.getUserId());
             kwpLedgerLogistics.setCreateTime(LocalDateTime.now());
             kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
             kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
-            kwpLedgerLogistics.setLLedgerNo(OrderGenerateUtils.generateOrderNo("LL"));
+            kwpLedgerLogistics.setLLedgerNo(OrderGenerateUtils.generateOrderNo("TR"));
             logisticsMapper.insert(kwpLedgerLogistics);
         } else {
             //校验是否可以修改对账单
@@ -322,6 +351,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      */
     @GlobalTransactional(name = "default_tx_group", rollbackFor = Exception.class)
     public String sendLedgerDraft(LogisticsSendReq logisticsReq) {
+        log.info("物流对账单草稿:{}", JSONObject.toJSONString(logisticsReq));
         logisticsReq.setGenerateTime(null);
         logisticsReq.setStatus(LedgerEnum.SAVE.getStatus());
         Long aLong = saveDraft(logisticsReq);
@@ -466,7 +496,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         kwpSettlementLogistics.setId(new IdWorker(NumberConstant.ONE).nextId());
         kwpSettlementLogistics.setEntId(LoginUserHolder.getEntId());
         kwpSettlementLogistics.setLLedgerId(kwpLedgerLogistics.getId());
-        kwpSettlementLogistics.setSlOrderNo(OrderGenerateUtils.generateOrderNo("SL"));
+        kwpSettlementLogistics.setSlOrderNo(OrderGenerateUtils.generateOrderNo("TP"));
         kwpSettlementLogistics.setName(kwpLedgerLogistics.getName());//取物流对账单名称
         kwpSettlementLogistics.setTotalPrice(kwpLedgerLogistics.getTotalPrice());
         kwpSettlementLogistics.setActualPrice(kwpLedgerLogistics.getActualPrice());
@@ -616,4 +646,31 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         return PageRes.build(pageInfo, acceptCarriageOrderList);
     }
 
+
+    public List<LogisticsOrderDTO> queryOrderList(LedgerListReq ledgerListReq) {
+        List<KwpLedgerLogisticsOrder> kwpLedgerLogisticsOrders = logisticsOrderService.queryList(ledgerListReq.getIdLong());
+        if (CollectionUtils.isEmpty(kwpLedgerLogisticsOrders)) {
+            return new ArrayList<>();
+        }
+        List<LogisticsOrderDTO> res = transportDubboService.getAcceptCarriageOrderList(kwpLedgerLogisticsOrders.stream().map(a -> String.valueOf(a.getLOrderId())).toList());
+        if (!CollectionUtils.isEmpty(res)) {
+            return res.stream().filter(o -> StringUtils.contains(o.getLOrderNO(), ledgerListReq.getKeywords()) ||
+                    StringUtils.contains(o.getGoodsName(), ledgerListReq.getKeywords())).toList();
+        }
+        return new ArrayList<>();
+    }
+
+    /**
+     * 合作单位-合作管理 校验订单
+     *
+     * @param entId 企业id
+     */
+    public List<String> checkOrder(Long entId) {
+        List<Long> longs = logisticsUnitService.selectByEnt(entId);
+        if (CollectionUtils.isEmpty(longs)) {
+            return new ArrayList<>();
+        }
+        List<KwpLedgerLogistics> kwpLedgerLogistics = logisticsMapper.selectBatchIds(longs);
+        return kwpLedgerLogistics.stream().filter(a->!Objects.equals(a.getStatus(),LedgerEnum.SUCCESS.getStatus())).map(KwpLedgerLogistics::getLLedgerNo).distinct().toList();
+    }
 }

+ 13 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsUnitService.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.sckw.core.model.constant.Global;
 import com.sckw.payment.dao.KwpLedgerLogisticsUnitMapper;
@@ -9,6 +10,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -47,4 +49,15 @@ public class KwpLedgerLogisticsUnitService {
         wrapper.eq(KwpLedgerLogisticsUnit::getDelFlag, Global.UN_DELETED);
         logisticsUnitMapper.update(logisticsUnit, wrapper);
     }
+
+    public List<Long> selectByEnt(Long entId) {
+        List<KwpLedgerLogisticsUnit> kwpLedgerLogisticsUnits = logisticsUnitMapper.selectList(new LambdaQueryWrapper<KwpLedgerLogisticsUnit>()
+                .eq(KwpLedgerLogisticsUnit::getTopEntId, entId)
+                .eq(KwpLedgerLogisticsUnit::getDelFlag, Global.UN_DELETED));
+        if (CollectionUtils.isEmpty(kwpLedgerLogisticsUnits)) {
+            return new ArrayList<>();
+        }
+        return kwpLedgerLogisticsUnits.stream().map(KwpLedgerLogisticsUnit::getLLedgerId).distinct().toList();
+
+    }
 }

+ 89 - 34
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -22,12 +22,13 @@ import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.dto.*;
 import com.sckw.payment.model.vo.req.*;
+import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import com.sckw.payment.model.vo.res.LedgerTradeDetailVo;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
 import io.seata.spring.annotation.GlobalTransactional;
-import jakarta.annotation.Resource;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -47,17 +48,13 @@ import java.util.stream.Collectors;
 
 @Service
 @Slf4j
+@RequiredArgsConstructor
 public class KwpLedgerTradeService extends AbsLedger {
-    @Resource
-    private KwpLedgerTradeMapper tradeMapper;
-    @Resource
-    private KwpLedgerTradeTrackService tradeTrackService;
-    @Resource
-    private KwpLedgerTradeOrderService tradeOrderService;
-    @Resource
-    private KwpSettlementTradeService settlementTradeService;
-    @Resource
-    private KwpLedgerTradeUnitService tradeUnitService;
+    private final KwpLedgerTradeMapper tradeMapper;
+    private final KwpLedgerTradeTrackService tradeTrackService;
+    private final KwpLedgerTradeOrderService tradeOrderService;
+    private final KwpSettlementTradeService settlementTradeService;
+    private final KwpLedgerTradeUnitService tradeUnitService;
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
     @DubboReference(version = "1.0.0", group = "design", check = false)
@@ -68,7 +65,7 @@ public class KwpLedgerTradeService extends AbsLedger {
      *
      * @param list
      */
-    private void changeDict(List<ILedger> list) {
+    private void changeDict(List<? extends ILedger> list) {
         List<SysDictResDto> taxRateDict = remoteSystemService.queryDictByType(DictTypeEnum.TAX_RATE.getType());
         Map<String, String> taxRateMap = new HashMap<>();
         Map<String, String> tradingMap = new HashMap<>();
@@ -111,43 +108,64 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @param tradeReq
      * @return
      */
-    public PageRes<ILedger> sellList(TradeReq tradeReq) {
+    public PageRes<LedgerSellDto> sellList(TradeReq tradeReq) {
         fillPara(tradeReq);
-        PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        if (tradeReq.getPage() != 0 && tradeReq.getPageSize() != 0) {
+            PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        }
         tradeReq.setUnitType(TradeUnitType.PURCHASE);
         tradeReq.setUnitTypeTwo(TradeUnitType.SELL);
         List<LedgerSellDto> ledgerTradeDto = tradeMapper.sellList(tradeReq);
-        PageInfo<ILedger> ledgerPageInfo = new PageInfo<>(ledgerTradeDto);
-
         //字典转换
         if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
-            changeDict(ledgerPageInfo.getList());
-            return new PageRes<>(ledgerPageInfo);
+            changeDict(ledgerTradeDto);
+            return new PageRes<>(ledgerTradeDto);
         }
         return new PageRes<>();
     }
 
+    /**
+     * app端统计对账数据
+     *
+     * @param tradeReq
+     * @return 总应收、对账单数
+     */
+    public LedgerCountSumVo sellSum(TradeReq tradeReq) {
+        fillPara(tradeReq);
+        tradeReq.setUnitType(TradeUnitType.PURCHASE);
+        tradeReq.setUnitTypeTwo(TradeUnitType.SELL);
+        return tradeMapper.countSum(tradeReq);
+    }
+
     /**
      * 采购方
      *
      * @param tradeReq
      * @return
      */
-    public PageRes<ILedger> purchaseList(TradeReq tradeReq) {
+    public PageRes<LedgerPurchaseDto> purchaseList(TradeReq tradeReq) {
         fillPara(tradeReq);
-        PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        if (tradeReq.getPage() != 0 && tradeReq.getPageSize() != 0) {
+            PageHelper.startPage(tradeReq.getPage(), tradeReq.getPageSize());
+        }
         tradeReq.setUnitType(TradeUnitType.SELL);
         tradeReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
         List<LedgerPurchaseDto> ledgerTradeDto = tradeMapper.purchaseList(tradeReq);
-        PageInfo<ILedger> ledgerPageInfo = new PageInfo<>(ledgerTradeDto);
         //字典转换
         if (!CollectionUtils.isEmpty(ledgerTradeDto)) {
-            changeDict(ledgerPageInfo.getList());
-            return new PageRes<>(ledgerPageInfo);
+            changeDict(ledgerTradeDto);
+            return new PageRes<>(ledgerTradeDto);
         }
         return new PageRes<>(new PageInfo<>());
     }
 
+    public LedgerCountSumVo purchaseSum(TradeReq tradeReq) {
+        fillPara(tradeReq);
+        tradeReq.setUnitType(TradeUnitType.SELL);
+        tradeReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
+        return tradeMapper.countSum(tradeReq);
+    }
+
     private void removeDraft(Long id) {
         //删除kwp_ledger_trade_order
         tradeOrderService.remove(id);
@@ -185,7 +203,7 @@ public class KwpLedgerTradeService extends AbsLedger {
 
         kwpLedgerTrade.setDelFlag(Global.UN_DELETED);
         if (Objects.isNull(tradeSendReq.getId())) {
-            kwpLedgerTrade.setTLedgerNo(OrderGenerateUtils.generateOrderNo("TL"));
+            kwpLedgerTrade.setTLedgerNo(OrderGenerateUtils.generateOrderNo("BR"));
             kwpLedgerTrade.setCreateBy(LoginUserHolder.getUserId());
             kwpLedgerTrade.setCreateTime(LocalDateTime.now());
             kwpLedgerTrade.setUpdateBy(LoginUserHolder.getUserId());
@@ -486,7 +504,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         kwpSettlementTrade.setId(new IdWorker(NumberConstant.ONE).nextId());
         kwpSettlementTrade.setEntId(LoginUserHolder.getEntId());
         kwpSettlementTrade.setTLedgerId(kwpLedgerTrade.getId());
-        kwpSettlementTrade.setStOrderNo(OrderGenerateUtils.generateOrderNo("ST"));
+        kwpSettlementTrade.setStOrderNo(OrderGenerateUtils.generateOrderNo("BP"));
         kwpSettlementTrade.setName(kwpLedgerTrade.getName());
         kwpSettlementTrade.setTotalPrice(kwpLedgerTrade.getTotalPrice());
         kwpSettlementTrade.setActualPrice(kwpLedgerTrade.getActualPrice());
@@ -546,14 +564,13 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @param ids 对账单id列表
      * @return 对账单数据
      */
-    public List<ILedger> selectSellList(List<Long> ids) {
+    public List<LedgerSellDto> selectSellList(List<Long> ids) {
         if (CollectionUtils.isEmpty(ids)) {
             return new ArrayList<>();
         }
         List<LedgerSellDto> ledgerTradeDto = tradeMapper.selectSellIds(ids);
-        List<ILedger> ledgerSellDto = new ArrayList<>(ledgerTradeDto);
-        changeDict(ledgerSellDto);
-        return ledgerSellDto;
+        changeDict(ledgerTradeDto);
+        return ledgerTradeDto;
     }
 
     /**
@@ -562,14 +579,13 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @param ids 对账单id列表
      * @return 对账单数据
      */
-    public List<ILedger> selectPurchaseList(List<Long> ids) {
+    public List<LedgerPurchaseDto> selectPurchaseList(List<Long> ids) {
         if (CollectionUtils.isEmpty(ids)) {
             return new ArrayList<>();
         }
         List<LedgerPurchaseDto> ledgerTradeDto = tradeMapper.selectPurchaseIds(ids);
-        List<ILedger> ledgerSellDto = new ArrayList<>(ledgerTradeDto);
-        changeDict(ledgerSellDto);
-        return ledgerSellDto;
+        changeDict(ledgerTradeDto);
+        return ledgerTradeDto;
     }
 
     /**
@@ -660,7 +676,7 @@ public class KwpLedgerTradeService extends AbsLedger {
                 }
             }
         }
-        orderDto.setTorderId(orderDetailRes.getId());
+        orderDto.setTOrderId(orderDetailRes.getId());
         return orderDto;
     }
 
@@ -692,4 +708,43 @@ public class KwpLedgerTradeService extends AbsLedger {
         }
         return PageRes.build(pageInfo, detailRes);
     }
+
+    /**
+     * 查询对账单关联订单 可通过商品名称、订单编号搜索
+     *
+     * @param ledgerListReq
+     * @return
+     */
+    public List<OrderDto> queryOrderList(LedgerListReq ledgerListReq) {
+        List<KwpLedgerTradeOrder> kwpLedgerLogisticsOrders = tradeOrderService.queryList(ledgerListReq.getIdLong());
+        if (CollectionUtils.isEmpty(kwpLedgerLogisticsOrders)) {
+            return new ArrayList<>();
+        }
+        List<OrderDto> detailRes = new ArrayList<>();
+        for (KwpLedgerTradeOrder kwpLedgerLogisticsOrder : kwpLedgerLogisticsOrders) {
+            OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(kwpLedgerLogisticsOrder.getTOrderId());
+            detailRes.add(changeOrder(orderDetailById));
+        }
+        //过滤筛选条件
+        if (StringUtils.isNotBlank(ledgerListReq.getKeywords())) {
+            return detailRes.stream().filter(o -> StringUtils.contains(o.getTOrderNo(), ledgerListReq.getKeywords()) ||
+                    StringUtils.contains(o.getGoodsName(), ledgerListReq.getKeywords())).toList();
+        }
+        return detailRes;
+    }
+
+    /**
+     * 根据企业id查询关联的订单
+     *
+     * @param entId
+     * @return
+     */
+    public List<String> checkOrder(Long entId) {
+        List<Long> longs = tradeUnitService.selectByEnt(entId);
+        if (CollectionUtils.isEmpty(longs)) {
+            return new ArrayList<>();
+        }
+        List<KwpLedgerTrade> kwpLedgerTrades = tradeMapper.selectBatchIds(longs);
+        return kwpLedgerTrades.stream().filter(a->!Objects.equals(a.getStatus(),LedgerEnum.SUCCESS.getStatus())).map(KwpLedgerTrade::getTLedgerNo).distinct().toList();
+    }
 }

+ 16 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeUnitService.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.sckw.core.model.constant.Global;
 import com.sckw.payment.dao.KwpLedgerTradeUnitMapper;
@@ -9,6 +10,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -47,4 +49,18 @@ public class KwpLedgerTradeUnitService {
         wrapper.eq(KwpLedgerTradeUnit::getDelFlag, Global.UN_DELETED);
         tradeUnitMapper.update(kwpLedgerTradeUnit, wrapper);
     }
+
+    /**
+     * 通过关联的企业id查询对账单id
+     *
+     * @param entId
+     * @return
+     */
+    public List<Long> selectByEnt(Long entId) {
+        List<KwpLedgerTradeUnit> kwpLedgerTradeUnits = tradeUnitMapper.selectList(new LambdaQueryWrapper<KwpLedgerTradeUnit>().eq(KwpLedgerTradeUnit::getTopEntId, entId).eq(KwpLedgerTradeUnit::getDelFlag, Global.UN_DELETED));
+        if (CollectionUtils.isEmpty(kwpLedgerTradeUnits)) {
+            return new ArrayList<>();
+        }
+        return kwpLedgerTradeUnits.stream().map(KwpLedgerTradeUnit::getTLedgerId).distinct().toList();
+    }
 }

+ 22 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -1,17 +1,19 @@
 package com.sckw.payment.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.vo.TableTop;
+import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringTimeUtil;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.SettlementEnum;
-import com.sckw.payment.model.constant.TradingEnum;
 import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
@@ -22,7 +24,7 @@ import com.sckw.payment.utils.PageMoreRes;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
-import lombok.AllArgsConstructor;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -30,18 +32,21 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author Aick Spt
  * @date 2023-07-10 16:38:36
  */
-@AllArgsConstructor
+@RequiredArgsConstructor
 @Service
 @Slf4j
 public class KwpSettlementLogisticsService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
     private final KwpSettlementLogisticsMapper settlementLogisticsMapper;
+    private final KwpLedgerLogisticsUnitService logisticsUnitService;
+
 
     public void save(KwpSettlementLogistics settlementLogistics) {
         settlementLogisticsMapper.insert(settlementLogistics);
@@ -325,4 +330,18 @@ public class KwpSettlementLogisticsService {
         }
     }
 
+    public List<String> checkOrder(Long entId) {
+        List<Long> longs = logisticsUnitService.selectByEnt(entId);
+        if (CollectionUtils.isEmpty(longs)) {
+            return new ArrayList<>();
+        }
+        List<KwpSettlementLogistics> kwpSettlementLogistics = settlementLogisticsMapper.selectList(new LambdaQueryWrapper<KwpSettlementLogistics>()
+                .in(KwpSettlementLogistics::getLLedgerId, longs).eq(KwpSettlementLogistics::getDelFlag, Global.UN_DELETED));
+        if (CollectionUtils.isEmpty(kwpSettlementLogistics)) {
+            return new ArrayList<>();
+        }
+        return kwpSettlementLogistics.stream()
+                .filter(a -> !Objects.equals(a.getStatus(), SettlementEnum.ALL_PAYMENT.getStatus()))
+                .map(KwpSettlementLogistics::getSlOrderNo).distinct().collect(Collectors.toList());
+    }
 }

+ 23 - 5
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java

@@ -1,8 +1,10 @@
 package com.sckw.payment.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.BeanUtils;
@@ -13,14 +15,12 @@ import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.dto.*;
-import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.req.SettlementTradeReq;
-import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
 import com.sckw.payment.model.vo.res.SettlementSumVo;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
-import jakarta.annotation.Resource;
+import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
@@ -28,17 +28,19 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * @author xucaiqin
  * @date 2023-07-10 16:38:36
  */
 @Service
+@RequiredArgsConstructor
 public class KwpSettlementTradeService {
-    @Resource
-    private KwpSettlementTradeMapper settlementTradeMapper;
+    private final KwpSettlementTradeMapper settlementTradeMapper;
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
+    private final KwpLedgerTradeUnitService tradeUnitService;
 
     /**
      * 查询结算单详情
@@ -219,4 +221,20 @@ public class KwpSettlementTradeService {
     public void updateById(KwpSettlementTrade kwpSettlementTrade) {
         settlementTradeMapper.updateById(kwpSettlementTrade);
     }
+
+    public List<String> checkOrder(Long entId) {
+        List<Long> longs = tradeUnitService.selectByEnt(entId);
+        if (CollectionUtils.isEmpty(longs)) {
+            return new ArrayList<>();
+        }
+        List<KwpSettlementTrade> kwpSettlementTrades = settlementTradeMapper.selectList(new LambdaQueryWrapper<KwpSettlementTrade>()
+                .in(KwpSettlementTrade::getTLedgerId, longs)
+                .eq(KwpSettlementTrade::getDelFlag, Global.UN_DELETED));
+        if (CollectionUtils.isEmpty(kwpSettlementTrades)) {
+            return new ArrayList<>();
+        }
+        return kwpSettlementTrades.stream()
+                .filter(a -> !Objects.equals(a.getStatus(), SettlementEnum.ALL_PAYMENT.getStatus()))
+                .map(KwpSettlementTrade::getStOrderNo).distinct().collect(Collectors.toList());
+    }
 }

+ 52 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java

@@ -0,0 +1,52 @@
+package com.sckw.payment.service.dubbo;
+
+import com.sckw.payment.api.dubbo.PaymentDubboService;
+import com.sckw.payment.api.model.constant.OrderEnum;
+import com.sckw.payment.service.KwpLedgerLogisticsService;
+import com.sckw.payment.service.KwpLedgerTradeService;
+import com.sckw.payment.service.KwpSettlementLogisticsService;
+import com.sckw.payment.service.KwpSettlementTradeService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author xucaiqin
+ * @date 2023-08-18 17:26:05
+ */
+@Service
+@DubboService(group = "design", version = "1.0.0")
+@RequiredArgsConstructor
+@Slf4j
+public class PaymentDubboServiceImpl implements PaymentDubboService {
+    private final KwpLedgerLogisticsService ledgerLogisticsService;
+    private final KwpLedgerTradeService ledgerTradeService;
+    private final KwpSettlementLogisticsService settlementLogisticsService;
+    private final KwpSettlementTradeService settlementTradeService;
+
+    @Override
+    public Map<OrderEnum,List<String>> checkLedger(Long entId) {
+        List<String> logistics = ledgerLogisticsService.checkOrder(entId);
+        List<String> trade = ledgerTradeService.checkOrder(entId);
+        Map<OrderEnum, List<String>> res = new HashMap<>(2);
+        res.put(OrderEnum.LOGISTICS,logistics);
+        res.put(OrderEnum.TRADE,trade);
+        return res;
+    }
+
+    @Override
+    public Map<OrderEnum,List<String>> checkSettlement(Long entId) {
+        List<String> logistics = settlementLogisticsService.checkOrder(entId);
+        List<String> trade = settlementTradeService.checkOrder(entId);
+        Map<OrderEnum, List<String>> res = new HashMap<>(2);
+        res.put(OrderEnum.LOGISTICS,logistics);
+        res.put(OrderEnum.TRADE,trade);
+        return res;
+    }
+}
+

+ 30 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -114,6 +114,36 @@
         </where>
         order by kll.generate_time desc
     </select>
+    <select id="countSum" resultType="com.sckw.payment.model.vo.res.LedgerCountSumVo">
+        select count(1)             "ledgerCount",
+        sum(kll.total_price) "totalPrice"
+        from kwp_ledger_logistics kll
+                 inner join kwp_ledger_logistics_unit kllu
+                            on kll.id = kllu.l_ledger_id and kllu.del_flag = 0 and kllu.unit_type = #{logisticsReq.unitType,jdbcType=INTEGER}
+                 inner join kwp_ledger_logistics_unit kllu2
+                            on kll.id = kllu2.l_ledger_id and kllu2.del_flag = 0 and kllu2.unit_type = #{logisticsReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            kll.del_flag = 0
+              and kllu2.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+            <if test="logisticsReq.status != null">
+                and kll.status = #{logisticsReq.status}
+            </if>
+            <if test="logisticsReq.trading != null">
+                and kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="logisticsReq.startCreateTime != null and logisticsReq.startCreateTime != '' and logisticsReq.endCreateTime != null and logisticsReq.endCreateTime != ''">
+                and kll.generate_time between #{logisticsReq.startCreateTime,jdbcType=TIMESTAMP}
+                    and #{logisticsReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="logisticsReq.keywords != null and logisticsReq.keywords != ''">
+                and (
+                            kll.l_ledger_no like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.firm_name like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+        </where>
+    </select>
     <!--托运方1 承运方2-->
     <select id="carrierSelect" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
         select

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

@@ -185,6 +185,44 @@
         </where>
         order by klt.generate_time desc
     </select>
+    <select id="countSum" resultType="com.sckw.payment.model.vo.res.LedgerCountSumVo">
+        select count(1)             "ledgerCount",
+               sum(klt.total_price) "totalPrice"
+        from kwp_ledger_trade klt
+                 inner join kwp_ledger_trade_unit kltu
+                            on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
+                               kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+                 inner join kwp_ledger_trade_unit kltu2
+                            on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and
+                               kltu2.unit_type = #{tradeReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            klt.del_flag = 0
+              and kltu2.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
+            <if test="tradeReq.status != null">
+                and klt.status = #{tradeReq.status}
+            </if>
+            <if test="tradeReq.trading != null">
+                and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                    and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
+                and (
+                            klt.t_ledger_no like concat('%'
+                            , #{tradeReq.keywords,jdbcType=VARCHAR}
+                            , '%')
+                        or kltu.firm_name like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                        or kltu.contacts like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                    )
+            </if>
+        </where>
+    </select>
     <select id="countOrder" resultType="java.util.Map">
         SELECT count(1)                           "0",
                count(IF(klt.status = 1, 1, NULL)) "1",