新增游戏王日榜记录
This commit is contained in:
parent
e2e7614216
commit
5176270766
@ -56,12 +56,13 @@ public class RankingActivityRestController extends BaseController {
|
|||||||
if (cmd.getCycleType() == null) {
|
if (cmd.getCycleType() == null) {
|
||||||
cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
|
cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
|
||||||
}
|
}
|
||||||
|
if (RankingActivityType.KING_GAMES_DAILY.getCode().equals(cmd.getActivityType())) {
|
||||||
|
cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt().toString());
|
||||||
|
}
|
||||||
return rankingActivityService.getRankingList(cmd);
|
return rankingActivityService.getRankingList(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询历史Top1列表(周榜)
|
* 查询历史Top1列表(周榜)
|
||||||
*
|
*
|
||||||
@ -105,4 +106,21 @@ public class RankingActivityRestController extends BaseController {
|
|||||||
public List<RankingUserVO> getTopThreeOverall(@RequestBody @Validated RankingListQueryCmd cmd) {
|
public List<RankingUserVO> getTopThreeOverall(@RequestBody @Validated RankingListQueryCmd cmd) {
|
||||||
return rankingActivityService.getTopThreeOverall(cmd);
|
return rankingActivityService.getTopThreeOverall(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询KING_GAMES_DAILY日榜前三名
|
||||||
|
*
|
||||||
|
* @eo.name KING_GAMES_DAILY日榜前三名
|
||||||
|
* @eo.url /king-games-daily-top-three
|
||||||
|
* @eo.method post
|
||||||
|
* @eo.request-type json
|
||||||
|
* @param cmd 查询命令
|
||||||
|
* @return 日榜前三名
|
||||||
|
*/
|
||||||
|
@PostMapping("/king-games-daily-top-three")
|
||||||
|
public List<RankingUserVO> getKingGamesDailyTopThree(@RequestBody RankingListQueryCmd cmd) {
|
||||||
|
cmd.setActivityType(RankingActivityType.KING_GAMES_DAILY.getCode());
|
||||||
|
cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt().toString());
|
||||||
|
return rankingActivityService.getKingGamesDailyTopThree(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -248,6 +248,9 @@ public class GameHkysRestController {
|
|||||||
receiverCmd.setBizNo(request.getGameId());
|
receiverCmd.setBizNo(request.getGameId());
|
||||||
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
||||||
rankingActivityService.accumulateRankingData(receiverCmd);
|
rankingActivityService.accumulateRankingData(receiverCmd);
|
||||||
|
|
||||||
|
//游戏王日榜
|
||||||
|
gameActivityService.incKingGameDaily(DataTypeUtils.toLong(request.getUid()), request.getCoin(), request.getGameId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,77 @@
|
|||||||
|
package com.red.circle.other.app.command.activity.query;
|
||||||
|
|
||||||
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
|
import com.red.circle.other.app.dto.clientobject.activity.RankingUserVO;
|
||||||
|
import com.red.circle.other.app.dto.cmd.activity.RankingListQueryCmd;
|
||||||
|
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;
|
||||||
|
import com.red.circle.other.infra.database.mongo.entity.activity.RankingActivityRecord;
|
||||||
|
import com.red.circle.other.infra.gateway.RankingActivityGateway;
|
||||||
|
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||||
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
|
import com.red.circle.tool.core.num.NumUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KING_GAMES_DAILY 日榜前三名查询执行器
|
||||||
|
*
|
||||||
|
* @author tf
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class KingGamesDailyTopThreeQryExe {
|
||||||
|
|
||||||
|
private final RankingActivityGateway rankingActivityGateway;
|
||||||
|
private final UserProfileGateway userProfileGateway;
|
||||||
|
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||||
|
|
||||||
|
public List<RankingUserVO> execute(RankingListQueryCmd cmd) {
|
||||||
|
List<RankingActivityRecord> records = rankingActivityGateway.getRankingList(
|
||||||
|
cmd.getReqSysOrigin().getOrigin(),
|
||||||
|
RankingActivityType.KING_GAMES_DAILY,
|
||||||
|
RankingCycleType.DAILY,
|
||||||
|
cmd.getCycleKey(),
|
||||||
|
null,
|
||||||
|
3
|
||||||
|
);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(records)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> userIds = records.stream()
|
||||||
|
.map(RankingActivityRecord::getUserId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
|
||||||
|
userProfileGateway.mapByUserIds(userIds));
|
||||||
|
|
||||||
|
return IntStream.range(0, records.size())
|
||||||
|
.mapToObj(i -> {
|
||||||
|
RankingActivityRecord record = records.get(i);
|
||||||
|
UserProfileDTO profile = userProfileMap.get(record.getUserId());
|
||||||
|
|
||||||
|
RankingUserVO vo = new RankingUserVO();
|
||||||
|
vo.setUserId(record.getUserId());
|
||||||
|
vo.setRank(i + 1);
|
||||||
|
vo.setQuantity(NumUtils.formatLong(record.getQuantity()));
|
||||||
|
|
||||||
|
if (profile != null) {
|
||||||
|
vo.setAccount(profile.getAccount());
|
||||||
|
vo.setNickname(profile.getUserNickname());
|
||||||
|
vo.setAvatar(profile.getUserAvatar());
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.red.circle.component.redis.service.RedisService;
|
import com.red.circle.component.redis.service.RedisService;
|
||||||
import com.red.circle.mq.business.model.event.GameKingRewardEvent;
|
import com.red.circle.mq.business.model.event.GameKingRewardEvent;
|
||||||
import com.red.circle.other.app.command.activity.query.HistoricalTop1QryExe;
|
import com.red.circle.other.app.command.activity.query.HistoricalTop1QryExe;
|
||||||
|
import com.red.circle.other.app.command.activity.query.KingGamesDailyTopThreeQryExe;
|
||||||
import com.red.circle.other.app.command.activity.query.RankingDataAccumulateCmdExe;
|
import com.red.circle.other.app.command.activity.query.RankingDataAccumulateCmdExe;
|
||||||
import com.red.circle.other.app.command.activity.query.RankingListQryExe;
|
import com.red.circle.other.app.command.activity.query.RankingListQryExe;
|
||||||
import com.red.circle.other.app.command.activity.query.UserRankQryExe;
|
import com.red.circle.other.app.command.activity.query.UserRankQryExe;
|
||||||
@ -46,6 +47,7 @@ public class RankingActivityServiceImpl implements RankingActivityService {
|
|||||||
private final RankingListQryExe rankingListQryExe;
|
private final RankingListQryExe rankingListQryExe;
|
||||||
private final UserRankQryExe userRankQryExe;
|
private final UserRankQryExe userRankQryExe;
|
||||||
private final HistoricalTop1QryExe historicalTop1QryExe;
|
private final HistoricalTop1QryExe historicalTop1QryExe;
|
||||||
|
private final KingGamesDailyTopThreeQryExe kingGamesDailyTopThreeQryExe;
|
||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
private final UserMqMessageService userMqMessageService;
|
private final UserMqMessageService userMqMessageService;
|
||||||
private final UserProfileGateway userProfileGateway;
|
private final UserProfileGateway userProfileGateway;
|
||||||
@ -230,6 +232,11 @@ public class RankingActivityServiceImpl implements RankingActivityService {
|
|||||||
return RANKING_LIST_CACHE_KEY_PREFIX + RankingActivityType.getByCode(cmd.getActivityType()).name() + ":" + cmd.getCycleKey();
|
return RANKING_LIST_CACHE_KEY_PREFIX + RankingActivityType.getByCode(cmd.getActivityType()).name() + ":" + cmd.getCycleKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RankingUserVO> getKingGamesDailyTopThree(RankingListQueryCmd cmd) {
|
||||||
|
return kingGamesDailyTopThreeQryExe.execute(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RankingUserVO> getTopThreeOverall(RankingListQueryCmd cmd) {
|
public List<RankingUserVO> getTopThreeOverall(RankingListQueryCmd cmd) {
|
||||||
// 查询总榜排行(按用户ID分组汇总)
|
// 查询总榜排行(按用户ID分组汇总)
|
||||||
|
|||||||
@ -1,9 +1,16 @@
|
|||||||
package com.red.circle.other.app.service.game;
|
package com.red.circle.other.app.service.game;
|
||||||
|
|
||||||
import com.red.circle.component.redis.service.RedisService;
|
import com.red.circle.component.redis.service.RedisService;
|
||||||
|
import com.red.circle.framework.core.dto.ReqSysOrigin;
|
||||||
import com.red.circle.other.app.dto.cmd.SpinsTaskProgressUpdateCmd;
|
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.service.SpinsUserTaskProgressService;
|
import com.red.circle.other.app.service.SpinsUserTaskProgressService;
|
||||||
|
import com.red.circle.other.app.service.activity.RankingActivityService;
|
||||||
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
|
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
|
||||||
|
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.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -23,6 +30,7 @@ public class GameActivityService {
|
|||||||
|
|
||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
private final SpinsUserTaskProgressService spinsUserTaskProgressService;
|
private final SpinsUserTaskProgressService spinsUserTaskProgressService;
|
||||||
|
private final RankingActivityService rankingActivityService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理游戏消费/获得任务
|
* 处理游戏消费/获得任务
|
||||||
@ -63,6 +71,21 @@ public class GameActivityService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void incKingGameDaily(Long userId, Long rewardAmount, String gameId) {
|
||||||
|
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
|
||||||
|
receiverCmd.setUserId(userId);
|
||||||
|
receiverCmd.setUserSex(1);
|
||||||
|
receiverCmd.setActivityType(RankingActivityType.KING_GAMES_DAILY.getCode());
|
||||||
|
receiverCmd.setCycleType(RankingCycleType.DAILY.getCode());
|
||||||
|
receiverCmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt().toString());
|
||||||
|
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
|
||||||
|
receiverCmd.setIncrementQuantity(rewardAmount);
|
||||||
|
receiverCmd.setBizNo(gameId);
|
||||||
|
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
||||||
|
rankingActivityService.accumulateRankingData(receiverCmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新游戏进度
|
* 更新游戏进度
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -324,6 +324,9 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
receiverCmd.setBizNo(request.getGameRoundId());
|
receiverCmd.setBizNo(request.getGameRoundId());
|
||||||
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
||||||
rankingActivityService.accumulateRankingData(receiverCmd);
|
rankingActivityService.accumulateRankingData(receiverCmd);
|
||||||
|
|
||||||
|
//游戏王日榜
|
||||||
|
gameActivityService.incKingGameDaily(DataTypeUtils.toLong(request.getUserId()), request.getCurrencyDiff(), request.getGameId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -427,6 +427,9 @@ public class HotGameServiceImpl implements HotGameService {
|
|||||||
receiverCmd.setBizNo(param.getGameId());
|
receiverCmd.setBizNo(param.getGameId());
|
||||||
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
||||||
rankingActivityService.accumulateRankingData(receiverCmd);
|
rankingActivityService.accumulateRankingData(receiverCmd);
|
||||||
|
|
||||||
|
//游戏王日榜
|
||||||
|
gameActivityService.incKingGameDaily(DataTypeUtils.toLong(param.getUid()), param.getCoin(), param.getGameId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -335,5 +335,8 @@ public class YomiGameServiceImpl implements YomiGameService {
|
|||||||
receiverCmd.setBizNo(gameId);
|
receiverCmd.setBizNo(gameId);
|
||||||
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
||||||
rankingActivityService.accumulateRankingData(receiverCmd);
|
rankingActivityService.accumulateRankingData(receiverCmd);
|
||||||
|
|
||||||
|
//游戏王日榜
|
||||||
|
gameActivityService.incKingGameDaily(userId, rewardAmount.longValue(), gameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,4 +63,12 @@ public interface RankingActivityService {
|
|||||||
* @return 总榜前三名用户列表
|
* @return 总榜前三名用户列表
|
||||||
*/
|
*/
|
||||||
List<RankingUserVO> getTopThreeOverall(RankingListQueryCmd cmd);
|
List<RankingUserVO> getTopThreeOverall(RankingListQueryCmd cmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取KING_GAMES_DAILY日榜前三名
|
||||||
|
*
|
||||||
|
* @param cmd 查询命令
|
||||||
|
* @return 日榜前三名用户列表
|
||||||
|
*/
|
||||||
|
List<RankingUserVO> getKingGamesDailyTopThree(RankingListQueryCmd cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,6 +54,8 @@ public enum RankingActivityType {
|
|||||||
RAMADAN(13, "'斋月活动'", "'统计送礼物消费排行'"),
|
RAMADAN(13, "'斋月活动'", "'统计送礼物消费排行'"),
|
||||||
|
|
||||||
INVITE(14, "'邀请活动'", "'邀请用户奖励金币排行'"),
|
INVITE(14, "'邀请活动'", "'邀请用户奖励金币排行'"),
|
||||||
|
|
||||||
|
KING_GAMES_DAILY(15, "游戏王日榜活动", "统计游戏数据排行"),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user