diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/famliy/FamilyDetailsDTO.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/famliy/FamilyDetailsDTO.java index b28ce901..304bc37c 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/famliy/FamilyDetailsDTO.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/famliy/FamilyDetailsDTO.java @@ -63,7 +63,7 @@ public class FamilyDetailsDTO implements Serializable { /** * 等级key */ - private String levelKey; + private Integer level; /** * 等级经验值 diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java index 410709ae..694e0496 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java @@ -6,28 +6,7 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.framework.web.controller.BaseController; import com.red.circle.other.app.dto.clientobject.family.*; import com.red.circle.other.app.dto.clientobject.room.RoomVoiceProfileCO; -import com.red.circle.other.app.dto.cmd.family.ApplyJoinFamilyCmd; -import com.red.circle.other.app.dto.cmd.family.CancelFamilyApplyCmd; -import com.red.circle.other.app.dto.cmd.family.ReapplyFamilyCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyBoxClaimCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyAdminQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyBaseInfoQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyCreateCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyDailyTaskCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyGrantUserRoleCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyGroupChatPayCheckCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyGroupChatQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyInfoEditCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyListCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMemberListCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMemberListQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMessageHandleCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMessageListCmd; -import com.red.circle.other.app.dto.cmd.family.MyFamilyApplyListCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyOnlineRoomQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyRemoveUserCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyUserInfoQueryCmd; -import com.red.circle.other.app.dto.cmd.family.ReceiveFamilyAwardCmd; +import com.red.circle.other.app.dto.cmd.family.*; import com.red.circle.other.app.service.family.FamilyService; import com.red.circle.framework.dto.PageResult; import java.math.BigDecimal; @@ -163,6 +142,14 @@ public class FamilyRestController extends BaseController { return familyService.listLevelConfig(cmd); } + /** + * 首页家族列表. + */ + @GetMapping("/home-list") + public PageResult familyHomeList(FamilyHomeListCmd cmd) { + return familyService.familyHomeList(cmd); + } + /** * 家族在线房间. * diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyBaseInfoExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyBaseInfoExe.java index 312d044c..d8b036f0 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyBaseInfoExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyBaseInfoExe.java @@ -9,12 +9,10 @@ import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.model.user.OwnSpecialId; import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.infra.common.family.FamilyCommon; -import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.rds.entity.family.FamilyBaseInfo; import com.red.circle.other.infra.database.rds.entity.family.FamilyBoxDaily; import com.red.circle.other.infra.database.rds.entity.family.FamilyBoxUserReward; import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberInfo; -import com.red.circle.other.infra.database.rds.enums.OtherConfigEnum; import com.red.circle.other.infra.database.rds.service.family.FamilyBaseInfoService; import com.red.circle.other.infra.database.rds.service.family.FamilyBoxDailyService; import com.red.circle.other.infra.database.rds.service.family.FamilyBoxUserContributeService; @@ -26,11 +24,8 @@ import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberSer import com.red.circle.other.infra.enums.family.FamilyRoleEnum; import com.red.circle.other.infra.enums.family.FamilyStatusEnum; import com.red.circle.other.infra.enums.family.FamilyBoxConfigEnum; -import com.red.circle.other.inner.enums.config.EnumConfigKey; -import com.red.circle.other.inner.enums.team.TeamMemberRole; import com.red.circle.other.inner.model.dto.famliy.FamilyDetailsDTO; -import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @@ -42,7 +37,6 @@ import java.util.stream.Collectors; import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; import lombok.RequiredArgsConstructor; -import org.jetbrains.annotations.Nullable; import org.springframework.stereotype.Component; /** @@ -120,8 +114,7 @@ public class FamilyBaseInfoExe { .setCurrentExp( familyLevelExpService.getExp(baseInfo.getId(), baseInfo.getFamilyLevelId()).longValue()) .setCurrentMember(getFamilyMemberCount(baseInfo.getId())) - .setFamilyLevel(Optional.ofNullable(familyLevel.getLevelKey()) - .map(key -> Integer.parseInt(key.substring(6))) + .setFamilyLevel(Optional.ofNullable(familyLevel.getLevel()) .orElse(0)) .setLevelExp(familyLevel.getLevelExp()) .setMaxMember(familyLevel.getMaxMember()) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyHomeListExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyHomeListExe.java new file mode 100644 index 00000000..43125f51 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyHomeListExe.java @@ -0,0 +1,231 @@ +package com.red.circle.other.app.command.family; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.app.dto.clientobject.family.FamilyHomeListCO; +import com.red.circle.other.app.dto.clientobject.family.FamilyHomeMemberCO; +import com.red.circle.other.app.dto.clientobject.family.FamilyHomeRoomCO; +import com.red.circle.other.app.dto.cmd.family.FamilyHomeListCmd; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.model.user.UserConsumptionLevel; +import com.red.circle.other.domain.model.user.UserProfile; +import com.red.circle.other.infra.common.family.FamilyCommon; +import com.red.circle.other.infra.database.mongo.entity.live.ActiveVoiceRoom; +import com.red.circle.other.infra.database.mongo.entity.user.status.OnlineUser; +import com.red.circle.other.infra.database.mongo.service.live.ActiveVoiceRoomService; +import com.red.circle.other.infra.database.mongo.service.user.status.OnlineUserService; +import com.red.circle.other.infra.database.rds.entity.family.FamilyBaseInfo; +import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberInfo; +import com.red.circle.other.infra.database.rds.service.family.FamilyBaseInfoService; +import com.red.circle.other.infra.database.rds.service.family.FamilyLevelExpService; +import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService; +import com.red.circle.other.infra.enums.family.FamilyRoleEnum; +import com.red.circle.other.infra.enums.family.FamilyStatusEnum; +import com.red.circle.other.inner.model.dto.famliy.FamilyDetailsDTO; +import com.red.circle.tool.core.collection.CollectionUtils; +import com.red.circle.tool.core.num.NumUtils; +import java.math.BigDecimal; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 家族首页列表 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class FamilyHomeListExe { + + private final FamilyCommon familyCommon; + private final UserProfileGateway userProfileGateway; + private final OnlineUserService onlineUserService; + private final ActiveVoiceRoomService activeVoiceRoomService; + private final FamilyBaseInfoService familyBaseInfoService; + private final FamilyLevelExpService familyLevelExpService; + private final FamilyMemberInfoService familyMemberInfoService; + + public PageResult execute(FamilyHomeListCmd cmd) { + List familyList = getFamilyList(cmd); + + if (CollectionUtils.isEmpty(familyList)) { + return PageResult.newPageResult(0); + } + + Set familyIds = familyList.stream() + .map(FamilyBaseInfo::getId) + .collect(Collectors.toSet()); + + Map expMap = familyLevelExpService.mapTotalExpCountByFamilyIds(familyIds); + + List result = familyList.stream() + .map(family -> buildFamilyHomeCO(cmd, family, expMap.getOrDefault(family.getId(), BigDecimal.ZERO))) + .sorted(Comparator.comparing(FamilyHomeListExe::replaceExp, Comparator.reverseOrder())) + .collect(Collectors.toList()); + + PageResult pageResult = new PageResult<>(); + pageResult.setCurrent(cmd.getCurrent()); + pageResult.setSize(cmd.getSize()); + pageResult.setRecords(result); + return pageResult; + } + + private static long replaceExp(FamilyHomeListCO co) { + String replace = co.getExp() + .replace(",", "") + .replace("K", "") + .replace("M", "") + ; + return Long.parseLong(replace); + } + + private List getFamilyList(FamilyHomeListCmd cmd) { + IPage page = new Page<>(); + page.setCurrent(cmd.getCurrent()); + page.setSize(cmd.getSize()); + + return familyBaseInfoService.page( + page, + familyBaseInfoService.query() + .eq(FamilyBaseInfo::getSysOrigin, cmd.requireReqSysOrigin()) + .eq(FamilyBaseInfo::getFamilyStatus, FamilyStatusEnum.NORMAL.name()) + .orderByDesc(FamilyBaseInfo::getCreateTime) + .getWrapper() + ).getRecords(); + } + + private FamilyHomeListCO buildFamilyHomeCO(FamilyHomeListCmd cmd, FamilyBaseInfo family, BigDecimal totalExp) { + FamilyDetailsDTO levelDetails = familyCommon.getFamilyDetails(cmd.requireReqSysOrigin(), family.getId()); + + List members = familyMemberInfoService.listByFamilyId(family.getId()); + Set memberUserIds = members.stream() + .map(FamilyMemberInfo::getMemberUserId) + .collect(Collectors.toSet()); + + List onlineUsers = CollectionUtils.isEmpty(memberUserIds) + ? List.of() + : onlineUserService.userOnlineByUserIds(memberUserIds); + + Set onlineUserIds = onlineUsers.stream() + .map(OnlineUser::getUserId) + .collect(Collectors.toSet()); + + List displayMembers = buildDisplayMembers(cmd, members, onlineUserIds); + + List onlineRooms = activeVoiceRoomService.listByFamilyId(family.getId(), 4); + List roomCOs = buildRoomCOs(onlineRooms); + + return new FamilyHomeListCO() + .setFamilyId(family.getId()) + .setFamilyName(family.getFamilyName()) + .setFamilyAvatar(family.getFamilyAvatar()) + .setFamilyAccount(family.getFamilyAccount()) + .setLevel(levelDetails.getLevel()) + .setMemberCount(members.size()) + .setOnlineCount(onlineUsers.size()) + .setExp(NumUtils.formatLong(totalExp.longValue())) + .setAvatarFrameCover(levelDetails.getAvatarFrameCover()) + .setAvatarFrameSvg(levelDetails.getAvatarFrameSvg()) + .setDisplayMembers(displayMembers) + .setOnlineRooms(roomCOs); + } + + private List buildDisplayMembers(FamilyHomeListCmd cmd, + List members, Set onlineUserIds) { + + if (CollectionUtils.isEmpty(members)) { + return List.of(); + } + + Set userIds = members.stream() + .map(FamilyMemberInfo::getMemberUserId) + .collect(Collectors.toSet()); + + Map profileMap = userProfileGateway.mapByUserIds(userIds); + Map levelMap = userProfileGateway.getUserConsumptionLevel( + cmd.requireReqSysOriginEnum(), userIds); + + return members.stream() + .limit(8) + .sorted(getMemberComparator(levelMap)) + .map(member -> { + UserProfile profile = profileMap.get(member.getMemberUserId()); + UserConsumptionLevel level = levelMap.get(member.getMemberUserId()); + + return new FamilyHomeMemberCO() + .setUserId(member.getMemberUserId()) + .setAvatar(Objects.nonNull(profile) ? profile.getUserAvatar() : "") + .setOnline(onlineUserIds.contains(member.getMemberUserId())) + .setFamilyRole(member.getMemberRole()) + .setConsumptionLevel(Objects.nonNull(level) ? level.getWealthLevel() : 0); + }) + .collect(Collectors.toList()); + } + + private Comparator getMemberComparator(Map levelMap) { + return (m1, m2) -> { + int roleOrder1 = getRoleOrder(m1.getMemberRole()); + int roleOrder2 = getRoleOrder(m2.getMemberRole()); + + if (roleOrder1 != roleOrder2) { + return Integer.compare(roleOrder1, roleOrder2); + } + + if (FamilyRoleEnum.MEMBER.name().equals(m1.getMemberRole())) { + UserConsumptionLevel level1 = levelMap.get(m1.getMemberUserId()); + UserConsumptionLevel level2 = levelMap.get(m2.getMemberUserId()); + + int l1 = Objects.nonNull(level1) ? level1.getWealthLevel() : 0; + int l2 = Objects.nonNull(level2) ? level2.getWealthLevel() : 0; + + return Integer.compare(l2, l1); + } + + return 0; + }; + } + + private int getRoleOrder(String role) { + if (FamilyRoleEnum.ADMIN.name().equals(role)) { + return 1; + } else if (FamilyRoleEnum.MANAGE.name().equals(role)) { + return 2; + } else { + return 3; + } + } + + private List buildRoomCOs(List rooms) { + if (CollectionUtils.isEmpty(rooms)) { + return List.of(); + } + + Set userIds = rooms.stream() + .map(ActiveVoiceRoom::getUserId) + .collect(Collectors.toSet()); + + Map profileMap = userProfileGateway.mapByUserIds(userIds); + + return rooms.stream() + .map(room -> { + UserProfile profile = profileMap.get(room.getUserId()); + + return new FamilyHomeRoomCO() + .setRoomId(room.getId()) + .setRoomAccount(room.getRoomAccount()) + .setUserId(room.getUserId()) + .setUserAvatar(Objects.nonNull(profile) ? profile.getUserAvatar() : "") + .setUserNickname(Objects.nonNull(profile) ? profile.getUserNickname() : "") + .setOnlineQuantity(room.getOnlineQuantity()); + }) + .collect(Collectors.toList()); + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLeaderboardExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLeaderboardExe.java index 8a34fc0e..1daa517c 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLeaderboardExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLeaderboardExe.java @@ -2,6 +2,7 @@ package com.red.circle.other.app.command.family; import com.google.common.collect.Lists; import com.red.circle.common.business.dto.cmd.AppExtCommand; +import com.red.circle.live.inner.endpoint.LiveMicClient; import com.red.circle.other.app.dto.clientobject.family.FamilyLeaderboardCO; import com.red.circle.other.app.dto.clientobject.family.FamilyMemberWeekRankCO; import com.red.circle.other.domain.gateway.user.UserProfileGateway; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLevelListExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLevelListExe.java index 5d1f9607..c55478c5 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLevelListExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyLevelListExe.java @@ -37,7 +37,7 @@ public class FamilyLevelListExe { private FamilyLevelCO convertToLevelCO(FamilyLevelConfig config) { return new FamilyLevelCO() - .setLevelKey(config.getLevelKey()) + .setLevel(config.getLevelKey().substring(6)) .setLevelExp(config.getLevelExp()) .setMaxMember(config.getMaxMember()) .setMaxManager(config.getMaxManager()) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyUserInfoExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyUserInfoExe.java index 18075fed..3cce080e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyUserInfoExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyUserInfoExe.java @@ -1,6 +1,5 @@ package com.red.circle.other.app.command.family; -import com.red.circle.mq.business.model.event.task.TaskApprovalEvent; import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.other.app.dto.clientobject.family.FamilyUserInfoCO; import com.red.circle.other.app.dto.cmd.family.FamilyUserInfoQueryCmd; @@ -12,7 +11,6 @@ import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoSe import com.red.circle.other.inner.model.dto.famliy.FamilyDetailsDTO; import java.util.Objects; -import com.red.circle.tool.core.date.LocalDateTimeUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -74,7 +72,7 @@ public class FamilyUserInfoExe { .setFamilyAvatar(baseInfo.getFamilyAvatar()) .setFamilyName(baseInfo.getFamilyName()) .setFamilyRole(familyMemberInfo.getMemberRole()) - .setLevelKey(familyLevel.getLevelKey()) + .setLevel(familyLevel.getLevel()) .setCurrentMember(getFamilyMemberCount(baseInfo)) .setMaxMember(familyLevel.getMaxMember()) .setLevelBackgroundPicture(familyLevel.getLevelBackgroundPicture()) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java index bf08aea0..bc795b56 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java @@ -31,39 +31,10 @@ import com.red.circle.other.app.command.family.ReapplyFamilyExe; import com.red.circle.other.app.command.family.FamilyListExe; import com.red.circle.other.app.command.family.FamilyBoxContributeExe; import com.red.circle.other.app.command.family.FamilyBoxClaimExe; -import com.red.circle.other.app.dto.clientobject.family.FamilyBaseInfoCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyCreateRulesCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyLeaderboardCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyLevelCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyListCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyMemberCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyMsgListCO; -import com.red.circle.other.app.dto.clientobject.family.MyFamilyApplyCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyRewardCO; -import com.red.circle.other.app.dto.clientobject.family.FamilyUserInfoCO; +import com.red.circle.other.app.command.family.FamilyHomeListExe; +import com.red.circle.other.app.dto.clientobject.family.*; import com.red.circle.other.app.dto.clientobject.room.RoomVoiceProfileCO; -import com.red.circle.other.app.dto.cmd.family.ApplyJoinFamilyCmd; -import com.red.circle.other.app.dto.cmd.family.CancelFamilyApplyCmd; -import com.red.circle.other.app.dto.cmd.family.ReapplyFamilyCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyBoxClaimCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyAdminQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyBaseInfoQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyCreateCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyDailyTaskCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyGrantUserRoleCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyGroupChatPayCheckCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyGroupChatQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyInfoEditCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyListCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMemberListCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMemberListQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMessageHandleCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyMessageListCmd; -import com.red.circle.other.app.dto.cmd.family.MyFamilyApplyListCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyOnlineRoomQueryCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyRemoveUserCmd; -import com.red.circle.other.app.dto.cmd.family.FamilyUserInfoQueryCmd; -import com.red.circle.other.app.dto.cmd.family.ReceiveFamilyAwardCmd; +import com.red.circle.other.app.dto.cmd.family.*; import com.red.circle.framework.dto.PageResult; import java.math.BigDecimal; import java.util.List; @@ -116,6 +87,7 @@ public class FamilyServiceImpl implements FamilyService { private final FamilyBoxContributeExe familyBoxContributeExe; private final FamilyBoxClaimExe familyBoxClaimExe; private final DistributedLockUtil distributedLockUtil; + private final FamilyHomeListExe familyHomeListExe; @Override public Long create(FamilyCreateCmd cmd) { @@ -285,4 +257,9 @@ public class FamilyServiceImpl implements FamilyService { familyBoxClaimExe.execute(cmd); }); } + + @Override + public PageResult familyHomeList(FamilyHomeListCmd cmd) { + return familyHomeListExe.execute(cmd); + } } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeListCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeListCO.java new file mode 100644 index 00000000..ac2462b4 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeListCO.java @@ -0,0 +1,80 @@ +package com.red.circle.other.app.dto.clientobject.family; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 家族首页列表 + */ +@Data +@Accessors(chain = true) +public class FamilyHomeListCO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 家族ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long familyId; + + /** + * 家族名称 + */ + private String familyName; + + /** + * 家族头像 + */ + private String familyAvatar; + + /** + * 家族ID号 + */ + private String familyAccount; + + /** + * 家族等级 + */ + private Integer level; + + /** + * 家族总人数 + */ + private Integer memberCount; + + /** + * 在线用户数 + */ + private Integer onlineCount; + + /** + * 家族经验值 + */ + private String exp; + + /** + * 头像框封面 + */ + private String avatarFrameCover; + + /** + * 头像框SVG + */ + private String avatarFrameSvg; + + /** + * 展示的成员列表(按规则排序) + */ + private List displayMembers; + + /** + * 在线房间列表(最多4个) + */ + private List onlineRooms; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeMemberCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeMemberCO.java new file mode 100644 index 00000000..e2fda599 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeMemberCO.java @@ -0,0 +1,44 @@ +package com.red.circle.other.app.dto.clientobject.family; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 家族首页成员信息 + */ +@Data +@Accessors(chain = true) +public class FamilyHomeMemberCO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long userId; + + /** + * 用户头像 + */ + private String avatar; + + /** + * 是否在线 + */ + private Boolean online; + + /** + * 家族角色 + */ + private String familyRole; + + /** + * 财富等级 + */ + private Integer consumptionLevel; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeRoomCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeRoomCO.java new file mode 100644 index 00000000..246d98fa --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyHomeRoomCO.java @@ -0,0 +1,50 @@ +package com.red.circle.other.app.dto.clientobject.family; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 家族首页房间信息 + */ +@Data +@Accessors(chain = true) +public class FamilyHomeRoomCO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 房间ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long roomId; + + /** + * 房间账号 + */ + private String roomAccount; + + /** + * 房主ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long userId; + + /** + * 房主头像 + */ + private String userAvatar; + + /** + * 房主昵称 + */ + private String userNickname; + + /** + * 在线人数 + */ + private Long onlineQuantity; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyLevelCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyLevelCO.java index 109676ec..3dc92c15 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyLevelCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyLevelCO.java @@ -23,7 +23,7 @@ public class FamilyLevelCO implements Serializable { /** * 等级key */ - private String levelKey; + private String level; /** * 等级经验值 diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyUserInfoCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyUserInfoCO.java index 0717be7a..c8cb1322 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyUserInfoCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/family/FamilyUserInfoCO.java @@ -51,9 +51,9 @@ public class FamilyUserInfoCO extends ClientObject { private String familyRole; /** - * 等级KEY. + * 等级 */ - private String levelKey; + private Integer level; /** * 当前成员数. diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/FamilyHomeListCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/FamilyHomeListCmd.java new file mode 100644 index 00000000..2671bfc1 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/FamilyHomeListCmd.java @@ -0,0 +1,18 @@ +package com.red.circle.other.app.dto.cmd.family; + +import com.red.circle.common.business.dto.PageQueryCmd; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 家族首页列表查询 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class FamilyHomeListCmd extends PageQueryCmd { + + private static final long serialVersionUID = 1L; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java index 0f647c68..0adb62f1 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java @@ -165,4 +165,9 @@ public interface FamilyService { * 领取家族宝箱奖励. */ void boxClaim(FamilyBoxClaimCmd cmd); + + /** + * 家族首页列表. + */ + PageResult familyHomeList(FamilyHomeListCmd cmd); } diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java index 55c454ac..9a1dbda8 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java @@ -144,6 +144,8 @@ public interface UserProfileGateway { */ UserConsumptionLevel getUserConsumptionLevel(SysOriginPlatformEnum sysOrigin, Long userId); + Map getUserConsumptionLevel(SysOriginPlatformEnum sysOrigin, Set userIds); + /** * 检测是否是好友关系. * diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java index 77453929..60ff1c7a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java @@ -190,7 +190,7 @@ public class FamilyCommon { } FamilyDetailsDTO currentLevel = getFamilyDetails(sysOrigin, member.getFamilyId()); - if (StringUtils.isBlank(sysOrigin) || Objects.isNull(currentLevel) || StringUtils.isBlank(currentLevel.getLevelKey())) { + if (StringUtils.isBlank(sysOrigin) || Objects.isNull(currentLevel) || Objects.isNull(currentLevel.getLevel())) { log.error("增加家族经验失败,FamilyId:{}", member.getFamilyId()); return; } @@ -460,7 +460,7 @@ public class FamilyCommon { familyCO.setLevelSort(levelConfig.getSort()); familyCO.setFamilyLevelId(levelConfig.getId()); - familyCO.setLevelKey(levelConfig.getLevelKey()); + familyCO.setLevel(Integer.parseInt(levelConfig.getLevelKey().substring(6))); familyCO.setLevelExp(Long.valueOf(levelConfig.getLevelExp())); familyCO.setMaxMember(levelConfig.getMaxMember()); familyCO.setMaxManager(levelConfig.getMaxManager()); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java index 83e87f9e..23d96d11 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java @@ -451,6 +451,19 @@ public class UserProfileGatewayImpl implements UserProfileGateway { ); } + @Override + public Map getUserConsumptionLevel(SysOriginPlatformEnum sysOrigin, Set userIds) { + if (CollectionUtils.isEmpty(userIds)) { + return Map.of(); + } + + return userIds.stream() + .collect(Collectors.toMap( + userId -> userId, + userId -> getUserConsumptionLevel(sysOrigin, userId) + )); + } + @Override public boolean checkFriend(Long userId, Long friendUserId) {