房间金币大放送 个人模块部分逻辑实现

This commit is contained in:
tianfeng 2026-03-04 11:58:33 +08:00
parent 786c9263bf
commit d85a1d8711
7 changed files with 161 additions and 0 deletions

View File

@ -0,0 +1,61 @@
package com.red.circle.other.inner.enums.task;
/**
* 每日任务类型.
*
* @author tf
*/
public enum RoomDailyTaskType {
// ==================== Personal Tasks ====================
/** 进入他人房间活跃 */
ACTIVE_IN_ROOM,
/** 进入他人房间上麦 */
MIC_IN_ROOM,
/** 给用户送礼 */
SEND_GIFT,
/** 送幸运礼物赢得金币数 */
LUCKY_GIFT_GOLD,
/** 送魔法礼物赢得金币数 */
MAGIC_GIFT_GOLD,
/** 游戏消费 */
GAME_CONSUME,
// ==================== Room Owner Tasks ====================
/** 房间新增成员数 */
NEW_MEMBER,
/** 房主发红包 */
OWNER_RED_PACKET,
/** 房主给用户送礼物 */
OWNER_SEND_GIFT,
/** 房主累计送礼金币数 */
OWNER_GIFT_GOLD,
/** 房间用户累计送礼金币数 */
ROOM_GIFT_GOLD,
/** 累计在麦位的用户数(按时长区分档位) */
MIC_USER_DURATION,
/** 房间内同时在线用户数 */
ONLINE_USER_COUNT,
/** 房主成功邀请用户上麦 */
OWNER_INVITE_MIC,
/** 房主在房间上麦 */
OWNER_MIC_TIME,
;
}

View File

@ -28,11 +28,13 @@ import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.dto.cmd.game.GameLxwlUpdateBalanceCmd;
import com.red.circle.other.app.dto.cmd.game.GameLxwlUserInfoCmd;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.enums.violation.GameOriginEnum;
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
import com.red.circle.other.app.service.activity.ActivityRechargeTicketService;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.game.GameActivityService;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.game.GameRankingIncrementCmd;
@ -46,6 +48,7 @@ import com.red.circle.other.infra.database.cache.service.other.GameListCacheServ
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.enums.task.RoomDailyTaskType;
import com.red.circle.other.inner.enums.team.TeamPolicyTypeEnum;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
@ -94,6 +97,7 @@ public class GameHkysRestController {
private final GameActivityService gameActivityService;
private final RedisService redisService;
private final ActivityRechargeTicketService activityRechargeTicketService;
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
@IgnoreResultResponse
@PostMapping("/getUserInfo")
@ -198,6 +202,15 @@ public class GameHkysRestController {
// 累加用户获得的金币并发送抽奖券
activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, Math.abs(cmd.getCoin()), MonthlyRechargeType.UNDEFINED);
} else {
RoomDailyTaskType taskType = RoomDailyTaskType.GAME_CONSUME;
roomDailyTaskProgressService.updateTaskProgress(
new RoomDailyTaskProgressUpdateCmd()
.setUserId(userId)
.setTaskCode(taskType.name())
.setProgressValue(param.getCoin().intValue())
);
}

View File

