Explorar o código

dubbo接口,新增销售订单下单时冻结电子钱包金额接口

xucaiqin %!s(int64=2) %!d(string=hai) anos
pai
achega
ac6e30ae66

+ 15 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java

@@ -1,13 +1,28 @@
 package com.sckw.payment.api.dubbo;
 package com.sckw.payment.api.dubbo;
 
 
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.dto.LedgerCount;
 import com.sckw.payment.api.model.dto.LedgerCount;
 import com.sckw.payment.api.model.dto.SettlementMoney;
 import com.sckw.payment.api.model.dto.SettlementMoney;
 
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 public interface PaymentDubboService {
 public interface PaymentDubboService {
+    /**
+     * 销售订单下单时,冻结资金
+     *
+     * @param payEntId     支付方企业
+     * @param channel      渠道
+     * @param receiveEntId 收款企业id
+     * @param money        订单金额
+     * @param tOrderId     贸易订单id
+     * @return
+     */
+    HttpResult freezeMoney(Long payEntId, ChannelEnum channel, Long receiveEntId, BigDecimal money, Long tOrderId);
+
     /**
     /**
      * 确认企业关联的对账单是否存在关联业务
      * 确认企业关联的对账单是否存在关联业务
      *
      *

+ 35 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java

@@ -1,7 +1,10 @@
 package com.sckw.payment.service.dubbo;
 package com.sckw.payment.service.dubbo;
 
 
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.utils.OrderUtils;
+import com.sckw.core.web.response.HttpResult;
 import com.sckw.payment.api.dubbo.PaymentDubboService;
 import com.sckw.payment.api.dubbo.PaymentDubboService;
+import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.dto.LedgerCount;
 import com.sckw.payment.api.model.dto.LedgerCount;
 import com.sckw.payment.api.model.dto.SettlementMoney;
 import com.sckw.payment.api.model.dto.SettlementMoney;
@@ -9,10 +12,7 @@ import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.dto.LedgerSize;
 import com.sckw.payment.model.dto.LedgerSize;
 import com.sckw.payment.model.dto.MoneyType;
 import com.sckw.payment.model.dto.MoneyType;
-import com.sckw.payment.service.KwpLedgerLogisticsService;
-import com.sckw.payment.service.KwpLedgerTradeService;
-import com.sckw.payment.service.KwpSettlementLogisticsService;
-import com.sckw.payment.service.KwpSettlementTradeService;
+import com.sckw.payment.service.*;
 import com.sckw.payment.utils.DateTimeUtil;
 import com.sckw.payment.utils.DateTimeUtil;
 import com.sckw.payment.utils.DecimalUtils;
 import com.sckw.payment.utils.DecimalUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
@@ -38,6 +38,8 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
     private final KwpLedgerTradeService kwpLedgerTradeService;
     private final KwpLedgerTradeService kwpLedgerTradeService;
     private final KwpSettlementLogisticsService kwpSettlementLogisticsService;
     private final KwpSettlementLogisticsService kwpSettlementLogisticsService;
     private final KwpSettlementTradeService kwpSettlementTradeService;
     private final KwpSettlementTradeService kwpSettlementTradeService;
+    private final WalletService walletService;
+    private final KwpTradeFreezeService kwpTradeFreezeService;
 
 
 
 
     private SettlementMoney change(List<MoneyType> moneyType) {
     private SettlementMoney change(List<MoneyType> moneyType) {
@@ -56,6 +58,35 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
         return new SettlementMoney(df.format(curMoney), df.format(preMoney), percent, flag);
         return new SettlementMoney(df.format(curMoney), df.format(preMoney), percent, flag);
     }
     }
 
 
+    @Override
+    public HttpResult freezeMoney(Long payEntId, ChannelEnum channel, Long receiveEntId, BigDecimal money, Long tOrderId) {
+        if (Objects.isNull(payEntId)) {
+            return HttpResult.error("支付企业不能为空");
+        }
+        if (Objects.isNull(channel)) {
+            return HttpResult.error("支付企业不能为空");
+        }
+        if (Objects.isNull(receiveEntId)) {
+            return HttpResult.error("收款企业不能为空");
+        }
+        if (Objects.isNull(money)) {
+            return HttpResult.error("订单金额不能为空");
+        }
+        long m;
+        try {
+            m = money.multiply(new BigDecimal("100")).longValueExact();
+        } catch (Exception e) {
+            log.error("金额转换异常:{}", e.getMessage(), e);
+            return HttpResult.error("金额异常");
+        }
+        //settlementTradeFreeze冻结订单编号规则
+        String orderNo = OrderUtils.generateOrderNo("STF");
+        HttpResult httpResult = walletService.freezeMoney(payEntId, channel, receiveEntId, m, orderNo);
+        //记录订单流水号
+        kwpTradeFreezeService.save(tOrderId, orderNo);
+        return httpResult;
+    }
+
     @Override
     @Override
     public Map<OrderEnum, List<String>> checkLedger(Long entId, Long entTarget) {
     public Map<OrderEnum, List<String>> checkLedger(Long entId, Long entTarget) {
         if (Objects.isNull(entId) || Objects.isNull(entTarget)) {
         if (Objects.isNull(entId) || Objects.isNull(entTarget)) {