新增bdleader 邀请 bdleader 功能

This commit is contained in:
tianfeng 2025-11-06 20:10:21 +08:00
parent 3c316cdb15
commit 898d1e593e
9 changed files with 194 additions and 29 deletions

View File

@ -165,7 +165,12 @@ public enum OfficialNoticeTypeEnum {
/**
* BD LEADER发出BD邀请.
*/
BD_LEADER_SEND_INVITE_BD,
BD_LEADER_INVITE_BD,
/**
* BD LEADER发出BDLEADER邀请.
*/
BD_LEADER_INVITE_BD_LEADER,
/**
* 用户拒绝BD LEADER成为BD邀请.

View File

@ -223,6 +223,10 @@ public enum TeamErrorCode implements IResponseErrorCode {
*/
QUIT_DATE_INVALID(6051, "The host can only leave the current agency on the 1st and 16th of each month"),
/**
* 用户不是BD Leader
*/
USER_NOT_BDLEADER(6052, "User is not BD Leader"),
;
private final Integer code;

View File

@ -92,6 +92,12 @@ public enum TeamAppProcessApprovalReason {
* 接受成为BD邀请.
*/
ACCEPT_BD_INVITE,
/**
* 接受成为BDLEADER邀请.
*/
ACCEPT_BDLEADER_INVITE,
/**
* 成员退出-后台.
*/

View File

@ -193,6 +193,74 @@ public class TeamBdRestController extends BaseController {
teamBdService.processBdLeaderInviteMessage(cmd);
}
// ===================================================================================
/**
* 邀请BDLEADER
*
* @eo.name 邀请成为BD-邀请BD.
* @eo.url /invite-bd
* @eo.method post
* @eo.request-type json
*/
@PostMapping("/invite-bdleader")
public void inviteBdLeader(@RequestBody @Validated DbLeaderInviteBdCmd cmd) {
teamBdService.inviteBdleader(cmd);
}
/**
* 获取被BDLEADER邀请消息
*
* @eo.name 获取被BDLEADER邀请消息-邀请BD.
* @eo.url /invite-bd-message
* @eo.method get
* @eo.request-type formdata
*/
@GetMapping("/invite-bdleader-message")
public List<BdInviteMessageCO> listInviteBdleaderMessage(BdInviteQryCmd cmd) {
cmd.setGroup(MessageInviteGroup.BD_LEADER_INVITE_BD_LEADER.name());
return teamBdService.listBdInviteMessage(cmd);
}
/**
* 获取邀请BDLEADER的消息
*
* @eo.name 获取被BDLEADER邀请消息-邀请BD.
* @eo.url /invite-bd-message
* @eo.method get
* @eo.request-type formdata
*/
@GetMapping("/invite-bdleader-message-own")
public List<BdInviteMessageCO> listInviteBdleaderMessageOwn(BdInviteQryCmd cmd) {
cmd.setGroup(MessageInviteGroup.BD_LEADER_INVITE_BD_LEADER.name());
return teamBdService.listBdInviteMessageOwn(cmd);
}
/**
* 邀请BDLEADER-撤销
*/
@PostMapping("/invite-bdleader-cancel/{id}")
public void inviteBdleaderCancel(@PathVariable("id") String id) {
teamBdService.inviteAgentCancel(id);
}
/**
* 处理邀请BDLEADER.
*
* @eo.name 处理邀请-邀请BD.
* @eo.url /invite-bd-message-process
* @eo.method post
* @eo.request-type json
*/
@PostMapping("/invite-bdleader-message-process")
public void processInviteBdleaderMessage(@RequestBody @Validated DbInviteMessageProcessCmd cmd) {
teamBdService.processBdLeaderInviteMessage2(cmd);
}
// ===================================================================================
/**
* Bd邀请成为代理-邀请代理.
*

View File

@ -87,13 +87,57 @@ public class BdLeaderInviteBdExe {
userProfileGateway.getByUserId(cmd.requiredReqUserId())
);
/*officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder()
officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder()
.toAccount(cmd.getInviteUserId())
.noticeType(OfficialNoticeTypeEnum.BD_LEADER_SEND_INVITE_BD)
.noticeType(OfficialNoticeTypeEnum.BD_LEADER_INVITE_BD)
.templateParam(OfficialNoticeUtils.buildUserProfile(userProfile))
.expand(messageId)
.build()
);*/
);
}
public void executeBdleader(DbLeaderInviteBdCmd cmd) {
// 权限不足
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
roomBdLeadService.checkBdLeader(cmd.requiredReqUserId()));
// 权限不足
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
roomBdLeadService.checkBdLeader(cmd.getInviteUserId()));
// 消息已发送
ResponseAssert.isFalse(TeamErrorCode.MESSAGE_PROCESSED,
bdInviteAgentMessageService.existsWaitMessage(cmd.requiredReqUserId(),
cmd.getInviteUserId(), MessageInviteGroup.BD_LEADER_INVITE_BD_LEADER.name()));
String messageId = IdWorkerUtils.getIdStr();
bdInviteAgentMessageService.add(new BdInviteAgentMessage()
.setId(messageId)
.setSysOrigin(cmd.requireReqSysOrigin())
.setUserId(cmd.requiredReqUserId())
.setInviteUserId(cmd.getInviteUserId())
.setMessage(cmd.getMessage())
.setGroup(MessageInviteGroup.BD_LEADER_INVITE_BD_LEADER.name())
.setCreateTime(TimestampUtils.now())
.setUpdateTime(TimestampUtils.now())
.setStatus(0)
.setExpiredTime(TimestampUtils.nowPlusDays(2))
);
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
userProfileGateway.getByUserId(cmd.requiredReqUserId())
);
officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder()
.toAccount(cmd.getInviteUserId())
.noticeType(OfficialNoticeTypeEnum.BD_LEADER_INVITE_BD_LEADER)
.templateParam(OfficialNoticeUtils.buildUserProfile(userProfile))
.expand(messageId)
.build()
);
}

