From c76526d3c0ca5a40681318a329443f2f5735cf75 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 12 Nov 2025 16:28:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=AB=E7=AE=AD=E6=B6=88=E6=81=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gift/OfflineStatisticsGiftEventType.java | 7 +- .../app/listener/GiftSendRocketListener.java | 72 ------------------- .../gift/strategy/GiftSendRocketListener.java | 29 ++++++++ .../app/manager/RocketImPushManager.java | 28 ++++++-- .../src/test/java/UserDataViolationTest.java | 2 +- 5 files changed, 58 insertions(+), 80 deletions(-) delete mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/GiftSendRocketListener.java create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftSendRocketListener.java diff --git a/rc-common-business/common-business-mq/business-mq-model/src/main/java/com/red/circle/mq/business/model/event/gift/OfflineStatisticsGiftEventType.java b/rc-common-business/common-business-mq/business-mq-model/src/main/java/com/red/circle/mq/business/model/event/gift/OfflineStatisticsGiftEventType.java index aff8952f..7aeb834d 100644 --- a/rc-common-business/common-business-mq/business-mq-model/src/main/java/com/red/circle/mq/business/model/event/gift/OfflineStatisticsGiftEventType.java +++ b/rc-common-business/common-business-mq/business-mq-model/src/main/java/com/red/circle/mq/business/model/event/gift/OfflineStatisticsGiftEventType.java @@ -30,6 +30,11 @@ public enum OfflineStatisticsGiftEventType { /** * 钻石统计. */ - DIAMOND_COUNT + DIAMOND_COUNT, + + /** + * 火箭统计 + */ + ROCKET_COUNT, } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/GiftSendRocketListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/GiftSendRocketListener.java deleted file mode 100644 index f8f067d8..00000000 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/GiftSendRocketListener.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.red.circle.other.app.listener; - -import com.red.circle.other.app.dto.cmd.RocketEnergyAddCmd; -import com.red.circle.other.app.service.RocketService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -/** - * 礼物送出事件监听器 - 触发火箭能量增加 - * - * @author system - * @date 2025-01-15 - */ -@Slf4j -@Component -@RequiredArgsConstructor -public class GiftSendRocketListener { - - private final RocketService rocketService; - - /** - * 监听礼物送出事件 - * 注意:需要项目中实际的GiftSendEvent类,这里使用占位符 - */ -// @Async("rocketExecutor") -// @EventListener - public void onGiftSend(Object event) { - // TODO: 替换为实际的GiftSendEvent类型 - // 示例代码,需要根据实际事件结构调整 - - /* - try { - // 1. 从事件中提取数据 - Long roomId = event.getRoomId(); - Long userId = event.getUserId(); - Long giftGoldValue = event.getGiftGoldValue(); - Boolean isLucky = event.getIsLuckyGift(); - String giftOrderId = event.getGiftOrderId(); - - // 2. 构建命令 - RocketEnergyAddCmd cmd = new RocketEnergyAddCmd(); - cmd.setRoomId(roomId); - cmd.setUserId(userId); - cmd.setGiftGoldValue(giftGoldValue); - cmd.setIsLucky(isLucky != null && isLucky); - cmd.setBizNo("GIFT_" + giftOrderId); - - // 3. 执行能量增加 - rocketService.addEnergy(cmd); - - log.info("礼物事件触发火箭能量增加成功: roomId={}, userId={}, energy={}", - roomId, userId, giftGoldValue); - - } catch (Exception e) { - log.error("礼物事件触发火箭能量增加失败", e); - } - */ - - log.warn("GiftSendRocketListener: 需要接入实际的礼物送出事件"); - } - - /** - * 说明: - * 1. 需要在项目中找到实际的礼物送出事件类(可能在live-service或other-service中) - * 2. 替换方法参数中的 Object 为实际的事件类型 - * 3. 根据实际事件结构提取 roomId、userId、giftGoldValue 等字段 - * 4. 确保事件中包含 isLuckyGift 字段或通过其他方式判断是否幸运礼物 - */ -} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftSendRocketListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftSendRocketListener.java new file mode 100644 index 00000000..440cb5be --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftSendRocketListener.java @@ -0,0 +1,29 @@ +package com.red.circle.other.app.listener.gift.strategy; + +import com.red.circle.mq.business.model.event.gift.OfflineProcessGiftEvent; +import com.red.circle.other.app.service.RocketService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +/** + * 火箭统计相关 + * + * @author system + * @date 2025-01-15 + */ +@Slf4j +@Service("ROCKET_COUNT_LISTENER") +@RequiredArgsConstructor +public class GiftSendRocketListener implements GiftStrategy { + + private final RocketService rocketService; + + + @Override + public void processor(OfflineProcessGiftEvent event) { + + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/manager/RocketImPushManager.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/manager/RocketImPushManager.java index 3e70af6b..ebfc57b8 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/manager/RocketImPushManager.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/manager/RocketImPushManager.java @@ -1,7 +1,16 @@ package com.red.circle.other.app.manager; import com.alibaba.fastjson.JSON; +import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; +import com.red.circle.external.inner.endpoint.message.ImGroupClient; +import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; +import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd; +import com.red.circle.external.inner.model.cmd.message.CustomGroupMsgBodyCmd; +import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; +import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum; +import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; import com.red.circle.other.app.dto.clientobject.RocketStatusCO; +import com.red.circle.other.app.util.OfficialNoticeUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -17,8 +26,7 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor public class RocketImPushManager { - // TODO: 注入实际的IM推送服务 - // private final ImPushService imPushService; + private final ImGroupClient imGroupClient; /** * 推送能量更新消息 @@ -28,8 +36,11 @@ public class RocketImPushManager { // 构建消息 ImMessage message = buildEnergyUpdateMessage(status); - // TODO: 调用实际的IM推送服务 - // imPushService.pushToRoom(roomId, message); + imGroupClient.sendCustomMessage(String.valueOf(roomId), + CustomGroupMsgBodyCmd.builder() + .type(GroupMessageTypeEnum.GAME_LUCKY_GIFT) + .data(message) + .build()); log.info("推送火箭能量更新消息成功: roomId={}, level={}, energy={}/{}", roomId, status.getLevel(), status.getCurrentEnergy(), status.getMaxEnergy()); @@ -47,8 +58,13 @@ public class RocketImPushManager { // 构建消息 ImMessage message = buildLaunchMessage(status); - // TODO: 调用实际的IM推送服务 - // imPushService.pushToRoom(roomId, message); + imGroupClient.sendMessageBroadcast( + BroadcastGroupMsgBodyCmd.builder() + .toPlatform(SysOriginPlatformEnum.LIKEI) + .type(GroupMessageTypeEnum.GAME_LUCKY_GIFT) + .data(message) + .build() + ); log.info("推送火箭发射消息成功: roomId={}, level={}", roomId, status.getLevel()); diff --git a/rc-service/rc-service-other/other-start/src/test/java/UserDataViolationTest.java b/rc-service/rc-service-other/other-start/src/test/java/UserDataViolationTest.java index 71eab2b4..36e5940b 100644 --- a/rc-service/rc-service-other/other-start/src/test/java/UserDataViolationTest.java +++ b/rc-service/rc-service-other/other-start/src/test/java/UserDataViolationTest.java @@ -177,7 +177,7 @@ public class UserDataViolationTest { @Test public void batchBanUsers() { // TODO: 修改为你实际的文件路径 - String inputFilePath = "C:\\Users\\Administrator\\Documents\\DataGripSql\\11.11同设备指纹用户统计英文版 - 副本.xlsx"; + String inputFilePath = "C:\\Users\\Administrator\\Documents\\DataGripSql\\11.11同设备指纹用户统计英文版.xlsx"; String outputFilePath = "D:\\ban_results_" + System.currentTimeMillis() + ".xlsx"; try {