Explorar el Código

Merge remote-tracking branch 'origin/dev' into dev

czh hace 2 años
padre
commit
b8f791b922
Se han modificado 23 ficheros con 575 adiciones y 93 borrados
  1. 23 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/app/AppKwpSettlementLogisticsController.java
  2. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/SettlementTradeController.java
  3. 14 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java
  4. 9 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementOfflineMapper.java
  5. 5 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementRecordMapper.java
  6. 9 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementWalletMapper.java
  7. 1 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementLogisticsDto.java
  8. 67 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/SettlementRecord.java
  9. 109 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/SettlementVo.java
  10. 41 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  11. 9 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java
  12. 5 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementRecordService.java
  13. 17 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  14. 5 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  15. 3 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java
  16. 38 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WorkbenchService.java
  17. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/FinanceTask.java
  18. 59 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DateTimeUtil.java
  19. 37 1
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml
  20. 13 2
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementOfflineMapper.xml
  21. 77 46
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementRecordMapper.xml
  22. 1 1
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml
  23. 30 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementWalletMapper.xml

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

@@ -1,6 +1,7 @@
 package com.sckw.payment.controller.app;
 
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.service.KwpSettlementLogisticsService;
 import jakarta.annotation.Resource;
@@ -36,6 +37,17 @@ public class AppKwpSettlementLogisticsController {
         return HttpResult.ok(kwpSettlementLogisticsService.detailCollection(id));
     }
 
+    /**
+     * 承运方 app端
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("carrierDetail")
+    public HttpResult carrierDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpSettlementLogisticsService.queryDetail(Long.parseLong(id), LogisticsUnitType.SHIPPER));
+    }
+
 
     //   ========= 运费付款 托运方 =========
     @PostMapping(name = "运费付款-物流订单列表", path = "pageListPayment")
@@ -52,4 +64,15 @@ public class AppKwpSettlementLogisticsController {
     public HttpResult detailPayment(@RequestParam("id") Long id) {
         return HttpResult.ok(kwpSettlementLogisticsService.detailPayment(id));
     }
+
+    /**
+     * app端详情
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("shipperDetail")
+    public HttpResult shipperDetail(@RequestParam("id") String id) {
+        return HttpResult.ok(kwpSettlementLogisticsService.queryDetail(Long.parseLong(id), LogisticsUnitType.CARRIER));
+    }
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/operate/SettlementTradeController.java

@@ -63,7 +63,7 @@ public class SettlementTradeController {
      * @param settlementReq
      * @return
      */
-    @PostMapping(name = "收款-表尾金额结算数据", path = "sum")
+    @PostMapping( "sum")
     public HttpResult sum(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.check();
         return HttpResult.ok(settlementTradeService.sumMoney(settlementReq));

+ 14 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java

@@ -109,5 +109,19 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
      */
     List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);
 
+    /**
+     * 物流结算定时任务归档数据查询
+     *
+     * @return
+     */
     List<KwpSettlementRecord> queryRecord();
+
+    /**
+     * app端详情
+     *
+     * @param id
+     * @param unitType
+     * @return
+     */
+    SettlementLogisticsDto selectDetail(@Param("id") Long id, @Param("unitType") Integer unitType);
 }

+ 9 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementOfflineMapper.java

@@ -3,6 +3,7 @@ package com.sckw.payment.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementOffline;
 import com.sckw.payment.model.dto.SettlementOfflineDto;
+import com.sckw.payment.model.vo.SettlementVo;
 import com.sckw.payment.model.vo.req.SettlementOfflineReq;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -19,10 +20,17 @@ public interface KwpSettlementOfflineMapper extends BaseMapper<KwpSettlementOffl
 
     SettlementOfflineDto detailLogisticsCollection(@Param("id") Long id);
 
-    Integer confirmLogisticsCollection(@Param("id") Long id, @Param("price") Float price);
 
     List<SettlementOfflineDto> pageList(@Param("offlineReq") SettlementOfflineReq settlementOfflineReq);
 
+    /**
+     * app端查询列表
+     *
+     * @param settlementOfflineReq
+     * @return
+     */
+    List<SettlementVo> appList(@Param("offlineReq") SettlementOfflineReq settlementOfflineReq);
+
     /**
      * 运营端查询
      *

+ 5 - 5
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementRecordMapper.java

@@ -2,19 +2,19 @@ package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementRecord;
-import com.sckw.payment.model.vo.req.FinanceCount;
+import com.sckw.payment.model.vo.SettlementRecord;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 /**
-* @date 2023-09-13 18:48:30
-* @author xucaiqin
-*/
+ * @author xucaiqin
+ * @date 2023-09-13 18:48:30
+ */
 @Mapper
 public interface KwpSettlementRecordMapper extends BaseMapper<KwpSettlementRecord> {
     void insertBatch(@Param("list") List<KwpSettlementRecord> list);
 
-    void countByDay(FinanceCount financeCount);
+    List<SettlementRecord> countByDay(@Param("time") List<String> time, @Param("entId")Long entId);
 }

