From 8a806029cb28835ff93e4999f1abd479dff0d435 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 20 Mar 2026 15:23:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E6=92=AD=E5=B7=A5?= =?UTF-8?q?=E8=B5=84=E6=98=AF=E5=90=A6=E5=85=81=E8=AE=B8=E6=8F=90=E7=8E=B0?= =?UTF-8?q?.=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/app/BankRestController.java | 13 ++++ .../command/bank/UserBankWithdrawCmdExe.java | 35 +++-------- .../HostSalaryWithdrawEnabledQryExe.java | 61 +++++++++++++++++++ .../app/service/UserBankServiceImpl.java | 7 +++ .../wallet/app/service/UserBankService.java | 5 ++ 5 files changed, 93 insertions(+), 28 deletions(-) create mode 100644 rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/query/HostSalaryWithdrawEnabledQryExe.java diff --git a/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/BankRestController.java b/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/BankRestController.java index 60184963..151ee8f1 100644 --- a/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/BankRestController.java +++ b/rc-service/rc-service-wallet/wallet-adapter/src/main/java/com/red/circle/wallet/adapter/app/BankRestController.java @@ -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); + } + /** * 钻石提现. * diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankWithdrawCmdExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankWithdrawCmdExe.java index bc390e48..14246f13 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankWithdrawCmdExe.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankWithdrawCmdExe.java @@ -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 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) { // 余额 diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/query/HostSalaryWithdrawEnabledQryExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/query/HostSalaryWithdrawEnabledQryExe.java new file mode 100644 index 00000000..86a8ecad --- /dev/null +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/query/HostSalaryWithdrawEnabledQryExe.java @@ -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 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 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); + } + } +} diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/UserBankServiceImpl.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/UserBankServiceImpl.java index 57425859..487f6d5d 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/UserBankServiceImpl.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/UserBankServiceImpl.java @@ -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()); + } + } diff --git a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/UserBankService.java b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/UserBankService.java index 421cc8be..d802f7b0 100644 --- a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/UserBankService.java +++ b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/UserBankService.java @@ -108,4 +108,9 @@ public interface UserBankService { * 提现美金手续费 */ Long serviceCharge(AppExtCommand cmd); + + /** + * 主播工资是否允许提现. + */ + boolean hostSalaryWithdrawEnabled(AppExtCommand cmd); }