特权逻辑修改

master_dev
grimm 2024-02-23 18:28:30 +08:00
parent 5ed94f515c
commit e3d0b77bac
8 changed files with 129 additions and 89 deletions

View File

@ -84,25 +84,16 @@ public class GetPlayerInfoHandler extends BaseHandler{
long now = TimeUtils.now();
playerInfoManager.setLoginTime(now);
Map<Integer, SPrivilegeTypeConfig> privilegeTypeConfigMap = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap();
Map<Integer, VipInfo> vipInfo = playerInfoManager.getVipInfo();
for(Map.Entry<Integer, SPrivilegeTypeConfig> entry:privilegeTypeConfigMap.entrySet()){
//如果是<4 系统内置特权 (6是新增的好感度特权收益加成 2021.9.26)
int unlockType = entry.getValue().getUnlockType();
if(unlockType < 4 || unlockType == 6 || unlockType == 11){
if (!vipInfo.containsKey(entry.getKey())){
playerInfoManager.addVipInfo(entry.getKey());
}
}
}
List<CommonProto.NewPlayerGuidePoint> list = new ArrayList<>();
Map<Integer, Integer> guidePoints = playerInfoManager.getGuidePoints();
for(Map.Entry<Integer,Integer> guideItem : guidePoints.entrySet()){
list.add(CommonProto.NewPlayerGuidePoint.newBuilder().setType(guideItem.getKey()).setId(guideItem.getValue()).build());
}
// 老玩家vip数据处理
// oldUserVipHandler(user);
List<CommonProto.Privilege> privilegeList = new ArrayList<>();
Map<Integer, VipInfo> vipInfo = playerInfoManager.getVipInfo();
for(Map.Entry<Integer,VipInfo> vipInfoItem : vipInfo.entrySet()){
privilegeList.add(CommonProto.Privilege.newBuilder().setId(vipInfoItem.getKey())
.setUsedTimes(vipInfoItem.getValue().getCount())
@ -258,6 +249,21 @@ public class GetPlayerInfoHandler extends BaseHandler{
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);
}
public void oldUserVipHandler(User user){
PlayerManager playerInfoManager = user.getPlayerInfoManager();
Map<Integer, VipInfo> vipInfo = playerInfoManager.getVipInfo();
Map<Integer, SPrivilegeTypeConfig> privilegeTypeConfigMap = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap();
for(Map.Entry<Integer, SPrivilegeTypeConfig> entry:privilegeTypeConfigMap.entrySet()){
//如果是<4 系统内置特权 (6是新增的好感度特权收益加成 2021.9.26)
int unlockType = entry.getValue().getUnlockType();
if(unlockType < 4 || unlockType == 6 || unlockType == 11){
if (!vipInfo.containsKey(entry.getKey())){
PlayerLogic.getInstance().uporsetVipInfo(user, entry.getKey());
}
}
}
}
//月卡特殊处理
// private void monthCardRefresh(User user){
// try {

View File

@ -3,6 +3,7 @@ package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.player.PlayerLogic;
import config.SGlobalActivity;
/**
@ -23,7 +24,7 @@ public class GmDialActivity extends LuckWheelNormalActivity{
super.initActivity(user);
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
if (activity.getPrivilege() != 0){
user.getPlayerInfoManager().addVipInfo(activity.getPrivilege());
PlayerLogic.getInstance().uporsetVipInfo(user, activity.getPrivilege());
}
}

View File

@ -71,7 +71,9 @@ public class ActivityStateChangeHandler implements IEventHandler {
ActivityMission activityMissionWillOpen = user.getActivityManager().getActivityMissionMap().get(s.getId());
if(activityMissionWillOpen!=null && activityMissionWillOpen.getActivityState() == ActivityType.UNOPEN_STATE){
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityById(s.getId());
abstractActivity.setOpenState(user,ActivityType.OPEN_STATE);
if (abstractActivity != null) {
abstractActivity.setOpenState(user,ActivityType.OPEN_STATE);
}
ActivityLogic.getInstance().sendActivityInfo(user,s.getId());
}
});

View File

@ -71,7 +71,7 @@ public class PlayerManager extends MongoBase {
private final Map<Integer,Integer> guidePoints = new HashMap<>();
private final Map<Integer,VipInfo> vipInfo = new HashMap<>();
private Map<Integer,VipInfo> vipInfo = new HashMap<>();
private final Set<Integer> vipGoodInfo = new HashSet<>();// 特权商品礼包
private Set<Integer> reds = new CopyOnWriteArraySet<>();
private NewRechargeInfo newRechargeInfo;
@ -523,7 +523,12 @@ public class PlayerManager extends MongoBase {
return vipInfo;
}
public void updateVipInfo(int unlockType,int condition) {
public void setVipInfo(Map<Integer, VipInfo> vipInfo) {
this.vipInfo = vipInfo;
updateString("vipInfo", vipInfo);
}
public void updateVipInfo(int unlockType, int condition) {
Map<Integer, Map<Integer, Integer>> conditionMap = SPrivilegeTypeConfig.conditionMap.get(unlockType);
if (conditionMap == null || conditionMap.isEmpty()){
return;
@ -562,68 +567,11 @@ public class PlayerManager extends MongoBase {
updateString("vipInfo", vipInfo);
}
public void vipFlush(Set<Integer> removePrivileges) {
if (vipInfo.isEmpty()) {
return;
}
for (Integer remove : removePrivileges) {
vipInfo.remove(remove);
}
for (Map.Entry<Integer, VipInfo> entry : vipInfo.entrySet()) {
Integer id = entry.getKey();
VipInfo info = entry.getValue();
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(id);
if (sPrivilegeTypeConfig == null) {
continue;
}
int refreshType = sPrivilegeTypeConfig.getRefreshType()[0];
if (refreshType == 1 && info.getCount() > 0) {
VipInfo refreshVipInfo = new VipInfo();
refreshVipInfo.setCount(0);
refreshVipInfo.setEffectTime(info.getEffectTime());
vipInfo.put(id,refreshVipInfo);
}
}
updateString("vipInfo", vipInfo);
}
public void clearVipCount(int priviliageId){
vipInfo.put(priviliageId,new VipInfo());
updateString("vipInfo", vipInfo);
}
public void addVipInfo(int privilegeId){
SPrivilegeTypeConfig config = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilegeId);
if (config==null){
return;
}
int maxTime;
int nowInt = TimeUtils.nowInt();
VipInfo newVipInfo = new VipInfo();
if(config.getContinueTime()!=null && config.getContinueTime().length>0){
if(vipInfo.containsKey(privilegeId)){
VipInfo info = vipInfo.get(privilegeId);
if(config.getContinueTime()[1]==1 && nowInt < info.getEffectTime()){
boolean aBool = config.getCondition().length == 1 && config.getCondition()[0][0] == 0;
if(!aBool){
newVipInfo.setCount(info.getCount()-config.getCondition()[0][1]);
newVipInfo.setEffectTime(info.getEffectTime());
vipInfo.put(privilegeId,newVipInfo);
updateString("vipInfo", this.vipInfo);
}
return;
}
maxTime = Math.max(nowInt, info.getEffectTime()) + config.getContinueTime()[0];
}else {
maxTime = nowInt + config.getContinueTime()[0];
}
maxTime = (int)(TimeUtils.getLastOrUnderHour(maxTime*1000L,0,0,true)/1000);
newVipInfo.setEffectTime(maxTime);
}
vipInfo.put(privilegeId,newVipInfo);
updateString("vipInfo", vipInfo);
}
/**
*
* @param privilageId id
@ -642,7 +590,6 @@ public class PlayerManager extends MongoBase {
/**
*
* @param privilegeType
*/
public void refreshVipByType(int privilegeType){
List<SPrivilegeTypeConfig> sPrivilegeTypeConfigs = SPrivilegeTypeConfig.privilegeByType.get(privilegeType);

View File

@ -6,10 +6,8 @@ import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
@ -133,6 +131,7 @@ public class UserManager {
playerManager.setSendDays(1);
playerManager.updateVipInfo(GlobalsDef.LEVEL_UNLOCK_PRIVILEGE,1);
playerManager.updateVipInfo(GlobalsDef.VIP_UNLOCK_PRIVILEGE,0);
playerManager.updateVipInfo(GlobalsDef.LIKABLE_UNLOCK,0);
playerManager.updateVipInfo(GlobalsDef.GOD_LV_UNLOCK,0);
playerManager.updateVipInfo(GlobalsDef.RENOWN_LV_UNLOCK,0);
playerManager.updateVipInfo(GlobalsDef.BRUSHING_LV_UNLOCK,0);

View File

@ -7,8 +7,6 @@ import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.config.clazzStaticCfg.HeroStaticConfig;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
@ -157,16 +155,17 @@ public class HeroLogic {
HeroManager heroManager = user.getHeroManager();
Set<Integer> mustSet = new HashSet<>();
Map<Integer, Map<Integer, Integer>> randomPoolByType = heroManager.getRandomPoolByType();
Map<Integer, Integer> poolRandom = randomPoolByType.get(mergePool);
//设置用户必出计数器
if (specialConfigs != null && !specialConfigs.isEmpty()) {
if (!randomPoolByType.containsKey(mergePool)) {
randomPoolByType.put(mergePool, new HashMap<>());
for (SLotterySpecialConfig config : specialConfigs) {
randomPoolByType.get(mergePool).put(config.getDifferentType(), 0);
poolRandom.put(config.getDifferentType(), 0);
}
}
//保底次数计算
for (Map.Entry<Integer, Integer> countEntry : randomPoolByType.get(mergePool).entrySet()) {
for (Map.Entry<Integer, Integer> countEntry : poolRandom.entrySet()) {
SLotterySpecialConfig config = null;
for (SLotterySpecialConfig everyConfig : specialConfigs) {
if (everyConfig.getDifferentType() != countEntry.getKey()) {
@ -208,7 +207,6 @@ public class HeroLogic {
// LOGGER.info("随机到了{}-->对应star-->{}", sLotteryRewardConfig.getId(), currStarId);
}
} else {
//有必出时比较各个优先级,取优先级高的
int maxId = 0;
for (int mustId : mustSet) {
@ -231,20 +229,20 @@ public class HeroLogic {
if (sLotteryRewardConfig == null) {
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE);
}
if (randomPoolByType.get(mergePool) != null) {
for (int key : randomPoolByType.get(mergePool).keySet()) {
if (poolRandom != null) {
for (int key : poolRandom.keySet()) {
//如果生效次数是0可重置
List<SLotterySpecialConfig> lotteryListByDifferentType = SLotterySpecialConfig.getLotteryListByDifferentType(key);
if (currStarId >= key && lotteryListByDifferentType != null && lotteryListByDifferentType.iterator().hasNext() && lotteryListByDifferentType.iterator().next().getMin_num() == 0) {
// LOGGER.info("清除计数{}下的--->{}", mergePool, key);
randomPoolByType.get(mergePool).put(key, 0);
poolRandom.put(key, 0);
} else {
int curValue = randomPoolByType.get(mergePool).getOrDefault(key, 0);
randomPoolByType.get(mergePool).put(key, curValue + 1);
int curValue = poolRandom.getOrDefault(key, 0);
poolRandom.put(key, curValue + 1);
}
}
}
heroManager.updateRandomPoolByType(mergePool, randomPoolByType.get(mergePool));
heroManager.updateRandomPoolByType(mergePool, poolRandom);
int result = sLotteryRewardConfig.getId();
heroManager.addRandomPoolInfo(sLotteryRewardConfig.getPool());

View File

@ -374,7 +374,7 @@ public class PlayerLogic {
LOGGER.info("特权刷新删除日志2{}-{}-{}",user.getId(), key, info.getEffectTime());
}
}
playerInfoManager.vipFlush(removePrivileges);
vipFlush(user, removePrivileges);
playerInfoManager.setHadTakeDailyBoxVip(-1);
// vip刷新后才能发给前端
if(fBuilder != null){
@ -390,6 +390,93 @@ public class PlayerLogic {
}
}
/**
* vip
* @param user
* @param removeIds
*/
public void vipFlush(User user, Set<Integer> removeIds){
PlayerManager playerManager = user.getPlayerInfoManager();
Map<Integer, VipInfo> vipInfo = playerManager.getVipInfo();
if (vipInfo == null || vipInfo.isEmpty()) {
LOGGER.error("vip刷新vipinfo为空uid{}",user.getId());
return;
}
for (Map.Entry<Integer, VipInfo> entry : vipInfo.entrySet()) {
Integer id = entry.getKey();
if (removeIds.contains(id)){
continue;
}
VipInfo info = entry.getValue();
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(id);
if (sPrivilegeTypeConfig == null) {
LOGGER.error("vip新增vipid查询表不存在已删除uid{}vipid:{}",user.getId(),id);
removeIds.add(id);
continue;
}
int refreshType = sPrivilegeTypeConfig.getRefreshType()[0];
if (refreshType == 1 && info.getCount() > 0) {
VipInfo refreshVipInfo = new VipInfo();
refreshVipInfo.setCount(0);
refreshVipInfo.setEffectTime(info.getEffectTime());
vipInfo.put(id,refreshVipInfo);
}
}
LOGGER.error("vip刷新删除前的vip数量uid{}vipnum{}removeIds{}",user.getId(),vipInfo.size(),removeIds);
// 删除vip
for (Integer remove : removeIds) {
vipInfo.remove(remove);
}
LOGGER.error("vip刷新删除后的vip数量uid{}vipnum{}",user.getId(),vipInfo.size());
playerManager.setVipInfo(vipInfo);
}
/**
* vip
* @param user
* @param privilegeId
*/
public void uporsetVipInfo(User user, int privilegeId){
SPrivilegeTypeConfig config = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilegeId);
if (config == null){
LOGGER.error("vip新增,vipid查询表不存在,uid{},vipid:{}",user.getId(),privilegeId);
return;
}
int maxTime;
int nowInt = TimeUtils.nowInt();
PlayerManager playerInfoManager = user.getPlayerInfoManager();
Map<Integer, VipInfo> vipInfo = playerInfoManager.getVipInfo();
VipInfo newVipInfo = new VipInfo();
if(config.getContinueTime()!=null && config.getContinueTime().length>0){
if(vipInfo.containsKey(privilegeId)){
VipInfo info = vipInfo.get(privilegeId);
if(config.getContinueTime()[1]==1 && nowInt < info.getEffectTime()){
boolean aBool = config.getCondition().length == 1 && config.getCondition()[0][0] == 0;
if(!aBool){
newVipInfo.setCount(info.getCount()-config.getCondition()[0][1]);
newVipInfo.setEffectTime(info.getEffectTime());
vipInfo.put(privilegeId,newVipInfo);
playerInfoManager.setVipInfo(vipInfo);
}
return;
}
maxTime = Math.max(nowInt, info.getEffectTime()) + config.getContinueTime()[0];
}else {
maxTime = nowInt + config.getContinueTime()[0];
}
maxTime = (int)(TimeUtils.getLastOrUnderHour(maxTime*1000L,0,0,true)/1000);
newVipInfo.setEffectTime(maxTime);
}
vipInfo.put(privilegeId,newVipInfo);
playerInfoManager.setVipInfo(vipInfo);
}
/**
* proto
* @param user
* @param collection
* @return
*/
public Set<CommonProto.Privilege> getPrivilege(User user, Collection<Integer> collection) {
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
HashSet<CommonProto.Privilege> set = new HashSet<>();

View File

@ -605,7 +605,7 @@ public class BuyGoodsNewLogic {
if(privilegeType == VipPrivilegeType.ADVENTURE_BASE_REWARD){
CombatLogic.getInstance().getNewAdventureReward(user,true,TimeUtils.nowInt());
}
user.getPlayerInfoManager().addVipInfo(privilege);
PlayerLogic.getInstance().uporsetVipInfo(user, privilege);
VipInfo vipInfo = user.getPlayerInfoManager().getVipInfo().get(privilege);
indication.addInfos(CommonProto.Privilege.newBuilder().setId(privilege).setUsedTimes(vipInfo.getCount()).setEffectTime(vipInfo.getEffectTime()).build());
}