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

Merge branch 'dev_spt' into dev

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

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

@@ -53,6 +53,20 @@ public class KwpSettlementWalletController {
     }
     }
 
 
 
 
+    /**
+     *
+     * 运费-货到付款-查询钱包余额
+     *
+     * @param id 结算单id
+     * @author Aick Spt
+     * @date 2023-08-16 11:15
+     */
+    @GetMapping(name = "运费-货到付款-查询钱包余额", path = "getConfirmLogisticsPay")
+    public HttpResult getConfirmLogisticsPay(@RequestParam("id") @NotBlank(message = "id不能为空") String id) {
+        return HttpResult.ok(kwpSettlementWalletService.getConfirmLogisticsPayment(Long.parseLong(id)));
+    }
+
+
     //  =========  销售收付款  =========
     //  =========  销售收付款  =========
 
 
     /**
     /**

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

@@ -2,6 +2,7 @@ package com.sckw.payment.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsSumVo;
 import com.sckw.payment.model.vo.res.SettlementLogisticsSumVo;
@@ -51,4 +52,6 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
      * @date 2023-07-24 16:24
      * @date 2023-07-24 16:24
      */
      */
     List<SettlementLogisticsDto> selectLogisticsList(@Param("settlementReq") SettlementReq settlementReq, @Param("ids") List<Long> ids);
     List<SettlementLogisticsDto> selectLogisticsList(@Param("settlementReq") SettlementReq settlementReq, @Param("ids") List<Long> ids);
+
+    List<LedgerUnitDto> getListById(@Param("id") Long id);
 }
 }

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

@@ -18,7 +18,7 @@ import java.util.Date;
 @Setter
 @Setter
 @NoArgsConstructor
 @NoArgsConstructor
 @AllArgsConstructor
 @AllArgsConstructor