+ 9 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementWalletMapper.java

@@ -3,6 +3,7 @@ package com.sckw.payment.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementWallet;
 import com.sckw.payment.model.dto.SettlementWalletDto;
+import com.sckw.payment.model.vo.SettlementVo;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -31,6 +32,14 @@ public interface KwpSettlementWalletMapper extends BaseMapper<KwpSettlementWalle
 
     List<SettlementWalletDto> pageList(@Param("walletReq") SettlementWalletReq walletReq);
 
+    /**
+     * app端结算列表
+     *
+     * @param walletReq
+     * @return
+     */
+    List<SettlementVo> appList(@Param("walletReq") SettlementWalletReq walletReq);
+
     /**
      * 运营端查询钱包结算记录
      *

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementLogisticsDto.java

@@ -188,4 +188,5 @@ public class SettlementLogisticsDto implements ISettlement  {
      */
     private String attachmentUrl;
 
+    private String percentage;
 }

+ 67 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/SettlementRecord.java

@@ -0,0 +1,67 @@
+package com.sckw.payment.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * 结算统计
+ *
+ * @author xucaiqin
+ * @date 2023-09-13 18:48:30
+ */
+@Data
+public class SettlementRecord {
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 总应收金额
+     */
+    private BigDecimal totalReceiveMoney;
+
+    /**
+     * 待收金额
+     */
+    private BigDecimal exactMoney;
+
+    /**
+     * 已收金额(累加金额)
+     */
+    private BigDecimal receivedMoney;
+
+    /**
+     * 逾期待收金额
+     */
+    private BigDecimal overdueExactMoney;
+
+    /**
+     * 总应付金额
+     */
+    private BigDecimal totalPayMoney;
+
+    /**
+     * 待付金额
+     */
+    private BigDecimal unpaidMoney;
+
+    /**
+     * 已付金额(累加金额)
+     */
+    private BigDecimal paidMoney;
+
+    /**
+     * 逾期待付金额
+     */
+    private BigDecimal overduePaidMoney;
+
+    /**
+     * 创建日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDate createTime;
+}

+ 109 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/SettlementVo.java

@@ -0,0 +1,109 @@
+package com.sckw.payment.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 结算记录 线下和电子钱包
+ */
+@Getter
+@Setter
+public class SettlementVo {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 企业类型
+     */
+    private Long entId;
+
+    /**
+     * 结算id(交易订单结算/物流订单结算)
+     */
+    private Long settlementId;
+
+    /**
+     * 1-物流 2-交易
+     */
+    private Integer orderType;
+
+    /**
+     * 线上渠道 1-huifu
+     */
+    private Integer channel;
+
+    /**
+     * 回款时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date payTime;
+
+    /**
+     * 金额
+     */
+    private BigDecimal payPrice;
+
+    /**
+     * 剩余待付金额
+     */
+    private BigDecimal topayPrice;
+
+    /**
+     * 类型(0付款、1退款)
+     */
+    private Integer type;
+    /**
+     * 附件地址
+     */
+    private String url;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态(0扣款、1结算、2异常、)
+     */
+    private Integer status;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建人名称
+     */
+    private String createByLabel;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private Long updateBy;
+
+    /**
+     * 更新人名称
+     */
+    private String updateByLabel;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+}

+ 41 - 5
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -12,9 +12,10 @@ 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.dto.LedgerUnitDto;
-import com.sckw.payment.model.dto.MoneyType;
-import com.sckw.payment.model.dto.SettlementLogisticsDto;
+import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
+import com.sckw.payment.model.constant.TradingEnum;
+import com.sckw.payment.model.dto.*;
+import com.sckw.payment.model.vo.SettlementVo;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
 import com.sckw.payment.model.vo.res.SettlementLogisticsSumVo;
@@ -23,6 +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 jakarta.annotation.Resource;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -45,7 +47,10 @@ public class KwpSettlementLogisticsService {
     private RemoteSystemService remoteSystemService;
     private final KwpSettlementLogisticsMapper settlementLogisticsMapper;
     private final KwpLedgerLogisticsUnitService logisticsUnitService;
-
+    @Resource
+    private KwpSettlementWalletService kwpSettlementWalletService;
+    @Resource
+    private KwpSettlementOfflineService kwpSettlementOfflineService;
 
     public void save(KwpSettlementLogistics settlementLogistics) {
         settlementLogisticsMapper.insert(settlementLogistics);
@@ -98,7 +103,38 @@ public class KwpSettlementLogisticsService {
         settlementReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
         return pageSelect(settlementReq);
     }
-
+    /**
+     * 查询贸易结算详情
+     *
+     * @param id       结算单id
+     * @param unitType 企业类型
+     * @return
+     */
+    public SettlementDetailDto<SettlementLogisticsDto, SettlementVo> queryDetail(Long id, Integer unitType) {
+        SettlementLogisticsDto settlementLogisticsDto = settlementLogisticsMapper.selectDetail(id, unitType);
+        if (Objects.isNull(settlementLogisticsDto)) {
+            throw new BusinessException("结算单不存在");
+        }
+        Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.TRADE_TYPE.getType());
+        String trading = settlementLogisticsDto.getTrading();
+        SysDictResDto sysDictResDto = dictResDtoMap.get(trading);
+        if (Objects.nonNull(sysDictResDto)) {
+            settlementLogisticsDto.setTradingLabel(sysDictResDto.getLabel());
+        }
+        settlementLogisticsDto.setPercentage(settlementLogisticsDto.changePercentage(settlementLogisticsDto.getActualPrice(), settlementLogisticsDto.getTotalPrice()));
+        settlementLogisticsDto.setStatusLabel(SettlementEnum.getStatusDesc(settlementLogisticsDto.getStatus()));
+        Integer payType = TradingEnum.getPrefix(trading);
+        List<SettlementVo> settlementVoList = new ArrayList<>();
+        if (Objects.nonNull(payType)) {
+            if(payType==TradingEnum.OFFLINE_PAY.getStatus()){
+                settlementVoList = kwpSettlementOfflineService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), payType);
+            }else {
+                settlementVoList = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), payType);
+            }
+        }
+        List<SettlementVo> settlementWallet = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), TradingEnum.getPrefix(trading));
+        return new SettlementDetailDto<>(settlementLogisticsDto, settlementVoList);
+    }
     /**
      * 运费收款-物流订单详情
      *

+ 9 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java

@@ -21,6 +21,7 @@ import com.sckw.payment.model.constant.*;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.dto.SettlementOfflineDto;
 import com.sckw.payment.model.dto.SettlementTradeDto;
+import com.sckw.payment.model.vo.SettlementVo;
 import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementOfflinePayReq;
 import com.sckw.payment.model.vo.req.SettlementOfflineReq;
@@ -416,4 +417,12 @@ public class KwpSettlementOfflineService {
         }
         return "请勿重复提交";
     }
+
+    public List<SettlementVo> queryList(Long id, int status, Integer payType) {
+        SettlementOfflineReq settlementWalletReq = new SettlementOfflineReq();
+        settlementWalletReq.setPayType(payType);
+        settlementWalletReq.setOrderType(status);
+        settlementWalletReq.setId(String.valueOf(id));
+        return settlementOfflineMapper.appList(settlementWalletReq);
+    }
 }

+ 5 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementRecordService.java

@@ -1,11 +1,13 @@
 package com.sckw.payment.service;
 
 import com.sckw.payment.dao.KwpSettlementRecordMapper;
-import com.sckw.payment.model.vo.req.FinanceCount;
+import com.sckw.payment.model.vo.SettlementRecord;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 归档记录
  *
@@ -19,8 +21,7 @@ public class KwpSettlementRecordService {
     private final KwpSettlementRecordMapper kwpSettlementRecordMapper;
 
 
-    public String financeCount(FinanceCount financeCount) {
-        kwpSettlementRecordMapper.countByDay(financeCount);
-        return null;
+    public List<SettlementRecord> financeCount(List<String> financeCount, Long entId) {
+        return kwpSettlementRecordMapper.countByDay(financeCount,entId);
     }
 }

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

@@ -16,6 +16,7 @@ import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
 import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.constant.TradingEnum;
 import com.sckw.payment.model.dto.*;
+import com.sckw.payment.model.vo.SettlementVo;
 import com.sckw.payment.model.vo.req.SettlementTradeReq;
 import com.sckw.payment.model.vo.res.SettlementSumVo;
 import com.sckw.system.api.RemoteSystemService;
@@ -47,6 +48,8 @@ public class KwpSettlementTradeService {
     private final KwpLedgerTradeUnitService tradeUnitService;
     @Resource
     private KwpSettlementWalletService kwpSettlementWalletService;
+    @Resource
+    private KwpSettlementOfflineService kwpSettlementOfflineService;
 
 
     /**
@@ -246,7 +249,7 @@ public class KwpSettlementTradeService {
      * @param unitType 企业类型
      * @return
      */
