diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java index 72daa97b..0544a34c 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java @@ -12,6 +12,7 @@ import com.red.circle.other.inner.model.cmd.user.UserBaseInfoCmd; import com.red.circle.other.inner.model.cmd.user.UserProfileListQryCmd; import com.red.circle.other.inner.model.cmd.user.UserRemoveUsePropsCmd; import com.red.circle.other.inner.model.cmd.user.UserSwitchUsePropsCmd; +import com.red.circle.other.inner.model.dto.user.SimpleUserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserPhotoWallDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserRegisterInfoDTO; @@ -236,4 +237,10 @@ public interface UserProfileClientApi { */ @GetMapping("/restoreAuth") ResultResponse restoreAuthDelByUserId(@RequestParam("userId") Long userId); + + /** + * 获取用户资料集合(简化版,不含 cpList/backgroundPhotos/personalPhotos/useProps/badge/honor/firstRecharge). + */ + @PostMapping("/mapByUserIds/simple") + ResultResponse> mapByUserIdsSimple(@RequestBody Set userIds); } diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/user/SimpleUserProfileDTO.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/user/SimpleUserProfileDTO.java new file mode 100644 index 00000000..74e8fb50 --- /dev/null +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/user/SimpleUserProfileDTO.java @@ -0,0 +1,185 @@ +package com.red.circle.other.inner.model.dto.user; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.red.circle.common.business.enums.AccountStatusEnum; +import com.red.circle.common.business.enums.ConsoleAccountStatusEnum; +import com.red.circle.tool.core.date.TimestampUtils; +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.List; +import java.util.Objects; +import lombok.Data; + +/** + * 用户资料(简化版,不含 cpList/backgroundPhotos/personalPhotos/useProps/badge/honor/firstRecharge). + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class SimpleUserProfileDTO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private String account; + + private String userAvatar; + + private String userNickname; + + private Integer userSex; + + private Integer age; + + private String accountStatus; + + private Timestamp freezingTime; + + private String isUpdateCountry; + + @JsonSerialize(using = ToStringSerializer.class) + private Long countryId; + + private String countryName; + + private String countryCode; + + private String autograph; + + private String hobby; + + private Boolean isCpRelation; + + @JsonSerialize(using = ToStringSerializer.class) + private Long familyId; + + private String inRoomId; + + private String roomIcon; + + private String regionCode; + + private Integer wealthLevel; + + private Integer charmLevel; + + private String originSys; + + private String sysOriginChild; + + private Boolean del; + + private Timestamp createTime; + + private Integer bornYear; + + private Integer bornMonth; + + private Integer bornDay; + + private OwnSpecialIdDTO ownSpecialId; + + private Boolean sameRegion; + + private Boolean isFreightAgent; + + private Boolean isSuperFreightAgent; + + private BigDecimal firstRechargeAmount; + + public void setCountryCode(String countryCode) { + if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "IA")) { + this.countryCode = "ID"; + } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "EY")) { + this.countryCode = "EG"; + } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "AB")) { + this.countryCode = "AE"; + } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "MB")) { + this.countryCode = "MA"; + } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "SP")) { + this.countryCode = "SA"; + } else { + this.countryCode = countryCode; + } + } + + @JsonSerialize(using = ToStringSerializer.class) + public Long getFreezingExpiredInterval() { + return TimestampUtils.expiredInterval(freezingTime); + } + + public boolean checkAccountAvailable() { + return !checkAccountArchive() && !checkAccountFreeze(); + } + + public boolean checkAccountArchive() { + return AccountStatusEnum.isArchive(this.accountStatus); + } + + public boolean checkAccountFreeze() { + return AccountStatusEnum.isFreeze(this.freezingTime); + } + + public AccountStatusEnum getAccountStatus() { + if (this.checkAccountAvailable()) { + return AccountStatusEnum.NORMAL; + } + if (Objects.equals(AccountStatusEnum.ARCHIVE.name(), this.accountStatus) && !this.checkAccountFreeze()) { + return AccountStatusEnum.NORMAL; + } + if (this.checkAccountFreeze()) { + return AccountStatusEnum.FREEZE; + } + return AccountStatusEnum.valueOf(this.accountStatus); + } + + public String getAccountStatusName() { + if (Objects.nonNull(this.freezingTime) && this.freezingTime.after(TimestampUtils.now())) { + return ConsoleAccountStatusEnum.FREEZE.getDesc(); + } + if (Objects.equals(ConsoleAccountStatusEnum.FREEZE.name(), accountStatus)) { + return ConsoleAccountStatusEnum.NORMAL.getDesc(); + } + return ConsoleAccountStatusEnum.getDescValue(this.getActualAccountStatus()); + } + + public String getActualAccountStatus() { + if (Objects.nonNull(this.freezingTime) && this.freezingTime.after(TimestampUtils.now())) { + return AccountStatusEnum.FREEZE.name(); + } + if (Objects.equals(AccountStatusEnum.FREEZE.name(), this.accountStatus)) { + return AccountStatusEnum.NORMAL.name(); + } + return this.accountStatus; + } + + @JsonIgnore + public String getActualAccount() { + return checkOwnSpecialIdAvailable() ? this.ownSpecialId.getAccount() : this.account; + } + + public String actualAccount() { + return checkOwnSpecialIdAvailable() ? this.ownSpecialId.getAccount() : this.account; + } + + public String specialAccount() { + return checkOwnSpecialIdAvailable() ? this.ownSpecialId.getAccount() : null; + } + + private boolean checkOwnSpecialIdAvailable() { + boolean exists = Objects.nonNull(this.ownSpecialId) + && Objects.nonNull(this.ownSpecialId.getAccount()); + if (!exists) { + return false; + } + return Objects.isNull(this.ownSpecialId.getExpiredTime()) + || this.ownSpecialId.getExpiredTime().after(TimestampUtils.now()); + } +} diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserWalletServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserWalletServiceImpl.java index 44c43cfd..154acdef 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserWalletServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserWalletServiceImpl.java @@ -26,6 +26,7 @@ import com.red.circle.tool.core.text.StringUtils; import com.red.circle.other.inner.asserts.user.UserErrorCode; import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; import com.red.circle.other.inner.endpoint.user.user.UserSvipClient; +import com.red.circle.other.inner.model.dto.user.SimpleUserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.wallet.inner.endpoint.wallet.WalletDiamondClient; import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient; @@ -91,8 +92,8 @@ public class UserWalletServiceImpl implements UserWalletService { return Lists.newArrayList(); } - Map userProfileMap = ResponseAssert.requiredSuccess( - userProfileClient.mapByUserIds( + Map userProfileMap = ResponseAssert.requiredSuccess( + userProfileClient.mapByUserIdsSimple( runningWaters.stream().map(UserGoldRunningWaterHistoryDTO::getUserId) .collect(Collectors.toSet()))); /* @@ -104,7 +105,7 @@ public class UserWalletServiceImpl implements UserWalletService { return runningWaters.stream() .map(runningWater -> { - UserProfileDTO userProfile = userProfileMap.get(runningWater. + SimpleUserProfileDTO userProfile = userProfileMap.get(runningWater. getUserId()); if (Objects.isNull(userProfile)) { @@ -144,7 +145,7 @@ public class UserWalletServiceImpl implements UserWalletService { List clsWaterWaters = clsWater.getWaters(); - Map userProfileMap = userProfileClient.mapByUserIds( + Map userProfileMap = userProfileClient.mapByUserIdsSimple( clsWaterWaters.stream().map(UserGoldRunningWaterHistoryDTO::getUserId) .collect(Collectors.toSet()) ).getBody(); @@ -163,7 +164,7 @@ public class UserWalletServiceImpl implements UserWalletService { .setWaters(clsWaterWaters.stream() .map(runningWater -> { - UserProfileDTO userProfile = userProfileMap.get(runningWater. + SimpleUserProfileDTO userProfile = userProfileMap.get(runningWater. getUserId()); if (Objects.isNull(userProfile)) { diff --git a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/user/UserGoldRunningWaterCO.java b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/user/UserGoldRunningWaterCO.java index 78232151..9f2ad6bf 100644 --- a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/user/UserGoldRunningWaterCO.java +++ b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/user/UserGoldRunningWaterCO.java @@ -1,7 +1,7 @@ package com.red.circle.console.app.dto.clienobject.user; import cn.hutool.core.convert.Convert; -import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import com.red.circle.other.inner.model.dto.user.SimpleUserProfileDTO; import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterDTO; import java.io.Serializable; import lombok.Data; @@ -21,7 +21,7 @@ public class UserGoldRunningWaterCO extends Convert implements Serializable { /** * 用户资料. */ - private UserProfileDTO userProfile; + private SimpleUserProfileDTO userProfile; /** * 流水. diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java index 3ea601c0..74e2028c 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java @@ -27,6 +27,7 @@ import com.red.circle.other.inner.model.dto.user.UserExpandDTO; import com.red.circle.other.inner.model.dto.user.UserPhotoWallDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserRegisterInfoDTO; +import com.red.circle.other.inner.model.dto.user.SimpleUserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserRunProfileDTO; import com.red.circle.other.inner.model.dto.user.WealthAndCharmExpLevelDTO; import java.sql.Timestamp; @@ -108,4 +109,6 @@ public interface UserProfileInnerConvertor { PageResult toListUserProfileDTO(PageResult userProfiles); Map toMapUserProfileDTO(Map map); + + SimpleUserProfileDTO toSimpleUserProfileDTO(UserProfile userProfile); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java index ce1da828..0fa57ae5 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java @@ -17,6 +17,7 @@ import com.red.circle.other.inner.model.cmd.user.UserBaseInfoCmd; import com.red.circle.other.inner.model.cmd.user.UserProfileListQryCmd; import com.red.circle.other.inner.model.cmd.user.UserRemoveUsePropsCmd; import com.red.circle.other.inner.model.cmd.user.UserSwitchUsePropsCmd; +import com.red.circle.other.inner.model.dto.user.SimpleUserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserPhotoWallDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserRegisterInfoDTO; @@ -267,4 +268,9 @@ public class UserProfileClientEndpoint implements UserProfileClientApi { userProfileClientService.restoreAuthDelByUserId(userId); return ResultResponse.success(); } + + @Override + public ResultResponse> mapByUserIdsSimple(Set userIds) { + return ResultResponse.success(userProfileClientService.mapByUserIdsSimple(userIds)); + } } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java index 92bbed58..2023f423 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java @@ -8,6 +8,7 @@ import com.red.circle.other.inner.model.cmd.user.UpdateUserNicknameBatchCmd; import com.red.circle.other.inner.model.cmd.user.UserBaseInfoCmd; import com.red.circle.other.inner.model.cmd.user.UserProfileListQryCmd; import com.red.circle.other.inner.model.dto.user.PetRelationshipFriendDTO; +import com.red.circle.other.inner.model.dto.user.SimpleUserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserPhotoWallDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserRegisterInfoDTO; @@ -71,6 +72,11 @@ public interface UserProfileClientService { */ Map mapByUserIds(Set userIds); + /** + * 获取用户资料集合(简化版,不含 cpList/backgroundPhotos/personalPhotos/useProps/badge/honor/firstRecharge). + */ + Map mapByUserIdsSimple(Set userIds); + /** * 根据id查询用户集合. */ diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java index 7b277e35..7e91e342 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java @@ -35,6 +35,7 @@ import com.red.circle.other.inner.model.cmd.user.UpdateUserNicknameBatchCmd; import com.red.circle.other.inner.model.cmd.user.UserBaseInfoCmd; import com.red.circle.other.inner.model.cmd.user.UserProfileListQryCmd; import com.red.circle.other.inner.model.dto.user.PetRelationshipFriendDTO; +import com.red.circle.other.inner.model.dto.user.SimpleUserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserPhotoWallDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserRegisterInfoDTO; @@ -200,6 +201,19 @@ public class UserProfileClientServiceImpl implements UserProfileClientService { .collect(Collectors.toMap(UserProfile::getId, userProfileInnerConvertor::toUserProfileDTO)); } + @Override + public Map mapByUserIdsSimple(Set userIds) { + if (CollectionUtils.isEmpty(userIds)) { + return Maps.newHashMap(); + } + List userProfiles = userProfileGateway.listByUserIds(userIds); + if (CollectionUtils.isEmpty(userProfiles)) { + return Maps.newHashMap(); + } + return userProfiles.stream() + .collect(Collectors.toMap(UserProfile::getId, userProfileInnerConvertor::toSimpleUserProfileDTO)); + } + @Override public List listByUserId(Set userIds) { return userProfileGateway.listByUserIds(userIds).stream()