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

确认企业关联的结算单是否存在关联业务 接口调整

xucaiqin 2 лет назад
Родитель
Сommit
28ef1cdc01
16 измененных файлов с 146 добавлено и 92 удалено
  1. 6 4
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java
  2. 6 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  3. 8 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  4. 14 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java
  5. 10 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  6. 3 8
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  7. 0 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsUnitService.java
  8. 3 8
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  9. 0 15
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeUnitService.java
  10. 7 16
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  11. 7 18
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  12. 18 10
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  13. 17 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  14. 16 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  15. 15 1
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml
  16. 16 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

+ 6 - 4
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java

@@ -9,17 +9,19 @@ public interface PaymentDubboService {
     /**
      * 确认企业关联的对账单是否存在关联业务
      *
-     * @param entId     企业id
+     * @param entId     企业id 托运方或采购方
+     * @param entTarget 另一方企业id 承运方或销售方
      * @return 关联的订单号
      */
-    Map<OrderEnum,List<String>> checkLedger(Long entId);
+    Map<OrderEnum, List<String>> checkLedger(Long entId, Long entTarget);
 
     /**
      * 确认企业关联的结算单是否存在关联业务
      *
-     * @param entId     企业id
+     * @param entId     企业id 托运方或采购方
+     * @param entTarget 另一方企业id 承运方或销售方
      * @return
      */
-    Map<OrderEnum,List<String>> checkSettlement(Long entId);
+    Map<OrderEnum, List<String>> checkSettlement(Long entId, Long entTarget);
 
 }

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

@@ -68,4 +68,10 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     LedgerCountSumVo countSum(@Param("logisticsReq") LogisticsReq logisticsReq);
 
+    /**
+     * @param entId     托运方企业
+     * @param entTarget 承运方企业
+     * @return
+     */
+    List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
 }

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

@@ -44,4 +44,12 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
     LedgerCountSumVo countSum(@Param("tradeReq") TradeReq tradeReq);
 
     void updatePrice(@Param("id") Long id, @Param("totalPrice") BigDecimal totalPrice);
+
+    /**
+     *
+     * @param entId 采购单位
+     * @param entTarget 销售单位
+     * @return
+     */
+    List<String> selectJoin(@Param("entId")Long entId, @Param("entTarget")Long entTarget);
 }

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

@@ -20,6 +20,7 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
 
     /**
      * 运费付款-物流订单列表
+     *
      * @author Aick Spt
      * @date 2023-07-24 16:23
      */
@@ -27,6 +28,7 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
 
     /**
      * 运费-物流订单各状态列表总数
+     *
      * @author Aick Spt
      * @date 2023-07-24 16:23
      */
@@ -34,6 +36,7 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
 
     /**
      * 运费-物流订单列表查询合计
+     *
      * @author Aick Spt
      * @date 2023-07-28 09:49
      */
@@ -41,6 +44,7 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
 
     /**
      * 运费-物流订单详情
+     *
      * @author Aick Spt
      * @date 2023-07-24 16:24
      */
@@ -48,10 +52,20 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
 
     /**
      * 根据条件查物流结算订单-导出
+     *
      * @author Aick Spt
      * @date 2023-07-24 16:24
      */
     List<SettlementLogisticsDto> selectLogisticsList(@Param("settlementReq") SettlementReq settlementReq, @Param("ids") List<Long> ids);
 
     List<LedgerUnitDto> getListById(@Param("id") Long id);
+
+    /**
+     * 根据双方企业查询
+     *
+     * @param entId     托运方
+     * @param entTarget 承运方
+     * @return
+     */
+    List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
 }

+ 10 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java

@@ -32,4 +32,14 @@ public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade>
     List<LedgerUnitDto> getListById(@Param("id") Long id);
 
     SettlementTradeDto selectDetail(@Param("id") Long id, @Param("unitTYpe") Integer unitType);
+
+    /**
+     * 根据双方企业查询
+     *
+     * @param entId     采购方
+     * @param entTarget 销售方
+     * @return
+     */
+    List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
+
 }

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

@@ -670,14 +670,9 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     /**
      * 合作单位-合作管理 校验订单
      *
-     * @param entId 企业id
+     * @param entId 企业id 托运方
      */
-    public List<String> checkOrder(Long entId) {
-        List<Long> longs = logisticsUnitService.selectByEnt(entId);
-        if (CollectionUtils.isEmpty(longs)) {
-            return new ArrayList<>();
-        }
-        List<KwpLedgerLogistics> kwpLedgerLogistics = logisticsMapper.selectBatchIds(longs);
-        return kwpLedgerLogistics.stream().filter(a->!Objects.equals(a.getStatus(),LedgerEnum.SUCCESS.getStatus())).map(KwpLedgerLogistics::getLLedgerNo).distinct().toList();
+    public List<String> checkOrder(Long entId, Long entTarget) {
+        return logisticsMapper.selectJoin(entId, entTarget);
     }
 }

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

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

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

