|
|
@@ -22,16 +22,14 @@ import com.sckw.payment.model.KwpWalletRefund;
|
|
|
import com.sckw.payment.model.KwpWalletTransfer;
|
|
|
import com.sckw.payment.model.constant.RefundEnum;
|
|
|
import com.sckw.payment.model.constant.TransferEnum;
|
|
|
+import com.sckw.payment.model.constant.WalletChannelEnum;
|
|
|
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.vo.PrePayWalletVo;
|
|
|
import com.sckw.payment.model.vo.req.*;
|
|
|
-import com.sckw.payment.model.vo.res.ApPageRes;
|
|
|
-import com.sckw.payment.model.vo.res.FundVo;
|
|
|
-import com.sckw.payment.model.vo.res.MorePageRes;
|
|
|
-import com.sckw.payment.model.vo.res.WalletDetail;
|
|
|
+import com.sckw.payment.model.vo.res.*;
|
|
|
import com.sckw.redis.config.RedisLockUtil;
|
|
|
import com.sckw.redis.constant.RedisLockKey;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
@@ -48,9 +46,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -186,21 +182,110 @@ public class WalletService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 按钱包渠道进行统计钱包清单数量
|
|
|
+ *
|
|
|
+ * @param entName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ChannelCount> walletCount(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);
|
|
|
+ } else {
|
|
|
+ //筛选所有的
|
|
|
+ filterList.add("");
|
|
|
+ }
|
|
|
+ List<ChannelCount> channelDetails = new ArrayList<>();
|
|
|
+ HashMap<String, Integer> mapCount = new HashMap<>();
|
|
|
+ int all = 0;
|
|
|
+ for (String filter : filterList) {
|
|
|
+ R<List<WalletDto>> wallet = payCenterService.wallet(uid, null, filter);
|
|
|
+ if (wallet.getStatus()) {
|
|
|
+ List<WalletDto> data = wallet.getData();
|
|
|
+ if (!CollectionUtils.isEmpty(data)) {
|
|
|
+ all += data.size();
|
|
|
+ Map<String, List<WalletDto>> map = data.stream().collect(Collectors.groupingBy(WalletDto::getChannel));
|
|
|
+ for (Map.Entry<String, List<WalletDto>> one : map.entrySet()) {
|
|
|
+ List<WalletDto> value = one.getValue();
|
|
|
+ Integer size = CollectionUtils.isEmpty(value) ? 0 : value.size();
|
|
|
+ mapCount.compute(one.getKey(), (k, v) -> Objects.isNull(v) ? size : size + v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //所有的
|
|
|
+ mapCount.put(WalletChannelEnum.ALL.getChannel(), all);
|
|
|
+ ChannelCount channelCount;
|
|
|
+ for (WalletChannelEnum value : WalletChannelEnum.values()) {
|
|
|
+ channelCount = new ChannelCount(value.getValue(), value.getDesc(), value.getChannel(), Objects.isNull(mapCount.get(value.getChannel())) ? 0 : mapCount.get(value.getChannel()));
|
|
|
+ channelDetails.add(channelCount);
|
|
|
+ }
|
|
|
+ return channelDetails;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 钱包总览信息
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public WalletDetail walletOverview() {
|
|
|
+ public WalletDetail walletOverview(boolean queryChannel) {
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
- String relation = walletRelationService.getRelation(entId);
|
|
|
- if (StringUtils.isBlank(relation)) {
|
|
|
+ String uid = walletRelationService.getRelation(entId);
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
throw new BusinessException("暂未开通电子钱包");
|
|
|
}
|
|
|
- R<WalletOverview> wallet = payCenterService.general(relation);
|
|
|
+ R<WalletOverview> wallet = payCenterService.general(uid);
|
|
|
if (wallet.getStatus()) {
|
|
|
WalletOverview data = wallet.getData();
|
|
|
- return new WalletDetail(LoginUserHolder.getEntName(), String.valueOf(data.getTotalMoney() / 100D), String.valueOf(data.getChargingMoney()), String.valueOf(data.getWdingMoney()), data.getChannelTotal(), data.getChannels());
|
|
|
+ List<ChannelDetail> channelDetails = new ArrayList<>();
|
|
|
+ if (queryChannel) {
|
|
|
+ R<List<WalletDto>> wallet1 = payCenterService.wallet(uid, null, "");
|
|
|
+ if (wallet1.getStatus()) {
|
|
|
+ List<WalletDto> data1 = wallet1.getData();
|
|
|
+ if (!CollectionUtils.isEmpty(data1)) {
|
|
|
+ Map<String, List<WalletDto>> map = data1.stream().collect(Collectors.groupingBy(WalletDto::getChannel));
|
|
|
+ ChannelDetail channelDetail;
|
|
|
+ for (Map.Entry<String, List<WalletDto>> one : map.entrySet()) {
|
|
|
+ String key = one.getKey();
|
|
|
+ List<WalletDto> value = one.getValue();
|
|
|
+ Long money = 0L;
|
|
|
+ Long totalMoney = 0L;
|
|
|
+ if (!CollectionUtils.isEmpty(value)) {
|
|
|
+ for (WalletDto walletDto : value) {
|
|
|
+ money += walletDto.getMoney();
|
|
|
+ totalMoney += walletDto.getTotalMoney();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ channelDetail = new ChannelDetail();
|
|
|
+ channelDetail.setChannel(key);
|
|
|
+ channelDetail.setMoney(String.valueOf(money / 100D));
|
|
|
+ channelDetail.setTotalMoney(String.valueOf(totalMoney / 100D));
|
|
|
+ channelDetails.add(channelDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<String> channels = data.getChannels();
|
|
|
+ if (!CollectionUtils.isEmpty(channels)) {
|
|
|
+ ChannelDetail channelDetail;
|
|
|
+ for (String channel : channels) {
|
|
|
+ channelDetail = new ChannelDetail();
|
|
|
+ channelDetail.setChannel(channel);
|
|
|
+ channelDetail.setMoney("-");
|
|
|
+ channelDetail.setTotalMoney("-");
|
|
|
+ channelDetails.add(channelDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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<>());
|
|
|
}
|
|
|
@@ -214,8 +299,8 @@ public class WalletService {
|
|
|
log.info("查询资金明细:{}", JSONObject.toJSONString(walletDetailReq));
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
//查询我方企业开通的渠道
|
|
|
- String relation = walletRelationService.getRelation(entId);
|
|
|
- if (StringUtils.isBlank(relation)) {
|
|
|
+ String uid = walletRelationService.getRelation(entId);
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
return PageRes.handPage(walletDetailReq.getPage(), walletDetailReq.getPageSize(), new ArrayList<>());
|
|
|
}
|
|
|
ChannelEnum channelEnum = null;
|
|
|
@@ -236,7 +321,7 @@ public class WalletService {
|
|
|
return PageRes.handPage(walletDetailReq.getPage(), walletDetailReq.getPageSize(), new ArrayList<>());
|
|
|
}
|
|
|
for (String filter : filterList) {
|
|
|
- R<Wallet> walletR = payCenterService.walletSum(relation, channelEnum, filter);
|
|
|
+ R<Wallet> walletR = payCenterService.walletSum(uid, channelEnum, filter);
|
|
|
if (walletR.getStatus()) {
|
|
|
Wallet data = walletR.getData();
|
|
|
sum += data.getTotalMoney();
|
|
|
@@ -249,7 +334,7 @@ public class WalletService {
|
|
|
}
|
|
|
} else {
|
|
|
//不搜索往来单位
|
|
|
- R<Wallet> wallet = payCenterService.walletSum(relation, channelEnum, "");
|
|
|
+ R<Wallet> wallet = payCenterService.walletSum(uid, channelEnum, "");
|
|
|
if (wallet.getStatus()) {
|
|
|
Wallet data = wallet.getData();
|
|
|
sum += data.getTotalMoney();
|