From 9a11b8e5fc578eccbc3b6e01a1ee9b400a1eb7e7 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 5 Mar 2026 12:00:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E9=87=91=E5=B8=81=E7=B4=AF?= =?UTF-8?q?=E8=AE=A1=E9=80=BB=E8=BE=91=E6=9B=B4=E6=94=B9=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=82=80=E8=AF=B7=E4=B8=8A=E9=BA=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/mic/LiveMicGoUpCmdExe.java | 40 ++++++++++++++++++- .../gift/strategy/GiftCountStrategy.java | 16 ++++---- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/mic/LiveMicGoUpCmdExe.java b/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/mic/LiveMicGoUpCmdExe.java index 52f3c3af..148a3441 100644 --- a/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/mic/LiveMicGoUpCmdExe.java +++ b/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/mic/LiveMicGoUpCmdExe.java @@ -1,5 +1,6 @@ package com.red.circle.live.app.command.mic; +import com.red.circle.component.redis.service.RedisService; import com.red.circle.external.inner.endpoint.message.TrtcClient; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.live.app.convertor.LiveMicAppConvertor; @@ -9,7 +10,14 @@ import com.red.circle.live.domain.gateway.LiveMicrophoneGateway; import com.red.circle.live.domain.live.dto.LiveMicrophoneNoticeDTO; import com.red.circle.live.infra.database.cache.service.UserAgoraTokenCacheService; import com.red.circle.live.infra.database.mongo.service.LiveMicSettingService; +import com.red.circle.live.infra.util.DateTimeAsiaRiyadhUtils; import com.red.circle.live.inner.error.LiveMicErrorCode; +import com.red.circle.other.inner.endpoint.live.RoomManagerClient; +import com.red.circle.other.inner.endpoint.task.RoomDailyTaskClient; +import com.red.circle.other.inner.enums.task.RoomDailyTaskCode; +import com.red.circle.other.inner.model.cmd.task.RoomDailyTaskProgressUpdateInnerCmd; +import com.red.circle.other.inner.model.dto.live.RoomProfileDTO; +import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +42,9 @@ public class LiveMicGoUpCmdExe { private final LiveMicrophoneGateway liveMicrophoneGateway; private final TrtcClient trtcClient; private final UserAgoraTokenCacheService userAgoraTokenCacheService; - + private final RedisService redisService; + private final RoomDailyTaskClient roomDailyTaskClient; + private final RoomManagerClient roomManagerClient; public LiveMicrophoneCO execute(MicUpDownCmd cmd) { checkPermissions(cmd); @@ -53,9 +63,37 @@ public class LiveMicGoUpCmdExe { notice.setRoomToken(roomToken); } //notice.setRoomToken(createAgoraTokenGoUp(cmd)); + + handleRoomDailyTask(cmd); + return notice; } + private void handleRoomDailyTask(MicUpDownCmd cmd) { + try { + boolean invite = cmd.eventTypeEqInvite(); + if (invite) { + RoomProfileDTO roomProfile = roomManagerClient.getById(cmd.getRoomId()).getBody(); + Long roomOwnerId = roomProfile.getUserId(); + handleInviteMicTask(roomOwnerId, RoomDailyTaskCode.ROOM_OWNER_INVITE_MIC); + } + } catch (Exception exception){ + log.error("handleRoomDailyTask exception: {}", exception.getMessage()); + } + } + + private void handleInviteMicTask(Long roomOwnerId, RoomDailyTaskCode taskCode) { + String redisKey = "room:daily:task:progress:" + taskCode.name() + ":" + roomOwnerId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate(); + Long total = redisService.increment(redisKey, 1); + redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS); + roomDailyTaskClient.updateTaskProgress( + new RoomDailyTaskProgressUpdateInnerCmd() + .setUserId(roomOwnerId) + .setTaskCode(taskCode.name()) + .setProgressValue(total.intValue()) + ); + } + private LiveMicrophoneCO returnMicrophoneCO(MicUpDownCmd cmd, LiveMicrophoneNoticeDTO notice) { return liveMicAppConvertor.toLiveMicrophoneCO(notice.filterMicIndex(cmd.getMickIndex())); } 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 2a7e9d68..8f60dc0a 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 @@ -212,15 +212,17 @@ public class GiftCountStrategy implements GiftStrategy { // 给用户送礼 handleSendGiftTask( runningWater.getUserId(), acceptUserIds, RoomDailyTaskCode.PERSONAL_SEND_GIFT); - // 房间用户累计送礼金币 - handleOwnerGiftGoldTask(runningWater.getUserId(), actualAmount, RoomDailyTaskCode.ROOM_USER_SEND_GIFT_GOLD); + if (roomProfile != null) { + if (roomProfile.getUserId().equals(runningWater.getUserId())) { + // 房主给用户送礼物 + handleSendGiftTask( runningWater.getUserId(), acceptUserIds, RoomDailyTaskCode.ROOM_OWNER_SEND_GIFT_USER); - if (roomProfile != null && roomProfile.getUserId().equals(runningWater.getUserId())) { - // 房主给用户送礼物 - handleSendGiftTask( runningWater.getUserId(), acceptUserIds, RoomDailyTaskCode.ROOM_OWNER_SEND_GIFT_USER); + // 房主累计送礼金币 + handleOwnerGiftGoldTask(runningWater.getUserId(), actualAmount, RoomDailyTaskCode.ROOM_OWNER_SEND_GIFT_GOLD); + } - // 房主累计送礼金币 - handleOwnerGiftGoldTask(runningWater.getUserId(), actualAmount, RoomDailyTaskCode.ROOM_OWNER_SEND_GIFT_GOLD); + // 房间用户累计送礼金币 + handleOwnerGiftGoldTask(roomProfile.getUserId(), actualAmount, RoomDailyTaskCode.ROOM_USER_SEND_GIFT_GOLD); } // giftGiveRunningWaterService.addLog(runningWater.getId(), "结束:礼物统计相关");