cp榜单我的排名处理
This commit is contained in:
parent
1e84507252
commit
44d7941e50
@ -50,7 +50,7 @@ public class WeekCpUserGiftQueryExe {
|
|||||||
|
|
||||||
private ActivityWeekCpGiftCO getWeekRanking(CpRankingQueryCmd cmd) {
|
private ActivityWeekCpGiftCO getWeekRanking(CpRankingQueryCmd cmd) {
|
||||||
List<ActivityCpUserRankingCO> topList = getThisWeekUser(cmd);
|
List<ActivityCpUserRankingCO> topList = getThisWeekUser(cmd);
|
||||||
ActivityCpUserRankingCO currentUser = getThisWeekCurrentUser(cmd, topList);
|
ActivityCpUserRankingCO currentUser = getCurrentUserRankingCO(cmd, topList);
|
||||||
|
|
||||||
return new ActivityWeekCpGiftCO()
|
return new ActivityWeekCpGiftCO()
|
||||||
.setThisWeekUserTop(topList)
|
.setThisWeekUserTop(topList)
|
||||||
@ -59,71 +59,50 @@ public class WeekCpUserGiftQueryExe {
|
|||||||
|
|
||||||
private ActivityWeekCpGiftCO getSeasonRanking(CpRankingQueryCmd cmd) {
|
private ActivityWeekCpGiftCO getSeasonRanking(CpRankingQueryCmd cmd) {
|
||||||
List<ActivityCpUserRankingCO> topList = getThisSeasonUser(cmd);
|
List<ActivityCpUserRankingCO> topList = getThisSeasonUser(cmd);
|
||||||
ActivityCpUserRankingCO currentUser = getThisSeasonCurrentUser(cmd, topList);
|
ActivityCpUserRankingCO currentUser = getCurrentUserRankingCO(cmd, topList);
|
||||||
|
|
||||||
return new ActivityWeekCpGiftCO()
|
return new ActivityWeekCpGiftCO()
|
||||||
.setThisWeekUserTop(topList)
|
.setThisWeekUserTop(topList)
|
||||||
.setThisUser(currentUser);
|
.setThisUser(currentUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityCpUserRankingCO getThisWeekCurrentUser(CpRankingQueryCmd cmd,
|
private ActivityCpUserRankingCO queryCurrentUserCO(Long reqUserId) {
|
||||||
List<ActivityCpUserRankingCO> topList) {
|
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
|
||||||
List<Long> cpUserIdList = cpRelationshipService.getCpUserId(cmd.getReqUserId());
|
userProfileGateway.mapByUserIds(Set.of(reqUserId)));
|
||||||
if (cpUserIdList.isEmpty()) {
|
ActivityCpUserRankingCO rankingCO = new ActivityCpUserRankingCO();
|
||||||
return new ActivityCpUserRankingCO();
|
UserProfileDTO userProfileDTO = userProfileMap.get(reqUserId);
|
||||||
|
if (userProfileDTO != null) {
|
||||||
|
rankingCO.setUserAvatar(userProfileDTO.getUserAvatar());
|
||||||
|
rankingCO.setUserNickname(userProfileDTO.getUserNickname());
|
||||||
|
rankingCO.setUserSex(userProfileDTO.getUserSex());
|
||||||
}
|
}
|
||||||
|
rankingCO.setRank(999);
|
||||||
Long cpUserId = cpUserIdList.get(0);
|
rankingCO.setTotalNumber(0L);
|
||||||
|
rankingCO.setTotal("0");
|
||||||
// 先在Top榜单中查找
|
return rankingCO;
|
||||||
ActivityCpUserRankingCO userInTop = findUserInTopList(cmd.getReqUserId(), cpUserId, topList);
|
|
||||||
if (Objects.nonNull(userInTop)) {
|
|
||||||
return userInTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 不在Top榜单,单独查询并设置排名为99
|
|
||||||
WeekCpValueCount thisUser = weekCpValueCountService.getUserThisWeekCount(
|
|
||||||
cmd.getReqSysOrigin().getOrigin(),
|
|
||||||
cmd.getReqUserId(), cpUserId);
|
|
||||||
if (Objects.isNull(thisUser)) {
|
|
||||||
return new ActivityCpUserRankingCO();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ActivityCpUserRankingCO> users = assemble(Lists.newArrayList(thisUser), OUT_OF_RANK);
|
|
||||||
if (CollectionUtils.isEmpty(users)) {
|
|
||||||
return new ActivityCpUserRankingCO();
|
|
||||||
}
|
|
||||||
return users.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityCpUserRankingCO getThisSeasonCurrentUser(CpRankingQueryCmd cmd,
|
private ActivityCpUserRankingCO getCurrentUserRankingCO(CpRankingQueryCmd cmd,
|
||||||
List<ActivityCpUserRankingCO> topList) {
|
List<ActivityCpUserRankingCO> topList) {
|
||||||
List<Long> cpUserIdList = cpRelationshipService.getCpUserId(cmd.getReqUserId());
|
List<Long> cpUserIdList = cpRelationshipService.getCpUserId(cmd.getReqUserId());
|
||||||
if (cpUserIdList.isEmpty()) {
|
if (cpUserIdList.isEmpty()) {
|
||||||
return new ActivityCpUserRankingCO();
|
return queryCurrentUserCO(cmd.getReqUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
Long cpUserId = cpUserIdList.get(0);
|
ActivityCpUserRankingCO userInTop = new ActivityCpUserRankingCO();
|
||||||
|
userInTop.setTotalNumber(0L);
|
||||||
// 先在Top榜单中查找
|
for (Long cpUserId : cpUserIdList) {
|
||||||
ActivityCpUserRankingCO userInTop = findUserInTopList(cmd.getReqUserId(), cpUserId, topList);
|
ActivityCpUserRankingCO rankingCO = findUserInTopList(cmd.getReqUserId(), cpUserId, topList);
|
||||||
if (Objects.nonNull(userInTop)) {
|
if (rankingCO != null && rankingCO.getTotalNumber() > userInTop.getTotalNumber()) {
|
||||||
return userInTop;
|
userInTop = rankingCO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不在Top榜单,单独查询并设置排名为99
|
if (Objects.isNull(userInTop.getUserId())) {
|
||||||
WeekCpValueCount thisSeason = weekCpValueCountService.getUserThisSeasonCount(
|
return queryCurrentUserCO(cmd.getReqUserId());
|
||||||
cmd.getReqSysOrigin().getOrigin(),
|
|
||||||
cmd.getReqUserId(), cpUserId);
|
|
||||||
if (Objects.isNull(thisSeason)) {
|
|
||||||
return new ActivityCpUserRankingCO();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ActivityCpUserRankingCO> users = assemble(Lists.newArrayList(thisSeason), OUT_OF_RANK);
|
return userInTop;
|
||||||
if (CollectionUtils.isEmpty(users)) {
|
|
||||||
return new ActivityCpUserRankingCO();
|
|
||||||
}
|
|
||||||
return users.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityCpUserRankingCO findUserInTopList(Long userId, Long cpUserId,
|
private ActivityCpUserRankingCO findUserInTopList(Long userId, Long cpUserId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user