-    public SettlementDetailDto<SettlementTradeDto, SettlementWalletDto> queryDetail(Long id, Integer unitType) {
+    public SettlementDetailDto<SettlementTradeDto, SettlementVo> queryDetail(Long id, Integer unitType) {
         SettlementTradeDto settlementTradeDto = settlementTradeMapper.selectDetail(id, unitType);
         if (Objects.isNull(settlementTradeDto)) {
             throw new BusinessException("结算单不存在");
@@ -259,14 +262,23 @@ public class KwpSettlementTradeService {
         }
         settlementTradeDto.setPercentage(settlementTradeDto.changePercentage(settlementTradeDto.getActualPrice(), settlementTradeDto.getTotalPrice()));
         settlementTradeDto.setStatusLabel(SettlementEnum.getStatusDesc(settlementTradeDto.getStatus()));
-        List<SettlementWalletDto> settlementWallet = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.TRADE.getStatus(), TradingEnum.getPrefix(trading));
-        return new SettlementDetailDto<>(settlementTradeDto, settlementWallet);
+        Integer payType = TradingEnum.getPrefix(trading);
+        List<SettlementVo> settlementVoList = new ArrayList<>();
+        if (Objects.nonNull(payType)) {
+            if(payType==TradingEnum.OFFLINE_PAY.getStatus()){
+                settlementVoList = kwpSettlementOfflineService.queryList(id, SettlementOrderTypeEnum.TRADE.getStatus(), payType);
+
+            }else {
+                settlementVoList = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.TRADE.getStatus(), payType);
+            }
+        }
+        return new SettlementDetailDto<>(settlementTradeDto, settlementVoList);
     }
 
     /**
      * @param entId    顶级企业id
-     * @param cur       当月/周
-     * @param pre       上月/周
+     * @param cur      当月/周
+     * @param pre      上月/周
      * @param unitType 企业类型 2-销售 1-采购
      */
     public List<MoneyType> moneySum(Long entId, List<LocalDateTime> cur, List<LocalDateTime> pre, Integer unitType) {

+ 5 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java

@@ -26,6 +26,7 @@ import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.dto.SettlementTradeDto;
 import com.sckw.payment.model.dto.SettlementWalletDto;
+import com.sckw.payment.model.vo.SettlementVo;
 import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
 import com.sckw.payment.model.vo.req.WalletPayReq;
@@ -68,7 +69,8 @@ public class KwpSettlementWalletService {
     private final KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
     private final KwpLedgerTradeOrderService tradeOrderService;
     private final KwpSettlementLogisticsService kwpSettlementLogisticsService;
-    private final KwpSettlementTradeService kwpSettlementTradeService;
+    @Resource
+    private KwpSettlementTradeService kwpSettlementTradeService;
     private final PayCenterService payCenterService;
     private final KwpWalletRelationService walletRelationService;
     private final RedisLockUtil redisLockUtil;
@@ -736,12 +738,12 @@ public class KwpSettlementWalletService {
      * @param status  订单类型 1-物流 2-贸易
      * @param payType 支付方式 1-预付款、2-货到付款
      */
-    public List<SettlementWalletDto> queryList(Long id, int status, Integer payType) {
+    public List<SettlementVo> queryList(Long id, int status, Integer payType) {
         SettlementWalletReq settlementWalletReq = new SettlementWalletReq();
         settlementWalletReq.setPayType(payType);
         settlementWalletReq.setOrderType(status);
         settlementWalletReq.setId(String.valueOf(id));
-        return settlementWalletMapper.pageList(settlementWalletReq);
+        return settlementWalletMapper.appList(settlementWalletReq);
     }
 }
 

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

@@ -365,9 +365,9 @@ public class PayCenterService {
         if (Objects.isNull(money)) {
             throw new BusinessException("提现金额不能为空");
         }
-        if (StringUtils.isBlank(remarks)) {
-            throw new BusinessException("备注不能为空");
-        }
+//        if (StringUtils.isBlank(remarks)) {
+//            throw new BusinessException("备注不能为空");
+//        }
         String sync = postHttp(PayCenterEnum.WITHDRAW_TAKE, new HashMap<>() {{
             put("uid", uid);
             put("channel", channel);

+ 38 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WorkbenchService.java

@@ -1,10 +1,17 @@
 package com.sckw.payment.service;
 
+import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.model.vo.req.FinanceCount;
+import com.sckw.payment.utils.DateTimeUtil;
+import jakarta.annotation.Resource;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 工作台
  *
@@ -16,8 +23,37 @@ import org.springframework.stereotype.Service;
 @RequiredArgsConstructor
 public class WorkbenchService {
 
+    @Resource
+    private KwpSettlementRecordService kwpSettlementRecordService;
+
+    public Object financeCount(FinanceCount financeCount) {
+        //周期维度 1-天 2-周 3-月
+        Integer circle = financeCount.getCircle();
+        List<String> time = new ArrayList<>();
 
-    public String financeCount(FinanceCount financeCount) {
-        return null;
+        //时间参数为空,按照默认维度统计
+        if (StringUtils.isBlank(financeCount.getStartTime()) && StringUtils.isBlank(financeCount.getEndTime())) {
+            //按照周期维度生成时间段
+            if (circle == 1) {
+                //从今天倒推15天
+                time.add(DateTimeUtil.getComputeDaysStr(-14));
+                time.add(DateTimeUtil.getComputeDaysStr(0));
+            } else if (circle == 3) {
+                //从当月倒推12月
+                time.add(DateTimeUtil.getComputeMonthStartDayStr(-12));
+                time.add(DateTimeUtil.getComputeMonthEndDayStr(0));
+            }
+        } else {
+            //按照给定的时间参数进行统计
+            if (circle == 1) {
+                time.add(financeCount.getStartTime());
+                time.add(financeCount.getEndTime());
+            } else if (circle == 3) {
+                time.add(DateTimeUtil.getComputeMonthStartDayStr(financeCount.getStartTime()));
+                time.add(DateTimeUtil.getComputeMonthEndDayStr(financeCount.getEndTime()));
+            }
+        }
+        Long entId = LoginUserHolder.getEntId();
+        return kwpSettlementRecordService.financeCount(time,entId);
     }
 }

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/FinanceTask.java

@@ -49,8 +49,8 @@ public class FinanceTask {
                     kwpSettlementRecord.setOrderType(2);
                     kwpSettlementRecord.setCreateTime(now);
                 }
-                kwpSettlementRecordMapper.insertBatch(moneyArchivedDto);
                 log.info("贸易归档:{}", JSONObject.toJSONString(moneyArchivedDto));
+                kwpSettlementRecordMapper.insertBatch(moneyArchivedDto);
             }
             if (!CollectionUtils.isEmpty(kwpSettlementRecords)) {
                 for (KwpSettlementRecord kwpSettlementRecord : kwpSettlementRecords) {
@@ -58,8 +58,8 @@ public class FinanceTask {
                     kwpSettlementRecord.setOrderType(1);
                     kwpSettlementRecord.setCreateTime(now);
                 }
-                kwpSettlementRecordMapper.insertBatch(kwpSettlementRecords);
                 log.info("物流归档:{}", JSONObject.toJSONString(kwpSettlementRecords));
+                kwpSettlementRecordMapper.insertBatch(kwpSettlementRecords);
             }
         } catch (Exception ex) {
             log.error("结算记录归档异常:{}", ex, ex);

+ 59 - 12
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DateTimeUtil.java

@@ -5,6 +5,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
 
 /**
  * @description: 时间工具类
@@ -20,6 +21,13 @@ public class DateTimeUtil {
     public static final DateTimeFormatter YYYY_MM_DD = DateTimeFormatter.ofPattern(YMD);
     public static final DateTimeFormatter HH_MM_SS = DateTimeFormatter.ofPattern(HMS);
 
+    public static LocalDateTime parse(String date) {
+        return LocalDateTime.parse(date, YYYY_MM_DD_HH_MM_SS);
+    }
+
+    public static LocalDate parseYMD(String date) {
+        return LocalDate.parse(date, YYYY_MM_DD);
+    }
     /*格式化*/
 
     /**
@@ -60,14 +68,6 @@ public class DateTimeUtil {
         return formatYMD(getComputeMonth(months));
     }
 
-    public static String getComputeMonthStartDay(long months) {
-        return formatYMD(getComputeMonth(months));
-    }
-
-    public static String getComputeMonthEndDay(long months) {
-        return formatYMD(getComputeMonth(months));
-    }
-
     /**
      * 从给定的日期计算月数差
      *
@@ -90,9 +90,32 @@ public class DateTimeUtil {
         return localDateTime.plusMonths(months);
     }
 
+    /**
+     * 从当前日期计算月数差,并取当月的第一天
+     *
+     * @param months 加或减的月数
+     * @return LocalDateTime,时间最小值
+     */
+    public static LocalDate getComputeMonthStartDay(long months) {
+        return getComputeMonth(months).with(TemporalAdjusters.firstDayOfMonth());
+    }
 
     /**
-     * 从当前日期计算月数差
+     * 获取传入日期的当月第一天
+     *
+     * @param date 日期(不能包含时分秒)
+     * @return
+     */
+    public static String getComputeMonthStartDayStr(String date) {
+        return formatYMD(parseYMD(date).with(TemporalAdjusters.firstDayOfMonth()));
+    }
+
+    public static String getComputeMonthStartDayStr(long months) {
+        return formatYMD(getComputeMonth(months).with(TemporalAdjusters.firstDayOfMonth()));
+    }
+
+    /**
+     * 从当前日期计算月数差,时间取最小值 00:00:00
      *
      * @param months 加或减的月数
      * @param offset 偏移的天数 ±1
@@ -103,7 +126,7 @@ public class DateTimeUtil {
     }
 
     /**
-     * 从当前日期计算月数差
+     * 从当前日期计算月数差,时间取最大值 23:59:59
      *
      * @param months 加或减的月数
      * @param offset 偏移的天数 ±1
@@ -112,6 +135,30 @@ public class DateTimeUtil {
     public static LocalDateTime getComputeMonthEnd(long months, long offset) {
         return LocalDateTime.of(getComputeMonth(months), LocalTime.MAX).plusDays(offset);
     }
+
+    /**
+     * 获取传入日期的当月最后一天
+     *
+     * @param date
+     * @return
+     */
+    public static String getComputeMonthEndDayStr(String date) {
+        return formatYMD(parseYMD(date).with(TemporalAdjusters.lastDayOfMonth()));
+    }
+
+    public static String getComputeMonthEndDayStr(long months) {
+        return formatYMD(getComputeMonth(months).with(TemporalAdjusters.lastDayOfMonth()));
+    }
+
+    /**
+     * 从当前日期计算月数差,并取当月的最后一天
+     *
+     * @param months 加或减的月数
+     * @return LocalDateTime,时间最小值
+     */
+    public static LocalDate getComputeMonthEndDay(long months) {
+        return getComputeMonth(months).with(TemporalAdjusters.lastDayOfMonth());
+    }
     /*天差计算*/
 
     /**
@@ -197,7 +244,7 @@ public class DateTimeUtil {
 
     public static void main(String[] args) {
 
-        System.out.println(getComputeDaysStr(0));
-        System.out.println(getComputeMonthStart(1, 0));
+        System.out.println(parse("2023-12-11"));
+        System.out.println(getComputeMonthEndDayStr(0));
     }
 }

+ 37 - 1
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -340,6 +340,42 @@
             and lu2.unit_type = #{unitTypeTwo,jdbcType=INTEGER}
         </if>
     </select>
+    <select id="selectDetail" parameterType="java.lang.Long"
+            resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
+        select s.id,
+               s.ent_id                       as entId,
+               s.l_ledger_id                  as lLedgerId,
+               s.sl_order_no                  as slOrderNo,
+               s.total_price                  as totalPrice,
+               s.actual_price                 as actualPrice,
+               s.total_price - s.actual_price as waitPrice,
+               s.receipt_time                 as receiptTime,
+               s.remark,
+               s.audit_user                   as auditUser,
+               s.audit_phone                  as auditPhone,
+               s.success_user                 as successUser,
+               s.success_phone                as successPhone,
+               s.status,
+               s.create_by                    as createBy,
+               s.create_time                  as createTime,
+               s.update_by                    as updateBy,
+               s.update_time                  as updateTime,
+               l.name,
+               l.generate_time                as generateTime,
+               l.l_ledger_no                  as lLedgerNo,
+               l.trading                      as trading,
+               l.settle_price                 as settlePrice,
+               l.url                          as url,
+               lu.firm_name                   as firm_name
+        from kwp_settlement_logistics s
+                 inner join kwp_ledger_logistics l on s.l_ledger_id = l.id and l.del_flag = 0
+                 inner join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id and lu.del_flag = 0 and
+                                                            lu.unit_type = #{unitType,jdbcType=INTEGER}
+        <where>
+            s.del_flag = 0
+            and s.id = #{id,jdbcType=BIGINT}
+        </where>
+    </select>
 
     <!--  根据多个结算运费物流订单id查订单,用于导出   -->
     <select id="selectLogisticsList" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
@@ -508,7 +544,7 @@
                             ksl.total_price - ksl.actual_price, 0.0)
                    )                                                                overduePaidMoney
         FROM kwp_settlement_logistics ksl
-                 LEFT JOIN kwp_ledger_logistics_unit kllu ON ksl.l_ledger_id = kllu.l_ledger_id
+                 inner JOIN kwp_ledger_logistics_unit kllu ON ksl.l_ledger_id = kllu.l_ledger_id
             AND kllu.del_flag = 0
         WHERE ksl.del_flag = 0
         GROUP BY kllu.top_ent_id

+ 13 - 2
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementOfflineMapper.xml

@@ -64,9 +64,20 @@
         </where>
     </select>
 
-    <select id="confirmLogisticsCollection" resultType="java.lang.Integer">
+    <select id="appList" resultType="com.sckw.payment.model.vo.SettlementVo">
+        select
+        <include refid="Base_Column_List"/>
+        FROM kwp_settlement_offline
+        <where>
+            del_flag = 0
+            <if test="offlineReq.orderType != null">
+                and order_type = #{offlineReq.orderType,jdbcType=INTEGER}
+            </if>
+            <if test="offlineReq.id != null and offlineReq.id != ''">
+                and settlement_id = #{offlineReq.id,jdbcType=INTEGER}
+            </if>
+        </where>
     </select>
-
     <select id="pageList" resultType="com.sckw.payment.model.dto.SettlementOfflineDto">
         select
         <include refid="Base_Column_List"/>

+ 77 - 46
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementRecordMapper.xml

@@ -1,52 +1,83 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.payment.dao.KwpSettlementRecordMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementRecord">
-    <!--@mbg.generated-->
-    <!--@Table kwp_settlement_record-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="ent_id" jdbcType="BIGINT" property="entId" />
-    <result column="total_receive_money" jdbcType="DECIMAL" property="totalReceiveMoney" />
-    <result column="exact_money" jdbcType="DECIMAL" property="exactMoney" />
-    <result column="received_money" jdbcType="DECIMAL" property="receivedMoney" />
-    <result column="overdue_exact_money" jdbcType="DECIMAL" property="overdueExactMoney" />
-    <result column="total_pay_money" jdbcType="DECIMAL" property="totalPayMoney" />
-    <result column="unpaid_money" jdbcType="DECIMAL" property="unpaidMoney" />
-    <result column="paid_money" jdbcType="DECIMAL" property="paidMoney" />
-    <result column="overdue_paid_money" jdbcType="DECIMAL" property="overduePaidMoney" />
-    <result column="create_time" jdbcType="DATE" property="createTime" />
-    <result column="order_type" jdbcType="INTEGER" property="orderType" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, ent_id, total_receive_money, exact_money, received_money, overdue_exact_money, 
-    total_pay_money, unpaid_money, paid_money, overdue_paid_money, create_time, order_type
-  </sql>
+    <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementRecord">
+        <!--@mbg.generated-->
+        <!--@Table kwp_settlement_record-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="ent_id" jdbcType="BIGINT" property="entId"/>
+        <result column="total_receive_money" jdbcType="DECIMAL" property="totalReceiveMoney"/>
+        <result column="exact_money" jdbcType="DECIMAL" property="exactMoney"/>
+        <result column="received_money" jdbcType="DECIMAL" property="receivedMoney"/>
+        <result column="overdue_exact_money" jdbcType="DECIMAL" property="overdueExactMoney"/>
+        <result column="total_pay_money" jdbcType="DECIMAL" property="totalPayMoney"/>
+        <result column="unpaid_money" jdbcType="DECIMAL" property="unpaidMoney"/>
+        <result column="paid_money" jdbcType="DECIMAL" property="paidMoney"/>
+        <result column="overdue_paid_money" jdbcType="DECIMAL" property="overduePaidMoney"/>
+        <result column="create_time" jdbcType="DATE" property="createTime"/>
+        <result column="order_type" jdbcType="INTEGER" property="orderType"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id,
+        ent_id,
+        total_receive_money,
+        exact_money,
+        received_money,
+        overdue_exact_money,
+        total_pay_money,
+        unpaid_money,
+        paid_money,
+        overdue_paid_money,
+        create_time,
+        order_type
+    </sql>
 
-  <insert id="insertBatch">
-      insert into kwp_settlement_record
-      <trim prefix="(" suffix=")" suffixOverrides=",">
-          id, ent_id, total_receive_money, exact_money, received_money, overdue_exact_money,
-          total_pay_money, unpaid_money, paid_money, overdue_paid_money, create_time, order_type
-      </trim>
-      values
-      <foreach collection="list" item="item" separator=",">
-          <trim prefix="(" suffix=")" suffixOverrides=",">
-              #{item.id,jdbcType=BIGINT},
-              #{item.entId,jdbcType=BIGINT},
-              #{item.totalReceiveMoney,jdbcType=DECIMAL},
-              #{item.exactMoney,jdbcType=DECIMAL},
-              #{item.receivedMoney,jdbcType=DECIMAL},
-              #{item.overdueExactMoney,jdbcType=DECIMAL},
-              #{item.totalPayMoney,jdbcType=DECIMAL},
-              #{item.unpaidMoney,jdbcType=DECIMAL},
-              #{item.paidMoney,jdbcType=DECIMAL},
-              #{item.overduePaidMoney,jdbcType=DECIMAL},
-              #{item.createTime,jdbcType=TIMESTAMP},
-              #{item.orderType,jdbcType=INTEGER}
-          </trim>
-      </foreach>
-  </insert>
-    <select id="countByDay">
+    <insert id="insertBatch">
+        insert into kwp_settlement_record
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            id, ent_id, total_receive_money, exact_money, received_money, overdue_exact_money,
+            total_pay_money, unpaid_money, paid_money, overdue_paid_money, create_time, order_type
+        </trim>
+        values
+        <foreach collection="list" item="item" separator=",">
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                #{item.id,jdbcType=BIGINT},
+                #{item.entId,jdbcType=BIGINT},
+                #{item.totalReceiveMoney,jdbcType=DECIMAL},
+                #{item.exactMoney,jdbcType=DECIMAL},
+                #{item.receivedMoney,jdbcType=DECIMAL},
+                #{item.overdueExactMoney,jdbcType=DECIMAL},
+                #{item.totalPayMoney,jdbcType=DECIMAL},
+                #{item.unpaidMoney,jdbcType=DECIMAL},
+                #{item.paidMoney,jdbcType=DECIMAL},
+                #{item.overduePaidMoney,jdbcType=DECIMAL},
+                #{item.createTime,jdbcType=TIMESTAMP},
+                #{item.orderType,jdbcType=INTEGER}
+            </trim>
+        </foreach>
+    </insert>
+    <select id="countByDay" resultType="com.sckw.payment.model.vo.SettlementRecord">
+        select sum(ksr.total_pay_money)     totalPayMoney,
+               sum(ksr.exact_money)         exactMoney,
+               sum(ksr.received_money)      receivedMoney,
+               sum(ksr.overdue_exact_money) overdueExactMoney,
+               sum(ksr.total_pay_money)     totalPayMoney,
+               sum(ksr.unpaid_money)        unpaidMoney,
+               sum(ksr.paid_money)          paidMoney,
+               sum(ksr.overdue_paid_money)  overduePaidMoney
+        from kwp_settlement_record ksr
+        <where>
+            <if test="entId != null">
+                and ksr.ent_id = #{entId,jdbcType=BIGINT}
+            </if>
+            <if test="time != null and time.size() != 0">
+                and ksr.create_time between
+                <foreach collection="time" open=" " separator="and" close=" " item="item">
+                    #{item,jdbcType=TIMESTAMP}
+                </foreach>
+            </if>
+        </where>
+        group by ksr.create_time
     </select>
 </mapper>

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

@@ -493,7 +493,7 @@
                             kst.total_price - kst.actual_price, 0.0)
                    )                                                                overduePaidMoney
         FROM `kwp_settlement_trade` kst
-                 LEFT JOIN kwp_ledger_trade_unit kltu ON kst.t_ledger_id = kltu.t_ledger_id
+                 inner JOIN kwp_ledger_trade_unit kltu ON kst.t_ledger_id = kltu.t_ledger_id
             AND kltu.del_flag = 0
         WHERE kst.del_flag = 0
         GROUP BY kltu.top_ent_id

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

@@ -121,6 +121,36 @@
             </if>
         </where>
     </select>
+    <select id="appList" resultType="com.sckw.payment.model.vo.SettlementVo">
+        select ksw.id,
+               ksw.ent_id,
+               ksw.settlement_id,
+               ksw.order_type,
+               ksw.channel,
+               ksw.order_type,
+               ksw.pay_time,
+               ksw.pay_price,
+               ksw.topay_price,
+               ksw.type,
+               ksw.remark,
+               ksw.create_by,
+               ksw.create_time,
+               ksw.update_by,
+               ksw.update_time
+        from kwp_settlement_wallet ksw
+        <where>
+            ksw.del_flag = 0
+            <if test="walletReq.id != null and walletReq.id != ''">
+                and ksw.settlement_id = #{walletReq.id,jdbcType=INTEGER}
+            </if>
+            <if test="walletReq.orderType != null">
+                and ksw.order_type = #{walletReq.orderType,jdbcType=INTEGER}
+            </if>
+            <if test="walletReq.payType != null">
+                and ksw.type = #{walletReq.payType,jdbcType=INTEGER}
+            </if>
+        </where>
+    </select>
     <select id="list" resultType="com.sckw.payment.model.dto.SettlementWalletDto">
         select ksw.id,
                ksw.ent_id,