进房间VIP等级问题修复
This commit is contained in:
parent
31a2522c64
commit
aefcf81c5d
@ -50,10 +50,7 @@ import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||
import com.red.circle.tool.core.text.StringUtils;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@ -319,23 +316,57 @@ public class RoomEnterCmdExe {
|
||||
manager.getSetting().setTakeMicRole(RoomTakeMicRoleEnum.ALL.name());
|
||||
}
|
||||
|
||||
NobleAbilityCO userNobleAbility = userProfileGateway.getUserNobleAbility(manager.getUserId());
|
||||
String mikeType = "";
|
||||
List<NobleAbilityCO> nobleAbilityCOList = userProfileGateway.getUserNobleAbility(manager.getUserId());
|
||||
String oldMikeType = manager.getSetting().getRoomSpecialMikeType();
|
||||
if (Objects.nonNull(userNobleAbility)) {
|
||||
if (StringUtils.isNotBlank(oldMikeType)) {
|
||||
RoomSetting setting = manager.getSetting();
|
||||
mikeType = "TYPE_VIP" + userNobleAbility.getVipLevel();
|
||||
setting.setRoomSpecialMikeType(mikeType);
|
||||
manager.setSetting(setting);
|
||||
Integer maxVipLevel = getMaxVipLevel(nobleAbilityCOList);
|
||||
Integer oldVipLevel = extractVipLevel(oldMikeType);
|
||||
|
||||
// 不一样则更新
|
||||
if (oldVipLevel > maxVipLevel) {
|
||||
String mikeType = "TYPE_VIP" + maxVipLevel;
|
||||
setting.setRoomSpecialMikeType(mikeType);
|
||||
manager.setSetting(setting);
|
||||
|
||||
roomProfileManagerService.updateSelectiveSetting(manager.getId(),
|
||||
roomProfileAppConvertor.toRoomSetting(new UpdateRoomSettingCmd().setRoomId(manager.getId()).setRoomSpecialMikeType(mikeType)));
|
||||
}
|
||||
}
|
||||
// 不一样则更新
|
||||
if (!mikeType.equals(oldMikeType)) {
|
||||
roomProfileManagerService.updateSelectiveSetting(manager.getId(),
|
||||
roomProfileAppConvertor.toRoomSetting(new UpdateRoomSettingCmd().setRoomId(manager.getId()).setRoomSpecialMikeType(mikeType)));
|
||||
}
|
||||
|
||||
private Integer getMaxVipLevel(List<NobleAbilityCO> nobleAbilityCOList) {
|
||||
if (CollectionUtils.isEmpty(nobleAbilityCOList)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return nobleAbilityCOList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(co -> co.getVipLevel() != null)
|
||||
.max(Comparator.comparing(NobleAbilityCO::getVipLevel))
|
||||
.map(NobleAbilityCO::getVipLevel)
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
private Integer extractVipLevel(String mikeType) {
|
||||
if (StringUtils.isBlank(mikeType)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String numberStr = mikeType.replaceAll(".*?(\\d+)$", "$1");
|
||||
|
||||
if (StringUtils.isBlank(numberStr) || numberStr.equals(mikeType)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(numberStr);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkSysOrigin(Long userId, String sysOrigin) {
|
||||
SysOriginPlatformEnum reqUserOrigin = SysOriginPlatformEnum.valueOf(
|
||||
userProfileGateway.getSysOrigin(userId));
|
||||
|
||||
@ -178,7 +178,7 @@ public interface UserProfileGateway {
|
||||
* @param userId 用户ID
|
||||
* @return 贵族能力信息
|
||||
*/
|
||||
NobleAbilityCO getUserNobleAbility(Long userId);
|
||||
List<NobleAbilityCO> getUserNobleAbility(Long userId);
|
||||
|
||||
/**
|
||||
* 修改用户签名为空.
|
||||
|
||||
@ -82,7 +82,7 @@ public interface UserCacheService {
|
||||
/**
|
||||
* 获取用户贵族能力.
|
||||
*/
|
||||
NobleAbilityCO getUserNobleAbility(Long userId, Function<Long, NobleAbilityCO> orElseGet);
|
||||
List<NobleAbilityCO> getUserNobleAbility(Long userId, Function<Long, List<NobleAbilityCO>> orElseGet);
|
||||
|
||||
/**
|
||||
* 移除权益缓存.
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.red.circle.other.infra.database.cache.service.user.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.red.circle.component.redis.service.RedisService;
|
||||
import com.red.circle.other.domain.model.user.NobleAbilityCO;
|
||||
@ -174,8 +175,8 @@ public class UserCacheServiceImpl implements UserCacheService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NobleAbilityCO getUserNobleAbility(Long userId,
|
||||
Function<Long, NobleAbilityCO> orElseGet) {
|
||||
public List<NobleAbilityCO> getUserNobleAbility(Long userId,
|
||||
Function<Long, List<NobleAbilityCO>> orElseGet) {
|
||||
|
||||
String key = UserKey.NOBLE_ABILITY.getKey(userId);
|
||||
|
||||
@ -183,13 +184,17 @@ public class UserCacheServiceImpl implements UserCacheService {
|
||||
|
||||
if (StringUtils.isNotBlank(cacheValue)) {
|
||||
try {
|
||||
return JSON.parseObject(cacheValue, NobleAbilityCO.class);
|
||||
JSONArray jsonArray = JSONArray.parseArray(cacheValue);
|
||||
return jsonArray.stream().map(e -> {
|
||||
NobleAbilityCO nobleAbilityCO = JSON.parseObject(JSON.toJSONString(e), NobleAbilityCO.class);
|
||||
return nobleAbilityCO;
|
||||
}).toList();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
NobleAbilityCO ability = orElseGet.apply(userId);
|
||||
List<NobleAbilityCO> ability = orElseGet.apply(userId);
|
||||
|
||||
if (Objects.nonNull(ability)) {
|
||||
redisService.setIfAbsent(key, JSON.toJSONString(ability), 10, TimeUnit.MINUTES);
|
||||
|
||||
@ -47,14 +47,7 @@ import com.red.circle.tool.core.text.StringUtils;
|
||||
import com.red.circle.tool.core.thread.ThreadPoolManager;
|
||||
import com.red.circle.tool.core.tuple.ImmutableKeyValuePair;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -521,11 +514,11 @@ public class UserProfileGatewayImpl implements UserProfileGateway {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NobleAbilityCO getUserNobleAbility(Long userId) {
|
||||
public List<NobleAbilityCO> getUserNobleAbility(Long userId) {
|
||||
return userCacheService.getUserNobleAbility(userId, this::getNobleAbility);
|
||||
}
|
||||
|
||||
private NobleAbilityCO getNobleAbility(Long userId) {
|
||||
private List<NobleAbilityCO> getNobleAbility(Long userId) {
|
||||
UserProfile userProfile = getByUserId(userId);
|
||||
if (Objects.isNull(userProfile)) {
|
||||
return null;
|
||||
@ -542,12 +535,13 @@ public class UserProfileGatewayImpl implements UserProfileGateway {
|
||||
return null;
|
||||
}
|
||||
|
||||
PropsNobleVipAbility ability = vipAbilities.get(0);
|
||||
NobleAbilityCO result = new NobleAbilityCO();
|
||||
result.setVipType(ability.getVipType());
|
||||
result.setVipLevel(ability.getVipLevel());
|
||||
result.setRoomMaxMember(ability.getRoomMaxMember());
|
||||
return result;
|
||||
return vipAbilities.stream().map(e -> {
|
||||
NobleAbilityCO result = new NobleAbilityCO();
|
||||
result.setVipType(e.getVipType());
|
||||
result.setVipLevel(e.getVipLevel());
|
||||
result.setRoomMaxMember(e.getRoomMaxMember());
|
||||
return result;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user