Kaynağa Gözat

新增账目问题修改,app端预付统计和预收统计

xucaiqin 2 yıl önce
ebeveyn
işleme
1ed6f1cc9f

+ 98 - 6
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -28,6 +28,7 @@ import com.sckw.payment.model.dto.common.BusinessNo;
 import com.sckw.payment.model.dto.page.CashPage;
 import com.sckw.payment.model.dto.page.PrePayWalletPage;
 import com.sckw.payment.model.dto.wallet.*;
+import com.sckw.payment.model.dto.wallet.ChannelStatistics;
 import com.sckw.payment.model.vo.PrePayWalletVo;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.*;
@@ -186,9 +187,7 @@ public class WalletService {
     private void transferMoney(FundVo fundVo) {
         DecimalFormat df = new DecimalFormat("0.00");
         LambdaQueryWrapper<KwpWalletTransfer> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletTransfer::getUid, fundVo.getUid())
-                .eq(KwpWalletTransfer::getFilter, fundVo.getFilter()).eq(KwpWalletTransfer::getChannel, fundVo.getChannel())
-                .eq(KwpWalletTransfer::getStatus, TransferEnum.TRANSFERRING.getStatus()).last("limit 1");
+        wrapper.eq(KwpWalletTransfer::getUid, fundVo.getUid()).eq(KwpWalletTransfer::getFilter, fundVo.getFilter()).eq(KwpWalletTransfer::getChannel, fundVo.getChannel()).eq(KwpWalletTransfer::getStatus, TransferEnum.TRANSFERRING.getStatus()).last("limit 1");
         KwpWalletTransfer kwpWalletTransfer = kwpWalletTransferMapper.selectOne(wrapper);
         if (Objects.nonNull(kwpWalletTransfer)) {
             fundVo.setTransferMoney(df.format(kwpWalletTransfer.getMoney()));
@@ -310,8 +309,7 @@ public class WalletService {
                     }
                 }
             }
-            return new WalletDetail(LoginUserHolder.getEntName(), String.valueOf(data.getTotalMoney() / 100D), String.valueOf(data.getChargingMoney()),
-                    String.valueOf(data.getWdingMoney()), data.getChannelTotal(), channelDetails);
+            return new WalletDetail(LoginUserHolder.getEntName(), String.valueOf(data.getTotalMoney() / 100D), String.valueOf(data.getChargingMoney()), String.valueOf(data.getWdingMoney()), data.getChannelTotal(), channelDetails);
         }
         return new WalletDetail(LoginUserHolder.getEntName(), "-", "-", "-", 0, new ArrayList<>());
     }
@@ -450,7 +448,7 @@ public class WalletService {
         if (StringUtils.isBlank(filter)) {
             throw new BusinessException("合作单位暂未开通电子钱包");
         }
-        ChannelEnum channelEnum = ChannelEnum.getByChannel(addWalletReq.getChannel());
+        ChannelEnum channelEnum = ChannelEnum.getByValue(addWalletReq.getChannel());
         if (Objects.isNull(channelEnum)) {
             throw new BusinessException("支付通道不存在");
         }
@@ -716,6 +714,53 @@ public class WalletService {
 
     }
 
+    /**
+     * 预付列表钱包统计
+     *
+     * @param entName
+     * @return
+     */
+    public List<ChannelCount> prePayCount(String entName) {
+        Long entId = LoginUserHolder.getEntId();
+        String uid = walletRelationService.getRelation(entId);
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("暂未开通电子钱包");
+        }
+        List<String> filterList = new ArrayList<>();
+        //筛选指定企业的数据
+        if (StringUtils.isNotBlank(entName)) {
+            filterList = findFilter(entName);
+        }
+        List<ChannelCount> channelDetails = new ArrayList<>();
+        //查询预付订单渠道统计数据
+        R<List<ChannelStatistics>> listR = payCenterService.advancePayWalletChannels(uid, StringUtils.join(filterList, ","));
+        Map<String, Integer> mapCount;
+        if (listR.getStatus()) {
+            List<ChannelStatistics> data = listR.getData();
+            if (!CollectionUtils.isEmpty(data)) {
+                mapCount = data.stream().collect(Collectors.toMap(ChannelStatistics::getChannel, ChannelStatistics::getCount, (k, v) -> k));
+            } else {
+                mapCount = new HashMap<>();
+            }
+            mapCount.compute("all", (k, v) -> {
+                Integer sum = 0;
+                for (Map.Entry<String, Integer> map : mapCount.entrySet()) {
+                    sum += map.getValue();
+                }
+                return sum;
+            });
+        } else {
+            mapCount = new HashMap<>();
+        }
+        ChannelCount channelCount;
+        for (WalletChannelEnum value : WalletChannelEnum.values()) {
+            Integer integer = mapCount.get(value.getChannel());
+            channelCount = new ChannelCount(value.getValue(), value.getDesc(), value.getChannel(), Objects.isNull(integer) ? 0 : integer);
+            channelDetails.add(channelCount);
+        }
+        return channelDetails;
+    }
+
     /**
      * 预收列表
      *
@@ -771,6 +816,53 @@ public class WalletService {
         return new PageRes<>(prePayPage.getPage(), prePayPage.getPageSize(), 0, 0, new ArrayList<>());
     }
 
+    /**
+     * 预收列表钱包统计
+     *
+     * @param entName
+     * @return
+     */
+    public List<ChannelCount> preReceiveCount(String entName) {
+        Long entId = LoginUserHolder.getEntId();
+        String uid = walletRelationService.getRelation(entId);
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("暂未开通电子钱包");
+        }
+        List<String> filterList = new ArrayList<>();
+        //筛选指定企业的数据
+        if (StringUtils.isNotBlank(entName)) {
+            filterList = findFilter(entName);
+        }
+        List<ChannelCount> channelDetails = new ArrayList<>();
+        //查询预付订单渠道统计数据
+        R<List<ChannelStatistics>> listR = payCenterService.advancePayWalletChannels(uid, StringUtils.join(filterList, ","));
+        Map<String, Integer> mapCount;
+        if (listR.getStatus()) {
+            List<ChannelStatistics> data = listR.getData();
+            if (!CollectionUtils.isEmpty(data)) {
+                mapCount = data.stream().collect(Collectors.toMap(ChannelStatistics::getChannel, ChannelStatistics::getCount, (k, v) -> k));
+            } else {
+                mapCount = new HashMap<>();
+            }
+            mapCount.compute("all", (k, v) -> {
+                Integer sum = 0;
+                for (Map.Entry<String, Integer> map : mapCount.entrySet()) {
+                    sum += map.getValue();
+                }
+                return sum;
+            });
+        } else {
+            mapCount = new HashMap<>();
+        }
+        ChannelCount channelCount;
+        for (WalletChannelEnum value : WalletChannelEnum.values()) {
+            Integer integer = mapCount.get(value.getChannel());
+            channelCount = new ChannelCount(value.getValue(), value.getDesc(), value.getChannel(), Objects.isNull(integer) ? 0 : integer);
+            channelDetails.add(channelCount);
+        }
+        return channelDetails;
+    }
+
     /**
      * 预付校验
      *