更新提现渠道逻辑

This commit is contained in:
墨大叔 2024-07-30 15:20:38 +08:00
parent 9250fa2160
commit 26ed635923
6 changed files with 43 additions and 7 deletions

View File

@ -32,7 +32,7 @@ public enum AccountType {
return obj;
}
}
throw new RuntimeException("不存在值为" + type + "的账户类型");
return null;
}
public static AccountType parseByChannel(Long channelId) {

View File

@ -99,4 +99,9 @@ public interface AccountService
* 查询一个
*/
AccountVO selectOne(AccountQuery query);
/**
* 根据用户查询
*/
List<AccountVO> selectByUserId(Long userId);
}

View File

@ -201,6 +201,16 @@ public class AccountServiceImpl implements AccountService {
return accountMapper.selectOne(query);
}
@Override
public List<AccountVO> selectByUserId(Long userId) {
if (userId == null) {
return Collections.emptyList();
}
AccountQuery query = new AccountQuery();
query.setUserId(userId);
return this.selectSmAccountList(query);
}
private boolean isRepeat(Account data) {
AccountQuery dto = new AccountQuery();
dto.setUserId(data.getUserId());

View File

@ -82,6 +82,6 @@ public interface ChannelService
/**
* 查询启用的提现渠道列表
*/
List<ChannelVO> selectEnabledWithdrawList();
List<ChannelVO> selectEnabledWithdrawList(Long userId);
}

View File

@ -1,6 +1,9 @@
package com.ruoyi.ss.channel.service.impl;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.ss.account.domain.AccountVO;
import com.ruoyi.ss.account.domain.enums.AccountType;
import com.ruoyi.ss.account.service.AccountService;
import com.ruoyi.ss.channel.domain.Channel;
import com.ruoyi.ss.channel.domain.ChannelQuery;
import com.ruoyi.ss.channel.domain.ChannelVO;
@ -9,9 +12,7 @@ import com.ruoyi.ss.channel.service.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -27,6 +28,9 @@ public class ChannelServiceImpl implements ChannelService
@Autowired
private ChannelMapper channelMapper;
@Autowired
private AccountService accountService;
/**
* 查询充值渠道
*
@ -107,9 +111,26 @@ public class ChannelServiceImpl implements ChannelService
}
@Override
public List<ChannelVO> selectEnabledWithdrawList() {
public List<ChannelVO> selectEnabledWithdrawList(Long userId) {
// 查询用户账户列表
List<AccountVO> accountList = accountService.selectByUserId(userId);
if (CollectionUtils.isEmptyElement(accountList)) {
return Collections.emptyList();
}
// 过滤出渠道ID列表
List<Long> channelIds = accountList.stream()
.map(item -> AccountType.parse(item.getAccountType()))
.filter(Objects::nonNull)
.map(AccountType::getChannelId)
.collect(Collectors.toList());
if (CollectionUtils.isEmptyElement(channelIds)) {
return Collections.emptyList();
}
// 查询渠道列表
ChannelQuery dto = new ChannelQuery();
dto.setWithdrawEnabled(true);
dto.setChannelIds(channelIds);
return this.selectSmChannelList(dto);
}

View File

@ -37,7 +37,7 @@ public class AppChannelController extends BaseController {
@JsonView(JsonViewProfile.App.class)
@GetMapping("/recharge/enabledWithdrawList")
public AjaxResult getWithdrawEnabledList() {
return success(channelService.selectEnabledWithdrawList());
return success(channelService.selectEnabledWithdrawList(getUserId()));
}
}