新增主播工资是否允许提现.接口

This commit is contained in:
tianfeng 2026-03-20 15:23:29 +08:00
parent 6a1385fc99
commit 8a806029cb
5 changed files with 93 additions and 28 deletions

View File

@ -91,6 +91,19 @@ public class BankRestController extends BaseController {
return userBankService.withdraw(cmd);
}
/**
* 主播工资是否允许提现.
*
* @eo.name 主播工资是否允许提现
* @eo.url /host-salary/withdraw/enabled
* @eo.method get
* @eo.request-type formdata
*/
@GetMapping("/host-salary/withdraw/enabled")
public boolean hostSalaryWithdrawEnabled(AppExtCommand cmd) {
return userBankService.hostSalaryWithdrawEnabled(cmd);
}
/**
* 钻石提现.
*

View File

@ -6,14 +6,10 @@ import com.red.circle.component.redis.service.RedisService;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.framework.core.response.ResponseErrorCode;
import com.red.circle.other.inner.asserts.team.TeamErrorCode;
import com.red.circle.other.inner.endpoint.team.target.TeamMemberClient;
import com.red.circle.other.inner.endpoint.team.target.TeamProfileClient;
import com.red.circle.other.inner.endpoint.user.region.RegionAssistConfigClient;
import com.red.circle.wallet.app.command.bank.query.HostSalaryWithdrawEnabledQryExe;
import com.red.circle.other.inner.endpoint.user.region.RegionConfigClient;
import com.red.circle.other.inner.enums.user.RegionAssistTypeEnum;
import com.red.circle.other.inner.model.dto.agency.agency.TeamMemberDTO;
import com.red.circle.other.inner.model.dto.agency.agency.TeamProfileDTO;
import com.red.circle.other.inner.model.dto.user.reigon.RegionConfigDTO;
import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.num.ArithmeticUtils;
@ -46,7 +42,6 @@ import com.red.circle.wallet.inner.model.enums.UserBankWaterEvent;
import com.red.circle.wallet.inner.model.enums.WithdrawMethod;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
@ -70,8 +65,7 @@ public class UserBankWithdrawCmdExe {
private final SalaryAccountGateway salaryAccountGateway;
private final UserBankBalanceService userBankBalanceService;
private final UserBankRunningWaterService userBankRunningWaterService;
private final TeamMemberClient teamMemberClient;
private final TeamProfileClient teamProfileClient;
private final HostSalaryWithdrawEnabledQryExe hostSalaryWithdrawEnabledQryExe;
public UserBankWithdrawResultCO execute(UserBankWithdrawCmd cmd) {
@ -162,27 +156,12 @@ public class UserBankWithdrawCmdExe {
.setWithdrawAmount(Objects.toString(cmd.getAmount()));
}
private void checkHostSalaryWithdrawEnabled(UserBankWithdrawCmd cmd) {
if ( SalaryType.HOST_SALARY != SalaryType.of(cmd.getSalaryType())) {
return;
}
TeamMemberDTO teamMemberDTO = teamMemberClient.getByMemberId(cmd.getReqUserId()).getBody();
if (teamMemberDTO == null) {
ResponseAssert.failure(TeamErrorCode.TEAM_NOT_FOUND);
}
List<TeamProfileDTO> profileDTOS = teamProfileClient.listByIds(Collections.singleton(teamMemberDTO.getTeamId())).getBody();
if (profileDTOS.isEmpty()) {
ResponseAssert.failure(TeamErrorCode.TEAM_NOT_FOUND);
}
TeamProfileDTO teamProfileDTO = profileDTOS.get(0);
if (!Boolean.TRUE.equals(teamProfileDTO.getWithdrawalEnabled())) {
ResponseAssert.failure(TeamErrorCode.WITHDRAW_NOT_ALLOWED);
}
private void checkHostSalaryWithdrawEnabled(UserBankWithdrawCmd cmd) {
if (SalaryType.HOST_SALARY != SalaryType.of(cmd.getSalaryType())) {
return;
}
hostSalaryWithdrawEnabledQryExe.check(cmd.requiredReqUserId());
}
private BigDecimal changeBalance(UserBankWithdrawCmd cmd, SalaryType salaryType, Long applyId) {
// 余额

View File

@ -0,0 +1,61 @@
package com.red.circle.wallet.app.command.bank.query;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.inner.asserts.team.TeamErrorCode;
import com.red.circle.other.inner.endpoint.team.target.TeamMemberClient;
import com.red.circle.other.inner.endpoint.team.target.TeamProfileClient;
import com.red.circle.other.inner.model.dto.agency.agency.TeamMemberDTO;
import com.red.circle.other.inner.model.dto.agency.agency.TeamProfileDTO;
import com.red.circle.wallet.inner.model.enums.SalaryType;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
/**
* 主播工资是否允许提现.
*
* @author tf
*/
@Component
@RequiredArgsConstructor
public class HostSalaryWithdrawEnabledQryExe {
private final TeamMemberClient teamMemberClient;
private final TeamProfileClient teamProfileClient;
/**
* 返回 true 表示允许提现.
*/
public boolean execute(Long userId) {
if (userId == null) {
return false;
}
TeamMemberDTO teamMemberDTO = teamMemberClient.getByMemberId(userId).getBody();
if (teamMemberDTO == null) {
return false;
}
List<TeamProfileDTO> profileDTOS = teamProfileClient.listByIds(Collections.singleton(teamMemberDTO.getTeamId())).getBody();
if (profileDTOS == null || profileDTOS.isEmpty()) {
return false;
}
return Boolean.TRUE.equals(profileDTOS.get(0).getWithdrawalEnabled());
}
/**
* 校验主播工资提现权限不满足则抛出异常.
*/
public void check(Long userId) {
TeamMemberDTO teamMemberDTO = teamMemberClient.getByMemberId(userId).getBody();
if (teamMemberDTO == null) {
ResponseAssert.failure(TeamErrorCode.TEAM_NOT_FOUND);
}
List<TeamProfileDTO> profileDTOS = teamProfileClient.listByIds(Collections.singleton(teamMemberDTO.getTeamId())).getBody();
if (profileDTOS == null || profileDTOS.isEmpty()) {
ResponseAssert.failure(TeamErrorCode.TEAM_NOT_FOUND);
}
if (!Boolean.TRUE.equals(profileDTOS.get(0).getWithdrawalEnabled())) {
ResponseAssert.failure(TeamErrorCode.WITHDRAW_NOT_ALLOWED);
}
}
}

