diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java index bfd99c87..02e6a765 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java @@ -262,6 +262,11 @@ public enum TeamErrorCode implements IResponseErrorCode { * 用户不是管理员. */ USER_IS_NOT_ADMIN(6058, "User is not an administrator"), + + /** + * 团队不允许提现 + */ + WITHDRAW_NOT_ALLOWED(6059, "The team is not allowed to withdraw funds.") ; private final Integer code; diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/agency/agency/TeamProfileDTO.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/agency/agency/TeamProfileDTO.java index c087629e..2be07cd6 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/agency/agency/TeamProfileDTO.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/agency/agency/TeamProfileDTO.java @@ -73,6 +73,12 @@ public class TeamProfileDTO implements Serializable { */ private List contacts; + /** + * 允许提现开关. + */ + private Boolean withdrawalEnabled; + + /** * 创建时间. */ 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 d89865b9..bc390e48 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,10 +6,14 @@ 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.other.inner.endpoint.user.region.RegionConfigClient; -import com.red.circle.other.inner.enums.team.TeamPolicyTypeEnum; 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; @@ -42,6 +46,7 @@ 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; @@ -65,10 +70,16 @@ public class UserBankWithdrawCmdExe { private final SalaryAccountGateway salaryAccountGateway; private final UserBankBalanceService userBankBalanceService; private final UserBankRunningWaterService userBankRunningWaterService; + private final TeamMemberClient teamMemberClient; + private final TeamProfileClient teamProfileClient; + public UserBankWithdrawResultCO execute(UserBankWithdrawCmd cmd) { ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, ArithmeticUtils.gtZero(cmd.getAmount())); + // 检查是否允许提现 + checkHostSalaryWithdrawEnabled(cmd); + // 上锁 String key = "UBWithdraw:" + cmd.requiredReqUserId(); ResponseAssert.isTrue(CommonErrorCode.REQUEST_LIMITING, redisService.lock(key, 60)); @@ -151,6 +162,28 @@ 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 BigDecimal changeBalance(UserBankWithdrawCmd cmd, SalaryType salaryType, Long applyId) { // 余额 BigDecimal balance; diff --git a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/dto/cmd/UserBankWithdrawCmd.java b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/dto/cmd/UserBankWithdrawCmd.java index 520ebf27..78f54980 100644 --- a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/dto/cmd/UserBankWithdrawCmd.java +++ b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/dto/cmd/UserBankWithdrawCmd.java @@ -31,6 +31,7 @@ public class UserBankWithdrawCmd extends AppExtCommand { @NotNull(message = "acceptBankCardId required.") private Long acceptBankCardId; + @NotNull(message = "salaryType required.") private String salaryType; }