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

结算-物流运费相关开发完成除对接中台外开发完成

sptkw 2 лет назад
Родитель
Сommit
1865375ed4

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

@@ -1,6 +1,5 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.payment.model.constant.LogisticsUnitType;
@@ -36,15 +35,9 @@ public class KwpSettlementLogisticsController {
     //   ========= 运费收款 承运方 =========
     @PostMapping(name = "运费收款-物流订单列表", path = "pageListCollection")
     public HttpResult pageSelectCollection(@RequestBody @Valid SettlementReq settlementReq) {
-        List<Long> idList = settlementReq.getIdList();
         return HttpResult.ok(kwpSettlementLogisticsService.pageSelectCollection(settlementReq));
     }
 
-//    @PostMapping(name = "物流-电子钱 -列表", path = "testpageSelectCollection")
-//    public HttpResult testpageSelectCollection(@RequestBody @Valid SettlementReq settlementReq) {
-//       System.out.println(settlementReq.getIds());
-//        return HttpResult.ok(settlementReq);
-//    }
     @PostMapping(name = "运费收款-物流订单各状态列表总数", path = "getCountListCollection")
     public HttpResult getCountListCollection(@RequestBody @Valid SettlementReq settlementReq) {
         return HttpResult.ok(kwpSettlementLogisticsService.getCountListCollection(settlementReq));
@@ -52,18 +45,9 @@ public class KwpSettlementLogisticsController {
 
     @PostMapping(name = "运费收款-根据条件导出物流订单表数据", path = "exportCollection")
     public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.CARRIER);
         List<SettlementLogisticsDto> list;
-        if (CollectionUtils.isEmpty(settlementReq.getIdList()) && settlementReq.getPage() != 0 && settlementReq.getPageSize() != 0) {
-            //有page、pageSize,无ids
-            PageRes<SettlementLogisticsDto> pageResult = kwpSettlementLogisticsService.pageSelectCollection(settlementReq);
-            list = pageResult.getList();
-        } else if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            //无page、pageSize,无ids
-            list = kwpSettlementLogisticsService.selectList(LogisticsUnitType.CARRIER);
-        } else {
-            //有ids
-            list = kwpSettlementLogisticsService.selectList(settlementReq.getIdList());
-        }
+        list = kwpSettlementLogisticsService.selectList(settlementReq);
         return this.export(response, list);
     }
 
@@ -86,18 +70,9 @@ public class KwpSettlementLogisticsController {
 
     @PostMapping(name = "运费付款-根据条件导出物流订单表数据", path = "exportPayment")
     public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
         List<SettlementLogisticsDto> list;
-        if (CollectionUtils.isEmpty(settlementReq.getIdList()) && settlementReq.getPage() != 0 && settlementReq.getPageSize() != 0) {
-            //有page、pageSize,无ids
-            PageRes<SettlementLogisticsDto> pageResult = kwpSettlementLogisticsService.pageSelectPayment(settlementReq);
-            list = pageResult.getList();
-        } else if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            //无page、pageSize,无ids
-            list = kwpSettlementLogisticsService.selectList(LogisticsUnitType.SHIPPER);
-        } else {
-            //有ids
-            list = kwpSettlementLogisticsService.selectList(settlementReq.getIdList());
-        }
+        list = kwpSettlementLogisticsService.selectList(settlementReq);
         return this.export(response, list);
     }
 

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

@@ -3,14 +3,11 @@ package com.sckw.payment.controller;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementOfflineReq;
-import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.service.KwpSettlementOfflineService;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
 import org.springframework.web.bind.annotation.*;
 
-import java.math.BigDecimal;
-
 /**
  * 结算-线下记录(交易订单结算/物流订单结算)
  *
@@ -37,7 +34,6 @@ public class KwpSettlementOfflineController {
     }
 
     @PostMapping(name = "物流-线下付款(运费收款)记录-新增", path = "confirmLogisticsCollection")
-//    public HttpResult confirmLogisticsCollection(@RequestParam("id") Long id, @RequestParam("price") BigDecimal price, @RequestParam("url") String url) {
     public HttpResult confirmLogisticsCollection(@RequestBody @Valid OfflinePaymentReq offlinePaymentReq) {
         return HttpResult.ok(kwpSettlementOfflineService.confirmLogisticsCollection(offlinePaymentReq));
     }

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

@@ -8,8 +8,6 @@ import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
 import org.springframework.web.bind.annotation.*;
 
-import java.math.BigDecimal;
-
 /**
  * 结算-电子钱包结算记录(交易订单结算/物流订单结算)
  *
@@ -39,7 +37,7 @@ public class KwpSettlementWalletController {
      * @author Aick Spt
      * @date 2023-07-25 09:55
      */
