我的排名问题修复
This commit is contained in:
parent
ddf44678f3
commit
5b25198884
@ -81,7 +81,7 @@ public class RankingListQryExe {
|
||||
// 查询当前用户排名(如果需要)
|
||||
UserRankInfoCO currentUserRank = null;
|
||||
if (cmd.getIncludeCurrentUser() && cmd.getReqUserId() != null) {
|
||||
currentUserRank = queryCurrentUserRank(cmd, activityType, cycleType);
|
||||
currentUserRank = queryCurrentUserRank(cmd, rankingList);
|
||||
UserProfile userProfile = userProfileGateway.getByUserId(cmd.getReqUserId());
|
||||
if (userProfile != null) {
|
||||
currentUserRank.setAccount(userProfile.getAccount());
|
||||
@ -117,6 +117,47 @@ public class RankingListQryExe {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从排行榜列表中查询当前用户排名
|
||||
*/
|
||||
private UserRankInfoCO queryCurrentUserRank(
|
||||
RankingListQueryCmd cmd,
|
||||
List<RankingActivityRecordCO> rankingList) {
|
||||
|
||||
UserRankInfoCO rankInfo = new UserRankInfoCO();
|
||||
rankInfo.setUserId(cmd.getReqUserId());
|
||||
|
||||
// 从排行榜列表中查找当前用户
|
||||
Optional<RankingActivityRecordCO> userInList = rankingList.stream()
|
||||
.filter(record -> record.getUserId().equals(cmd.getReqUserId()))
|
||||
.findFirst();
|
||||
|
||||
if (userInList.isPresent()) {
|
||||
// 用户在榜单中
|
||||
RankingActivityRecordCO userRecord = userInList.get();
|
||||
rankInfo.setRank(userRecord.getRank());
|
||||
rankInfo.setQuantity(userRecord.getQuantity());
|
||||
rankInfo.setIsRanked(true);
|
||||
} else {
|
||||
// 用户不在榜单中,显示为0
|
||||
rankInfo.setRank(0);
|
||||
rankInfo.setQuantity(0L);
|
||||
rankInfo.setIsRanked(false);
|
||||
}
|
||||
|
||||
Optional<RankingActivityRecord> userRecord = rankingActivityGateway.getUserRecord(
|
||||
cmd.getReqSysOrigin().getOrigin(),
|
||||
cmd.getReqUserId(),
|
||||
RankingActivityType.getByCode(cmd.getActivityType()),
|
||||
cmd.getCycleKey()
|
||||
);
|
||||
|
||||
userRecord.ifPresent(rankingActivityRecord -> rankInfo.setQuantity(rankingActivityRecord.getQuantity()));
|
||||
|
||||
|
||||
return rankInfo;
|
||||
}
|
||||
|
||||
private Set<Long> getUserIds(List<RankingActivityRecord> weekStarGiftCounts) {
|
||||
|
||||
return weekStarGiftCounts.stream().map(RankingActivityRecord::getUserId)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user