feat: batch query wealthLevel and set to userBaseInfo in pageFreight

This commit is contained in:
tianfeng 2026-05-27 12:03:48 +08:00
parent a2f94f029c
commit 0dee3e6ca9

View File

@ -11,6 +11,7 @@ import com.red.circle.other.app.dto.clientobject.user.UserFreightBalanceCO;
import com.red.circle.other.app.service.sys.AppConfigService;
import com.red.circle.other.app.service.user.UserFreightBalanceRestService;
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.database.mongo.entity.user.region.SysRegionConfig;
import com.red.circle.other.infra.database.mongo.service.user.region.SysRegionConfigService;
@ -103,6 +104,8 @@ public class UserFreightBalanceRestServiceImpl implements UserFreightBalanceRest
Map<Long, UserProfileDTO> userBaseInfoMap = ResponseAssert.requiredSuccess(userProfileClient.mapByUserIds(pagedUserIds));
Map<Long, Long> transactionCountMap = freightGoldClient.mapTransactionCountByUserIds(pagedUserIds).getBody();
Map<Long, Boolean> followMap = userProfileGateway.mapIsFollow(reqUserId, pagedUserIds);
Map<Long, UserConsumptionLevel> consumptionLevelMap = userProfileGateway.getUserConsumptionLevel(
appExtCommand.getReqSysOriginPlatformEnum(), pagedUserIds);
AppCountryCodeCO appCountryCode = appConfigService.getAppCountryCode();
Map<String, String> countryFlagMap = buildCountryFlagMap(appCountryCode);
@ -120,6 +123,14 @@ public class UserFreightBalanceRestServiceImpl implements UserFreightBalanceRest
co.setIsFollow(Boolean.TRUE.equals(followMap.get(dto.getUserId())));
co.setUserBaseInfo(userBaseInfoMap.get(dto.getUserId()));
UserProfileDTO userBaseInfo = co.getUserBaseInfo();
if (userBaseInfo != null) {
UserConsumptionLevel level = consumptionLevelMap.get(dto.getUserId());
if (level != null) {
userBaseInfo.setWealthLevel(level.getWealthLevel());
}
}
if (dto.getCreateTime() != null) {
long days = ChronoUnit.DAYS.between(dto.getCreateTime().toLocalDateTime(), LocalDateTime.now());
co.setBecomeDays((int) days);