-    @GetMapping(name = "物流-电子钱包付款(货到付款)结算记录-新增", path = "confirmLogisticsPayment")
+    @PostMapping(name = "物流-电子钱包付款(货到付款)结算记录-新增", path = "confirmLogisticsPayment")
     public HttpResult confirmLogisticsPayment(@RequestBody @Valid OfflinePaymentReq offlinePaymentReq) {
         return HttpResult.ok(kwpSettlementWalletService.confirmLogisticsPayment(offlinePaymentReq));
     }

+ 12 - 39
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java

@@ -18,64 +18,37 @@ import java.util.List;
 public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLogistics> {
 
     /**
-     * 运费收款-物流订单列表
-     *
-     * @author Aick Spt
-     * @date 2023-07-24 16:21
-     */
-    List<SettlementLogisticsDto> pageSelectCollection(@Param("settlementReq") SettlementReq settlementReq);
-
-
-    SettlementLogisticsSumVo selectCollectionSum(@Param("settlementReq") SettlementReq settlementReq);
-
-
-    /**
-     * 运费收款-物流订单各状态列表总数
-     *
-     * @author Aick Spt
-     * @date 2023-07-24 16:21
-     */
-    Long getCountListCollection(@Param("settlementReq") SettlementReq settlementReq);
-
-    /**
-     * 运费收款-物流订单详情
-     *
+     * 运费付款-物流订单列表
      * @author Aick Spt
-     * @date 2023-07-24 16:22
+     * @date 2023-07-24 16:23
      */
-    SettlementLogisticsDto detailCollection(@Param("id") Long id);
-
+    List<SettlementLogisticsDto> pageSelect(@Param("settlementReq") SettlementReq settlementReq);
 
     /**
-     * 运费付款-物流订单列表
-     *
+     * 运费-物流订单各状态列表总数
      * @author Aick Spt
      * @date 2023-07-24 16:23
      */
-    List<SettlementLogisticsDto> pageSelectPayment(@Param("settlementReq") SettlementReq settlementReq);
+    Long getCountList(@Param("settlementReq") SettlementReq settlementReq);
 
     /**
-     * 运费付款-物流订单各状态列表总数
-     *
+     * 运费-物流订单列表查询合计
      * @author Aick Spt
-     * @date 2023-07-24 16:23
+     * @date 2023-07-28 09:49
      */
-    Long getCountListPayment(@Param("settlementReq") SettlementReq settlementReq);
+    SettlementLogisticsSumVo selectSum(@Param("settlementReq") SettlementReq settlementReq);
 
     /**
-     * 运费付款-物流订单详情
-     *
+     * 运费-物流订单详情
      * @author Aick Spt
      * @date 2023-07-24 16:24
      */
-    SettlementLogisticsDto detailPayment(@Param("id") Long id);
+    SettlementLogisticsDto detail(@Param("id") Long id, @Param("unitType") Integer unitType);
 
     /**
-     * 根据id查物流结算订单
-     *
+     * 根据条件查物流结算订单-导出
      * @author Aick Spt
      * @date 2023-07-24 16:24
      */
-    List<SettlementLogisticsDto> selectIds(@Param("ids") List<Long> ids);
-    List<SettlementLogisticsDto> selectList(@Param("unitType") Integer unitType);
+    List<SettlementLogisticsDto> selectLogisticsList(@Param("settlementReq") SettlementReq settlementReq, @Param("ids") List<Long> ids);
 }

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

@@ -13,9 +13,6 @@ import java.time.LocalDateTime;
 /**
  * @author xucaiqin
  * @date 2023-07-10 16:42:20
- */
-
-/**
  * 结算-物流订单-状态信息
  */
 @Getter