View File

@ -12,6 +12,7 @@ import com.red.circle.wallet.app.command.bank.query.UserBankBalanceQryExe;
import com.red.circle.wallet.app.command.bank.query.UserBankExchangeGoldTipQryExe;
import com.red.circle.wallet.app.command.bank.query.UserBankSearchUserProfileQryExe;
import com.red.circle.wallet.app.command.bank.query.UserBankWaterQryExe;
import com.red.circle.wallet.app.command.bank.query.HostSalaryWithdrawEnabledQryExe;
import com.red.circle.wallet.app.command.bank.query.UserBankWithdrawalServiceChargeQryExe;
import com.red.circle.wallet.app.command.bank.query.UserBankWithdrawalWaysQryExe;
import com.red.circle.wallet.app.dto.clientobject.UserBankCheckExchangeGoldCO;
@ -53,6 +54,7 @@ public class UserBankServiceImpl implements UserBankService {
private final UserBankSearchUserProfileQryExe userBankSearchUserProfileQryExe;
private final UserBankCheckExchangeGoldQryExe userBankCheckExchangeGoldQryExe;
private final UserBankWithdrawalServiceChargeQryExe userBankWithdrawalServiceChargeQryExe;
private final HostSalaryWithdrawEnabledQryExe hostSalaryWithdrawEnabledQryExe;
@Override
public BigDecimal getBalance(AppExtCommand cmd) {
@ -139,5 +141,10 @@ public class UserBankServiceImpl implements UserBankService {
return userBankWithdrawalServiceChargeQryExe.execute(cmd);
}
@Override
public boolean hostSalaryWithdrawEnabled(AppExtCommand cmd) {
return hostSalaryWithdrawEnabledQryExe.execute(cmd.requiredReqUserId());
}
}

View File

@ -108,4 +108,9 @@ public interface UserBankService {
* 提现美金手续费
*/
Long serviceCharge(AppExtCommand cmd);
/**
* 主播工资是否允许提现.
*/
boolean hostSalaryWithdrawEnabled(AppExtCommand cmd);
}