累计榜

This commit is contained in:
tianfeng 2025-11-06 14:40:52 +08:00
parent f9b4d8468a
commit 26af4f0410
2 changed files with 72 additions and 77 deletions

View File

@ -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();
}
}

View File

@ -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, "经验值", "");
;
/**
* 维度编码
*/