VIP权益暂时 增加白名单处理

This commit is contained in:
tianfeng 2026-03-17 19:06:24 +08:00
parent 206383602d
commit 0ccb38c460

View File

@ -20,6 +20,7 @@ import com.red.circle.other.infra.common.props.PropsBackpackCommon;
import com.red.circle.other.infra.common.props.UserBadgeCommon;
import com.red.circle.other.infra.convertor.user.UserProfileInfraConvertor;
import com.red.circle.other.infra.database.cache.entity.user.ConsumptionLevelCache;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
import com.red.circle.other.infra.database.cache.service.user.UserCacheService;
import com.red.circle.other.infra.database.cache.service.user.UserRegionCacheService;
import com.red.circle.other.infra.database.cache.service.user.UserRelationshipCacheService;
@ -45,6 +46,7 @@ import com.red.circle.other.inner.enums.material.PropsCommodityType;
import com.red.circle.other.inner.enums.material.PropsVipActualEquityEnum;
import com.red.circle.other.inner.model.cmd.user.UserProfileListQryCmd;
import com.red.circle.other.inner.model.dto.material.UsePropsDTO;
import com.red.circle.other.inner.model.dto.sys.EnumConfigDTO;
import com.red.circle.other.inner.model.dto.user.props.UserUsePropsDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.date.TimestampUtils;
@ -88,6 +90,7 @@ public class UserProfileGatewayImpl implements UserProfileGateway {
private final UserRunProfileCacheService userRunProfileCacheService;
private final UserRegionCacheService userRegionCacheService;
private final UserVipAbilitySettingService userVipAbilitySettingService;
private final EnumConfigCacheService enumConfigCacheService;
@Override
@ -502,13 +505,32 @@ public class UserProfileGatewayImpl implements UserProfileGateway {
@Override
public boolean getUserVipAbility(Long userId, VipAbilityType abilityType) {
if (!inWhiteList(userId)) return false;
boolean hasVipLevel = abilityType.hasAbility(resolveUserVipName(userId));
boolean switchOn = userVipAbilitySettingService.isEnabled(userId, abilityType);
return hasVipLevel && switchOn;
}
private boolean inWhiteList(Long userId) {
EnumConfigDTO configDTO = enumConfigCacheService.getByCode("LOGIN_WHITE_CONFIG", "LIKEI");
String whiteConfig = Optional.ofNullable(configDTO).map(EnumConfigDTO::getVal).orElse(null);
UserProfile userProfile = getByUserId(userId);
if (whiteConfig == null || userProfile == null) {
return false;
}
List<String> whiteIds = StringUtils.isNotBlank(whiteConfig) ? Arrays.asList(whiteConfig.split(",")) : Collections.emptyList();
if (!whiteIds.contains(userProfile.getAccount())) {
return false;
}
return true;
}
@Override
public BigDecimal getUserVipBenefit(Long userId, VipBenefitType benefitType) {
if (!inWhiteList(userId)) return BigDecimal.ONE;
return benefitType.getValue(resolveUserVipName(userId));
}