去掉金币限制
This commit is contained in:
parent
65d3a85c18
commit
9427b7e41b
@ -2,15 +2,14 @@ package com.red.circle.other.app.command.team;
|
||||
|
||||
|
||||
import com.red.circle.common.business.enums.OperationUserOrigin;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
import com.red.circle.mq.business.model.event.BadgeOperateEvent;
|
||||
import com.red.circle.mq.rocket.business.producer.TeamSalaryMqMessage;
|
||||
import com.red.circle.mq.rocket.business.producer.UserMqMessageService;
|
||||
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamApplicationProcess;
|
||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamApplicationProcessApproval;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
import com.red.circle.mq.business.model.event.BadgeOperateEvent;
|
||||
import com.red.circle.mq.rocket.business.producer.TeamSalaryMqMessage;
|
||||
import com.red.circle.mq.rocket.business.producer.UserMqMessageService;
|
||||
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamApplicationProcess;
|
||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamApplicationProcessApproval;
|
||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMember;
|
||||
import com.red.circle.other.infra.database.mongo.service.activity.ActivityAgentAnchorCountService;
|
||||
import com.red.circle.other.infra.database.mongo.service.activity.AgentActivityCountService;
|
||||
@ -31,15 +30,12 @@ import com.red.circle.other.inner.enums.team.TeamAppProcessApprovalReason;
|
||||
import com.red.circle.other.inner.enums.team.TeamAppProcessReason;
|
||||
import com.red.circle.other.inner.enums.team.TeamApplicationProcessStatus;
|
||||
import com.red.circle.other.inner.enums.team.TeamApplicationType;
|
||||
import com.red.circle.other.inner.enums.team.TeamMemberRole;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||
import com.red.circle.tool.core.num.ArithmeticUtils;
|
||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import com.red.circle.other.inner.enums.team.TeamMemberRole;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -50,12 +46,10 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class TeamHandleUserApplyExe {
|
||||
|
||||
private final WalletGoldClient walletGoldClient;
|
||||
private final UserRegionGateway userRegionGateway;
|
||||
private final TeamMemberService teamMemberService;
|
||||
private final TeamProfileService teamProfileService;
|
||||
public class TeamHandleUserApplyExe {
|
||||
|
||||
private final TeamMemberService teamMemberService;
|
||||
private final TeamProfileService teamProfileService;
|
||||
private final TeamSalaryMqMessage teamSalaryMqMessage;
|
||||
private final TeamMemberTargetService teamMemberTargetService;
|
||||
private final AgentActivityCountService agentActivityCountService;
|
||||
@ -87,10 +81,8 @@ public class TeamHandleUserApplyExe {
|
||||
ResponseAssert.isFalse(TeamErrorCode.PERMISSION_DENIED,
|
||||
Objects.equals(teamMember.getRole(), TeamMemberRole.MEMBER));
|
||||
|
||||
checkJoinTeam(process, teamMember, status);
|
||||
|
||||
// 修改状态
|
||||
teamApplicationProcessService.changeStatus(new TeamApplicationProcessChangeCmd()
|
||||
// 修改状态
|
||||
teamApplicationProcessService.changeStatus(new TeamApplicationProcessChangeCmd()
|
||||
.setId(process.getId())
|
||||
.setStatus(status)
|
||||
.setUpdateUserId(cmd.getReqUserId())
|
||||
@ -203,33 +195,6 @@ public class TeamHandleUserApplyExe {
|
||||
|
||||
}
|
||||
|
||||
private void checkJoinTeam(TeamApplicationProcess process,
|
||||
TeamMember teamMember, TeamApplicationProcessStatus status) {
|
||||
|
||||
if (!Objects.equals(status, TeamApplicationProcessStatus.AGREE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Objects.equals(userRegionGateway.getRegionId(process.getCreateUser()),
|
||||
teamProfileService.getTeamRegionId(teamMember.getTeamId()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(ArithmeticUtils.lt(getBalance(process.getCreateUser()),
|
||||
ArithmeticUtils.toBigDecimal("100")))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 申请人与团队区域不一致,则申请人金币多余100则不允许申请
|
||||
ResponseAssert.failure(TeamErrorCode.JOIN_RESTRICTIONS);
|
||||
|
||||
}
|
||||
|
||||
private BigDecimal getBalance(Long userId) {
|
||||
return ResponseAssert.requiredSuccess(walletGoldClient.getBalance(userId))
|
||||
.getDollarAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动业务.
|
||||
*/
|
||||
|
||||
@ -12,13 +12,11 @@ import com.red.circle.other.app.dto.cmd.team.TeamUserApplyCmd;
|
||||
import com.red.circle.other.app.util.OfficialNoticeUtils;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.domain.gateway.user.ability.RegisterDeviceGateway;
|
||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamApplicationProcess;
|
||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamProfile;
|
||||
import com.red.circle.other.infra.database.mongo.service.team.team.TeamApplicationProcessService;
|
||||
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberService;
|
||||
import com.red.circle.other.infra.database.mongo.service.team.team.TeamProfileService;
|
||||
import com.red.circle.other.infra.database.rds.service.user.device.LatestMobileDeviceService;
|
||||
import com.red.circle.other.inner.asserts.user.UserErrorCode;
|
||||
import com.red.circle.other.inner.asserts.user.UserRelationErrorCode;
|
||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||
@ -27,15 +25,9 @@ import com.red.circle.other.inner.model.dto.agency.agency.TeamStatus;
|
||||
import com.red.circle.other.inner.enums.team.TeamAppProcessReason;
|
||||
import com.red.circle.other.inner.enums.team.TeamApplicationProcessStatus;
|
||||
import com.red.circle.other.inner.enums.team.TeamApplicationType;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||
import com.red.circle.tool.core.text.StringUtils;
|
||||
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -50,14 +42,11 @@ public class TeamUserApplyJoinExe {
|
||||
|
||||
private static final String TEAM_APPLY_NOTICE_TITLE = "apply agent";
|
||||
|
||||
private final WalletGoldClient walletGoldClient;
|
||||
private final UserRegionGateway userRegionGateway;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final TeamMemberService teamMemberService;
|
||||
private final TeamProfileService teamProfileService;
|
||||
private final OfficialNoticeClient officialNoticeClient;
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
private final LatestMobileDeviceService latestMobileDeviceService;
|
||||
private final TeamApplicationProcessService teamApplicationProcessService;
|
||||
private final RegisterDeviceGateway registerDeviceGateway;
|
||||
|
||||
@ -92,13 +81,8 @@ public class TeamUserApplyJoinExe {
|
||||
cmd.getReqUserId());
|
||||
ResponseAssert.isFalse(TeamErrorCode.DEVICE_FINGERPRINT_USED_BY_ANCHOR, hasAnchorWithSameDevice);
|
||||
|
||||
|
||||
// ResponseAssert.isTrue(TeamErrorCode.JOIN_RESTRICTIONS, checkJoinLimit(cmd));
|
||||
|
||||
checkApply(cmd, teamProfile);
|
||||
|
||||
Long messageId = IdWorkerUtils.getId();
|
||||
teamApplicationProcessService.add(new TeamApplicationProcess()
|
||||
Long messageId = IdWorkerUtils.getId();
|
||||
teamApplicationProcessService.add(new TeamApplicationProcess()
|
||||
.setId(messageId)
|
||||
.setSysOrigin(teamProfile.getSysOrigin())
|
||||
.setType(TeamApplicationType.TEAM)
|
||||
@ -116,52 +100,6 @@ public class TeamUserApplyJoinExe {
|
||||
return Objects.toString(messageId);
|
||||
}
|
||||
|
||||
private void checkApply(TeamUserApplyCmd cmd, TeamProfile teamProfile) {
|
||||
|
||||
// 申请人与团队区域不一致或者申请人金币多余100则不允许申请
|
||||
if (Boolean.TRUE.equals(Objects.equals(userRegionGateway.getRegionId(cmd.getReqUserId()), teamProfile.getRegion()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ResponseAssert.requiredSuccess(walletGoldClient.getBalance(cmd.getReqUserId()))
|
||||
.getDollarAmount().longValue() < 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResponseAssert.failure(TeamErrorCode.NOT_AUTHORIZED_TO_JOIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入限制: 20230401, 刘占洋需求(同一个设备的账户只能加入同一个代理)
|
||||
*/
|
||||
private boolean checkJoinLimit(TeamUserApplyCmd cmd) {
|
||||
|
||||
String imei = latestMobileDeviceService.getImeiByUserId(cmd.getReqUserId());
|
||||
|
||||
ResponseAssert.isTrue(CommonErrorCode.DEVICE_UNAVAILABLE, StringUtils.isNotBlank(imei));
|
||||
|
||||
List<Long> userIds = latestMobileDeviceService.listUserIdByImei(
|
||||
cmd.getReqImei(), cmd.requireReqSysOrigin());
|
||||
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<Long> otherUserIds = userIds.stream()
|
||||
.filter(userId -> !Objects.equals(cmd.getReqUserId(), userId)).collect(
|
||||
Collectors.toSet());
|
||||
|
||||
if (CollectionUtils.isEmpty(otherUserIds)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<Long> teamIds = teamMemberService.listTeamIdByMemberIds(otherUserIds);
|
||||
if (CollectionUtils.isEmpty(teamIds)) {
|
||||
return true;
|
||||
}
|
||||
return teamIds.contains(cmd.getTeamId());
|
||||
}
|
||||
|
||||
private void sendMessage(TeamUserApplyCmd cmd, TeamProfile teamProfile, Long messageId) {
|
||||
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
|
||||
userProfileGateway.getByUserId(cmd.requiredReqUserId())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user