房间金币大放送新增roomMember逻辑
This commit is contained in:
parent
0958146a18
commit
1640830664
@ -13,14 +13,17 @@ 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.live.RoomMemberClient;
|
||||
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.RoomMemberDTO;
|
||||
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;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -45,6 +48,8 @@ public class LiveMicGoUpCmdExe {
|
||||
private final RedisService redisService;
|
||||
private final RoomDailyTaskClient roomDailyTaskClient;
|
||||
private final RoomManagerClient roomManagerClient;
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final RoomMemberClient roomMemberClient;
|
||||
|
||||
public LiveMicrophoneCO execute(MicUpDownCmd cmd) {
|
||||
checkPermissions(cmd);
|
||||
@ -64,6 +69,7 @@ public class LiveMicGoUpCmdExe {
|
||||
}
|
||||
//notice.setRoomToken(createAgoraTokenGoUp(cmd));
|
||||
|
||||
// 房主邀请成员上麦
|
||||
handleRoomDailyTask(cmd);
|
||||
|
||||
return notice;
|
||||
@ -71,26 +77,40 @@ public class LiveMicGoUpCmdExe {
|
||||
|
||||
private void handleRoomDailyTask(MicUpDownCmd cmd) {
|
||||
try {
|
||||
RoomProfileDTO roomProfile = roomManagerClient.getById(cmd.getRoomId()).getBody();
|
||||
if (Objects.isNull(roomProfile)) {
|
||||
return;
|
||||
}
|
||||
RoomMemberDTO roomMemberDTO = roomMemberClient.getMember(cmd.getRoomId(), cmd.getReqUserId()).getBody();
|
||||
if (Objects.isNull(roomMemberDTO)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean invite = cmd.eventTypeEqInvite();
|
||||
if (invite) {
|
||||
RoomProfileDTO roomProfile = roomManagerClient.getById(cmd.getRoomId()).getBody();
|
||||
if (invite && Objects.equals(roomProfile.getUserId(), cmd.getInviterId())) {
|
||||
Long roomOwnerId = roomProfile.getUserId();
|
||||
handleInviteMicTask(roomOwnerId, RoomDailyTaskCode.ROOM_OWNER_INVITE_MIC);
|
||||
handleInviteMicTask(roomOwnerId, cmd.requiredReqUserId(), 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);
|
||||
private void handleInviteMicTask(Long roomOwnerId, Long userId, RoomDailyTaskCode taskCode) {
|
||||
String setKey = "room:daily:task:progress:" + taskCode.name() + ":" + roomOwnerId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
||||
Long added = redisTemplate.opsForSet().add(setKey, userId);
|
||||
redisService.expire(setKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
|
||||
|
||||
if (!Long.valueOf(1L).equals(added)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int uniqueCount = (int) redisService.setSize(setKey);
|
||||
roomDailyTaskClient.updateTaskProgress(
|
||||
new RoomDailyTaskProgressUpdateInnerCmd()
|
||||
.setUserId(roomOwnerId)
|
||||
.setTaskCode(taskCode.name())
|
||||
.setProgressValue(total.intValue())
|
||||
.setProgressValue(uniqueCount)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import com.red.circle.component.mq.service.Action;
|
||||
import com.red.circle.component.mq.service.ConsumerMessage;
|
||||
import com.red.circle.component.mq.service.MessageListener;
|
||||
import com.red.circle.component.redis.service.RedisService;
|
||||
import com.red.circle.framework.dto.ResultResponse;
|
||||
import com.red.circle.live.app.dto.cmd.HeartbeatStatusEnum;
|
||||
import com.red.circle.live.domain.gateway.LiveMicrophoneGateway;
|
||||
import com.red.circle.live.domain.live.LiveMicrophone;
|
||||
@ -19,12 +20,14 @@ import com.red.circle.mq.business.model.event.user.UserHeartbeatEvent;
|
||||
import com.red.circle.mq.rocket.business.producer.UserMqMessageService;
|
||||
import com.red.circle.mq.rocket.business.streams.UserHeartbeatSink;
|
||||
import com.red.circle.other.inner.endpoint.live.RoomManagerClient;
|
||||
import com.red.circle.other.inner.endpoint.live.RoomMemberClient;
|
||||
import com.red.circle.other.inner.endpoint.task.RoomDailyTaskClient;
|
||||
import com.red.circle.other.inner.endpoint.user.user.UserOnlineClient;
|
||||
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
|
||||
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.cmd.user.OnlineStatusUploadCmd;
|
||||
import com.red.circle.other.inner.model.dto.live.RoomMemberDTO;
|
||||
import com.red.circle.other.inner.model.dto.live.RoomProfileDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
@ -65,6 +68,7 @@ public class UserHeartbeatListener implements MessageListener {
|
||||
private final LiveMicUserCacheService liveMicUserCacheService;
|
||||
private final RoomDailyTaskClient roomDailyTaskClient;
|
||||
private final RedisService redisService;
|
||||
private final RoomMemberClient roomMemberClient;
|
||||
|
||||
private static final int HEARTBEAT_INTERVAL_SECONDS = 60;
|
||||
|
||||
@ -139,6 +143,12 @@ public class UserHeartbeatListener implements MessageListener {
|
||||
}
|
||||
|
||||
private void updateDailyTask(Long roomId, Long userId, RoomDailyTaskCode taskType) {
|
||||
ResultResponse<RoomMemberDTO> response = roomMemberClient.getMember(roomId, userId);
|
||||
RoomMemberDTO roomMemberDTO = response.getBody();
|
||||
if (!response.checkSuccess() || roomMemberDTO == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String redisKey = "room:daily:task:progress:" + taskType.name() + ":" + userId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
||||
Long total = redisService.increment(redisKey, 1);
|
||||
redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
|
||||
|
||||
@ -33,6 +33,11 @@ public class MicUpDownCmd extends AppExtCommand {
|
||||
@NotNull(message = "mickIndex required.")
|
||||
private Integer mickIndex;
|
||||
|
||||
/**
|
||||
* 邀请人ID
|
||||
*/
|
||||
private Long inviterId;
|
||||
|
||||
/**
|
||||
* 事件类型.
|
||||
*/
|
||||
|
||||
@ -31,6 +31,8 @@ import com.red.circle.other.infra.database.mongo.entity.live.RoomSetting;
|
||||
import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService;
|
||||
import com.red.circle.other.infra.database.mongo.service.live.RoomTouristService;
|
||||
import com.red.circle.other.infra.database.mongo.service.live.RoomUserBlacklistService;
|
||||
import com.red.circle.other.infra.database.rds.entity.live.RoomMember;
|
||||
import com.red.circle.other.infra.database.rds.service.live.RoomMemberService;
|
||||
import com.red.circle.other.infra.database.rds.service.props.PropsRoomLockService;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||
@ -92,6 +94,7 @@ public class RoomEnterCmdExe {
|
||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
||||
private final RedisService redisService;
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final RoomMemberService roomMemberService;
|
||||
|
||||
public EntryRoomResponseCO execute(RoomEntryCmd cmd) {
|
||||
//checkEntryUserId(cmd);
|
||||
@ -135,7 +138,7 @@ public class RoomEnterCmdExe {
|
||||
}
|
||||
|
||||
// 房间每日任务
|
||||
updateRoomDailyTask(cmd.getReqUserId(), manager.getUserId());
|
||||
updateRoomDailyTask(cmd.getReqUserId(), manager.getUserId(), manager.getId());
|
||||
|
||||
return new EntryRoomResponseCO()
|
||||
.setRoomProfile(
|
||||
@ -161,16 +164,25 @@ public class RoomEnterCmdExe {
|
||||
);
|
||||
}
|
||||
|
||||
private void updateRoomDailyTask(Long enterUserId, Long roomOwnerId) {
|
||||
private void updateRoomDailyTask(Long enterUserId, Long roomOwnerId, Long roomId) {
|
||||
// 只处理用户进入非自己房间的情况
|
||||
if (Objects.equals(enterUserId, roomOwnerId)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
RoomMember roomMember = roomMemberService.getRoomMember(roomId, enterUserId);
|
||||
if (Objects.isNull(roomMember)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Redis 去重:同一用户当天进入同一房间只计一次
|
||||
String redisKey = "room:daily:task:new_member:" + roomOwnerId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
||||
redisTemplate.opsForSet().add(redisKey, enterUserId);
|
||||
redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
|
||||
Long added = redisTemplate.opsForSet().add(redisKey, enterUserId);
|
||||
redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
|
||||
|
||||
if (!Long.valueOf(1L).equals(added)) {
|
||||
return;
|
||||
}
|
||||
|
||||
long uniqueCount = redisService.setSize(redisKey);
|
||||
roomDailyTaskProgressService.updateTaskProgress(
|
||||
|
||||
@ -15,6 +15,8 @@ import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarg
|
||||
import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService;
|
||||
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberService;
|
||||
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberTargetService;
|
||||
import com.red.circle.other.infra.database.rds.entity.live.RoomMember;
|
||||
import com.red.circle.other.infra.database.rds.service.live.RoomMemberService;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||
import com.red.circle.other.inner.asserts.RoomErrorCode;
|
||||
|
||||
@ -50,6 +52,7 @@ public class TeamMemberHeartbeatCmdExe {
|
||||
private final TaskService taskService;
|
||||
private final RedisService redisService;
|
||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
||||
private final RoomMemberService roomMemberService;
|
||||
|
||||
private static final int HEARTBEAT_INTERVAL_SECONDS = 60;
|
||||
|
||||
@ -103,6 +106,11 @@ public class TeamMemberHeartbeatCmdExe {
|
||||
}
|
||||
|
||||
private void updateDailyTask(AppRoomIdCmd cmd, RoomDailyTaskCode taskType) {
|
||||
RoomMember roomMember = roomMemberService.getRoomMember(cmd.getRoomId(), cmd.requiredReqUserId());
|
||||
if (roomMember == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Long userId = cmd.requiredReqUserId();
|
||||
String redisKey = "room:daily:task:progress:" + taskType.name() + ":" + userId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
||||
Long total = redisService.increment(redisKey, 1);
|
||||
@ -153,6 +161,15 @@ public class TeamMemberHeartbeatCmdExe {
|
||||
* 统计用户在房间的麦位时长,到达30/60/120分钟时更新房主任务进度
|
||||
*/
|
||||
private void updateRoomMicUserDurationTask(Long userId, Long roomOwnerId, Long roomId) {
|
||||
if (roomOwnerId.equals(userId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomMember roomMember = roomMemberService.getRoomMember(roomId, userId);
|
||||
if (roomMember == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String redisKey = "room:daily:task:mic_duration:" + roomId + ":" + userId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
||||
Long minutes = redisService.increment(redisKey, 1);
|
||||
redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
|
||||
|
||||
@ -51,10 +51,12 @@ import com.red.circle.other.infra.database.rds.entity.game.GameLuckyGiftCount;
|
||||
import com.red.circle.other.infra.database.rds.entity.game.GameLuckyGiftRuleConfig;
|
||||
import com.red.circle.other.infra.database.rds.entity.game.LuckyGiftProbability;
|
||||
import com.red.circle.other.infra.database.rds.entity.game.LuckyGiftProbabilityDetails;
|
||||
import com.red.circle.other.infra.database.rds.entity.live.RoomMember;
|
||||
import com.red.circle.other.infra.database.rds.service.game.GameLuckyGiftCountService;
|
||||
import com.red.circle.other.infra.database.rds.service.game.GameLuckyGiftRuleConfigService;
|
||||
import com.red.circle.other.infra.database.rds.service.game.LuckyGiftProbabilityDetailsService;
|
||||
import com.red.circle.other.infra.database.rds.service.game.LuckyGiftProbabilityService;
|
||||
import com.red.circle.other.infra.database.rds.service.live.RoomMemberService;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.EnumConfigService;
|
||||
import com.red.circle.other.inner.enums.config.EnumConfigKey;
|
||||
import com.red.circle.other.inner.enums.game.luckgift.GameLuckyGiftModeEnum;
|
||||
@ -118,6 +120,7 @@ public class GameLuckyGiftCommon {
|
||||
private final GiftAppConvertor giftAppConvertor;
|
||||
private final ActivityRechargeTicketService activityRechargeTicketService;
|
||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
||||
private final RoomMemberService roomMemberService;
|
||||
|
||||
/**
|
||||
* 发送幸运礼物抽奖mq.
|
||||
@ -274,6 +277,11 @@ public class GameLuckyGiftCommon {
|
||||
}
|
||||
|
||||
private void updateRoomDailyTask(GameLuckyGiftParam param, Long rewardAmount, RoomDailyTaskCode taskType) {
|
||||
RoomMember roomMember = roomMemberService.getRoomMember(param.getRoomId(), param.getUserId());
|
||||
if (roomMember == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
roomDailyTaskProgressService.updateTaskProgress(
|
||||
new RoomDailyTaskProgressUpdateCmd()
|
||||
.setUserId(param.getUserId())
|
||||
|
||||
@ -48,6 +48,7 @@ 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.live.RoomMember;
|
||||
import com.red.circle.other.infra.database.rds.entity.user.user.ConfessionChance;
|
||||
import com.red.circle.other.infra.database.rds.entity.user.user.CpBlessRecord;
|
||||
import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship;
|
||||
@ -206,26 +207,45 @@ public class GiftCountStrategy implements GiftStrategy {
|
||||
// Spins 送礼物任务
|
||||
handleSpinsGiftTask(runningWater);
|
||||
|
||||
// roomDailyTask
|
||||
List<Long> acceptUserIds = runningWater.getAcceptUsers().stream().map(GiftAcceptUser::getAcceptUserId).toList();
|
||||
long actualAmount = runningWater.getGiftValue().getActualAmount().longValue();
|
||||
// 房间金币大放送
|
||||
handleRoomDailyTask(runningWater, roomProfile);
|
||||
|
||||
// giftGiveRunningWaterService.addLog(runningWater.getId(), "结束:礼物统计相关");
|
||||
}
|
||||
|
||||
private void handleRoomDailyTask(GiftGiveRunningWater runningWater, RoomProfile roomProfile) {
|
||||
Long userId = runningWater.getUserId();
|
||||
if (roomProfile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomMember roomMember = roomMemberService.getRoomMember(roomProfile.getId(), userId);
|
||||
if (Objects.isNull(roomMember)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> acceptUserIds = runningWater.getAcceptUsers().stream()
|
||||
.map(GiftAcceptUser::getAcceptUserId)
|
||||
.filter(e -> !userId.equals(e))
|
||||
.toList();
|
||||
long actualAmount = getActualAmount(runningWater.getGiftValue(), runningWater.getGiftValue().getActualAmount());
|
||||
|
||||
// 给用户送礼
|
||||
handleSendGiftTask( runningWater.getUserId(), acceptUserIds, RoomDailyTaskCode.PERSONAL_SEND_GIFT);
|
||||
if (!roomMember.getUserId().equals(userId)) {
|
||||
handleSendGiftTask(userId, acceptUserIds, RoomDailyTaskCode.PERSONAL_SEND_GIFT);
|
||||
}
|
||||
|
||||
if (roomProfile != null) {
|
||||
if (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);
|
||||
}
|
||||
if (roomProfile.getUserId().equals(userId)) {
|
||||
// 房主给用户送礼物
|
||||
handleSendGiftTask(userId, acceptUserIds, RoomDailyTaskCode.ROOM_OWNER_SEND_GIFT_USER);
|
||||
|
||||
// 房主累计送礼金币
|
||||
handleOwnerGiftGoldTask(userId, actualAmount, RoomDailyTaskCode.ROOM_OWNER_SEND_GIFT_GOLD);
|
||||
} else {
|
||||
// 房间用户累计送礼金币
|
||||
handleOwnerGiftGoldTask(roomProfile.getUserId(), actualAmount, RoomDailyTaskCode.ROOM_USER_SEND_GIFT_GOLD);
|
||||
}
|
||||
|
||||
// giftGiveRunningWaterService.addLog(runningWater.getId(), "结束:礼物统计相关");
|
||||
}
|
||||
|
||||
private void saveConfessionChance(GiftGiveRunningWater runningWater) {
|
||||
@ -728,6 +748,10 @@ public class GiftCountStrategy implements GiftStrategy {
|
||||
}
|
||||
|
||||
private void handleSendGiftTask(Long userId, List<Long> acceptUserIds, RoomDailyTaskCode taskType) {
|
||||
if (acceptUserIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String redisKey = "room:daily:task:send_gift:" + taskType.name() + ":" + userId + ":"
|
||||
+ ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user