Przeglądaj źródła

渠道开通情况接口调整

xucaiqin 2 lat temu
rodzic
commit
27ed12b7b0

+ 22 - 44
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -66,6 +66,7 @@ import java.util.stream.Collectors;
 public class WalletService {
     private final PayCenterService payCenterService;
     private final KwpWalletRelationService walletRelationService;
+    private final WalletOrderService walletOrderService;
     private final KwpWalletRefundMapper kwpWalletRefundMapper;
     private final KwpWalletTransferMapper kwpWalletTransferMapper;
     private final RedisLockUtil redisLockUtil;
@@ -159,17 +160,7 @@ public class WalletService {
      */
     private void refundMoney(PrePayWallet prePayWallet, PrePayWalletVo prePayWalletVo, boolean change) {
         DecimalFormat df = new DecimalFormat("0.00");
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        //预收时,切换预收预付的双方人员
-        if (change) {
-            wrapper.eq(KwpWalletRefund::getUid, prePayWallet.getFilter()).eq(KwpWalletRefund::getFilter, prePayWallet.getUid());
-        } else {
-            wrapper.eq(KwpWalletRefund::getUid, prePayWallet.getUid()).eq(KwpWalletRefund::getFilter, prePayWallet.getFilter());
-        }
-        wrapper.eq(KwpWalletRefund::getChannel, prePayWallet.getChannel())
-                .eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus())
-                .orderByDesc(KwpWalletRefund::getCreateTime).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
+        KwpWalletRefund kwpWalletRefund = walletOrderService.query(change, prePayWallet.getUid(), prePayWallet.getFilter(), prePayWallet.getChannel());
         if (Objects.nonNull(kwpWalletRefund)) {
             prePayWalletVo.setRefundApMoney(df.format(kwpWalletRefund.getActualMoney()));
         } else {
@@ -184,9 +175,7 @@ public class WalletService {
      */
     private void refundMoney2(FundVo fundVo) {
         DecimalFormat df = new DecimalFormat("0.00");
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletRefund::getUid, fundVo.getUid()).eq(KwpWalletRefund::getFilter, fundVo.getFilter()).eq(KwpWalletRefund::getChannel, fundVo.getChannel()).eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus()).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
+        KwpWalletRefund kwpWalletRefund = walletOrderService.queryOne(fundVo.getUid(), fundVo.getFilter(), fundVo.getChannel(), RefundEnum.REFUNDING);
         if (Objects.nonNull(kwpWalletRefund)) {
             fundVo.setRefundMoney(df.format(kwpWalletRefund.getActualMoney()));
         } else {
@@ -330,28 +319,26 @@ public class WalletService {
      * @return
      */
     public Object channel() {
-        Long entId = LoginUserHolder.getEntId();
-        String uid = walletRelationService.getRelation(entId);
-        if (StringUtils.isBlank(uid)) {
-            throw new BusinessException("暂未开通电子钱包");
-        }
-        R<WalletOverview> wallet = payCenterService.general(uid);
-        if (wallet.getStatus()) {
-            WalletOverview data = wallet.getData();
-            //已开通的渠道
-            List<String> channels = data.getChannels();
+        String uid = walletRelationService.getRelation(LoginUserHolder.getEntId());
+        if (StringUtils.isNotBlank(uid)) {
+            R<WalletOverview> wallet = payCenterService.general(uid);
+            if (wallet.getStatus()) {
+                WalletOverview data = wallet.getData();
+                //已开通的渠道
+                List<String> channels = data.getChannels();
 
-            List<ChannelDetail> res = new ArrayList<>();
-            for (WalletChannelEnum value : WalletChannelEnum.channelEnumList()) {
-                ChannelDetail channelDetail = new ChannelDetail();
-                channelDetail.setChannel(value.getChannel());
-                channelDetail.setName(value.getDesc());
-                channelDetail.setMoney("-");
-                channelDetail.setTotalMoney("-");
-                channelDetail.setOpenFlag(channels.contains(value.getChannel()));
-                res.add(channelDetail);
+                List<ChannelDetail> res = new ArrayList<>();
+                for (WalletChannelEnum value : WalletChannelEnum.channelEnumList()) {
+                    ChannelDetail channelDetail = new ChannelDetail();
+                    channelDetail.setChannel(value.getChannel());
+                    channelDetail.setName(value.getDesc());
+                    channelDetail.setMoney("-");
+                    channelDetail.setTotalMoney("-");
+                    channelDetail.setOpenFlag(channels.contains(value.getChannel()));
+                    res.add(channelDetail);
+                }
+                return res;
             }
-            return res;
         }
         return WalletChannelEnum.channelEnumList().stream().map(a -> {
             ChannelDetail channelDetail = new ChannelDetail();
@@ -975,12 +962,6 @@ public class WalletService {
      * @return
      */
     public Object applyRefund(RefundReq refundReq) {
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletRefund::getChannel, refundReq.getChannel()).eq(KwpWalletRefund::getUid, refundReq.getUid()).eq(KwpWalletRefund::getFilter, refundReq.getFilter()).eq(KwpWalletRefund::getStatus, RefundEnum.APPLY.getStatus()).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
-        if (Objects.nonNull(kwpWalletRefund)) {
-            throw new BusinessException("存在未完成的退款订单");
-        }
         ChannelEnum channelEnum = ChannelEnum.getByChannel(refundReq.getChannel());
         if (Objects.isNull(channelEnum)) {
             throw new BusinessException("支付通道不存在");
@@ -1017,10 +998,7 @@ public class WalletService {
      * @return
      */
     public Object launchRefund(RefundReq refundReq) {
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletRefund::getChannel, refundReq.getChannel());
-        wrapper.eq(KwpWalletRefund::getUid, refundReq.getUid()).eq(KwpWalletRefund::getFilter, refundReq.getFilter()).eq(KwpWalletRefund::getStatus, RefundEnum.APPLY.getStatus()).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
+        KwpWalletRefund kwpWalletRefund = walletOrderService.queryOne(refundReq.getUid(), refundReq.getFilter(), refundReq.getChannel(), RefundEnum.APPLY);
         if (Objects.isNull(kwpWalletRefund)) {
             throw new BusinessException("未找到待完成的退款订单");
         }