Просмотр исходного кода

bugfix:对账列表页、列表统计数据不对的问题

xucaiqin 2 лет назад
Родитель
Сommit
e3f37ca3d9
19 измененных файлов с 444 добавлено и 189 удалено
  1. 6 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java
  2. 4 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java
  3. 2 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementOfflineController.java
  4. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java
  5. 14 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  6. 12 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java
  7. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsReq.java
  8. 2 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java
  9. 2 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java
  10. 2 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/WalletPayReq.java
  11. 10 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  12. 9 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  13. 40 26
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java
  14. 37 23
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  15. 124 24
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java
  16. 18 7
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PayCenterServiceImpl.java
  17. 65 12
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  18. 92 81
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  19. 2 1
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

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

@@ -139,7 +139,9 @@ public class KwpLedgerLogisticsController {
      */
     @PostMapping("shipperCount")
     public HttpResult shipperCount(@RequestBody @Valid LogisticsReq logisticsReq) {
-        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 1));
+        logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
+        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq));
     }
 
     /**
@@ -150,7 +152,9 @@ public class KwpLedgerLogisticsController {
      */
     @PostMapping("carrierCount")
     public HttpResult carrierCount(@RequestBody @Valid LogisticsReq logisticsReq) {
-        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 2));
+        logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.CARRIER);
+        return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq));
     }
 
     /**

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

@@ -8,6 +8,7 @@ import com.sckw.payment.model.dto.ILedger;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.LedgerTradeVo;
 import com.sckw.payment.service.KwpLedgerTradeService;
+import io.seata.spring.annotation.GlobalTransactional;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
@@ -140,6 +141,7 @@ public class KwpLedgerTradeController {
     @PostMapping("sellCount")
     public HttpResult sellCount(@RequestBody @Valid TradeReq tradeReq) {
         tradeReq.setUnitType(TradeUnitType.PURCHASE);
+        tradeReq.setUnitTypeTwo(TradeUnitType.SELL);
         return HttpResult.ok(kwpLedgerTradeService.orderCount(tradeReq));
     }
 
@@ -151,6 +153,7 @@ public class KwpLedgerTradeController {
     @PostMapping("purchaseCount")
     public HttpResult purchaseCount(@RequestBody @Valid TradeReq tradeReq) {
         tradeReq.setUnitType(TradeUnitType.SELL);
+        tradeReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
         return HttpResult.ok(kwpLedgerTradeService.orderCount(tradeReq));
     }
 
@@ -219,6 +222,7 @@ public class KwpLedgerTradeController {
      * @return
      */
     @PostMapping("success")
+    @GlobalTransactional(name = "default_tx_group", rollbackFor = Exception.class)
     public HttpResult orderSuccess(@RequestBody @Valid LedgerSuccessReq ledgerReq) {
         return HttpResult.ok(kwpLedgerTradeService.orderSuccess(ledgerReq));
     }

+ 2 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementOfflineController.java

@@ -6,6 +6,7 @@ import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
 import com.sckw.payment.model.vo.req.SettlementOfflinePayReq;
 import com.sckw.payment.model.vo.req.SettlementOfflineReq;
 import com.sckw.payment.service.KwpSettlementOfflineService;
+import io.seata.spring.annotation.GlobalTransactional;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
 import org.springframework.web.bind.annotation.*;