@ -31,8 +31,10 @@ import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.clientobject.game.GameLuckyGiftMsgCO;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.dto.cmd.gift.GiveAwayGiftBatchCmd;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.service.activity.ActivityRechargeTicketService;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.ranking.RankingActivityType;
import com.red.circle.other.domain.ranking.RankingCycleType;
@ -59,6 +61,7 @@ import com.red.circle.other.inner.enums.game.luckgift.GameLuckyGiftModeEnum;
import com.red.circle.other.inner.enums.game.luckgift.GameLuckyGiftMultipleEnum;
import com.red.circle.other.inner.enums.material.GiftTabEnum;
import com.red.circle.other.inner.enums.material.PropsCommodityType;
import com.red.circle.other.inner.enums.task.RoomDailyTaskType;
import com.red.circle.other.inner.model.dto.material.GiftConfigDTO;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.other.inner.model.dto.user.props.UserPropsResourcesDTO;
@ -114,6 +117,7 @@ public class GameLuckyGiftCommon {
private final GiftMqMessage giftMqMessage;
private final GiftAppConvertor giftAppConvertor;
private final ActivityRechargeTicketService activityRechargeTicketService;
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
/**
* 发送幸运礼物抽奖mq.
@ -257,10 +261,25 @@ public class GameLuckyGiftCommon {
GiveAwayGiftBatchEvent giftBatchEvent = buildGiftBatchEvent(cmd, timeId, param, giftConfigDTO);
giftMqMessage.sendGift(timeId, giftBatchEvent);
updateRoomDailyTask(param, rewardAmount, RoomDailyTaskType.MAGIC_GIFT_GOLD);
} else {
updateRoomDailyTask(param, rewardAmount, RoomDailyTaskType.LUCKY_GIFT_GOLD);
}
// 累加用户获得的金币并发送抽奖券
activityRechargeTicketService.accumulatedRechargeAndAddTicket(param.getUserId(), rewardAmount, MonthlyRechargeType.LUCKY_WIN);
}
private void updateRoomDailyTask(GameLuckyGiftParam param, Long rewardAmount, RoomDailyTaskType taskType) {
roomDailyTaskProgressService.updateTaskProgress(
new RoomDailyTaskProgressUpdateCmd()
.setUserId(param.getUserId())
.setTaskCode(taskType.name())
.setProgressValue(rewardAmount.intValue())
);
}
@NotNull

View File

@ -19,7 +19,9 @@ import com.red.circle.other.app.dto.clientobject.dynamic.MessageItemCO;
import com.red.circle.other.app.dto.clientobject.game.GameRoomPkUserCO;
import com.red.circle.other.app.dto.cmd.SpinsTaskProgressUpdateCmd;
import com.red.circle.other.app.dto.cmd.dynamic.DynamicLikeCmd;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.service.SpinsUserTaskProgressService;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
@ -75,6 +77,7 @@ import com.red.circle.other.inner.enums.material.BadgeKeyEnum;
import com.red.circle.other.inner.enums.material.GiftCurrencyType;
import com.red.circle.other.inner.enums.material.GiftSpecialEnum;
import com.red.circle.other.inner.enums.material.GiftTabEnum;
import com.red.circle.other.inner.enums.task.RoomDailyTaskType;
import com.red.circle.other.inner.model.dto.material.GiftConfigDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.collection.MapBuilder;
@ -139,6 +142,7 @@ public class GiftCountStrategy implements GiftStrategy {
private final OfficialNoticeClient officialService;
private final TaskMqMessage taskMqMessage;
private final SpinsUserTaskProgressService spinsUserTaskProgressService;
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
private final RedisService redisService;
private final DynamicContentService dynamicContentService;
private final DynamicGiftService dynamicGiftService;
@ -207,6 +211,9 @@ public class GiftCountStrategy implements GiftStrategy {
// Spins 送礼物任务
handleSpinsGiftTask(runningWater);
// roomDailyTask
handleSendGiftTask(runningWater.getUserId(), runningWater.getAcceptUsers().stream().map(GiftAcceptUser::getAcceptUserId).toList());
// giftGiveRunningWaterService.addLog(runningWater.getId(), "结束:礼物统计相关");
}
@ -709,6 +716,28 @@ public class GiftCountStrategy implements GiftStrategy {
}
}
private void handleSendGiftTask(Long userId, List<Long> acceptUserIds) {
RoomDailyTaskType taskType = RoomDailyTaskType.SEND_GIFT;
String redisKey = "room:daily:task:send_gift:users:" + userId + ":"
+ ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
// 将本次接收用户加入 set返回新增数量已存在的不计入
long expireSeconds = DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight();
for (Long acceptUserId : acceptUserIds) {
redisService.setAdd(redisKey, acceptUserId, expireSeconds, TimeUnit.SECONDS);
}
// 获取去重后的总人数
int uniqueCount = (int) redisService.setSize(redisKey);
roomDailyTaskProgressService.updateTaskProgress(
new RoomDailyTaskProgressUpdateCmd()
.setUserId(userId)
.setTaskCode(taskType.name())
.setProgressValue(uniqueCount)
);
}
/**
* 增加用户每日送礼物数量
* @param userId 用户ID

View File

@ -28,11 +28,13 @@ import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.cmd.SpinsTaskProgressUpdateCmd;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.enums.violation.GameOriginEnum;
import com.red.circle.other.app.service.SpinsUserTaskProgressService;
import com.red.circle.other.app.service.activity.ActivityRechargeService;
import com.red.circle.other.app.service.activity.ActivityRechargeTicketService;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.app.service.task.TaskService;
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
import com.red.circle.other.app.util.OfficialNoticeUtils;
@ -47,6 +49,7 @@ import com.red.circle.other.infra.database.cache.service.other.GameListCacheServ
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.enums.task.RoomDailyTaskType;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.DateUtils;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
@ -93,6 +96,7 @@ public class GameBaishunServiceImpl implements GameBaishunService {
private final TaskService taskService;
private final GameActivityService gameActivityService;
private final ActivityRechargeTicketService activityRechargeTicketService;
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
@Value("${red-circle.game-rank.gameid}")
private String gameId;
@ -228,6 +232,14 @@ public class GameBaishunServiceImpl implements GameBaishunService {
// 累加用户获得的金币并发送抽奖券
activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, request.getCurrencyDiff(), MonthlyRechargeType.UNDEFINED);
} else {
RoomDailyTaskType taskType = RoomDailyTaskType.GAME_CONSUME;
roomDailyTaskProgressService.updateTaskProgress(
new RoomDailyTaskProgressUpdateCmd()
.setUserId(userId)
.setTaskCode(taskType.name())
.setProgressValue(Math.abs(request.getCurrencyDiff().intValue()))
);
}
}

View File

@ -24,12 +24,14 @@ import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.clientobject.game.HotGameUpdateRequest;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.dto.cmd.game.GameLxwlUpdateBalanceCmd;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.enums.violation.GameOriginEnum;
import com.red.circle.other.app.service.activity.ActivityRechargeTicketService;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.game.GameActivityService;
import com.red.circle.other.app.service.game.override.domain.HotGameUserProfile;
import com.red.circle.other.app.service.game.override.service.HotGameService;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.game.GameRankingIncrementCmd;
@ -47,6 +49,7 @@ import com.red.circle.other.infra.database.rds.service.game.GameVipLevelWeeklySe
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.enums.game.VipLevelRule;
import com.red.circle.other.inner.enums.task.RoomDailyTaskType;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
@ -99,6 +102,7 @@ public class HotGameServiceImpl implements HotGameService {
private final UserActivityRechargeService userActivityRechargeService;
private final GameVipLevelWeeklyService gameVipLevelWeeklyService;
private final ActivityRechargeTicketService activityRechargeTicketService;
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
@Value("${red-circle.game-rank.gameid}")
private String gameId;
@ -335,6 +339,17 @@ public class HotGameServiceImpl implements HotGameService {
activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, Math.abs(param.getCoin()), MonthlyRechargeType.UNDEFINED);
}
// 处理游戏消费人任务
else {
RoomDailyTaskType taskType = RoomDailyTaskType.GAME_CONSUME;
roomDailyTaskProgressService.updateTaskProgress(
new RoomDailyTaskProgressUpdateCmd()
.setUserId(userId)
.setTaskCode(taskType.name())
.setProgressValue(param.getCoin().intValue())
);
}
return new HotGameResponse<HotGameCoin>()
.setData(new HotGameCoin()
.setBalanceCoin(res.getBalance().getDollarAmount().longValue())

View File

@ -12,10 +12,12 @@ import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.dto.cmd.party3rd.*;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.enums.violation.GameOriginEnum;
import com.red.circle.other.app.service.activity.ActivityRechargeTicketService;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.game.override.service.YomiGameService;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.game.GameRankingIncrementCmd;
import com.red.circle.other.domain.gateway.game.GameRankingGateway;
@ -29,6 +31,7 @@ import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheSe
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.enums.task.RoomDailyTaskType;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
import com.red.circle.tool.core.num.ArithmeticUtils;
@ -70,6 +73,7 @@ public class YomiGameServiceImpl implements YomiGameService {
private final GameActivityService gameActivityService;
private final GameRankingGateway gameRankingGateway;
private final ActivityRechargeTicketService activityRechargeTicketService;
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
@Override
public YomiTokenCO getToken(YomiGetTokenCmd cmd) {
@ -180,6 +184,14 @@ public class YomiGameServiceImpl implements YomiGameService {
// 累加用户获得的金币并发送抽奖券
activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, Math.abs(changeValue.longValue()), MonthlyRechargeType.UNDEFINED);
} else {
RoomDailyTaskType taskType = RoomDailyTaskType.GAME_CONSUME;
roomDailyTaskProgressService.updateTaskProgress(
new RoomDailyTaskProgressUpdateCmd()
.setUserId(userId)
.setTaskCode(taskType.name())
.setProgressValue(cmd.getChangeValue())
);
}
return new YomiBalanceCO(currentBalance);