@@ -42,7 +39,7 @@ public class KwpSettlementLogisticsTrack {
     private String remark;
 
     /**
-     * 用户状态(0正常、1已锁
+     * 用户状态(1待结算,2部分结算,3全部结算
      */
     @TableField(value = "`status`")
     private Integer status;

+ 14 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementReq.java

@@ -45,5 +45,19 @@ public class SettlementReq extends BasePara {
      */
     private Integer status;
 
+    /**
+     * 多用于导出时的id集合
+     */
     private String ids;
+
+    /**
+     * 用于过滤当前登录者企业id
+     */
+    private Long entId;
+
+    /**
+     * 筛选交易方
+     */
+    private Integer unitType;
+
 }

+ 87 - 105
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -3,9 +3,10 @@ package com.sckw.payment.service;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
-import com.sckw.core.model.page.PageRes;
+import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
@@ -15,9 +16,9 @@ import com.sckw.payment.utils.CommonValidator;
 import com.sckw.payment.utils.PageMoreRes;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -33,25 +34,6 @@ public class KwpSettlementLogisticsService {
     public void save(KwpSettlementLogistics settlementLogistics) {
         settlementLogisticsMapper.insert(settlementLogistics);
     }
-//    public SettlementLogisticsStatusCountVo getCountList() {
-//        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-//        LambdaQueryWrapper<KwpSettlementLogistics> wrapper = new LambdaQueryWrapper<>();
-//
-//        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        wrapper.eq(KwpSettlementLogistics::getStatus, SettlementEnum.WAITING_PAYMENT.getStatus());//待结算
-//        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        wrapper.clear();
-//        wrapper.eq(KwpSettlementLogistics::getStatus, SettlementEnum.PARTIAL_PAYMENT.getStatus());//部分结算
-//        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        wrapper.clear();
-//        wrapper.eq(KwpSettlementLogistics::getStatus, SettlementEnum.ALL_PAYMENT.getStatus());//全部结算
-//        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        return settlementLogisticsStatusCountVos;
-//    }
 
     /**
      * 运费收款-物流订单各状态列表总数
@@ -60,24 +42,8 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:21
      */
     public SettlementLogisticsStatusCountVo getCountListCollection(SettlementReq settlementReq) {
-        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-        //总
-        settlementReq.setStatus(null);
-        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        //待结算
-        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        //部分结算
-        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        //全部结算
-        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        return settlementLogisticsStatusCountVos;
+        settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
+        return getCountList(settlementReq);
     }
 
     /**
@@ -87,24 +53,8 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:23
      */
     public SettlementLogisticsStatusCountVo getCountListPayment(SettlementReq settlementReq) {
-        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-        //总
-        settlementReq.setStatus(null);
-        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        //待结算
-        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        //部分结算
-        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        //全部结算
-        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        return settlementLogisticsStatusCountVos;
+        settlementReq.setUnitType(LogisticsUnitType.CARRIER);
+        return getCountList(settlementReq);
     }
 
     /**
@@ -114,47 +64,21 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:21
      */
     public PageMoreRes<SettlementLogisticsDto> pageSelectCollection(SettlementReq settlementReq) {
-        CommonValidator.isValidCoexisting(settlementReq.getStartCreateTime(), settlementReq.getEndCreateTime(), "");
-        CommonValidator.isValidCoexisting(settlementReq.getStartReceiptTime(), settlementReq.getEndReceiptTime(), "预计收款开始和结束时间");
-
-        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
-        List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementLogisticsMapper.pageSelectCollection(settlementReq);
-        SettlementLogisticsSumVo settlementLogisticsSum = settlementLogisticsMapper.selectCollectionSum(settlementReq);
-
-        // 对查询结果进行处理,转换 status 到 desc
-        return new PageMoreRes<>(getSettlementLogisticsDtoPageRes(kwpLedgerLogisticsList), settlementLogisticsSum);
+        settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
+        return pageSelect(settlementReq);
     }
 
-
     /**
      * 运费付款-物流订单列表
      *
      * @author Aick Spt
      * @date 2023-07-24 16:23
      */
-    public PageRes<SettlementLogisticsDto> pageSelectPayment(SettlementReq settlementReq) {
-        CommonValidator.isValidCoexisting(settlementReq.getStartCreateTime(), settlementReq.getEndCreateTime(), "");
-        CommonValidator.isValidCoexisting(settlementReq.getStartReceiptTime(), settlementReq.getEndReceiptTime(), "预计付款开始和结束时间");
-
-        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
-        List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementLogisticsMapper.pageSelectPayment(settlementReq);
-
-        // 对查询结果进行处理,转换 status 到 desc
-        return new PageRes<>(getSettlementLogisticsDtoPageRes(kwpLedgerLogisticsList));
-    }
-
-    @NotNull
-    private PageInfo<SettlementLogisticsDto> getSettlementLogisticsDtoPageRes(List<SettlementLogisticsDto> kwpLedgerLogisticsList) {
-        for (SettlementLogisticsDto entity : kwpLedgerLogisticsList) {
-            entity.setStatusText(SettlementEnum.getStatusDesc(entity.getStatus()));
-            entity.setResiduePrice(entity.getLedgerSettlePrice().subtract(entity.getActualPrice()));
-            entity.setCreateByText("创建人名称");
-            entity.setUpdateByText("更新人名称");
-        }
-        return new PageInfo<>(kwpLedgerLogisticsList);
+    public PageMoreRes<SettlementLogisticsDto> pageSelectPayment(SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.CARRIER);
+        return pageSelect(settlementReq);
     }
 
-
     /**
      * 运费收款-物流订单详情
      *
@@ -162,11 +86,7 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:22
      */
     public SettlementLogisticsDto detailCollection(Long id) {
-        SettlementLogisticsDto settlementLogisticsDto = settlementLogisticsMapper.detailCollection(id);
-        if (settlementLogisticsDto == null) {
-            throw new BusinessException("查无数据");
-        }
-        return settlementLogisticsDto;
+        return detail(id, LogisticsUnitType.SHIPPER);
     }
 
     /**
@@ -176,27 +96,89 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:24
      */
     public SettlementLogisticsDto detailPayment(Long id) {
-        SettlementLogisticsDto settlementLogisticsDto = settlementLogisticsMapper.detailPayment(id);
-        if (settlementLogisticsDto == null) {
-            throw new BusinessException("查无数据");
-        }
-        return settlementLogisticsDto;
+        return detail(id, LogisticsUnitType.CARRIER);
     }
 
-
     /**
-     * 根据id查物流结算订单
+     * 根据条件查物流结算订单-导出
      *
-     * @param ids 物流结算订单集合List<Long>
      * @author Aick Spt
      * @date 2023-07-21 16:16
      */
-    public List<SettlementLogisticsDto> selectList(List<Long> ids) {
-        return settlementLogisticsMapper.selectIds(ids);
+    public List<SettlementLogisticsDto> selectList(SettlementReq settlementReq) {
+        return settlementLogisticsMapper.selectLogisticsList(settlementReq, settlementReq.getIdList());
     }
 
-    public List<SettlementLogisticsDto> selectList(Integer unitType) {
-        return settlementLogisticsMapper.selectList(unitType);
+
+    private PageMoreRes<SettlementLogisticsDto> pageSelect(SettlementReq settlementReq) {
+        CommonValidator.isValidCoexisting(settlementReq.getStartCreateTime(), settlementReq.getEndCreateTime(), "");
+        CommonValidator.isValidCoexisting(settlementReq.getStartReceiptTime(), settlementReq.getEndReceiptTime(), "预计付款开始和结束时间");
+
+        //加上当前登录者顶级企业id用于过滤数据
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+
+        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
+        List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementLogisticsMapper.pageSelect(settlementReq);
+        SettlementLogisticsSumVo settlementLogisticsSum = settlementLogisticsMapper.selectSum(settlementReq);
+
+        // 对查询结果进行处理,转换 status 到 desc
+        return new PageMoreRes<>(getSettlementLogisticsDtoPageRes(kwpLedgerLogisticsList), settlementLogisticsSum);
+    }
+
+    private PageInfo<SettlementLogisticsDto> getSettlementLogisticsDtoPageRes(List<SettlementLogisticsDto> kwpLedgerLogisticsList) {
+        for (SettlementLogisticsDto entity : kwpLedgerLogisticsList) {
+            setDetailDesc(entity);
+        }
+        return new PageInfo<>(kwpLedgerLogisticsList);
+    }
+
+    public SettlementLogisticsStatusCountVo getCountList(SettlementReq settlementReq) {
+        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
+
+        //加上当前登录者顶级企业id用于过滤数据
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+
+        //总
+        settlementReq.setStatus(null);
+        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountList(settlementReq));
+
+        //待结算
+        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
+        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
+
+        //部分结算
+        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
+        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
+
+        //全部结算
+        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
+        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
+
+        return settlementLogisticsStatusCountVos;
+    }
+
+    private SettlementLogisticsDto detail(Long id, Integer unitType) {
+        SettlementLogisticsDto settlementLogisticsDto = settlementLogisticsMapper.detail(id, unitType);
+        if (settlementLogisticsDto == null) {
+            throw new BusinessException("查无数据");
+        }
+        setDetailDesc(settlementLogisticsDto);
+        return settlementLogisticsDto;
+    }
+
+    private void setDetailDesc(SettlementLogisticsDto settlementLogisticsDto) {
+        settlementLogisticsDto.setStatusText(SettlementEnum.getStatusDesc(settlementLogisticsDto.getStatus()));
+        if (settlementLogisticsDto.getLedgerSettlePrice() != null) {
+            if (settlementLogisticsDto.getActualPrice() != null) {
+                settlementLogisticsDto.setResiduePrice(settlementLogisticsDto.getLedgerSettlePrice().subtract(settlementLogisticsDto.getActualPrice()));
+            } else {
+                settlementLogisticsDto.setResiduePrice(settlementLogisticsDto.getLedgerSettlePrice());
+            }
+        } else {
+            settlementLogisticsDto.setResiduePrice(new BigDecimal(0));
+        }
+        settlementLogisticsDto.setCreateByText("创建人名称");//"创建人名称"
+        settlementLogisticsDto.setUpdateByText("更新人名称");//"更新人名称"
     }
 
 }

+ 29 - 10
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java

@@ -6,9 +6,12 @@ import com.sckw.core.exception.BusinessException;
 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.payment.dao.KwpSettlementLogisticsMapper;
+import com.sckw.payment.dao.KwpSettlementLogisticsTrackMapper;
 import com.sckw.payment.dao.KwpSettlementOfflineMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.KwpSettlementLogisticsTrack;
 import com.sckw.payment.model.KwpSettlementOffline;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
@@ -43,6 +46,8 @@ public class KwpSettlementOfflineService {
 
     private final KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
 
+    private final KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
+
     /**
      * 物流-线下付款(运费收款)记录-列表
      *
@@ -127,19 +132,33 @@ public class KwpSettlementOfflineService {
             throw new BusinessException("参数错误:输入金额过大 " + price + " 剩余金额最大值:" + remainingReceivables);
         }
         //累加入库结算单
-        KwpSettlementLogistics settlementLogistics1 = new KwpSettlementLogistics();
-        settlementLogistics1.setId(settlementLogisticsDto.getId());
-        settlementLogistics1.setUpdateTime(LocalDateTime.now());
+        KwpSettlementLogistics settlementLogistics = new KwpSettlementLogistics();
+        settlementLogistics.setId(settlementLogisticsDto.getId());
+        settlementLogistics.setUpdateTime(LocalDateTime.now());
         if (remainingReceivables.compareTo(price) == 0) {//全部结算
-            settlementLogistics1.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
+            settlementLogistics.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
         }
         if (remainingReceivables.compareTo(price) > 0) {//部分结算
-            settlementLogistics1.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
+            settlementLogistics.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
         }
         BigDecimal actualPrice = settlementLogisticsDto.getActualPrice();
-        settlementLogistics1.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
-        int upInt = kwpSettlementLogisticsMapper.updateById(settlementLogistics1);
+        settlementLogistics.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
+        int upInt = kwpSettlementLogisticsMapper.updateById(settlementLogistics);
         if (upInt > 0) {
+            //新增一条修改记录
+            String remark = LoginUserHolder.getUserName() + "[" + LoginUserHolder.getUserId() + "]" + "结算[" + settlementLogistics.getId() + "]" + settlementLogistics.getActualPrice() + "(" + SettlementEnum.getStatusDesc(settlementLogistics.getStatus()) + ")";
+            KwpSettlementLogisticsTrack kwpSettlementLogisticsTrack = new KwpSettlementLogisticsTrack();
+            kwpSettlementLogisticsTrack.setId(new IdWorker(1).nextId());
+            kwpSettlementLogisticsTrack.setLSettlementId(settlementLogistics.getId());
+            kwpSettlementLogisticsTrack.setRemark(remark);
+            kwpSettlementLogisticsTrack.setStatus(settlementLogistics.getStatus());
+            kwpSettlementLogisticsTrack.setCreateBy(LoginUserHolder.getUserId());
+            kwpSettlementLogisticsTrack.setCreateTime(LocalDateTime.now());
+            kwpSettlementLogisticsTrack.setUpdateBy(LoginUserHolder.getUserId());
+            kwpSettlementLogisticsTrack.setUpdateTime(LocalDateTime.now());
+            kwpSettlementLogisticsTrack.setDelFlag(0);
+            kwpSettlementLogisticsTrackMapper.insert(kwpSettlementLogisticsTrack);
+
             //新增一条线下结算记录
             //当前剩余金额
             remainingReceivables = remainingReceivables.subtract(price);
@@ -153,11 +172,11 @@ public class KwpSettlementOfflineService {
             kwpSettlementOffline.setPayPrice(price);
             kwpSettlementOffline.setTopayPrice(remainingReceivables);
             kwpSettlementOffline.setUrl(url);
-            kwpSettlementOffline.setRemark("");
+            kwpSettlementOffline.setRemark(remark);
             kwpSettlementOffline.setStatus(1);
-            kwpSettlementOffline.setCreateBy(1L);//todo 待处理明确创建人
+            kwpSettlementOffline.setCreateBy(LoginUserHolder.getUserId());
             kwpSettlementOffline.setCreateTime(LocalDateTime.now());
-            kwpSettlementOffline.setUpdateBy(1L);//todo 待处理明确更新人
+            kwpSettlementOffline.setUpdateBy(LoginUserHolder.getUserId());
             kwpSettlementOffline.setUpdateTime(LocalDateTime.now());
             kwpSettlementOffline.setDelFlag(0);
             return settlementOfflineMapper.insert(kwpSettlementOffline);

+ 28 - 9
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java

@@ -5,10 +5,13 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
+import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
+import com.sckw.payment.dao.KwpSettlementLogisticsTrackMapper;
 import com.sckw.payment.dao.KwpSettlementTradeMapper;
 import com.sckw.payment.dao.KwpSettlementWalletMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.KwpSettlementLogisticsTrack;
 import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.KwpSettlementWallet;
 import com.sckw.payment.model.constant.SettlementEnum;
@@ -52,6 +55,8 @@ public class KwpSettlementWalletService {
 
     private final KwpSettlementTradeMapper kwpSettlementTradeMapper;
 
+    private final KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
+
     /**
      * 物流-电子钱包付款(货到付款)结算记录-列表
      *
@@ -134,19 +139,33 @@ public class KwpSettlementWalletService {
             throw new BusinessException("参数错误:输入金额过大 " + price + " 剩余金额最大值:" + remainingReceivables);
         }
         //累加入库结算单
-        KwpSettlementLogistics settlementLogistics1 = new KwpSettlementLogistics();
-        settlementLogistics1.setId(settlementLogisticsDto.getId());
-        settlementLogistics1.setUpdateTime(LocalDateTime.now());
+        KwpSettlementLogistics settlementLogistics = new KwpSettlementLogistics();
+        settlementLogistics.setId(settlementLogisticsDto.getId());
+        settlementLogistics.setUpdateTime(LocalDateTime.now());
         if (remainingReceivables.compareTo(price) == 0) {//全部结算
-            settlementLogistics1.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
+            settlementLogistics.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
         }
         if (remainingReceivables.compareTo(price) > 0) {//部分结算
-            settlementLogistics1.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
+            settlementLogistics.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
         }
         BigDecimal actualPrice = settlementLogisticsDto.getActualPrice();
-        settlementLogistics1.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
-        int upInt = kwpSettlementLogisticsMapper.updateById(settlementLogistics1);
+        settlementLogistics.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
+        int upInt = kwpSettlementLogisticsMapper.updateById(settlementLogistics);
         if (upInt > 0) {
+            //新增一条修改记录
+            String remark = LoginUserHolder.getUserName() + "[" + LoginUserHolder.getUserId() + "]" + "结算[" + settlementLogistics.getId() + "]" + settlementLogistics.getActualPrice() + "(" + SettlementEnum.getStatusDesc(settlementLogistics.getStatus()) + ")";
+            KwpSettlementLogisticsTrack kwpSettlementLogisticsTrack = new KwpSettlementLogisticsTrack();
+            kwpSettlementLogisticsTrack.setId(new IdWorker(1).nextId());
+            kwpSettlementLogisticsTrack.setLSettlementId(settlementLogistics.getId());
+            kwpSettlementLogisticsTrack.setRemark(remark);
+            kwpSettlementLogisticsTrack.setStatus(settlementLogistics.getStatus());
+            kwpSettlementLogisticsTrack.setCreateBy(LoginUserHolder.getUserId());
+            kwpSettlementLogisticsTrack.setCreateTime(LocalDateTime.now());
+            kwpSettlementLogisticsTrack.setUpdateBy(LoginUserHolder.getUserId());
+            kwpSettlementLogisticsTrack.setUpdateTime(LocalDateTime.now());
+            kwpSettlementLogisticsTrack.setDelFlag(0);
+            kwpSettlementLogisticsTrackMapper.insert(kwpSettlementLogisticsTrack);
+
             //新增一条电子钱包结算记录
             remainingReceivables = remainingReceivables.subtract(price);
             KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
@@ -161,9 +180,9 @@ public class KwpSettlementWalletService {
             kwpSettlementWallet.setType(SettlementPayTypeEnum.CASH_ON_DELIVERY.getStatus());
             kwpSettlementWallet.setRemark("");
             kwpSettlementWallet.setStatus(1);
-            kwpSettlementWallet.setCreateBy(1L);//todo 待处理明确创建人
+            kwpSettlementWallet.setCreateBy(LoginUserHolder.getUserId());
             kwpSettlementWallet.setCreateTime(LocalDateTime.now());
-            kwpSettlementWallet.setUpdateBy(1L);//todo 待处理明确更新人
+            kwpSettlementWallet.setUpdateBy(LoginUserHolder.getUserId());
             kwpSettlementWallet.setUpdateTime(LocalDateTime.now());
             kwpSettlementWallet.setDelFlag(0);
             Integer insertKwpSettlementWallet = settlementWalletMapper.insert(kwpSettlementWallet);

+ 44 - 102
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -69,22 +69,13 @@
         s.del_flag      as delFlag
     </sql>
 
-
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        <!--@mbg.generated-->
-        select
-        <include refid="Base_Column_List"/>
-        from kwp_settlement_logistics
-        where id = #{id,jdbcType=BIGINT}
-    </select>
-
     <!--  连表筛选准备  -->
     <sql id="settlementLogisticsSelect">
-        select l.name       as ledgerName,
+        select l.name         as ledgerName,
                l.l_ledger_no  as lLedgerNo,
                l.trading      as ledgerTrading,
                l.settle_price as ledgerSettlePrice,
-                l.url          as attachmentUrl,
+               l.url          as attachmentUrl,
 
                lu.unit_type   as unitType,
                lu.firm_name   as CustomerName,
@@ -96,9 +87,9 @@
     </sql>
     <!--  连表筛选准备  -->
     <sql id="settlementLogisticsSelectSum">
-        select count(l.id)                                    total,
-               sum(l.settle_price)                         as actualReceivable,
-               sum(s.actual_price)                         as currentReceipt
+        select count(l.id)            total,
+               sum(l.settle_price) as actualReceivable,
+               sum(s.actual_price) as currentReceipt
         from kwp_settlement_logistics s
                  left join kwp_ledger_logistics l on s.l_ledger_id = l.id
                  left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
@@ -110,6 +101,14 @@
             and s.status = #{settlementReq.status}
         </if>
 
+        <if test="settlementReq.unitType != null">
+            and lu.unit_type = #{settlementReq.unitType}
+        </if>
+
+        <if test="settlementReq.entId != null">
+            and lu.top_ent_id = #{settlementReq.entId}
+        </if>
+
         <if test="settlementReq.startCreateTime != null and settlementReq.endCreateTime != null">
             and s.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
         </if>
@@ -118,20 +117,20 @@
         </if>
 
         <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
-            and ( l.l_ledger_no like concat('%'
-                 , #{settlementReq.keywords}
-                 , '%')
-                )
+            and l.name like concat('%'
+            , #{settlementReq.keywords}
+            , '%')
+                and lu.firm_name like concat('%'
+            , #{settlementReq.keywords}
+            , '%')
         </if>
     </sql>
 
-
-    <!-- 结算运费收款(承运方)-物流订单列表  -->
-    <select id="pageSelectCollection" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
+    <!-- 结算运费-物流订单列表  -->
+    <select id="pageSelect" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
         <include refid="settlementLogisticsSelect"/>
         <where>
-            lu.unit_type = 1
-              and l.del_flag = 0
+            l.del_flag = 0
               and s.del_flag = 0
               and lu.del_flag = 0
             <include refid="settlementLogisticsSelectWhere"/>
@@ -139,13 +138,12 @@
         order by s.update_time desc
     </select>
 
-    <!--  结算运费收款(承运方)-物流订单列表合计  -->
-    <select id="selectCollectionSum" resultType="com.sckw.payment.model.vo.res.SettlementLogisticsSumVo">
+    <!--  结算运费-物流订单列表合计  -->
+    <select id="selectSum" resultType="com.sckw.payment.model.vo.res.SettlementLogisticsSumVo">
         select a.*, (a.actualReceivable - a.currentReceipt) AS remainingReceivables From (
         <include refid="settlementLogisticsSelectSum"/>
         <where>
-            lu.unit_type = 1
-              and l.del_flag = 0
+            l.del_flag = 0
               and s.del_flag = 0
               and lu.del_flag = 0
             <include refid="settlementLogisticsSelectWhere"/>
@@ -153,71 +151,23 @@
         ) a
     </select>
 
-    <!-- 结算运费收款(承运方)-物流订单列表头部汇总数  -->
-    <select id="getCountListCollection" resultType="java.lang.Long">
-        select count(s.id) as num
-        from kwp_settlement_logistics s
-                 left join kwp_ledger_logistics l on s.l_ledger_id = l.id
-                 left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
-        <where>
-            lu.unit_type = 1
-              and l.del_flag = 0
-              and s.del_flag = 0
-              and lu.del_flag = 0
-            <include refid="settlementLogisticsSelectWhere"/>
-        </where>
-    </select>
-
-    <!--  根据结算(承运方)物流订单id查详情   -->
-    <select id="detailCollection" parameterType="java.lang.Long" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
-        select l.name         as ledgerName,
-               l.l_ledger_no  as lLedgerNo,
-               l.trading      as ledgerTrading,
-               l.settle_price as ledgerSettlePrice,
-        l.url          as attachmentUrl,
-
-               lu.unit_type   as unitType,
-               lu.firm_name   as CustomerName,
-        <include refid="Join_Column_List"/>
-        from kwp_settlement_logistics s
-                 left join kwp_ledger_logistics l on s.l_ledger_id = l.id
-                 left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
-        where s.id = #{id,jdbcType=BIGINT}
-          and lu.unit_type = 1
-    </select>
-
-
-
-    <!-- 结算运费付款(托运方)-物流订单列表  -->
-    <select id="pageSelectPayment" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
-        <include refid="settlementLogisticsSelect"/>
-        <where>
-            lu.unit_type = 2
-              and l.del_flag = 0
-              and s.del_flag = 0
-              and lu.del_flag = 0
-            <include refid="settlementLogisticsSelectWhere"/>
-        </where>
-        order by s.update_time desc
-    </select>
-
-    <!-- 结算运费付款(托运方)-物流订单列表头部汇总数  -->
-    <select id="getCountListPayment" resultType="java.lang.Long">
+    <!-- 结算运费-物流订单列表头部汇总数  -->
+    <select id="getCountList" resultType="java.lang.Long">
         select count(s.id) as num
         from kwp_settlement_logistics s
                  left join kwp_ledger_logistics l on s.l_ledger_id = l.id
                  left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
         <where>
-            lu.unit_type = 2
-              and l.del_flag = 0
+            l.del_flag = 0
               and s.del_flag = 0
               and lu.del_flag = 0
             <include refid="settlementLogisticsSelectWhere"/>
         </where>
     </select>
 
-    <!-- 根据结算(托运方)物流订单id查详情   -->
-    <select id="detailPayment" parameterType="java.lang.Long" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
+    <!-- 根据结算物流订单id查详情   -->
+    <select id="detail" parameterType="java.lang.Long"
+            resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
         select l.name         as ledgerName,
                l.l_ledger_no  as lLedgerNo,
                l.trading      as ledgerTrading,
@@ -231,33 +181,25 @@
                  left join kwp_ledger_logistics l on s.l_ledger_id = l.id
                  left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
         where s.id = #{id,jdbcType=BIGINT}
-          and lu.unit_type = 2
-    </select>
-
-
-    <!--  根据多个结算运费收款(线下收款)物流订单id查订单,用于导出   -->
-    <select id="selectIds" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
-        <include refid="settlementLogisticsSelect"/>
-        <where>
-            lu.unit_type = 2
-            and l.del_flag = 0
-            and s.del_flag = 0
-            and lu.del_flag = 0
-              and s.id in
-            <foreach collection="ids" item="id" close=")" open="(" separator=",">
-                #{id,jdbcType=BIGINT}
-            </foreach>
-        </where>
-        order by s.update_time desc
+        <if test="unitType != null">
+            and lu.unit_type = #{unitType}
+        </if>
     </select>
 
-    <select id="selectList" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
+    <!--  根据多个结算运费物流订单id查订单,用于导出   -->
+    <select id="selectLogisticsList" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
         <include refid="settlementLogisticsSelect"/>
         <where>
-            lu.unit_type = #{unitType,jdbcType=INTEGER}
-              and l.del_flag = 0
+            l.del_flag = 0
               and s.del_flag = 0
               and lu.del_flag = 0
+            <include refid="settlementLogisticsSelectWhere"/>
+            <if test="ids != null and ids.size() > 0">
+                and s.id in
+                <foreach collection="ids" item="id" close=")" open="(" separator=",">
+                    #{id,jdbcType=BIGINT}
+                </foreach>
+            </if>
         </where>
         order by s.update_time desc
     </select>