@@ -61,6 +62,7 @@ public class KwpSettlementOfflineController {
      * @param payReq
      * @return
      */
+    @GlobalTransactional(name = "default_tx_group", rollbackFor = Exception.class)
     @PostMapping(name = "销售收款-收款确认-线下付款", path = "confirmTradeCollection")
     public HttpResult confirmTradeCollection(@Valid @RequestBody SettlementOfflinePayReq payReq) {
         payReq.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java

@@ -7,14 +7,13 @@ import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
 import com.sckw.payment.model.vo.req.WalletPayReq;
 import com.sckw.payment.service.KwpSettlementWalletService;
+import io.seata.spring.annotation.GlobalTransactional;
 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.math.BigDecimal;
-
 /**
  * 结算-电子钱包结算记录(交易订单结算/物流订单结算)
  *
@@ -82,6 +81,7 @@ public class KwpSettlementWalletController {
      * 采购-货到付款
      */
     @PostMapping(name = "销售-付款确认-(新增电子钱包记录-采购货到付款)", path = "confirmReceive")
+    @GlobalTransactional(name = "default_tx_group", rollbackFor = Exception.class)
     public HttpResult confirmTradePayment(@RequestBody @Valid WalletPayReq payReq) {
         return HttpResult.ok(kwpSettlementWalletService.confirmTradePayment(payReq));
     }

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

@@ -36,13 +36,26 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     List<LedgerCarrierDto> carrierSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
 
-    Map<String, Long> countOrder(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("unitType") Integer unitType);
+    /**
+     * 统计订单数量
+     *
+     * @param logisticsReq
+     * @return
+     */
+    Map<String, Long> countOrder(@Param("logisticsReq") LogisticsReq logisticsReq);
 
     LedgerLogisticsDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
 
     List<LedgerShipperDto> selectShipperIds(@Param("ids") List<Long> ids);
 
+    /**
+     * 承运方
+     * 1托运方、2承运方
+     *
+     * @param ids
+     * @return
+     */
     List<LedgerCarrierDto> selectCarrierIds(@Param("ids") List<Long> ids);
 
 

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

@@ -13,7 +13,10 @@ import java.util.Objects;
  * @date 2023-07-20 12:26
  */
 public class SettlementTradeDto implements ISettlement {
-
+    /**
+     * 对账单id主键
+     */
+    private Long ledgerId;
     /**
      * 主键
      */
@@ -119,6 +122,14 @@ public class SettlementTradeDto implements ISettlement {
      */
     private Integer delFlag;
 
+    public Long getLedgerId() {
+        return ledgerId;
+    }
+
+    public void setLedgerId(Long ledgerId) {
+        this.ledgerId = ledgerId;
+    }
+
     public Long getId() {
         return id;
     }

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

@@ -29,4 +29,5 @@ public class LogisticsReq extends BasePara {
     private String ids;
     private Long entId;
     private Integer unitType;
+    private Integer unitTypeTwo;
 }

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

@@ -3,6 +3,7 @@ package com.sckw.payment.model.vo.req;
 import com.sckw.core.model.base.IdsList;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Positive;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -26,6 +27,7 @@ public class SettlementOfflinePayReq implements IdsList, Serializable {
     @NotBlank(message = "结算单id不能为空")
     private String id;
     @NotNull(message = "结算单金额不能为空")
+    @Positive(message = "结算金额必须大于0")
     private BigDecimal payPrice;
     @NotBlank(message = "相关附近不能为空")
     private String url;

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

@@ -26,5 +26,7 @@ public class TradeReq extends BasePara {
     private String ids;
     private Long entId;
     private Integer unitType;
+    //另一方企业
+    private Integer unitTypeTwo;
 
 }

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

@@ -3,6 +3,7 @@ package com.sckw.payment.model.vo.req;
 import com.sckw.core.model.base.IdsList;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Positive;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -25,5 +26,6 @@ public class WalletPayReq implements IdsList {
      * 金额
      */
     @NotNull(message = "付款金额不能为空")
+    @Positive(message = "付款金额必须大于0")
     private BigDecimal price;
 }

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

@@ -101,6 +101,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     public PageRes<ILedger> shipperList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
         logisticsReq.setUnitType(LogisticsUnitType.CARRIER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
         List<LedgerShipperDto> kwpLedgerLogisticsList = logisticsMapper.shipperSelect(logisticsReq);
         PageInfo<ILedger> ledgerShipperDtoPageInfo = new PageInfo<>(kwpLedgerLogisticsList);
@@ -115,6 +116,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     public PageRes<ILedger> carrierList(LogisticsReq logisticsReq) {
         fillPara(logisticsReq);
         logisticsReq.setUnitType(LogisticsUnitType.SHIPPER);
+        logisticsReq.setUnitTypeTwo(LogisticsUnitType.CARRIER);
         PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
         List<LedgerCarrierDto> kwpLedgerLogisticsList = logisticsMapper.carrierSelect(logisticsReq);
         PageInfo<ILedger> ledgerShipperDtoPageInfo = new PageInfo<>(kwpLedgerLogisticsList);
@@ -457,13 +459,14 @@ public class KwpLedgerLogisticsService extends AbsLedger {
 
     /**
      * 按类型统计表头的数据
+     * 1-托运方 2-承运方
      *
-     * @param unitType 1-托运方 2-承运方
+     * @param logisticsReq 查询参数
      * @return 统计数据
      */
-    public List<TableTop> orderCount(LogisticsReq logisticsReq, Integer unitType) {
+    public List<TableTop> orderCount(LogisticsReq logisticsReq) {
         logisticsReq.setEntId(LoginUserHolder.getEntId());
-        Map<String, Long> map = logisticsMapper.countOrder(logisticsReq, unitType);
+        Map<String, Long> map = logisticsMapper.countOrder(logisticsReq);
         TableTop ledgerCountVo;
         /*统计数据转换*/
         List<TableTop> res = new ArrayList<>();
@@ -551,8 +554,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         ledgerLogisticsDetailVo.setEndTime(ledgerLogisticsDto.getEndTime());
         ledgerLogisticsDetailVo.setRemark(ledgerLogisticsDto.getRemark());
         /*查询物流订单详情*/
-        List<LogisticsOrderVO> acceptCarriageOrderList = transportDubboService.getAcceptCarriageOrderList(kwpLedgerLogisticsOrders.stream().map(a -> Long.toString(a.getLOrderId())).collect(Collectors.toList()));
-        ledgerLogisticsDetailVo.setOrderList(acceptCarriageOrderList);
+        if (!CollectionUtils.isEmpty(kwpLedgerLogisticsOrders)) {
+            List<LogisticsOrderVO> acceptCarriageOrderList = transportDubboService.getAcceptCarriageOrderList(kwpLedgerLogisticsOrders.stream().map(a -> Long.toString(a.getLOrderId())).collect(Collectors.toList()));
+            ledgerLogisticsDetailVo.setOrderList(acceptCarriageOrderList);
+        }
         return ledgerLogisticsDetailVo;
     }
 

+ 9 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -33,7 +33,6 @@ 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.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -122,6 +121,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         fillPara(tradeReq);
         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);
 
@@ -143,6 +143,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         fillPara(tradeReq);
         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);
         //字典转换
@@ -219,7 +220,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         }
         List<KwpLedgerTradeOrder> collect = resList.stream().map(a -> {
             KwpLedgerTradeOrder kwpLedgerTradeOrder = new KwpLedgerTradeOrder();
-            kwpLedgerTradeOrder.setId(new IdWorker(1).nextId());
+            kwpLedgerTradeOrder.setId(new IdWorker(NumberConstant.ONE).nextId());
             kwpLedgerTradeOrder.setTLedgerId(kwpLedgerTrade.getId());
             kwpLedgerTradeOrder.setTOrderId(a.getId());
             kwpLedgerTradeOrder.setTOrderNo(a.getTOrderNo());
@@ -435,8 +436,6 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @param ledgerReq 对账完成参数
      * @return
      */
-    @Transactional(rollbackFor = Exception.class)
-    @GlobalTransactional(rollbackFor = Exception.class)
     public String orderSuccess(LedgerSuccessReq ledgerReq) {
         Long id = ledgerReq.getIdLong();
         //校验对账单状态
@@ -519,6 +518,9 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @return 对账单数据
      */
     public List<ILedger> 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);
@@ -532,6 +534,9 @@ public class KwpLedgerTradeService extends AbsLedger {
      * @return 对账单数据
      */
     public List<ILedger> 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);

+ 40 - 26
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java

@@ -2,10 +2,15 @@ package com.sckw.payment.service;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
+import com.sckw.order.api.model.UpdateOrderStatusParam;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
 import com.sckw.payment.dao.KwpSettlementLogisticsTrackMapper;
 import com.sckw.payment.dao.KwpSettlementOfflineMapper;
@@ -22,13 +27,12 @@ import com.sckw.redis.config.RedisLockUtil;
 import com.sckw.redis.constant.RedisConstant;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
-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;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
@@ -45,24 +49,20 @@ import java.util.stream.Collectors;
  */
 @Service
 @Slf4j
+@RequiredArgsConstructor
 public class KwpSettlementOfflineService {
-    @Resource
-    private KwpSettlementOfflineMapper settlementOfflineMapper;
-    @Resource
-    private KwpSettlementTradeService settlementTradeService;
-    @Resource
-    private KwpSettlementTradeTrackService settlementTradeTrackService;
+    private final KwpSettlementOfflineMapper settlementOfflineMapper;
+    private final KwpSettlementTradeService settlementTradeService;
+    private final KwpLedgerTradeOrderService tradeOrderService;
+    private final KwpSettlementTradeTrackService settlementTradeTrackService;
     @DubboReference(version = "2.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
-    @Resource
-    private RedisLockUtil redisLockUtil;
-
-    @Resource
-    private KwpSettlementLogisticsService kwpSettlementLogisticsService;
-    @Resource
-    private KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
-    @Resource
-    private KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private TradeOrderInfoService tradeOrderInfoService;
+    private final RedisLockUtil redisLockUtil;
+    private final KwpSettlementLogisticsService kwpSettlementLogisticsService;
+    private final KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
+    private final KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
 
     /**
      * 物流-线下付款(运费收款)记录-列表
@@ -200,7 +200,7 @@ public class KwpSettlementOfflineService {
             remainingReceivables = remainingReceivables.subtract(price);
             //入库
             KwpSettlementOffline kwpSettlementOffline = new KwpSettlementOffline();
-            kwpSettlementOffline.setId(new IdWorker(1).nextId());
+            kwpSettlementOffline.setId(new IdWorker(NumberConstant.ONE).nextId());
             kwpSettlementOffline.setEntId(settlementLogisticsDto.getEntId());
             kwpSettlementOffline.setSettlementId(settlementLogisticsDto.getId());
             kwpSettlementOffline.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
@@ -268,7 +268,6 @@ public class KwpSettlementOfflineService {
      * @param payReq
      * @return
      */
-    @Transactional(rollbackFor = Exception.class)
     public String confirmTradeCollection(SettlementOfflinePayReq payReq) {
         String key = String.format(RedisConstant.SETTLEMENT_KEY, payReq.getId());
         if (redisLockUtil.tryLock(key)) {
@@ -294,7 +293,7 @@ public class KwpSettlementOfflineService {
                 BigDecimal payPrice = payReq.getPayPrice();
                 //剩余待付款-本次付款=下次剩余待付款
                 BigDecimal subtract1 = subtract.subtract(payPrice);
-                if (subtract1.compareTo(new BigDecimal("0.0")) < 0) {
+                if (subtract1.compareTo(new BigDecimal("0.0")) < NumberConstant.ZERO) {
                     throw new BusinessException("实际付款金额大于剩余待付款金额");
                 }
                 //更新结算单记录
@@ -302,9 +301,24 @@ public class KwpSettlementOfflineService {
                 kwpSettlementTrade.setId(byId.getId());
                 kwpSettlementTrade.setActualPrice(actualPrice.add(payPrice));//已收款加本次收款
                 int status = 0;
-                if (subtract1.compareTo(new BigDecimal("0.0")) == 0) {
+                //全部结算,修改贸易订单状态
+                if (subtract1.compareTo(new BigDecimal("0.0")) == NumberConstant.ZERO) {
                     status = SettlementEnum.ALL_PAYMENT.getStatus();
-                } else if (subtract1.compareTo(new BigDecimal("0.0")) > 0) {
+                    //查询对账单关联的订单
+                    List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(byId.getLedgerId());
+                    if (CollectionUtils.isEmpty(kwpLedgerTradeOrders)) {
+                        throw new BusinessException("未找到关联的贸易订单");
+                    }
+                    List<Long> list = kwpLedgerTradeOrders.stream().map(KwpLedgerTradeOrder::getTOrderId).toList();
+                    for (Long aLong : list) {
+                        UpdateOrderStatusParam updateOrderStatusParam = new UpdateOrderStatusParam();
+                        updateOrderStatusParam.setTOrderId(aLong);
+                        updateOrderStatusParam.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_7.getValue()));
+                        updateOrderStatusParam.setUpdateBy(LoginUserHolder.getUserId());
+                        updateOrderStatusParam.setUpdateByName(LoginUserHolder.getUserName());
+                        tradeOrderInfoService.updateOrderStatus(updateOrderStatusParam);
+                    }
+                } else if (subtract1.compareTo(new BigDecimal("0.0")) > NumberConstant.ZERO) {
                     status = SettlementEnum.PARTIAL_PAYMENT.getStatus();
                 }
                 kwpSettlementTrade.setStatus(status);
@@ -313,7 +327,7 @@ public class KwpSettlementOfflineService {
                 settlementTradeService.updateById(kwpSettlementTrade);
                 //新增线下结算记录
                 KwpSettlementOffline kwpSettlementOffline = new KwpSettlementOffline();
-                kwpSettlementOffline.setId(new IdWorker(1).nextId());
+                kwpSettlementOffline.setId(new IdWorker(NumberConstant.ONE).nextId());
                 kwpSettlementOffline.setEntId(LoginUserHolder.getEntId());
                 kwpSettlementOffline.setSettlementId(byId.getId());
                 kwpSettlementOffline.setOrderType(payReq.getOrderType());
@@ -321,13 +335,13 @@ public class KwpSettlementOfflineService {
                 kwpSettlementOffline.setPayPrice(payReq.getPayPrice());
                 kwpSettlementOffline.setTopayPrice(subtract1);
                 kwpSettlementOffline.setUrl(payReq.getUrl());
-                kwpSettlementOffline.setRemark("");
-                kwpSettlementOffline.setStatus(0);
+                kwpSettlementOffline.setRemark(LoginUserHolder.getUserName() + "结算" + payReq.getPayPrice());
+                kwpSettlementOffline.setStatus(NumberConstant.ZERO);
                 kwpSettlementOffline.setCreateBy(LoginUserHolder.getUserId());
                 kwpSettlementOffline.setCreateTime(LocalDateTime.now());
                 kwpSettlementOffline.setUpdateBy(LoginUserHolder.getUserId());
                 kwpSettlementOffline.setUpdateTime(LocalDateTime.now());
-                kwpSettlementOffline.setDelFlag(0);
+                kwpSettlementOffline.setDelFlag(Global.UN_DELETED);
 
                 settlementOfflineMapper.insert(kwpSettlementOffline);
 

+ 37 - 23
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java

@@ -3,12 +3,15 @@ package com.sckw.payment.service;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
+import com.sckw.order.api.model.UpdateOrderStatusParam;
 import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.dto.WalletDto;
 import com.sckw.payment.api.model.dto.common.R;
@@ -29,7 +32,7 @@ import com.sckw.redis.config.RedisLockUtil;
 import com.sckw.redis.constant.RedisConstant;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
-import jakarta.annotation.Resource;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.BeanUtils;
@@ -51,28 +54,22 @@ import java.util.stream.Collectors;
  */
 @Service
 @Slf4j
+@RequiredArgsConstructor
 public class KwpSettlementWalletService {
-    @Resource
-    private KwpSettlementWalletMapper settlementWalletMapper;
-    @Resource
-    private KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
-    @Resource
-    private KwpSettlementLogisticsService kwpSettlementLogisticsService;
-    @Resource
-    private KwpSettlementTradeService kwpSettlementTradeService;
-    @Resource
-    private PayCenterService payCenterService;
-    @Resource
-    private KwpWalletRelationService walletRelationService;
-    @Resource
-    private RedisLockUtil redisLockUtil;
-    @Resource
-    private KwpSettlementTradeTrackService settlementTradeTrackService;
+    private final KwpSettlementWalletMapper settlementWalletMapper;
+    private final KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
+    private final KwpLedgerTradeOrderService tradeOrderService;
+    private final KwpSettlementLogisticsService kwpSettlementLogisticsService;
+    private final KwpSettlementTradeService kwpSettlementTradeService;
+    private final PayCenterService payCenterService;
+    private final KwpWalletRelationService walletRelationService;
+    private final RedisLockUtil redisLockUtil;
+    private final KwpSettlementTradeTrackService settlementTradeTrackService;
     @DubboReference(version = "2.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
-
-    @Resource
-    private KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private TradeOrderInfoService tradeOrderInfoService;
+    private final KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
 
     /**
      * 物流-电子钱包付款(货到付款)结算记录-列表
@@ -267,7 +264,6 @@ public class KwpSettlementWalletService {
      * @author Aick Spt
      * @date 2023-07-27 16:13
      */
-    @Transactional(rollbackFor = Exception.class)
     public String confirmTradePayment(WalletPayReq walletPayReq) {
         String key = String.format(RedisConstant.SETTLEMENT_KEY, walletPayReq.getId());
         if (redisLockUtil.tryLock(key)) {
@@ -343,13 +339,31 @@ public class KwpSettlementWalletService {
                 KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
                 kwpSettlementTrade.setId(byId.getId());
                 kwpSettlementTrade.setActualPrice(byId.getActualPrice().add(price));
-                kwpSettlementTrade.setStatus(subtract.compareTo(new BigDecimal("0.0")) == NumberConstant.ZERO ? SettlementEnum.ALL_PAYMENT.getStatus()
-                        : SettlementEnum.PARTIAL_PAYMENT.getStatus());
+                int status = subtract.compareTo(new BigDecimal("0.0")) == NumberConstant.ZERO ? SettlementEnum.ALL_PAYMENT.getStatus()
+                        : SettlementEnum.PARTIAL_PAYMENT.getStatus();
+                kwpSettlementTrade.setStatus(status);
                 kwpSettlementTrade.setUpdateBy(LoginUserHolder.getUserId());
                 kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
                 kwpSettlementTradeService.updateById(kwpSettlementTrade);
 
                 settlementTradeTrackService.save(KwpSettlementTradeTrack.build(byId.getId(), SettlementTrackEnum.RECEIVE_PAY.getStatus()));
+                //更新贸易订单状态
+                if (status == SettlementEnum.ALL_PAYMENT.getStatus()) {
+                    //查询对账单关联的订单
+                    List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(byId.getLedgerId());
+                    if (CollectionUtils.isEmpty(kwpLedgerTradeOrders)) {
+                        throw new BusinessException("未找到关联的贸易订单");
+                    }
+                    List<Long> list = kwpLedgerTradeOrders.stream().map(KwpLedgerTradeOrder::getTOrderId).toList();
+                    for (Long aLong : list) {
+                        UpdateOrderStatusParam updateOrderStatusParam = new UpdateOrderStatusParam();
+                        updateOrderStatusParam.setTOrderId(aLong);
+                        updateOrderStatusParam.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_7.getValue()));
+                        updateOrderStatusParam.setUpdateBy(LoginUserHolder.getUserId());
+                        updateOrderStatusParam.setUpdateByName(LoginUserHolder.getUserName());
+                        tradeOrderInfoService.updateOrderStatus(updateOrderStatusParam);
+                    }
+                }
                 //todo-xcq 调用中台接口
 
                 return "付款确认成功";

+ 124 - 24
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java

@@ -3,6 +3,7 @@ package com.sckw.payment.service;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.TypeReference;
+import com.sckw.core.exception.BusinessException;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.OkHttpUtils;
 import com.sckw.payment.api.model.constant.ChannelEnum;
@@ -20,9 +21,11 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Service;
-import org.springframework.validation.annotation.Validated;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * 转发中台接口
@@ -33,7 +36,6 @@ import java.util.*;
 @Service
 @Slf4j
 @RefreshScope
-@Validated
 public class PayCenterService {
     @Value("${payCenter.address}")
     private String payCenterAddr;
@@ -56,14 +58,27 @@ public class PayCenterService {
         if (!CollectionUtils.isEmpty(para)) {
             for (Map.Entry<String, Object> p : para.entrySet()) {
                 //跳过非空参数
-                if (Objects.isNull(p.getValue())) {
+                Object v = p.getValue();
+                String k = p.getKey();
+                if (Objects.isNull(v)) {
                     continue;
                 }
-                if (p.getValue() instanceof ChannelEnum channelEnum) {
-                    okHttpUtils.addPara(p.getKey(), channelEnum.getChannel());
+                if (v instanceof ChannelEnum channelEnum) {
+                    okHttpUtils.addPara(k, channelEnum.getChannel());
+                } else if (v instanceof Integer i) {
+                    okHttpUtils.addPara(k, String.valueOf(i));
+                } else if (v instanceof Long i) {
+                    okHttpUtils.addPara(k, String.valueOf(i));
+                } else if (v instanceof String i) {
+                    okHttpUtils.addPara(k, i);
+                } else if ((v.getClass().isArray()) && v instanceof String[] l) {
+                    for (int i = 0; i < l.length; i++) {
+                        okHttpUtils.addPara(k + "[" + i + "]", l[i]);
+                    }
                 } else {
-                    okHttpUtils.addPara(p.getKey(), (String) p.getValue());
+                    okHttpUtils.addPara(k, v.toString());
                 }
+
             }
         }
         String sync;
@@ -83,13 +98,25 @@ public class PayCenterService {
         if (!CollectionUtils.isEmpty(para)) {
             for (Map.Entry<String, Object> p : para.entrySet()) {
                 //跳过非空参数
-                if (Objects.isNull(p.getValue())) {
+                Object v = p.getValue();
+                String k = p.getKey();
+                if (Objects.isNull(v)) {
                     continue;
                 }
-                if (p.getValue() instanceof ChannelEnum channelEnum) {
-                    okHttpUtils.addBodyPara(p.getKey(), channelEnum.getChannel());
+                if (v instanceof ChannelEnum channelEnum) {
+                    okHttpUtils.addBodyPara(k, channelEnum.getChannel());
+                } else if (v instanceof Integer i) {
+                    okHttpUtils.addBodyPara(k, String.valueOf(i));
+                } else if (v instanceof Long i) {
+                    okHttpUtils.addBodyPara(k, String.valueOf(i));
+                } else if (v instanceof String i) {
+                    okHttpUtils.addBodyPara(k, i);
+                } else if ((v.getClass().isArray()) && v instanceof String[] l) {
+                    for (int i = 0; i < l.length; i++) {
+                        okHttpUtils.addPara(k + "[" + i + "]", l[i]);
+                    }
                 } else {
-                    okHttpUtils.addBodyPara(p.getKey(), (String) p.getValue());
+                    okHttpUtils.addBodyPara(k, v.toString());
                 }
             }
         }
@@ -141,6 +168,9 @@ public class PayCenterService {
      * @return
      */
     public R<List<WalletDto>> wallet(@NotNull String uid, ChannelEnum channel, String filter) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("提现用户不能为空");
+        }
         String sync = getHttp(PayCenterEnum.MEMBER_WALLET, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);
@@ -157,7 +187,13 @@ public class PayCenterService {
      * @param orderNo
      * @return
      */
-    public R<CashDetail> withdrawDetail(@NotBlank(message = "提现用户不能为空") String uid, @NotBlank(message = "") String view, @NotBlank(message = "订单编号不能为空") String orderNo) {
+    public R<CashDetail> withdrawDetail(String uid, String view, String orderNo) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("提现用户不能为空");
+        }
+        if (StringUtils.isBlank(orderNo)) {
+            throw new BusinessException("订单编号不能为空");
+        }
         String sync = getHttp(PayCenterEnum.WITHDRAW_DETAIL, new HashMap<>() {{
             put("uid", uid);
             put("view", view);
@@ -176,12 +212,26 @@ public class PayCenterService {
      * @param pageSize
      * @return
      */
-    public R<CashPage> withdrawIndex(@NotBlank(message = "提现用户不能为空") String uid, @NotNull(message = "支付渠道不能为空") ChannelEnum channel, @NotNull(message = "分页参数不能为空") Integer page, @NotNull(message = "分页大小参数不能为空") Integer pageSize) {
+    public R<CashPage> withdrawIndex(String uid, ChannelEnum channel, Integer page, Integer pageSize) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("用户不能为空");
+        }
+        if (Objects.isNull(channel)) {
+            throw new BusinessException("支付渠道不能为空");
+        }
+        if (Objects.isNull(page)) {
+            page = 1;
+        }
+        if (Objects.isNull(pageSize)) {
+            pageSize = 5;
+        }
+        Integer finalPage = page;
+        Integer finalPageSize = pageSize;
         String sync = getHttp(PayCenterEnum.WITHDRAW_INDEX, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);
-            put("page", page);
-            put("pageSize", pageSize);
+            put("page", finalPage);
+            put("pageSize", finalPageSize);
         }});
         return JSONObject.parseObject(sync, new TypeReference<>() {
         });
@@ -212,7 +262,13 @@ public class PayCenterService {
      * @param orderNo
      * @return
      */
-    public R<Object> withdrawCancel(@NotBlank(message = "提现用户不能为空") String uid, @NotBlank(message = "体现订单号不能为空") String orderNo) {
+    public R<Object> withdrawCancel(String uid, String orderNo) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("用户不能为空");
+        }
+        if (StringUtils.isBlank(orderNo)) {
+            throw new BusinessException("提现订单不能为空");
+        }
         String sync = postHttp(PayCenterEnum.WITHDRAW_CANCEL, new HashMap<>() {{
             put("uid", uid);
             put("order_no", orderNo);
@@ -230,7 +286,19 @@ public class PayCenterService {
      * @param remarks
      * @return
      */
-    public R<Order> withdrawTake(@NotBlank(message = "提现用户不能为空") String uid, @NotBlank(message = "渠道不能为空") ChannelEnum channel, @NotBlank(message = "金额(分)不能为空") Long money, @NotBlank(message = "备注不能为空") String remarks) {
+    public R<Order> withdrawTake(String uid, @NotBlank(message = "渠道不能为空") ChannelEnum channel, Long money, String remarks) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("提现用户不能为空");
+        }
+        if (Objects.isNull(channel)) {
+            throw new BusinessException("提现渠道不能为空");
+        }
+        if (Objects.isNull(money)) {
+            throw new BusinessException("提现金额不能为空");
+        }
+        if (StringUtils.isBlank(remarks)) {
+            throw new BusinessException("备注不能为空");
+        }
         String sync = postHttp(PayCenterEnum.WITHDRAW_TAKE, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);
@@ -249,7 +317,16 @@ public class PayCenterService {
      * @param filter
      * @return
      */
-    public R<WalletInfo> totalInfo(@NotBlank(message = "用户不能为空") String uid, @NotBlank(message = "渠道不能为空") ChannelEnum channel, @NotBlank(message = "乙方用户不能为空") String filter) {
+    public R<WalletInfo> totalInfo(String uid, ChannelEnum channel, String filter) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("提现用户不能为空");
+        }
+        if (Objects.isNull(channel)) {
+            throw new BusinessException("提现渠道不能为空");
+        }
+        if (StringUtils.isBlank(filter)) {
+            throw new BusinessException("乙方用户不能为空");
+        }
         String sync = getHttp(PayCenterEnum.TOTAL_INFO, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);
@@ -268,6 +345,15 @@ public class PayCenterService {
      * @return
      */
     public R<OperateDown> operateDownload(String uid, ChannelEnum channel, String filter) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("提现用户不能为空");
+        }
+        if (Objects.isNull(channel)) {
+            throw new BusinessException("提现渠道不能为空");
+        }
+        if (StringUtils.isBlank(filter)) {
+            throw new BusinessException("乙方用户不能为空");
+        }
         String sync = getHttp(PayCenterEnum.OPERATE_DOWNLOAD, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);
@@ -297,12 +383,28 @@ public class PayCenterService {
      * @param pageSize
      * @return
      */
-    public R<Operate> operateIndex(String uid, ChannelEnum channel, Integer page, Integer pageSize) {
+    public R<Operate> operateIndex(String uid, ChannelEnum channel, Integer page, Integer pageSize, String[] createTime, String[] money) {
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("用户不能为空");
+        }
+        if (Objects.isNull(channel)) {
+            throw new BusinessException("支付渠道不能为空");
+        }
+        if (Objects.isNull(page)) {
+            page = 1;
+        }
+        if (Objects.isNull(pageSize)) {
+            pageSize = 5;
+        }
+        Integer finalPage = page;
+        Integer finalPageSize = pageSize;
         String sync = getHttp(PayCenterEnum.OPERATE_INDEX, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);
-            put("page", page);
-            put("pageSize", pageSize);
+            put("page", finalPage);
+            put("pageSize", finalPageSize);
+            put("createTime", createTime);
+            put("money", money);
         }});
         return JSONObject.parseObject(sync, new TypeReference<>() {
         });
@@ -561,9 +663,7 @@ public class PayCenterService {
      * @param nickname
      * @return
      */
-    public R<Object> walletIndex(@NotBlank(message = "uid不能为空") String uid,
-                                 @NotNull(message = "支付渠道不能为空") ChannelEnum channel,
-                                 @NotBlank(message = "filter不能为空") String filter, String nickname) {
+    public R<Object> walletIndex(@NotBlank(message = "uid不能为空") String uid, @NotNull(message = "支付渠道不能为空") ChannelEnum channel, @NotBlank(message = "filter不能为空") String filter, String nickname) {
         String sync = postHttp(PayCenterEnum.WALLET_INDEX, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);

+ 18 - 7
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PayCenterServiceImpl.java

@@ -27,14 +27,25 @@ public class PayCenterServiceImpl implements PayCenterDubboService {
 
     @Override
     public R<MemberDetail> memberDetail(Long entId, ChannelEnum channel) {
-        String uid = kwpWalletRelationService.getRelation(entId);
-        if (StringUtils.isBlank(uid)) {
-            throw new BusinessException("企业未开通电子钱包");
-        }
-        payCenterService.withdrawDetail("kll_0001", "", "");
-        payCenterService.walletUnFreeze("kll_0001");
+//        String uid = kwpWalletRelationService.getRelation(entId);
+//        if (StringUtils.isBlank(uid)) {
+//            throw new BusinessException("企业未开通电子钱包");
+//        }
+//        payCenterService.withdrawDetail("kll_0001", "", "1");
+//        payCenterService.withdrawIndex("kll_0001", ChannelEnum.HF, 1, 5);
+//        payCenterService.walletUnFreeze("kll_0001");
+//        payCenterService.withdrawStatus("");
+//        payCenterService.withdrawCancel("kll_0001", "123");
+//        payCenterService.withdrawTake("kll_0001", ChannelEnum.HF, 123L, "1");
+//        payCenterService.totalInfo("kll_0001", ChannelEnum.HF, "kll_0002");
+//        payCenterService.operateDownload("kll_0001", ChannelEnum.HF, "kll_0002");
+//        payCenterService.operateCategory();
+//        payCenterService.operateIndex("kll_0001", ChannelEnum.HF, 1, 5, new String[]{"2023-07-20", "2023-07-21"}, null);
+        payCenterService.logCategory();
+        payCenterService.record("kll_0001", "kll_0002", 1, 5);
+
 //        payCenterService.payAgentPay("kll_0001");
-        return payCenterService.memberDetail(uid, ChannelEnum.HF);
+        return payCenterService.memberDetail("kll_0001", ChannelEnum.HF);
     }
 
     @Override

+ 65 - 12
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -82,15 +82,17 @@
         kllu.firm_name    firmName,
         kll.order_count   orderCount
     </sql>
-    <sql id="pageList">
+    <select id="shipperSelect" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
         select
         <include refid="list_col"/>
         from kwp_ledger_logistics kll
-                 inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
+                 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 kllu.unit_type = #{logisticsReq.unitType,jdbcType=INTEGER}
-              and kllu.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+              and kllu2.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
             <if test="logisticsReq.status != null">
                 and kll.status = #{logisticsReq.status}
             </if>
@@ -110,12 +112,40 @@
             </if>
         </where>
         order by kll.generate_time desc
-    </sql>
-    <select id="shipperSelect" resultType="com.sckw.payment.model.dto.LedgerShipperDto">
-        <include refid="pageList"/>
     </select>
+    <!--托运方1 承运方2-->
     <select id="carrierSelect" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
-        <include refid="pageList"/>
+        select
+        <include refid="list_col"/>
+        from kwp_ledger_logistics kll
+                 inner join kwp_ledger_logistics_unit kllu
+                            on kll.id = kllu.l_ledger_id and kllu.del_flag = 0 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>
+        order by kll.generate_time desc
     </select>
 
     <select id="countOrder" resultType="java.util.Map">
@@ -127,10 +157,33 @@
                count(IF(kll.status = 5, 1, NULL)) "5",
                count(IF(kll.status = 6, 1, NULL)) "6"
         FROM kwp_ledger_logistics kll
-                 inner join kwp_ledger_logistics_unit kllu on kll.id = kllu.l_ledger_id and kllu.del_flag = 0
-        WHERE kll.del_flag = 0
-          and kllu.unit_type = #{unitType,jdbcType=INTEGER}
-          and kllu.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+                 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>
 
     <select id="selectCarrierIds" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">

+ 92 - 81
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -59,7 +59,7 @@
         del_flag
     </sql>
     <sql id="sell_col">
-         klt.id,
+        klt.id,
         klt.t_ledger_no   tLedgerNo,
         klt.name,
         klt.start_time    startTime,
@@ -106,16 +106,20 @@
         kltu.firm_name    firmName,
         klt.order_count   orderCount
     </sql>
+    <!--销售2 采购1-->
     <select id="sellList" resultType="com.sckw.payment.model.dto.LedgerSellDto">
         select
         <include refid="sell_col"/>
         from kwp_ledger_trade klt
                  inner join kwp_ledger_trade_unit kltu
-        on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+                            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 kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
-            and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
+              and kltu2.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
             <if test="tradeReq.status != null">
                 and klt.status = #{tradeReq.status}
             </if>
@@ -124,19 +128,19 @@
             </if>
             <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
                 and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
-                and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+                    and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
                 and (
-                    klt.t_ledger_no like concat('%'
-                  , #{tradeReq.keywords,jdbcType=VARCHAR}
-                  , '%')
-                 or kltu.firm_name like concat('%'
-                  , #{tradeReq.keywords,jdbcType=VARCHAR}
-                  , '%')
-                 or kltu.contacts like concat('%'
-                  , #{tradeReq.keywords,jdbcType=VARCHAR}
-                  , '%')
+                            klt.t_ledger_no like concat('%'
+                            , #{tradeReq.keywords,jdbcType=VARCHAR}
+                            , '%')
+                        or kltu.firm_name like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                        or kltu.contacts like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
                     )
             </if>
         </where>
@@ -146,12 +150,15 @@
         select
         <include refid="purchase_col"/>
         from kwp_ledger_trade klt
-        inner join kwp_ledger_trade_unit kltu
-        on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu
+                            on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 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 kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
-            and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
+              and kltu2.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
             <if test="tradeReq.status != null">
                 and klt.status = #{tradeReq.status}
             </if>
@@ -160,20 +167,20 @@
             </if>
             <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
                 and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
-                and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+                    and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
                 and (
-                klt.t_ledger_no like concat('%'
-                , #{tradeReq.keywords,jdbcType=VARCHAR}
-                , '%')
-                or kltu.firm_name like concat('%'
-                , #{tradeReq.keywords,jdbcType=VARCHAR}
-                , '%')
-                or kltu.contacts like concat('%'
-                , #{tradeReq.keywords,jdbcType=VARCHAR}
-                , '%')
-                )
+                            klt.t_ledger_no like concat('%'
+                            , #{tradeReq.keywords,jdbcType=VARCHAR}
+                            , '%')
+                        or kltu.firm_name like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                        or kltu.contacts like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                    )
             </if>
         </where>
         order by klt.generate_time desc
@@ -186,12 +193,16 @@
                count(IF(klt.status = 4, 1, NULL)) "4",
                count(IF(klt.status = 5, 1, NULL)) "5",
                count(IF(klt.status = 6, 1, NULL)) "6"
-        FROM kwp_ledger_trade klt
-                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        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 kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
-              and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
+              and kltu2.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
             <if test="tradeReq.status != null">
                 and klt.status = #{tradeReq.status}
             </if>
@@ -220,33 +231,33 @@
 
     <select id="selectSellIds" resultType="com.sckw.payment.model.dto.LedgerSellDto">
         select klt.id,
-        klt.t_ledger_no   tLedgerNo,
-        klt.name,
-        klt.start_time    startTime,
-        klt.end_time      endTime,
-        klt.tax_rate      taxRate,
-        klt.trading,
-        klt.total_price   totalPrice,
-        klt.ex_tax_price  exTaxPrice,
-        klt.settle_price  settlePrice,
-        klt.actual_price  actualPrice,
-        klt.audit_phone   auditPhone,
-        klt.audit_user    auditUser,
-        klt.url,
-        klt.generate_time generateTime,
-        klt.receipt_time  receiptTime,
-        klt.remark,
-        klt.status,
-        kltu.contacts,
-        kltu.phone,
-        kltu.firm_name    firmName,
-        klt.order_count   orderCount
+               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
+                 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
+              and kltu.unit_type = 1
+              and klt.id in
             <foreach collection="ids" item="id" close=")" open="(" separator=",">
                 #{id,jdbcType=BIGINT}
             </foreach>
@@ -255,33 +266,33 @@
     </select>
     <select id="selectPurchaseIds" resultType="com.sckw.payment.model.dto.LedgerPurchaseDto">
         select klt.id,
-        klt.t_ledger_no   tLedgerNo,
-        klt.name,
-        klt.start_time    startTime,
-        klt.end_time      endTime,
-        klt.tax_rate      taxRate,
-        klt.trading,
-        klt.total_price   totalPrice,
-        klt.ex_tax_price  exTaxPrice,
-        klt.settle_price  settlePrice,
-        klt.actual_price  actualPrice,
-        klt.audit_phone   auditPhone,
-        klt.audit_user    auditUser,
-        klt.url,
-        klt.generate_time generateTime,
-        klt.receipt_time  receiptTime,
-        klt.remark,
-        klt.status,
-        kltu.contacts,
-        kltu.phone,
-        kltu.firm_name    firmName,
-        klt.order_count   orderCount
+               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
+                 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
+              and kltu.unit_type = 2
+              and klt.id in
             <foreach collection="ids" item="id" close=")" open="(" separator=",">
                 #{id,jdbcType=BIGINT}
             </foreach>

+ 2 - 1
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -154,6 +154,7 @@
                kst.success_user,
                kst.success_phone,
                kst.create_time,
+               klt.id                                             ledgerId,
                klt.name,
                klt.trading,
                kltu.firm_name
@@ -163,7 +164,7 @@
         <where>
             kst.del_flag = 0
               and kst.id = #{id,jdbcType=BIGINT}
-            and kltu.unit_type = #{unitType,jdbcType=INTEGER}
+              and kltu.unit_type = #{unitType,jdbcType=INTEGER}
         </where>
     </select>