@@ -753,16 +753,11 @@ public class KwpLedgerTradeService extends AbsLedger {
     /**
      * 根据企业id查询关联的订单
      *
-     * @param entId
+     * @param entId 采购单位
      * @return
      */
-    public List<String> checkOrder(Long entId) {
-        List<Long> longs = tradeUnitService.selectByEnt(entId);
-        if (CollectionUtils.isEmpty(longs)) {
-            return new ArrayList<>();
-        }
-        List<KwpLedgerTrade> kwpLedgerTrades = tradeMapper.selectBatchIds(longs);
-        return kwpLedgerTrades.stream().filter(a -> !Objects.equals(a.getStatus(), LedgerEnum.SUCCESS.getStatus())).map(KwpLedgerTrade::getTLedgerNo).distinct().toList();
+    public List<String> checkOrder(Long entId, Long entTarget) {
+        return tradeMapper.selectJoin(entId,entTarget);
     }
 
     /**

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

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

+ 7 - 16
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -1,13 +1,11 @@
 package com.sckw.payment.service;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.vo.TableTop;
-import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringTimeUtil;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
@@ -32,7 +30,6 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @author Aick Spt
@@ -332,18 +329,12 @@ public class KwpSettlementLogisticsService {
         }
     }
 
-    public List<String> checkOrder(Long entId) {
-        List<Long> longs = logisticsUnitService.selectByEnt(entId);
-        if (CollectionUtils.isEmpty(longs)) {
-            return new ArrayList<>();
-        }
-        List<KwpSettlementLogistics> kwpSettlementLogistics = settlementLogisticsMapper.selectList(new LambdaQueryWrapper<KwpSettlementLogistics>()
-                .in(KwpSettlementLogistics::getLLedgerId, longs).eq(KwpSettlementLogistics::getDelFlag, Global.UN_DELETED));
-        if (CollectionUtils.isEmpty(kwpSettlementLogistics)) {
-            return new ArrayList<>();
-        }
-        return kwpSettlementLogistics.stream()
-                .filter(a -> !Objects.equals(a.getStatus(), SettlementEnum.ALL_PAYMENT.getStatus()))
-                .map(KwpSettlementLogistics::getSlOrderNo).distinct().collect(Collectors.toList());
+    /**
+     * @param entId     企业id 托运方
+     * @param entTarget 另一方企业id 承运方
+     * @return
+     */
+    public List<String> checkOrder(Long entId, Long entTarget) {
+        return settlementLogisticsMapper.selectJoin(entId, entTarget);
     }
 }

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

@@ -1,11 +1,9 @@
 package com.sckw.payment.service;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
-import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.BeanUtils;
@@ -32,7 +30,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.stream.Collectors;
 
 /**
  * 贸易结算
@@ -231,21 +228,13 @@ public class KwpSettlementTradeService {
     public void updateById(KwpSettlementTrade kwpSettlementTrade) {
         settlementTradeMapper.updateById(kwpSettlementTrade);
     }
-
-    public List<String> checkOrder(Long entId) {
-        List<Long> longs = tradeUnitService.selectByEnt(entId);
-        if (CollectionUtils.isEmpty(longs)) {
-            return new ArrayList<>();
-        }
-        List<KwpSettlementTrade> kwpSettlementTrades = settlementTradeMapper.selectList(new LambdaQueryWrapper<KwpSettlementTrade>()
-                .in(KwpSettlementTrade::getTLedgerId, longs)
-                .eq(KwpSettlementTrade::getDelFlag, Global.UN_DELETED));
-        if (CollectionUtils.isEmpty(kwpSettlementTrades)) {
-            return new ArrayList<>();
-        }
-        return kwpSettlementTrades.stream()
-                .filter(a -> !Objects.equals(a.getStatus(), SettlementEnum.ALL_PAYMENT.getStatus()))
-                .map(KwpSettlementTrade::getStOrderNo).distinct().collect(Collectors.toList());
+    /**
+     * @param entId     企业id 采购方
+     * @param entTarget 另一方企业id 销售方
+     * @return
+     */
+    public List<String> checkOrder(Long entId, Long entTarget) {
+        return settlementTradeMapper.selectJoin(entId,entTarget);
     }
 
     /**

+ 18 - 10
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.service.dubbo;
 
+import com.sckw.core.exception.BusinessException;
 import com.sckw.payment.api.dubbo.PaymentDubboService;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.service.KwpLedgerLogisticsService;
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * @author xucaiqin
@@ -30,22 +32,28 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
     private final KwpSettlementTradeService settlementTradeService;
 
     @Override
-    public Map<OrderEnum,List<String>> checkLedger(Long entId) {
-        List<String> logistics = ledgerLogisticsService.checkOrder(entId);
-        List<String> trade = ledgerTradeService.checkOrder(entId);
+    public Map<OrderEnum, List<String>> checkLedger(Long entId, Long entTarget) {
+        if (Objects.isNull(entId) || Objects.isNull(entTarget)) {
+            throw new BusinessException("企业id不能为空");
+        }
+        List<String> logistics = ledgerLogisticsService.checkOrder(entId, entTarget);
+        List<String> trade = ledgerTradeService.checkOrder(entId, entTarget);
         Map<OrderEnum, List<String>> res = new HashMap<>(2);
-        res.put(OrderEnum.LOGISTICS,logistics);
-        res.put(OrderEnum.TRADE,trade);
+        res.put(OrderEnum.LOGISTICS, logistics);
+        res.put(OrderEnum.TRADE, trade);
         return res;
     }
 
     @Override
-    public Map<OrderEnum,List<String>> checkSettlement(Long entId) {
-        List<String> logistics = settlementLogisticsService.checkOrder(entId);
-        List<String> trade = settlementTradeService.checkOrder(entId);
+    public Map<OrderEnum, List<String>> checkSettlement(Long entId, Long entTarget) {
+        if (Objects.isNull(entId) || Objects.isNull(entTarget)) {
+            throw new BusinessException("企业id不能为空");
+        }
+        List<String> logistics = settlementLogisticsService.checkOrder(entId, entTarget);
+        List<String> trade = settlementTradeService.checkOrder(entId, entTarget);
         Map<OrderEnum, List<String>> res = new HashMap<>(2);
-        res.put(OrderEnum.LOGISTICS,logistics);
-        res.put(OrderEnum.TRADE,trade);
+        res.put(OrderEnum.LOGISTICS, logistics);
+        res.put(OrderEnum.TRADE, trade);
         return res;
     }
 }

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

@@ -263,4 +263,21 @@
               and kll.id = #{id}
         </where>
     </select>
+
+    <select id="selectJoin" resultType="java.lang.String">
+        select kll.l_ledger_no
+        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 = 1
+                 inner join kwp_ledger_logistics_unit kllu2
+                            on kll.id = kllu2.l_ledger_id and kllu2.del_flag = 0 and
+                               kllu2.unit_type = 2
+        <where>
+            kll.del_flag = 0
+              and kll.status != 4
+              and kllu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and kllu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
+        </where>
+    </select>
 </mapper>

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

@@ -379,4 +379,20 @@
         set actual_price = IFNULL(actual_price,0) + #{totalPrice,jdbcType=DECIMAL}
         where id = #{id,jdbcType=BIGINT}
     </update>
+
+    <select id="selectJoin" resultType="java.lang.String">
+        SELECT klt.t_ledger_no
+        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 = 1
+                 inner join kwp_ledger_trade_unit kltu2
+                            on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and kltu2.unit_type = 2
+        <where>
+            klt.del_flag = 0
+              and klt.status != 4
+              and kltu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and kltu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
+        </where>
+    </select>
 </mapper>

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

@@ -236,5 +236,19 @@
         </where>
     </select>
 
-
+    <select id="selectJoin" resultType="java.lang.String">
+        select s.sl_order_no
+        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 = 1
+                 inner join kwp_ledger_logistics_unit lu2 on s.l_ledger_id = lu2.l_ledger_id and lu2.del_flag = 0
+            and lu2.unit_type = 2
+        <where>
+            s.del_flag = 0
+              and s.status != 3
+              and lu.top_ent_id = #{entId,jdbcType=BIGINT}
+              and lu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
+        </where>
+    </select>
 </mapper>

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

@@ -298,4 +298,20 @@
               and kst.id = #{id,jdbcType=BIGINT}
         </where>
     </select>
+
+    <select id="selectJoin" resultType="java.lang.String">
+        select kst.st_order_no
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.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 = 1
+                 inner join kwp_ledger_trade_unit kltu2 on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and
+                                                           kltu2.unit_type = 2
+        <where>
+            kst.del_flag = 0
+            and kst.status != 3
+            and kltu.top_ent_id = #{entId,jdbcType=BIGINT}
+            and kltu2.top_ent_id = #{entTarget,jdbcType=BIGINT}
+        </where>
+    </select>
 </mapper>