diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/WeekCpUserGiftQueryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/WeekCpUserGiftQueryExe.java index 2524b4d3..43955b9d 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/WeekCpUserGiftQueryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/WeekCpUserGiftQueryExe.java @@ -50,7 +50,7 @@ public class WeekCpUserGiftQueryExe { private ActivityWeekCpGiftCO getWeekRanking(CpRankingQueryCmd cmd) { List topList = getThisWeekUser(cmd); - ActivityCpUserRankingCO currentUser = getThisWeekCurrentUser(cmd, topList); + ActivityCpUserRankingCO currentUser = getCurrentUserRankingCO(cmd, topList); return new ActivityWeekCpGiftCO() .setThisWeekUserTop(topList) @@ -59,71 +59,50 @@ public class WeekCpUserGiftQueryExe { private ActivityWeekCpGiftCO getSeasonRanking(CpRankingQueryCmd cmd) { List topList = getThisSeasonUser(cmd); - ActivityCpUserRankingCO currentUser = getThisSeasonCurrentUser(cmd, topList); + ActivityCpUserRankingCO currentUser = getCurrentUserRankingCO(cmd, topList); return new ActivityWeekCpGiftCO() .setThisWeekUserTop(topList) .setThisUser(currentUser); } - private ActivityCpUserRankingCO getThisWeekCurrentUser(CpRankingQueryCmd cmd, - List topList) { - List cpUserIdList = cpRelationshipService.getCpUserId(cmd.getReqUserId()); - if (cpUserIdList.isEmpty()) { - return new ActivityCpUserRankingCO(); + private ActivityCpUserRankingCO queryCurrentUserCO(Long reqUserId) { + Map userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( + userProfileGateway.mapByUserIds(Set.of(reqUserId))); + ActivityCpUserRankingCO rankingCO = new ActivityCpUserRankingCO(); + UserProfileDTO userProfileDTO = userProfileMap.get(reqUserId); + if (userProfileDTO != null) { + rankingCO.setUserAvatar(userProfileDTO.getUserAvatar()); + rankingCO.setUserNickname(userProfileDTO.getUserNickname()); + rankingCO.setUserSex(userProfileDTO.getUserSex()); } - - Long cpUserId = cpUserIdList.get(0); - - // 先在Top榜单中查找 - 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 users = assemble(Lists.newArrayList(thisUser), OUT_OF_RANK); - if (CollectionUtils.isEmpty(users)) { - return new ActivityCpUserRankingCO(); - } - return users.get(0); + rankingCO.setRank(999); + rankingCO.setTotalNumber(0L); + rankingCO.setTotal("0"); + return rankingCO; } - private ActivityCpUserRankingCO getThisSeasonCurrentUser(CpRankingQueryCmd cmd, - List topList) { + private ActivityCpUserRankingCO getCurrentUserRankingCO(CpRankingQueryCmd cmd, + List topList) { List cpUserIdList = cpRelationshipService.getCpUserId(cmd.getReqUserId()); if (cpUserIdList.isEmpty()) { - return new ActivityCpUserRankingCO(); + return queryCurrentUserCO(cmd.getReqUserId()); } - Long cpUserId = cpUserIdList.get(0); - - // 先在Top榜单中查找 - ActivityCpUserRankingCO userInTop = findUserInTopList(cmd.getReqUserId(), cpUserId, topList); - if (Objects.nonNull(userInTop)) { - return userInTop; + ActivityCpUserRankingCO userInTop = new ActivityCpUserRankingCO(); + userInTop.setTotalNumber(0L); + for (Long cpUserId : cpUserIdList) { + ActivityCpUserRankingCO rankingCO = findUserInTopList(cmd.getReqUserId(), cpUserId, topList); + if (rankingCO != null && rankingCO.getTotalNumber() > userInTop.getTotalNumber()) { + userInTop = rankingCO; + } } - - // 不在Top榜单,单独查询并设置排名为99 - WeekCpValueCount thisSeason = weekCpValueCountService.getUserThisSeasonCount( - cmd.getReqSysOrigin().getOrigin(), - cmd.getReqUserId(), cpUserId); - if (Objects.isNull(thisSeason)) { - return new ActivityCpUserRankingCO(); + + if (Objects.isNull(userInTop.getUserId())) { + return queryCurrentUserCO(cmd.getReqUserId()); } - - List users = assemble(Lists.newArrayList(thisSeason), OUT_OF_RANK); - if (CollectionUtils.isEmpty(users)) { - return new ActivityCpUserRankingCO(); - } - return users.get(0); + + return userInTop; } private ActivityCpUserRankingCO findUserInTopList(Long userId, Long cpUserId,