diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java index 709dfabc..7e44ed40 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java @@ -438,38 +438,42 @@ public class UserRunProfileTransportGatewayImpl implements UserRunProfileTranspo // 2. 检查当前VIP是否过期 Timestamp now = TimestampUtils.now(); - if (currentVip != null && currentVip.getExpireTime().after(now)) { + if (currentVip == null) { // 当前VIP未过期,无需切换 return; } // 3. 如果当前VIP已过期,卸下它 - if (currentVip != null) { + if (currentVip.getExpireTime().before(now)) { propsBackpackService.unloadUseProps(userId, PropsCommodityType.NOBLE_VIP); log.info("用户VIP已过期并卸下, userId={}, propsId={}, expireTime={}", userId, currentVip.getPropsId(), currentVip.getExpireTime()); } // 4. 使用最高等级的可用VIP - useMaxNobleVip(userId); + useMaxNobleVip(userId, currentVip.getPropsId()); } /** * 切换到最高等级VIP */ - private void useMaxNobleVip(Long userId) { + private void useMaxNobleVip(Long userId, Long currentVipId) { PropsNobleVipAbilityDTO abilityDTO = propsNobleVipGateway.getUserMaxAbilityDTO(userId); if (Objects.isNull(abilityDTO)) { log.info("用户没有可用的VIP道具, userId={}", userId); return; } + Long vipId = abilityDTO.getId(); + if (Objects.equals(vipId, currentVipId)) { + return; + } - propsBackpackCommon.switchUseProps(userId, abilityDTO.getId()); + propsBackpackCommon.switchUseProps(userId, vipId); propsBackpackCommon.switchUseProps(userId, abilityDTO.getAvatarFrameId()); propsBackpackCommon.switchUseProps(userId, abilityDTO.getDataCardId()); propsBackpackCommon.switchUseProps(userId, abilityDTO.getCarId()); - log.info("自动切换到最高等级VIP, userId={}, vipId={}", userId, abilityDTO.getId()); + log.info("自动切换到最高等级VIP, userId={}, vipId={}", userId, vipId); } private UsePropsDTO mergeUserUsePropsEntity(