-public class SettlementLogisticsDto {
+public class SettlementLogisticsDto implements ISettlement  {
     /**
     /**
      * 主键
      * 主键
      */
      */

+ 0 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/OfflinePaymentReq.java

@@ -38,10 +38,6 @@ public class OfflinePaymentReq extends BasePara {
     private BigDecimal price;
     private BigDecimal price;
 
 
 
 
-    /**
-     * 附件地址
-     */
-    @NotBlank(message = "相关附件不能为空")
     private String url;
     private String url;
 
 
 
 

+ 12 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -12,6 +12,7 @@ import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.constant.TradingEnum;
 import com.sckw.payment.model.constant.TradingEnum;
+import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
 import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
@@ -238,7 +239,7 @@ public class KwpSettlementLogisticsService {
      * @author Aick Spt
      * @author Aick Spt
      * @date 2023-08-07 10:14
      * @date 2023-08-07 10:14
      */
      */
-    private SettlementLogisticsDto detail(Long id, Integer unitType, Integer unitTypeTwo) {
+    public SettlementLogisticsDto detail(Long id, Integer unitType, Integer unitTypeTwo) {
         SettlementLogisticsDto settlementLogisticsDto = settlementLogisticsMapper.detail(id, unitType, unitTypeTwo);
         SettlementLogisticsDto settlementLogisticsDto = settlementLogisticsMapper.detail(id, unitType, unitTypeTwo);
         if (settlementLogisticsDto == null) {
         if (settlementLogisticsDto == null) {
             throw new BusinessException("查无数据");
             throw new BusinessException("查无数据");
@@ -247,6 +248,16 @@ public class KwpSettlementLogisticsService {
         return settlementLogisticsDto;
         return settlementLogisticsDto;
     }
     }
 
 
+    /**
+     * 根据id查询结算单关联的企业信息
+     *
+     * @param id 结算单id
+     * @return
+     */
+    public List<LedgerUnitDto> getListById(Long id) {
+        return settlementLogisticsMapper.getListById(id);
+    }
+
 
 
     private String changeDict(String trading) {
     private String changeDict(String trading) {
         //字典等数据转换
         //字典等数据转换

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

@@ -20,10 +20,7 @@ import com.sckw.payment.dao.KwpSettlementLogisticsTrackMapper;
 import com.sckw.payment.dao.KwpSettlementWalletMapper;
 import com.sckw.payment.dao.KwpSettlementWalletMapper;
 import com.sckw.payment.model.*;
 import com.sckw.payment.model.*;
 import com.sckw.payment.model.constant.*;
 import com.sckw.payment.model.constant.*;
-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.dto.*;
 import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
 import com.sckw.payment.model.vo.req.WalletPayReq;
 import com.sckw.payment.model.vo.req.WalletPayReq;
@@ -516,6 +513,22 @@ public class KwpSettlementWalletService {
 
 
     }
     }
 
 
+    public BigDecimal getConfirmLogisticsPayment(Long id) {
+        SettlementLogisticsDto byId = kwpSettlementLogisticsService.detail(id, LogisticsUnitType.CARRIER, LogisticsUnitType.SHIPPER);
+        if (Objects.isNull(byId)) {
+            throw new BusinessException("结算单不存在");
+        }
+        if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.RECEIVE_PAY.getValue())) {
+            throw new BusinessException("只支持货货到付款方式订单进行当前操作");
+        }
+        List<LedgerUnitDto> listById = kwpSettlementLogisticsService.getListById(id);
+        if (CollectionUtils.isEmpty(listById) || listById.size() != NumberConstant.TWO) {
+            throw new BusinessException("对账单交易企业双方不存在或缺少");
+        }
+        return getWalletBalance(listById, byId.getTrading());
+    }
+
+
     /**
     /**
      * 货到付款-查询钱包余额
      * 货到付款-查询钱包余额
      *
      *
@@ -534,6 +547,35 @@ public class KwpSettlementWalletService {
         if (CollectionUtils.isEmpty(listById) || listById.size() != NumberConstant.TWO) {
         if (CollectionUtils.isEmpty(listById) || listById.size() != NumberConstant.TWO) {
             throw new BusinessException("对账单交易企业双方不存在或缺少");
             throw new BusinessException("对账单交易企业双方不存在或缺少");
         }
         }
+        return getWalletBalance(listById, byId.getTrading());
+
+
+//        Long uid = null;
+//        Long filter = null;
+//        for (LedgerUnitDto ledgerUnitDto : listById) {
+//            Integer unitType = ledgerUnitDto.getUnitType();
+//            if (TradeUnitType.PURCHASE.equals(unitType)) {
+//                uid = ledgerUnitDto.getTopEntId();
+//                continue;
+//            }
+//            if (TradeUnitType.SELL.equals(unitType)) {
+//                filter = ledgerUnitDto.getTopEntId();
+//            }
+//        }
+//        String relation = walletRelationService.getRelation(uid);
+//        String filterUser = walletRelationService.getRelation(filter);
+//        if (StringUtils.isBlank(relation) || StringUtils.isBlank(filterUser)) {
+//            throw new BusinessException("顶级企业未开通电子钱包");
+//        }
+//        R<List<WalletDto>> wallet = payCenterService.wallet(relation, ChannelEnum.getByCode(byId.getTrading()), filterUser);
+//        if (CollectionUtils.isEmpty(wallet.getData())) {
+//            throw new BusinessException("暂未开通电子钱包");
+//        }
+//        List<WalletDto> data = wallet.getData();
+//        return BigDecimal.valueOf(data.get(NumberConstant.ZERO).getMoney() / 100.0);
+    }
+
+    private BigDecimal getWalletBalance(List<LedgerUnitDto> listById, String trading) {
         Long uid = null;
         Long uid = null;
         Long filter = null;
         Long filter = null;
         for (LedgerUnitDto ledgerUnitDto : listById) {
         for (LedgerUnitDto ledgerUnitDto : listById) {
@@ -551,12 +593,14 @@ public class KwpSettlementWalletService {
         if (StringUtils.isBlank(relation) || StringUtils.isBlank(filterUser)) {
         if (StringUtils.isBlank(relation) || StringUtils.isBlank(filterUser)) {
             throw new BusinessException("顶级企业未开通电子钱包");
             throw new BusinessException("顶级企业未开通电子钱包");
         }
         }
-        R<List<WalletDto>> wallet = payCenterService.wallet(relation, ChannelEnum.getByCode(byId.getTrading()), filterUser);
+        R<List<WalletDto>> wallet = payCenterService.wallet(relation, ChannelEnum.getByCode(trading), filterUser);
         if (CollectionUtils.isEmpty(wallet.getData())) {
         if (CollectionUtils.isEmpty(wallet.getData())) {
             throw new BusinessException("暂未开通电子钱包");
             throw new BusinessException("暂未开通电子钱包");
         }
         }
         List<WalletDto> data = wallet.getData();
         List<WalletDto> data = wallet.getData();
         return BigDecimal.valueOf(data.get(NumberConstant.ZERO).getMoney() / 100.0);
         return BigDecimal.valueOf(data.get(NumberConstant.ZERO).getMoney() / 100.0);
     }
     }
+
+
 }
 }
 
 

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

@@ -217,4 +217,19 @@
         </where>
         </where>
         order by s.update_time desc
         order by s.update_time desc
     </select>
     </select>
+
+    <select id="getListById" resultType="com.sckw.payment.model.dto.LedgerUnitDto">
+        select kltu.top_ent_id,
+        kltu.ent_id,
+        kltu.unit_type
+        from kwp_settlement_logistics kst
+        inner join kwp_ledger_logistics klt on kst.l_ledger_id = klt.id and klt.del_flag = 0
+        inner join kwp_ledger_logistics_unit kltu on klt.id = kltu.l_ledger_id and kltu.del_flag = 0
+        <where>
+            kst.del_flag = 0
+            and kst.id = #{id,jdbcType=BIGINT}
+        </where>
+    </select>
+
+
 </mapper>
 </mapper>