房间金币累计逻辑更改 新增邀请上麦处理

This commit is contained in:
tianfeng 2026-03-05 12:00:45 +08:00
parent b7ddf2d56f
commit 9a11b8e5fc
2 changed files with 48 additions and 8 deletions

View File

@ -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()));
}

View File

@ -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(), "结束:礼物统计相关");