View File

@ -101,34 +101,47 @@ public class BdLeaderInviteMessageProcessExe {
);
userHistoryIdentityService.saveBd(cmd.requiredReqUserId());
sendMessage(message, OfficialNoticeTypeEnum.AGREE_BD_LEADER_INVITE_AGENT);
return;
}
sendMessage(message, OfficialNoticeTypeEnum.REFUSE_BD_LEADER_INVITE_AGENT);
}
private void sendMessage(BdInviteAgentMessage message, OfficialNoticeTypeEnum noticeTypeEnum) {
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
userProfileGateway.getByUserId(message.getInviteUserId())
);
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile);
NoticeExtTemplateTypeCmd userProfile1 = NoticeExtTemplateTypeCmd.builder()
.toAccount(message.getUserId())
.noticeType(noticeTypeEnum)
.templateParam(MapBuilder.builder()
.put("userProfile", String.format("%s(%s)", userProfile.getUserNickname(),
userProfile.actualAccount()))
.build())
.build();
/*officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder()
.toAccount(message.getUserId())
.noticeType(noticeTypeEnum)
.templateParam(MapBuilder.builder()
.put("userProfile", String.format("%s(%s)", userProfile.getUserNickname(),
userProfile.actualAccount()))
.build())
.build());*/
public void executeBdleader(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.NOT_FOUND_RECORD_INFO,
Objects.equals(message.getGroup(), MessageInviteGroup.BD_LEADER_INVITE_BD_LEADER.name()));
ResponseAssert
.isTrue(TeamErrorCode.USER_NOT_BDLEADER,
roomBdLeadService.checkBdLeader(cmd.requiredReqUserId()));
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
Objects.equals(message.getInviteUserId(), cmd.requiredReqUserId()));
ResponseAssert.isTrue(TeamErrorCode.MESSAGE_PROCESSED, Objects.equals(message.getStatus(), 0));
RoomBdLead roomBdLead = roomBdLeadService.getByUserId(message.getUserId());
ResponseAssert.notNull(TeamErrorCode.USER_IS_NOT_BD, roomBdLead);
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, bdInviteAgentMessageService.
updateStatus(cmd.getId(), message.getStatus(), cmd.getStatus(),
MessageInviteGroup.BD_LEADER_INVITE_BD.name()));
if (Objects.equals(cmd.getStatus(), 1)) {
teamApplicationProcessApprovalService.add(new TeamApplicationProcessApproval()
.setSysOrigin(cmd.requireReqSysOrigin())
.setType(TeamApplicationType.BD)
.setReason(TeamAppProcessApprovalReason.ACCEPT_BDLEADER_INVITE)
.setAssociateId(message.getUserId())
.setBeProcessUserId(message.getInviteUserId())
.setCreateTime(TimestampUtils.now())
.setCreateUser(cmd.requiredReqUserId())
.setCreateUserOrigin(0)
);
}
}
}

View File

@ -95,11 +95,21 @@ public class TeamBdServiceImpl implements TeamBdService {
bdLeaderInviteBdCmdExe.execute(cmd);
}
@Override
public void inviteBdleader(DbLeaderInviteBdCmd cmd) {
bdLeaderInviteBdCmdExe.executeBdleader(cmd);
}
@Override
public void processBdLeaderInviteMessage(DbInviteMessageProcessCmd cmd) {
bdLeaderInviteMessageProcessCmdExe.execute(cmd);
}
@Override
public void processBdLeaderInviteMessage2(DbInviteMessageProcessCmd cmd) {
bdLeaderInviteMessageProcessCmdExe.executeBdleader(cmd);
}
@Override
public void inviteAgent(DbInviteAgentCmd cmd) {
bdAgentInviteCmdExe.execute(cmd);

View File

@ -71,11 +71,21 @@ public interface TeamBdService {
*/
void inviteBd(DbLeaderInviteBdCmd cmd);
/**
* 邀请成为BDLEADER-邀请BDLEADER.
*/
void inviteBdleader(DbLeaderInviteBdCmd cmd);
/**
* 处理邀请消息-邀请BD.
*/
void processBdLeaderInviteMessage(DbInviteMessageProcessCmd cmd);
/**
* 处理BDLEADER邀请BDLEADER消息
*/
void processBdLeaderInviteMessage2(DbInviteMessageProcessCmd cmd);
/**
* 邀请成为代理-邀请代理.
*/

View File

@ -7,6 +7,11 @@ package com.red.circle.other.infra.database.mongo.entity.team.bd;
*/
public enum MessageInviteGroup {
/**
* bd leader 邀请 bdleader
*/
BD_LEADER_INVITE_BD_LEADER,
/**
* bd 邀请代理.
*/