房间金币大放送-送礼物逻辑处理

This commit is contained in:
tianfeng 2026-03-04 20:01:19 +08:00
parent e148da7e7f
commit 04d01a92ae

View File

@ -168,8 +168,9 @@ public class GiftCountStrategy implements GiftStrategy {
BigDecimal luckyGiftRatio = gameLuckyGiftCommon.getLuckyGiftShareRatio(runningWater.getSysOrigin());
log.info("GiftCountStrategy.processor---幸运礼物比例:{}", luckyGiftRatio);
// 房间内贡献
RoomProfile roomProfile = null;
if (runningWater.getOriginId().matches(RegexConstant.NUMBER)) {
RoomProfile roomProfile = roomProfileManagerService
roomProfile = roomProfileManagerService
.getProfileById(Long.parseLong(runningWater.getOriginId()));
if (Objects.nonNull(roomProfile)) {
@ -206,7 +207,21 @@ public class GiftCountStrategy implements GiftStrategy {
handleSpinsGiftTask(runningWater);
// roomDailyTask
handleSendGiftTask(runningWater.getUserId(), runningWater.getAcceptUsers().stream().map(GiftAcceptUser::getAcceptUserId).toList());
List<Long> acceptUserIds = runningWater.getAcceptUsers().stream().map(GiftAcceptUser::getAcceptUserId).toList();
long actualAmount = runningWater.getGiftValue().getActualAmount().longValue();
// 给用户送礼
handleSendGiftTask( runningWater.getUserId(), acceptUserIds, RoomDailyTaskCode.PERSONAL_SEND_GIFT);
// 房间用户累计送礼金币
handleOwnerGiftGoldTask(runningWater.getUserId(), actualAmount, RoomDailyTaskCode.ROOM_USER_SEND_GIFT_GOLD);
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);
}
// giftGiveRunningWaterService.addLog(runningWater.getId(), "结束:礼物统计相关");
}
@ -710,19 +725,16 @@ public class GiftCountStrategy implements GiftStrategy {
}
}
private void handleSendGiftTask(Long userId, List<Long> acceptUserIds) {
RoomDailyTaskCode taskType = RoomDailyTaskCode.PERSONAL_SEND_GIFT;
String redisKey = "room:daily:task:send_gift:users:" + userId + ":"
private void handleSendGiftTask(Long userId, List<Long> acceptUserIds, RoomDailyTaskCode taskType) {
String redisKey = "room:daily:task:send_gift:" + taskType.name() + ":" + userId + ":"
+ ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
// 将本次接收用户加入 set返回新增数量已存在的不计入
long expireSeconds = DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight();
for (Long acceptUserId : acceptUserIds) {
redisTemplate.opsForSet().add(redisKey, acceptUserId);
redisService.expire(redisKey, expireSeconds, TimeUnit.SECONDS);
}
redisService.expire(redisKey, expireSeconds, TimeUnit.SECONDS);
// 获取去重后的总人数
int uniqueCount = (int) redisService.setSize(redisKey);
roomDailyTaskProgressService.updateTaskProgress(
@ -733,6 +745,21 @@ public class GiftCountStrategy implements GiftStrategy {
);
}
private void handleOwnerGiftGoldTask(Long roomOwnerId, Long goldAmount, RoomDailyTaskCode taskType) {
String redisKey = "room:daily:task:progress:" + taskType.name() + ":" + roomOwnerId + ":"
+ ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
Long total = redisService.increment(redisKey, goldAmount);
redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
roomDailyTaskProgressService.updateTaskProgress(
new RoomDailyTaskProgressUpdateCmd()
.setUserId(roomOwnerId)
.setTaskCode(taskType.name())
.setProgressValue(total.intValue())
);
}
/**
* 增加用户每日送礼物数量
* @param userId 用户ID