From 04d01a92ae84e55215b290e642744149aa26ce44 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 4 Mar 2026 20:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E9=87=91=E5=B8=81=E5=A4=A7?= =?UTF-8?q?=E6=94=BE=E9=80=81-=E9=80=81=E7=A4=BC=E7=89=A9=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gift/strategy/GiftCountStrategy.java | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) 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 427d0bb1..2a7e9d68 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 @@ -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 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 acceptUserIds) { - RoomDailyTaskCode taskType = RoomDailyTaskCode.PERSONAL_SEND_GIFT; - String redisKey = "room:daily:task:send_gift:users:" + userId + ":" + private void handleSendGiftTask(Long userId, List 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