主播工资提现增加提现开关
This commit is contained in:
parent
289e6e4e11
commit
7a9f404233
@ -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;
|
||||
|
||||
@ -73,6 +73,12 @@ public class TeamProfileDTO implements Serializable {
|
||||
*/
|
||||
private List<TeamContactDTO> contacts;
|
||||
|
||||
/**
|
||||
* 允许提现开关.
|
||||
*/
|
||||
private Boolean withdrawalEnabled;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间.
|
||||
*/
|
||||
|
||||
@ -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<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 BigDecimal changeBalance(UserBankWithdrawCmd cmd, SalaryType salaryType, Long applyId) {
|
||||
// 余额
|
||||
BigDecimal balance;
|
||||
|
||||
@ -31,6 +31,7 @@ public class UserBankWithdrawCmd extends AppExtCommand {
|
||||
@NotNull(message = "acceptBankCardId required.")
|
||||
private Long acceptBankCardId;
|
||||
|
||||
@NotNull(message = "salaryType required.")
|
||||
private String salaryType;
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user