diff --git a/rc-service/rc-service-external/external-infrastructure/src/main/java/com/red/circle/external/infra/common/OfficialNoticeCommonService.java b/rc-service/rc-service-external/external-infrastructure/src/main/java/com/red/circle/external/infra/common/OfficialNoticeCommonService.java index fb7a5a1f..20f8afbc 100644 --- a/rc-service/rc-service-external/external-infrastructure/src/main/java/com/red/circle/external/infra/common/OfficialNoticeCommonService.java +++ b/rc-service/rc-service-external/external-infrastructure/src/main/java/com/red/circle/external/infra/common/OfficialNoticeCommonService.java @@ -1,5 +1,6 @@ package com.red.circle.external.infra.common; +import com.alibaba.fastjson.JSON; import com.red.circle.component.instant.msg.tencet.notice.official.NoticeExtParam; import com.red.circle.component.instant.msg.tencet.service.endpoint.api.im.account.ImMessageManagerService; import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateAbstract; @@ -161,8 +162,8 @@ public class OfficialNoticeCommonService { : noticeTypeEnum.getTitle(locale); String content = Objects.nonNull(typeCmd.getTemplateParam()) - ? noticeTypeEnum.getBodyFormat(locale, typeCmd.getTemplateParam()) - : noticeTypeEnum.getBody(locale); + ? JSON.toJSONString(typeCmd.getTemplateParam()) + : ""; return NoticeExtParam.builder() .id(getId(cmd)) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AgentInviteHostExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AgentInviteHostExe.java index 08db0e56..0b3574b5 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AgentInviteHostExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AgentInviteHostExe.java @@ -72,8 +72,9 @@ public class AgentInviteHostExe { bdInviteAgentMessageService.existsWaitMessage(cmd.requiredReqUserId(), cmd.getInviteUserId(), MessageInviteGroup.AGENT_INVITE_HOST.name())); + String messageId = IdWorkerUtils.getIdStr(); bdInviteAgentMessageService.add(new BdInviteAgentMessage() - .setId(IdWorkerUtils.getIdStr()) + .setId(messageId) .setSysOrigin(cmd.requireReqSysOrigin()) .setUserId(cmd.requiredReqUserId()) .setInviteUserId(cmd.getInviteUserId()) @@ -85,7 +86,16 @@ public class AgentInviteHostExe { .setExpiredTime(TimestampUtils.nowPlusDays(2)) ); - sendMessage(cmd); + UserProfileDTO userProfileDTO = userProfileAppConvertor.toUserProfileDTO(userProfileGateway.getByUserId(cmd.requiredReqUserId())); + ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfileDTO); + + officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() + .toAccount(cmd.getInviteUserId()) + .noticeType(OfficialNoticeTypeEnum.AGENT_SEND_INVITE_HOST) + .templateParam(OfficialNoticeUtils.buildUserProfile(userProfileDTO)) + .expand(messageId) + .build() + ); } public List messageCOList(BdInviteQryCmd cmd) { @@ -131,6 +141,7 @@ public class AgentInviteHostExe { 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); ResponseAssert.isTrue(CommonErrorCode.NOT_FOUND_RECORD_INFO, @@ -189,19 +200,4 @@ public class AgentInviteHostExe { .build() ); } - - private void sendMessage(AgentInviteHostCmd cmd) { - UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(userProfileGateway.getByUserId(cmd.requiredReqUserId())); - ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile); -// String h5Url = enumConfigCacheService.getValue(EnumConfigKey.H5_DOMAIN_BASE_URL_V2,cmd.requireReqSysOrigin()); - - officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() - .toAccount(cmd.getInviteUserId()) - .noticeType(OfficialNoticeTypeEnum.AGENT_SEND_INVITE_HOST) - .templateParam(OfficialNoticeUtils.buildUserProfile(userProfile)) -// .expand(h5Url) - .build() - ); - } - } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdAgentInviteExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdAgentInviteExe.java index 336ee32c..35b0c181 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdAgentInviteExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdAgentInviteExe.java @@ -88,8 +88,9 @@ public class BdAgentInviteExe { // 校验邀请人与被邀请人的区域 checkInvite(cmd); + String messageId = IdWorkerUtils.getIdStr(); bdInviteAgentMessageService.add(new BdInviteAgentMessage() - .setId(IdWorkerUtils.getIdStr()) + .setId(messageId) .setSysOrigin(cmd.requireReqSysOrigin()) .setUserId(cmd.requiredReqUserId()) .setInviteUserId(cmd.getInviteUserId()) @@ -101,7 +102,18 @@ public class BdAgentInviteExe { .setExpiredTime(TimestampUtils.nowPlusDays(2)) ); - sendMessage(cmd); + UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( + userProfileGateway.getByUserId(cmd.requiredReqUserId()) + ); + ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile); + + officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() + .toAccount(cmd.getInviteUserId()) + .noticeType(OfficialNoticeTypeEnum.BD_SEND_INVITE_AGENT) + .templateParam(OfficialNoticeUtils.buildUserProfile(userProfile)) + .expand(messageId) + .build() + ); } public void cancel(String id) { @@ -153,17 +165,4 @@ public class BdAgentInviteExe { return CollectionUtils.isEmpty(teamMemberService.listMemberIds(userIds)); } - private void sendMessage(DbInviteAgentCmd cmd) { - UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( - userProfileGateway.getByUserId(cmd.requiredReqUserId()) - ); - ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile); - - officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() - .toAccount(cmd.getInviteUserId()) - .noticeType(OfficialNoticeTypeEnum.BD_SEND_INVITE_AGENT) - .templateParam(OfficialNoticeUtils.buildUserProfile(userProfile)) - .build() - ); - } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdInviteMessageProcessExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdInviteMessageProcessExe.java index 70a30e97..0fb8bff5 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdInviteMessageProcessExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdInviteMessageProcessExe.java @@ -9,6 +9,7 @@ import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.framework.core.response.ResponseErrorCode; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.cmd.team.DbInviteMessageProcessCmd; +import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.database.mongo.entity.team.bd.BdInviteAgentMessage; import com.red.circle.other.infra.database.mongo.entity.team.bd.MessageInviteGroup; @@ -72,6 +73,7 @@ public class BdInviteMessageProcessExe { 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); ResponseAssert.isTrue(CommonErrorCode.NOT_FOUND_RECORD_INFO, @@ -193,10 +195,7 @@ public class BdInviteMessageProcessExe { officialNoticeClient.send( NoticeExtTemplateTypeCmd.builder() .toAccount(message.getUserId()) - .templateParam(MapBuilder.builder() - .put("userProfile", String.format("%s(%s)", userProfile.getUserNickname(), - userProfile.actualAccount())) - .build()) + .templateParam(OfficialNoticeUtils.buildUserProfile(userProfile)) .noticeType(noticeTypeEnum) .build() ); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdLeaderInviteBdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdLeaderInviteBdExe.java index fe49c983..123c0659 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdLeaderInviteBdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/BdLeaderInviteBdExe.java @@ -8,6 +8,7 @@ import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.cmd.team.DbLeaderInviteBdCmd; +import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.mongo.entity.team.bd.BdInviteAgentMessage; @@ -68,8 +69,9 @@ public class BdLeaderInviteBdExe { bdInviteAgentMessageService.existsWaitMessage(cmd.requiredReqUserId(), cmd.getInviteUserId(), MessageInviteGroup.BD_LEADER_INVITE_BD.name())); + String messageId = IdWorkerUtils.getIdStr(); bdInviteAgentMessageService.add(new BdInviteAgentMessage() - .setId(IdWorkerUtils.getIdStr()) + .setId(messageId) .setSysOrigin(cmd.requireReqSysOrigin()) .setUserId(cmd.requiredReqUserId()) .setInviteUserId(cmd.getInviteUserId()) @@ -81,7 +83,18 @@ public class BdLeaderInviteBdExe { .setExpiredTime(TimestampUtils.nowPlusDays(2)) ); - sendMessage(cmd); + UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( + userProfileGateway.getByUserId(cmd.requiredReqUserId()) + ); + + officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() + .toAccount(cmd.getInviteUserId()) + .noticeType(OfficialNoticeTypeEnum.BD_LEADER_SEND_INVITE_BD) + .templateParam(OfficialNoticeUtils.buildUserProfile(userProfile)) + .expand(messageId) + .build() + ); + } private BusinessDevelopmentBaseInfo getDevelopmentBaseInfoServiceByUserId( @@ -89,25 +102,4 @@ public class BdLeaderInviteBdExe { return businessDevelopmentBaseInfoService.getByUserId(cmd.getInviteUserId()); } - private void sendMessage(DbLeaderInviteBdCmd cmd) { - UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( - userProfileGateway.getByUserId(cmd.requiredReqUserId()) - ); - ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile); - - String h5Url = enumConfigCacheService.getValue(EnumConfigKey.H5_DOMAIN_BASE_URL_V2, - cmd.requireReqSysOrigin()); - if (StringUtils.isBlank(h5Url)) { - return; - } - officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() - .toAccount(cmd.getInviteUserId()) - .noticeType(OfficialNoticeTypeEnum.BD_LEADER_SEND_INVITE_BD) - .templateParam(Map.of("userProfile", String.format("%s(%s)", userProfile.getUserNickname(), - userProfile.actualAccount()))) - .expand(h5Url + "/team/bd") - .build() - ); - - } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/util/OfficialNoticeUtils.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/util/OfficialNoticeUtils.java index 778a7844..30ab10d5 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/util/OfficialNoticeUtils.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/util/OfficialNoticeUtils.java @@ -10,7 +10,8 @@ public class OfficialNoticeUtils { public static Map buildUserProfile(UserProfileDTO userProfile) { return MapBuilder.builder() .put("userNickname", userProfile.getUserNickname()) - .put("account", userProfile.actualAccount()) + .put("account", userProfile.getAccount()) + .put("actualAccount", userProfile.actualAccount()) .put("userAvatar", userProfile.getUserAvatar()) .put("countryCode", userProfile.getCountryCode()) .put("countryName", userProfile.getCountryName())