用户VIP获取逻辑修复

This commit is contained in:
tianfeng 2026-03-19 18:15:07 +08:00
parent 1526e10404
commit f8d01ec784

View File

@ -637,33 +637,25 @@ public class UserProfileGatewayImpl implements UserProfileGateway {
@Override
public List<NobleAbilityCO> getUserNobleAbility(Long userId) {
return userCacheService.getUserNobleAbility(userId, this::getNobleAbility);
}
private List<NobleAbilityCO> getNobleAbility(Long userId) {
UserProfile userProfile = getByUserId(userId);
if (Objects.isNull(userProfile)) {
if (Objects.isNull(userProfile) || CollectionUtils.isEmpty(userProfile.getUseProps())) {
return null;
}
Set<Long> userVipPropsIds = getUserVipPropsIds(userProfile.getUseProps());
if (CollectionUtils.isEmpty(userVipPropsIds)) {
return null;
}
List<PropsNobleVipAbility> vipAbilities = propsNobleVipAbilityService.listByIds(userVipPropsIds);
if (CollectionUtils.isEmpty(vipAbilities)) {
return null;
}
return vipAbilities.stream().map(e -> {
NobleAbilityCO result = new NobleAbilityCO();
result.setVipType(e.getVipType());
result.setVipLevel(e.getVipLevel());
result.setRoomMaxMember(e.getRoomMaxMember());
return result;
}).toList();
return userProfile.getUseProps().stream()
.filter(props -> Objects.nonNull(props.getPropsResources())
&& PropsCommodityType.NOBLE_VIP.name().equals(props.getPropsResources().getType())
&& props.getExpireTime() != null
&& props.getExpireTime() > System.currentTimeMillis())
.map(props -> {
String vipName = props.getPropsResources().getName();
NobleVipEnum vipEnum = NobleVipEnum.valueOf(vipName);
NobleAbilityCO co = new NobleAbilityCO();
co.setVipType(vipName);
co.setVipLevel(vipEnum.ordinal() + 1);
return co;
})
.toList();
}
/**