vip刷新逻辑修改
parent
0c55069829
commit
16e05fd4b7
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"version":"8",
|
||||
"tables":"GlobalActivity"
|
||||
"version":"5",
|
||||
"tables":""
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
{
|
||||
"version":"7",
|
||||
"version":"5",
|
||||
"classes":[
|
||||
{"name":"PlayerManager.class","fullName":"com.ljsd.jieling.logic.dao.PlayerManager"},
|
||||
{"name":"PlayerLogic.class","fullName":"com.ljsd.jieling.logic.player.PlayerLogic"}
|
||||
]
|
||||
}
|
|
@ -91,7 +91,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
int unlockType = entry.getValue().getUnlockType();
|
||||
if(unlockType < 4 || unlockType == 6 || unlockType == 11){
|
||||
if (!vipInfo.containsKey(entry.getKey())){
|
||||
playerInfoManager.addVipInfo(entry.getKey());
|
||||
PlayerLogic.getInstance().addVipInfo(user, entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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().addVipInfo(user, activity.getPrivilege());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -514,6 +514,11 @@ public class PlayerManager extends MongoBase {
|
|||
return vipInfo;
|
||||
}
|
||||
|
||||
public void setVipInfo(Map<Integer, VipInfo> vipInfo) {
|
||||
this.vipInfo = vipInfo;
|
||||
updateString("vipInfo", vipInfo);
|
||||
}
|
||||
|
||||
public Set<Integer> getHadTakeLevelBoxVip() {
|
||||
return vipGoodInfo;
|
||||
}
|
||||
|
@ -562,74 +567,12 @@ public class PlayerManager extends MongoBase {
|
|||
updateString("vipInfo", vipInfo);
|
||||
}
|
||||
|
||||
public void vipFlush(Set<Integer> removePrivileges) {
|
||||
System.out.println("开始刷新特权:"+removePrivileges);
|
||||
if (vipInfo.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
System.out.println("开始刷新特权,删除前特权数量:"+vipInfo.size());
|
||||
for (Integer remove : removePrivileges) {
|
||||
vipInfo.remove(remove);
|
||||
}
|
||||
System.out.println("开始刷新特权,删除后特权数量:"+vipInfo.size());
|
||||
for (Map.Entry<Integer, VipInfo> entry : vipInfo.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
VipInfo info = entry.getValue();
|
||||
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(id);
|
||||
if (null == sPrivilegeTypeConfig) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
System.out.println("刷新特权完成,特权数量:"+vipInfo.size());
|
||||
updateString("vipInfo", vipInfo);
|
||||
setHadTakeDailyBoxVip(-1);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.vipInfo.put(privilegeId,newVipInfo);
|
||||
updateString("vipInfo", this.vipInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间添加权限
|
||||
* @param privilageId 权限id
|
||||
|
|
|
@ -57,6 +57,7 @@ import util.MathUtils;
|
|||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class PlayerLogic {
|
||||
|
@ -375,7 +376,7 @@ public class PlayerLogic {
|
|||
}
|
||||
}
|
||||
LOGGER.info("特权刷新删除日志3:{};{}",user.getId(),removePrivileges);
|
||||
playerInfoManager.vipFlush(removePrivileges);
|
||||
vipFlush(user, removePrivileges);
|
||||
|
||||
// vip刷新后才能发给前端
|
||||
if(fBuilder != null){
|
||||
|
@ -391,6 +392,95 @@ public class PlayerLogic {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* vip刷新逻辑测试
|
||||
* @param uid
|
||||
* @param remove
|
||||
* @throws Exception
|
||||
*/
|
||||
public void vipFlushTest(int uid, int[] remove) throws Exception {
|
||||
LOGGER.info("刷新特权测试,uid:{},remove:{}",uid,remove);
|
||||
User user = UserManager.getUser(uid);
|
||||
Set<Integer> collect = Arrays.stream(remove).boxed().collect(Collectors.toSet());
|
||||
vipFlush(user, collect);
|
||||
}
|
||||
|
||||
/**
|
||||
* vip刷新逻辑
|
||||
* @param user
|
||||
* @param removePrivileges
|
||||
*/
|
||||
public void vipFlush(User user, Set<Integer> removePrivileges) {
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
Map<Integer, VipInfo> vipInfo = playerInfoManager.getVipInfo();
|
||||
LOGGER.info("开始刷新特权,uid:{},list:{}",user.getId(),removePrivileges);
|
||||
if (vipInfo.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
LOGGER.info("开始刷新特权,删除前特权数量,uid:{},size:{}",user.getId(),vipInfo.size());
|
||||
for (Integer remove : removePrivileges) {
|
||||
vipInfo.remove(remove);
|
||||
}
|
||||
LOGGER.info("开始刷新特权,删除后特权数量,uid:{},size:{}",user.getId(),vipInfo.size());
|
||||
for (Map.Entry<Integer, VipInfo> entry : vipInfo.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
VipInfo info = entry.getValue();
|
||||
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(id);
|
||||
if (null == sPrivilegeTypeConfig) {
|
||||
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.info("刷新特权完成,特权数量,uid:{},size:{}",user.getId(),vipInfo.size());
|
||||
playerInfoManager.setVipInfo(vipInfo);
|
||||
playerInfoManager.setHadTakeDailyBoxVip(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或刷新vip信息
|
||||
* @param user
|
||||
* @param privilegeId
|
||||
*/
|
||||
public void addVipInfo(User user, int privilegeId){
|
||||
SPrivilegeTypeConfig config = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilegeId);
|
||||
if (config==null){
|
||||
return;
|
||||
}
|
||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||
Map<Integer, VipInfo> vipInfo = playerManager.getVipInfo();
|
||||
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);
|
||||
playerManager.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);
|
||||
playerManager.setVipInfo(vipInfo);
|
||||
}
|
||||
|
||||
public Set<CommonProto.Privilege> getPrivilege(User user, Collection<Integer> collection) {
|
||||
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
|
||||
HashSet<CommonProto.Privilege> set = new HashSet<>();
|
||||
|
|
|
@ -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().addVipInfo(user, privilege);
|
||||
VipInfo vipInfo = user.getPlayerInfoManager().getVipInfo().get(privilege);
|
||||
indication.addInfos(CommonProto.Privilege.newBuilder().setId(privilege).setUsedTimes(vipInfo.getCount()).setEffectTime(vipInfo.getEffectTime()).build());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue