fix legacy invite message processing

This commit is contained in:
hy001 2026-04-22 21:51:51 +08:00
parent 77a938f553
commit 4396f34b3b
3 changed files with 119 additions and 22 deletions

View File

@ -143,12 +143,12 @@ public class AgentInviteHostExe {
bdInviteAgentMessageService.remove(id);
}
public void processInvite(AgentInviteMessageProcessCmd cmd) {
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getStatus() > 0);
BdInviteAgentMessage message = bdInviteAgentMessageService.getById(cmd.getId());
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, message.getStatus() == 0);
ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_RECORD_INFO, message);
public void processInvite(AgentInviteMessageProcessCmd cmd) {
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getStatus() > 0);
BdInviteAgentMessage message = bdInviteAgentMessageService.getById(cmd.getId());
ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_RECORD_INFO, message);
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, message.getStatus() == 0);
ResponseAssert.isTrue(CommonErrorCode.NOT_FOUND_RECORD_INFO,
Objects.equals(message.getGroup(), MessageInviteGroup.AGENT_INVITE_HOST.name()) ||
@ -165,10 +165,10 @@ public class AgentInviteHostExe {
ResponseAssert.isFalse(TeamErrorCode.USER_IS_ALREADY_A_ANCHOR,
teamMemberService.existsMember(cmd.requiredReqUserId()));
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE,
bdInviteAgentMessageService.updateStatus(cmd.getId(), message.getStatus(),
cmd.getStatus(), MessageInviteGroup.AGENT_INVITE_HOST.name()));
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE,
bdInviteAgentMessageService.updateStatus(cmd.getId(), message.getStatus(),
cmd.getStatus(), message.getGroup()));
if (Objects.equals(cmd.getStatus(), 1)) {
// 主播设备指纹校验

View File

@ -79,13 +79,13 @@ public class BdInviteMessageProcessExe {
private final AdministratorService administratorService;
private final TaskMqMessage taskMqMessage;
public void execute(DbInviteMessageProcessCmd cmd) {
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getStatus() > 0);
BdInviteAgentMessage message = bdInviteAgentMessageService.getById(cmd.getId());
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, message.getStatus() == 0);
ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_RECORD_INFO, message);
public void execute(DbInviteMessageProcessCmd cmd) {
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getStatus() > 0);
BdInviteAgentMessage message = bdInviteAgentMessageService.getById(cmd.getId());
ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_RECORD_INFO, message);
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, message.getStatus() == 0);
ResponseAssert.isTrue(CommonErrorCode.NOT_FOUND_RECORD_INFO,
Objects.equals(message.getGroup(), MessageInviteGroup.BD_INVITE_TEAM.name()) ||
@ -98,11 +98,11 @@ public class BdInviteMessageProcessExe {
Objects.equals(message.getInviteUserId(), cmd.requiredReqUserId()));
ResponseAssert.isTrue(TeamErrorCode.MESSAGE_PROCESSED, Objects.equals(message.getStatus(), 0));
// 6014 用户正在申请加入其他代理
ResponseAssert.isFalse(TeamErrorCode.USER_APPLY_JOIN_OTHER_AGENT,
teamMemberService.existsMember(cmd.requiredReqUserId()));
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE,
bdInviteAgentMessageService.updateStatus(cmd.getId(), message.getStatus(),
cmd.getStatus(), MessageInviteGroup.BD_INVITE_TEAM.name()));
ResponseAssert.isFalse(TeamErrorCode.USER_APPLY_JOIN_OTHER_AGENT,
teamMemberService.existsMember(cmd.requiredReqUserId()));
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE,
bdInviteAgentMessageService.updateStatus(cmd.getId(), message.getStatus(),
cmd.getStatus(), message.getGroup()));
if (Objects.equals(cmd.getStatus(), 1)) {
Long teamId = createTeam(cmd, message);

View File

@ -0,0 +1,97 @@
package com.red.circle.other.app.command.team;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.red.circle.framework.core.dto.ReqSysOrigin;
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.mq.rocket.business.producer.UserMqMessageService;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.cmd.team.DbInviteMessageProcessCmd;
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.model.user.UserProfile;
import com.red.circle.other.infra.database.mongo.entity.team.bd.BdInviteAgentMessage;
import com.red.circle.other.infra.database.mongo.service.team.bd.BdInviteAgentMessageService;
import com.red.circle.other.infra.database.mongo.service.team.team.TeamBillCycleService;
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.sys.AdministratorService;
import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService;
import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentTeamService;
import com.red.circle.other.infra.database.rds.service.team.UserHistoryIdentityService;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import org.junit.jupiter.api.Test;
class BdInviteMessageProcessExeTest {
@Test
void executeShouldAcceptLegacyBlankGroupMessage() {
TeamMemberService teamMemberService = mock(TeamMemberService.class);
UserProfileGateway userProfileGateway = mock(UserProfileGateway.class);
TeamProfileService teamProfileService = mock(TeamProfileService.class);
RegisterDeviceGateway registerDeviceGateway = mock(RegisterDeviceGateway.class);
TeamBillCycleService teamBillCycleService = mock(TeamBillCycleService.class);
UserProfileAppConvertor userProfileAppConvertor = mock(UserProfileAppConvertor.class);
UserHistoryIdentityService userHistoryIdentityService = mock(UserHistoryIdentityService.class);
BdInviteAgentMessageService bdInviteAgentMessageService = mock(BdInviteAgentMessageService.class);
BusinessDevelopmentTeamService businessDevelopmentTeamService =
mock(BusinessDevelopmentTeamService.class);
BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService =
mock(BusinessDevelopmentBaseInfoService.class);
UserMqMessageService userMqMessageService = mock(UserMqMessageService.class);
AdministratorService administratorService = mock(AdministratorService.class);
TaskMqMessage taskMqMessage = mock(TaskMqMessage.class);
BdInviteMessageProcessExe exe = new BdInviteMessageProcessExe(
teamMemberService,
userProfileGateway,
teamProfileService,
registerDeviceGateway,
teamBillCycleService,
userProfileAppConvertor,
userHistoryIdentityService,
bdInviteAgentMessageService,
businessDevelopmentTeamService,
businessDevelopmentBaseInfoService,
userMqMessageService,
administratorService,
taskMqMessage
);
DbInviteMessageProcessCmd cmd = new DbInviteMessageProcessCmd();
cmd.setId("legacy-msg");
cmd.setStatus(2);
cmd.setReqUserId(300L);
cmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI", "LIKEI"));
BdInviteAgentMessage message = new BdInviteAgentMessage();
message.setId("legacy-msg");
message.setGroup("");
message.setUserId(200L);
message.setInviteUserId(300L);
message.setStatus(0);
UserProfile userProfile = new UserProfile();
userProfile.setId(300L);
UserProfileDTO userProfileDTO = new UserProfileDTO();
userProfileDTO.setId(300L);
when(bdInviteAgentMessageService.getById("legacy-msg")).thenReturn(message);
when(teamMemberService.existsMember(300L)).thenReturn(false);
when(bdInviteAgentMessageService.updateStatus("legacy-msg", 0, 2, "")).thenReturn(true);
when(userProfileGateway.getByUserId(300L)).thenReturn(userProfile);
when(userProfileAppConvertor.toUserProfileDTO(userProfile)).thenReturn(userProfileDTO);
exe.execute(cmd);
verify(bdInviteAgentMessageService).updateStatus("legacy-msg", 0, 2, "");
verify(userProfileAppConvertor).toUserProfileDTO(userProfile);
verify(userMqMessageService, org.mockito.Mockito.never()).sendBadgeOperateEvent(any(), any(), any());
verify(businessDevelopmentTeamService, org.mockito.Mockito.never()).save(any());
verify(businessDevelopmentBaseInfoService, org.mockito.Mockito.never()).incrMemberCount(any());
}
}