From b1cbd6b81f10f1a1c64e01ebaf04995bef83a3ec Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 2 Feb 2026 14:06:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=B6=88=E6=81=AF=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/enums/DynamicMessageEnum.java | 5 +++++ .../command/dynamic/DynamicCommentCmdExe.java | 6 ++++-- .../dynamic/DynamicCommentLikeCmdExe.java | 18 ++++++++++++++++++ .../app/command/dynamic/DynamicLikeCmdExe.java | 17 +++++++++++++++++ .../dynamic/query/DynamicMessageQryExe.java | 2 +- .../gift/strategy/GiftCountStrategy.java | 14 +++++++++++++- .../app/dto/cmd/dynamic/DynamicLimitCmd.java | 5 +++++ .../rds/entity/dynamic/DynamicMessage.java | 6 ++++++ .../service/dynamic/DynamicMessageService.java | 2 +- .../impl/DynamicMessageServiceImpl.java | 12 +++++------- 10 files changed, 75 insertions(+), 12 deletions(-) diff --git a/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/DynamicMessageEnum.java b/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/DynamicMessageEnum.java index d20e9cad..445b8cfb 100644 --- a/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/DynamicMessageEnum.java +++ b/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/DynamicMessageEnum.java @@ -29,6 +29,11 @@ public enum DynamicMessageEnum { */ LIKE_COMMENT, + /** + * 动态礼物 + */ + DYNAMIC_GIFT, + /** * 驳回举报. */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentCmdExe.java index 880c3b7c..67a2f755 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentCmdExe.java @@ -82,10 +82,12 @@ public class DynamicCommentCmdExe { //评论不属于自己的动态,发送消息 if (Objects.isNull(cmd.getToUserId())) { cmd.setToUserId(dynamicContent.getCreateUser()); + saveDynamicMessage(cmd, DynamicMessageEnum.COMMENT_DYNAMIC); + } else { + //发送消息给动态被回复人 + saveDynamicMessage(cmd, DynamicMessageEnum.REPLY_COMMENT); } - //发送消息给动态被回复人 - saveDynamicMessage(cmd, DynamicMessageEnum.REPLY_COMMENT); return convert(dynamicComment, userProfileMap); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentLikeCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentLikeCmdExe.java index 4702b395..35982b71 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentLikeCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicCommentLikeCmdExe.java @@ -2,14 +2,17 @@ package com.red.circle.other.app.command.dynamic; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.common.business.enums.DynamicMessageEnum; import com.red.circle.other.app.common.room.DynamicCommon; import com.red.circle.other.app.dto.cmd.dynamic.DynamicLikeCmd; import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService; import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicCommentLike; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent; +import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicMessage; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentLikeService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService; +import com.red.circle.other.infra.database.rds.service.dynamic.DynamicMessageService; import com.red.circle.other.inner.asserts.DynamicErrorCode; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.num.NumUtils; @@ -35,6 +38,7 @@ public class DynamicCommentLikeCmdExe { private final DynamicContentService dynamicContentService; private final DynamicPopularService dynamicPopularService; private final DynamicCommentLikeService dynamicCommentLikeService; + private final DynamicMessageService dynamicMessageService; public Long execute(DynamicLikeCmd cmd) { @@ -52,6 +56,9 @@ public class DynamicCommentLikeCmdExe { //热门权重 updateScore(cmd, content, 1); + // 保存点赞评论消息 + saveDynamicMessage(cmd, DynamicMessageEnum.LIKE_COMMENT); + dynamicCommon.sendMsg(cmd.getToUserId()); return getIncrQuantity(cmd); } @@ -119,5 +126,16 @@ public class DynamicCommentLikeCmdExe { .exist(cmd.getDynamicId(), cmd.getCommentId(), cmd.getReqUserId()); } + private void saveDynamicMessage(DynamicLikeCmd cmd, DynamicMessageEnum type) { + DynamicMessage message = new DynamicMessage(); + message.setId(IdWorkerUtils.getId()); + message.setDynamicContentId(cmd.getDynamicId()); + message.setDynamicCommentId(cmd.getCommentId()); + message.setType(type.name()); + message.setToUserId(cmd.getToUserId()); + message.setCreateTime(TimestampUtils.now()); + message.setCreateUser(cmd.getReqUserId()); + dynamicMessageService.save(message); + } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicLikeCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicLikeCmdExe.java index 0fa38548..f18ee87b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicLikeCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicLikeCmdExe.java @@ -1,14 +1,17 @@ package com.red.circle.other.app.command.dynamic; import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.common.business.enums.DynamicMessageEnum; import com.red.circle.other.app.common.room.DynamicCommon; import com.red.circle.other.app.dto.cmd.dynamic.DynamicLikeCmd; import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService; import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicLike; +import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicMessage; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicLikeService; +import com.red.circle.other.infra.database.rds.service.dynamic.DynamicMessageService; import com.red.circle.other.inner.asserts.DynamicErrorCode; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.num.NumUtils; @@ -34,6 +37,7 @@ public class DynamicLikeCmdExe { private final DynamicCacheService dynamicCacheService; private final DynamicContentService dynamicContentService; private final DynamicPopularService dynamicPopularService; + private final DynamicMessageService dynamicMessageService; public Long execute(DynamicLikeCmd cmd) { @@ -55,6 +59,9 @@ public class DynamicLikeCmdExe { dynamicPopularService.updateScore(content.getId(), dynamicCacheService.getLikeScore(), cmd.getReqSysOrigin().getOrigin(), content.getRegion()); + // 保存点赞动态消息 + saveDynamicMessage(cmd, content, DynamicMessageEnum.LIKE_DYNAMIC); + dynamicCommon.sendMsg(content.getCreateUser()); return quantity; } @@ -99,5 +106,15 @@ public class DynamicLikeCmdExe { return dynamicLikeService.exist(cmd.getDynamicId(), cmd.getReqUserId()); } + private void saveDynamicMessage(DynamicLikeCmd cmd, DynamicContent content, DynamicMessageEnum type) { + DynamicMessage message = new DynamicMessage(); + message.setId(IdWorkerUtils.getId()); + message.setDynamicContentId(cmd.getDynamicId()); + message.setType(type.name()); + message.setToUserId(content.getCreateUser()); + message.setCreateTime(TimestampUtils.now()); + message.setCreateUser(cmd.getReqUserId()); + dynamicMessageService.save(message); + } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java index cf8eda17..c6026087 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java @@ -85,7 +85,7 @@ public class DynamicMessageQryExe { } private PageResult getMessages(DynamicLimitCmd cmd) { - return dynamicMessageService.pageByTimeDesc(cmd.getPageReq(), cmd.getReqUserId()); + return dynamicMessageService.pageByTimeDesc(cmd.getPageReq(), cmd.getReqUserId(), cmd.getDynamicMessageEnums()); } private Set getUserIds(PageResult messages) { diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java index c7b9639f..85fe912a 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.google.common.collect.Lists; import com.red.circle.common.business.core.enums.GameStateEnum; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; +import com.red.circle.common.business.enums.DynamicMessageEnum; import com.red.circle.component.redis.service.RedisService; import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; @@ -43,6 +44,8 @@ import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManager import com.red.circle.other.infra.database.mongo.service.sys.ActivityConfigService; import com.red.circle.other.infra.database.mongo.service.user.count.UserGuardCountService; import com.red.circle.other.infra.database.mongo.service.user.count.WeekFriendshipCardCountService; +import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent; +import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicMessage; import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkIntegralRecord; import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkRecord; import com.red.circle.other.infra.database.rds.entity.user.user.ConfessionChance; @@ -52,6 +55,7 @@ import com.red.circle.other.infra.database.rds.entity.user.user.CpValue; import com.red.circle.other.infra.database.rds.entity.user.user.FriendshipCard; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicGiftService; +import com.red.circle.other.infra.database.rds.service.dynamic.DynamicMessageService; import com.red.circle.other.infra.database.rds.service.game.GameRoomPkIntegralRecordService; import com.red.circle.other.infra.database.rds.service.game.GameRoomPkRecordService; import com.red.circle.other.infra.database.rds.service.live.RoomContributionBalanceService; @@ -135,6 +139,7 @@ public class GiftCountStrategy implements GiftStrategy { private final RedisService redisService; private final DynamicContentService dynamicContentService; private final DynamicGiftService dynamicGiftService; + private final DynamicMessageService dynamicMessageService; private static final List inRegionCodes = List.of("IN", "PK", "BD"); private final UserRegionCacheService userRegionCacheService; @@ -729,7 +734,7 @@ public class GiftCountStrategy implements GiftStrategy { } // 验证动态是否存在 - com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent dynamicContent = + DynamicContent dynamicContent = dynamicContentService.getById(runningWater.getDynamicContentId()); if (dynamicContent == null || Boolean.TRUE.equals(dynamicContent.getDel())) { @@ -757,6 +762,13 @@ public class GiftCountStrategy implements GiftStrategy { giftValue.getUnitPrice() ); + dynamicMessageService.save( + runningWater.getGiftId() + " * " + giftValue.getQuantity(), + Long.parseLong(runningWater.getDynamicContentId()), + dynamicContent.getCreateUser(), + DynamicMessageEnum.DYNAMIC_GIFT + ); + } catch (Exception e) { log.error("处理动态礼物失败", e); } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicLimitCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicLimitCmd.java index ba54b3d3..ed29cf25 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicLimitCmd.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicLimitCmd.java @@ -2,9 +2,12 @@ package com.red.circle.other.app.dto.cmd.dynamic; import com.red.circle.common.business.dto.PageReq; import com.red.circle.common.business.dto.cmd.AppExtCommand; +import com.red.circle.common.business.enums.DynamicMessageEnum; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + /** * 动态-内容分页. * @@ -20,4 +23,6 @@ public class DynamicLimitCmd extends AppExtCommand { */ private PageReq pageReq; + private List dynamicMessageEnums; + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/dynamic/DynamicMessage.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/dynamic/DynamicMessage.java index 051a8b47..3b784914 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/dynamic/DynamicMessage.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/dynamic/DynamicMessage.java @@ -39,6 +39,12 @@ public class DynamicMessage extends TimestampBaseEntity { @TableField("dynamic_content_id") private Long dynamicContentId; + /** + * 动态评论ID + */ + @TableField("dynamic_comment_id") + private Long dynamicCommentId; + /** * 内容. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicMessageService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicMessageService.java index f7d9db2e..aeeb4228 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicMessageService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicMessageService.java @@ -46,7 +46,7 @@ public interface DynamicMessageService extends BaseService { * @param pageNumber 第几页 * @param toUserId 被评价人或点赞ID */ - PageResult pageByTimeDesc(PageQuery pageQuery, Long toUserId); + PageResult pageByTimeDesc(PageQuery pageQuery, Long toUserId, List dynamicMessageEnums); /** * 我的消息列表统计 diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicMessageServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicMessageServiceImpl.java index 29103f58..11bb56e3 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicMessageServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicMessageServiceImpl.java @@ -11,12 +11,8 @@ import com.red.circle.other.infra.database.rds.service.dynamic.DynamicMessageSer 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 java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; + +import java.util.*; import java.util.stream.Collectors; import org.springframework.stereotype.Service; @@ -93,11 +89,13 @@ public class DynamicMessageServiceImpl extends } @Override - public PageResult pageByTimeDesc(PageQuery pageQuery, Long toUserId) { + public PageResult pageByTimeDesc(PageQuery pageQuery, Long toUserId, List dynamicMessageEnums) { return query() .eq(DynamicMessage::getToUserId, toUserId) .eq(DynamicMessage::getDel, Boolean.FALSE) + .in(dynamicMessageEnums != null, DynamicMessage::getType, + dynamicMessageEnums != null ? dynamicMessageEnums.stream().map(Enum::name).toList() : Collections.emptyList()) .orderByDesc(DynamicMessage::getCreateTime) .page(pageQuery); }