diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java index b0a1f4fc..e0873d37 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java @@ -4,7 +4,14 @@ import com.alibaba.fastjson.JSON; import com.google.common.collect.Lists; import com.red.circle.mq.business.model.event.gift.OfflineProcessGiftEvent; import com.red.circle.other.app.common.gift.GameLuckyGiftCommon; +import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd; +import com.red.circle.other.app.service.activity.RankingActivityService; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; +import com.red.circle.other.domain.model.user.UserProfile; +import com.red.circle.other.domain.ranking.RankingActivityType; +import com.red.circle.other.domain.ranking.RankingCycleType; +import com.red.circle.other.domain.ranking.RankingDimension; import com.red.circle.other.infra.common.game.GameKtvCommon; import com.red.circle.other.infra.database.cache.service.user.UserCpValueCacheService; import com.red.circle.other.infra.database.mongo.dto.TemporaryActivityCountParam; @@ -33,6 +40,7 @@ import com.red.circle.other.inner.enums.material.GiftTabEnum; import com.red.circle.other.inner.model.dto.sys.SysActivityCountType; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.date.TimestampUtils; +import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; import com.red.circle.tool.core.json.JacksonUtils; import com.red.circle.tool.core.regex.RegexConstant; import java.math.BigDecimal; @@ -56,6 +64,7 @@ public class RankCountStrategy implements GiftStrategy { private final GameKtvCommon gameKtvCommon; private final CpValueService cpValueService; + private final UserProfileGateway userProfileGateway; private final UserRegionGateway userRegionGateway; private final AppRankCountService appRankCountService; private final GameLuckyGiftCommon gameLuckyGiftCommon; @@ -69,6 +78,7 @@ public class RankCountStrategy implements GiftStrategy { private final WeekKingQueenCountService weekKingQueenCountService; private final GiftGiveRunningWaterService giftGiveRunningWaterService; private final TemporaryActivityCountService temporaryActivityCountService; + private final RankingActivityService rankingActivityService; @Override public void processor(OfflineProcessGiftEvent event) { @@ -143,6 +153,9 @@ public class RankCountStrategy implements GiftStrategy { getActualAmount(isLuckyGift, giftValue.getGiftValue(), luckyGiftRatio))); } + // 新排行榜累计数据 + accumulateNewRankingData(runningWater, isLuckyGift, luckyGiftRatio); + // cp if (isCpGift(giftValue)) { countCpValue(runningWater); @@ -158,7 +171,7 @@ public class RankCountStrategy implements GiftStrategy { sysActivityCount(runningWater); // KTV游戏统计 - gameKtv(runningWater, luckyGiftRatio); +// gameKtv(runningWater, luckyGiftRatio); giftGiveRunningWaterService.addLog(runningWater.getId(), "结束:排行榜相关统计"); } @@ -370,4 +383,60 @@ public class RankCountStrategy implements GiftStrategy { return giftValue.getGiftType().contains(GiftTabEnum.CP.name()); } + /** + * 累计新排行榜数据 + */ + private void accumulateNewRankingData(GiftGiveRunningWater runningWater, boolean isLuckyGift, BigDecimal luckyGiftRatio) { + try { + // 获取送礼用户信息 + UserProfile senderProfile = userProfileGateway.getByUserId(runningWater.getUserId()); + if (Objects.isNull(senderProfile)) { + log.warn("累计排行榜数据失败:未找到送礼用户信息, userId={}", runningWater.getUserId()); + return; + } + + // 生成本周周一的cycleKey(格式:yyyyMMdd) + String cycleKey = generateWeeklyCycleKey(); + + // 计算实际金额 + Long actualAmount = getActualAmount(isLuckyGift, runningWater.getGiftValue().getActualAmount(), luckyGiftRatio); + + String giftType = runningWater.getGiftValue().getGiftType(); + + if (giftType.contains(RankingActivityType.REVOLUTION_DAY.name())) { + // 累计送礼用户数据(革命日) + getDataUpdateCmd(runningWater, senderProfile.getUserSex(), cycleKey, actualAmount, RankingActivityType.REVOLUTION_DAY); + } + + if (giftType.contains(RankingActivityType.HEROES_DAY.name())) { + // 累计接收用户数据(英雄日 ) + getDataUpdateCmd(runningWater, senderProfile.getUserSex(), cycleKey, actualAmount, RankingActivityType.HEROES_DAY); + } + + } catch (Exception e) { + log.error("累计新排行榜数据异常, runningWaterId={}", runningWater.getId(), e); + } + } + + private void getDataUpdateCmd(GiftGiveRunningWater runningWater, Integer userSex, String cycleKey, Long actualAmount, RankingActivityType activityType) { + RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd(); + receiverCmd.setUserId(runningWater.getUserId()); + receiverCmd.setUserSex(userSex); + receiverCmd.setActivityType(activityType.getCode()); + receiverCmd.setCycleType(RankingCycleType.WEEKLY.getCode()); + receiverCmd.setCycleKey(cycleKey); + receiverCmd.setDimension(RankingDimension.CONSUME_AMOUNT.getCode()); + receiverCmd.setIncrementQuantity(actualAmount); + receiverCmd.setBizNo(runningWater.getId().toString()); + rankingActivityService.accumulateRankingData(receiverCmd); + } + + /** + * 生成本周周一的cycleKey + * 格式:yyyyMMdd + */ + private String generateWeeklyCycleKey() { + return ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString(); + } + } diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java index bb62377e..0eeb4a59 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java @@ -15,85 +15,11 @@ public enum RankingDimension { /** * 消费金额(金币) * - * 适用活动:国王/皇后榜、送礼榜 + * 适用活动:打赏礼物消费金币 */ CONSUME_AMOUNT(1, "消费金额", "金币"), - /** - * 收入金额(钻石) - * - * 适用活动:收礼榜、主播收益榜 - */ - INCOME_AMOUNT(2, "收入金额", "钻石"), - - /** - * 直播时长 - * - * 适用活动:直播时长榜 - * 单位:秒 - */ - LIVE_DURATION(3, "直播时长", "秒"), - - /** - * 充值金额 - * - * 适用活动:充值榜 - * 单位:钻石 - */ - RECHARGE_AMOUNT(4, "充值金额", "钻石"), - - /** - * 魅力值 - * - * 适用活动:魅力榜 - * 综合计算:收礼 + 粉丝 + 互动等 - */ - CHARM_VALUE(5, "魅力值", "分"), - - /** - * 贵族积分 - * - * 适用活动:贵族榜 - * 根据贵族等级计算积分 - */ - NOBILITY_SCORE(6, "贵族积分", "分"), - - /** - * 粉丝数量 - * - * 适用活动:粉丝榜 - */ - FANS_COUNT(7, "粉丝数量", "人"), - - /** - * 活跃度积分 - * - * 适用活动:活跃度榜 - * 综合计算:登录 + 互动 + 时长等 - */ - ACTIVITY_SCORE(8, "活跃度积分", "分"), - - /** - * 家族贡献值 - * - * 适用活动:家族榜 - */ - FAMILY_CONTRIBUTION(9, "家族贡献值", "分"), - - /** - * 礼物数量 - * - * 适用活动:特定礼物榜 - */ - GIFT_COUNT(10, "礼物数量", "个"), - - /** - * 经验值 - * - * 适用活动:等级榜 - */ - EXPERIENCE(11, "经验值", "点"); - + ; /** * 维度编码 */