活动推送过长问题处理
parent
9b339bc710
commit
7862405b57
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
|
|
@ -17,8 +18,10 @@ import com.ljsd.jieling.util.ItemUtil;
|
|||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SUniversalWelfareConfig;
|
||||
import manager.STableManager;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -45,6 +48,7 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
long now = TimeUtils.now();
|
||||
// 类型验证
|
||||
if (!(event instanceof SuperBoxEvent)) {
|
||||
return;
|
||||
|
|
@ -52,31 +56,14 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
// 获取信息
|
||||
SuperBoxEvent event1 = (SuperBoxEvent) event;
|
||||
User user = UserManager.getUser(event1.getUserId());
|
||||
int giftId = event1.getGiftId();
|
||||
// 活动数据处理
|
||||
updateValue(event1.getGiftId());
|
||||
// 状态推送
|
||||
sendActivityProgress(user, null);
|
||||
}
|
||||
|
||||
public static int getValue(int goodId){
|
||||
Integer value = RedisUtil.getInstence().old_getmapvalue(RedisKey.ALL_PEOPLE_WELFARE_BUY_COUNT,"", String.valueOf(goodId), Integer.class);
|
||||
return Optional.ofNullable(value).orElse(0);
|
||||
}
|
||||
|
||||
public static void addValue(int goodId, int count){
|
||||
int value = getValue(goodId)+count;
|
||||
RedisUtil.getInstence().old_putmap(RedisKey.ALL_PEOPLE_WELFARE_BUY_COUNT,"", String.valueOf(goodId), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改参数
|
||||
* @param giftId
|
||||
*/
|
||||
private void updateValue(int giftId){
|
||||
// 验证礼包id
|
||||
if (SUniversalWelfareConfig.getGoods().contains(giftId)){
|
||||
addValue(giftId,1);
|
||||
}
|
||||
// 状态推送
|
||||
sendActivityProgress(user, null);
|
||||
LOGGER.info("superbox-全民福利活动:{},耗时:{}",id,TimeUtils.now()-now);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -88,17 +75,17 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
Map<Integer, ActivityProgressInfo> progressInfoMap = activityMission.getActivityMissionMap();
|
||||
// 策划表的配置
|
||||
Map<Integer, SUniversalWelfareConfig> config = STableManager.getConfig(SUniversalWelfareConfig.class);
|
||||
Map<Integer, Integer> allValue = getAllValue();
|
||||
// 返回对象
|
||||
List<CommonProto.ActivityInfo.MissionInfo> missionInfos = new ArrayList<>(config.size());
|
||||
for (Map.Entry<Integer, SUniversalWelfareConfig> entry : config.entrySet()) {
|
||||
for (Integer missionId : config.keySet()) {
|
||||
// 参数初始化
|
||||
int missionId = entry.getKey();
|
||||
int value = getValue(entry.getValue().getRechargeCom());
|
||||
int state = getState(missionId, progressInfoMap.get(missionId));
|
||||
int count = allValue.getOrDefault(missionId, 0);
|
||||
int state = getState(missionId, count, progressInfoMap.get(missionId));
|
||||
// 封装proto并返回
|
||||
CommonProto.ActivityInfo.MissionInfo build = CommonProto.ActivityInfo.MissionInfo.newBuilder()
|
||||
.setMissionId(missionId)
|
||||
.setProgress(value)
|
||||
.setProgress(count)
|
||||
.setState(state)
|
||||
.build();
|
||||
missionInfos.add(build);
|
||||
|
|
@ -106,18 +93,39 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
return missionInfos;
|
||||
}
|
||||
|
||||
public static void addValue(int goodId, int count){
|
||||
String key = RedisUtil.getInstence().getKeyNew(RedisKey.ALL_PEOPLE_WELFARE_BUY_COUNT, String.valueOf(GameApplication.serverId));
|
||||
RedisUtil.getInstence().zsetAddOne(key, String.valueOf(goodId), count);
|
||||
}
|
||||
|
||||
public static int getValue(int goodId){
|
||||
String key = RedisUtil.getInstence().getKeyNew(RedisKey.ALL_PEOPLE_WELFARE_BUY_COUNT, String.valueOf(GameApplication.serverId));
|
||||
Double zSetScore = RedisUtil.getInstence().getZSetScoreOrigin(key, String.valueOf(goodId));
|
||||
return Optional.ofNullable(zSetScore).orElse(0d).intValue();
|
||||
}
|
||||
|
||||
public static Map<Integer, Integer> getAllValue(){
|
||||
String key = RedisUtil.getInstence().getKeyNew(RedisKey.ALL_PEOPLE_WELFARE_BUY_COUNT, String.valueOf(GameApplication.serverId));
|
||||
Set<ZSetOperations.TypedTuple<String>> tuples = RedisUtil.getInstence().getZsetRangeWithScore(key, 0, -1);
|
||||
HashMap<Integer, Integer> result = new HashMap<>();
|
||||
Iterator<ZSetOperations.TypedTuple<String>> iterator = tuples.iterator();
|
||||
while (iterator.hasNext()){
|
||||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
result.put(Integer.parseInt(next.getValue()), next.getScore().intValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态
|
||||
* @param progressInfo
|
||||
* @return
|
||||
*/
|
||||
private int getState(int missionId, ActivityProgressInfo progressInfo){
|
||||
private int getState(int missionId, int value, ActivityProgressInfo progressInfo){
|
||||
int state = 0;
|
||||
SUniversalWelfareConfig welfareConfig = STableManager.getConfig(SUniversalWelfareConfig.class).get(missionId);
|
||||
if (progressInfo != null && progressInfo.getState() == 2){
|
||||
state = 2;
|
||||
}
|
||||
else if (getValue(welfareConfig.getRechargeCom()) >= welfareConfig.getPeolple()){
|
||||
else if (value >= welfareConfig.getPeolple()){
|
||||
state = 1;
|
||||
}
|
||||
return state;
|
||||
|
|
@ -125,10 +133,6 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
|
||||
/**
|
||||
* 领取奖励
|
||||
* @param session
|
||||
* @param missionId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean takeReward(ISession session, int missionId) throws Exception {
|
||||
|
|
@ -142,7 +146,8 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
if (welfareConfig == null){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"领取挡位不存在,活动id ==> "+id+",挡位id==>"+missionId);
|
||||
}
|
||||
int state = getState(missionId, mission.getActivityMissionMap().get(missionId));
|
||||
int value = getValue(missionId);
|
||||
int state = getState(missionId, value, mission.getActivityMissionMap().get(missionId));
|
||||
if (state != 1){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"档位已领取或条件不满足,活动id ==> "+id+",挡位id ==>"+missionId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,6 @@ class RechargeTotalActivity extends AbstractActivity {
|
|||
|
||||
/**
|
||||
* 领取奖励
|
||||
* @param session
|
||||
* @param missionId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean takeReward(ISession session, int missionId) throws Exception {
|
||||
|
|
@ -60,7 +56,8 @@ class RechargeTotalActivity extends AbstractActivity {
|
|||
SActivityRewardConfig config = SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId);
|
||||
ActivityProgressInfo info = mission.getActivityMissionMap().get(missionId);
|
||||
// 条件判断
|
||||
int state = getState(user, config, info);
|
||||
long firstRechargeTime = BuyGoodsNewLogic.getFirstRechargeTime(user.getId());
|
||||
int state = getState(user, info, config, firstRechargeTime);
|
||||
if (state != 2){
|
||||
return false;
|
||||
}
|
||||
|
|
@ -83,12 +80,9 @@ class RechargeTotalActivity extends AbstractActivity {
|
|||
* 0:未完成
|
||||
* 1:已领取
|
||||
* 2:可领取
|
||||
* @param user
|
||||
* @param config
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
int getState(User user, SActivityRewardConfig config, ActivityProgressInfo info){
|
||||
int getState(User user, ActivityProgressInfo info, SActivityRewardConfig config, long firstRechargeTime){
|
||||
long now = TimeUtils.now();
|
||||
// 表里为空
|
||||
if (config == null){
|
||||
return 0;
|
||||
|
|
@ -97,9 +91,8 @@ class RechargeTotalActivity extends AbstractActivity {
|
|||
if (info != null && info.getState() == 1){
|
||||
return 1;
|
||||
}
|
||||
long now = TimeUtils.now();
|
||||
NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
int days = TimeUtils.differentDaysByHour(BuyGoodsNewLogic.getFirstRechargeTime(user.getId()), now,0) + 1;
|
||||
int days = TimeUtils.differentDaysByHour(firstRechargeTime, now,0) + 1;
|
||||
// 判断金额和天数
|
||||
if (rechargeInfo.getRr() >= config.getValues()[0][0] && days >= config.getValues()[0][1]){
|
||||
return 2;
|
||||
|
|
@ -117,11 +110,11 @@ class RechargeTotalActivity extends AbstractActivity {
|
|||
// 表里的
|
||||
List<SActivityRewardConfig> rewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
|
||||
List<CommonProto.ActivityInfo.MissionInfo> missionInfos = new ArrayList<>(rewardConfigs.size());
|
||||
|
||||
long firstRechargeTime = BuyGoodsNewLogic.getFirstRechargeTime(user.getId());
|
||||
int progress = (int) (user.getPlayerInfoManager().getNewRechargeInfo().getRr() * 1000);
|
||||
for (SActivityRewardConfig config : rewardConfigs) {
|
||||
ActivityProgressInfo info = progressInfoMap.get(config.getId());
|
||||
int state = getState(user, config, info);
|
||||
int state = getState(user, info, config, firstRechargeTime);
|
||||
state = state == 1?1:0;
|
||||
CommonProto.ActivityInfo.MissionInfo build = CommonProto.ActivityInfo.MissionInfo.newBuilder()
|
||||
.setMissionId(config.getId())
|
||||
|
|
@ -149,9 +142,10 @@ class RechargeTotalActivity extends AbstractActivity {
|
|||
User user = UserManager.getUser(uid);
|
||||
Map<Integer, ActivityProgressInfo> missionMap = activityMission.getActivityMissionMap();
|
||||
List<SActivityRewardConfig> rewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
|
||||
long firstRechargeTime = BuyGoodsNewLogic.getFirstRechargeTime(user.getId());
|
||||
for (SActivityRewardConfig config : rewardConfigs) {
|
||||
ActivityProgressInfo info = missionMap.get(config.getId());
|
||||
int state = getState(user, config, info);
|
||||
int state = getState(user, info, config, firstRechargeTime);
|
||||
if (state != ActivityType.HAD_TAKED) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@ public class CrossYuxulundaoLogic {
|
|||
return;
|
||||
}
|
||||
Set<Integer> robotIds = new HashSet<>(5);
|
||||
PlayerManager player = user.getPlayerInfoManager();
|
||||
ArenaManager arenaManager = user.getArenaManager();
|
||||
int curLevel = arenaManager.getCrossYuxulundaoNewLevelId();//当前段位
|
||||
List<ArenaEnemy> arenaEnemies = new ArrayList<>(); //得存储
|
||||
|
|
@ -165,7 +164,7 @@ public class CrossYuxulundaoLogic {
|
|||
//匹配机器人
|
||||
List<SArenaRobotConfig> robotConfig = STableManager.getConfig(SArenaRobotConfig.class).values().stream().filter(n -> n.getPoolId() == timePool[1]).collect(Collectors.toList());
|
||||
Collections.shuffle(robotConfig);
|
||||
robotConfig.subList(0, robotIds.size()).forEach(n -> robotIds.add(n.getId()));
|
||||
robotConfig.subList(0, 0).forEach(n -> robotIds.add(n.getId()));
|
||||
for (int robot : robotIds) {
|
||||
arenaEnemies.add(new ArenaEnemy(robot, 1, 0));
|
||||
}
|
||||
|
|
@ -212,11 +211,11 @@ public class CrossYuxulundaoLogic {
|
|||
Set<ZSetOperations.TypedTuple<String>> matchRival= RedisUtil.getInstence().getZsetRangeWithScore(
|
||||
RedisUtil.getInstence().getKeyLocal(RedisKey.CROSS_YUXULUNDAO_RANK_PERSON,Integer.toString(crossGroup)),(double)con.getScoreLow1(),(double)con.getScoreUp1()
|
||||
);
|
||||
matchRival = matchRival.stream().filter(n->Integer.valueOf(n.getValue())!=user.getId()).collect(Collectors.toSet());
|
||||
if(matchRival.size() >0){
|
||||
matchRival = matchRival.stream().filter(n->Integer.parseInt(n.getValue())!=user.getId()).collect(Collectors.toSet());
|
||||
if(!matchRival.isEmpty()){
|
||||
if(matchRival.size()<5){
|
||||
//需要填充机器人
|
||||
matchRival.forEach(n->{ arenaRank.add(Integer.valueOf(n.getValue())); });
|
||||
matchRival.forEach(n-> arenaRank.add(Integer.valueOf(n.getValue())));
|
||||
arenaRank.addAll(SArenaRobotConfig.getSArenaRobotConfigsByRangeAndCount(con.getScoreLow1(),con.getScoreUp1(),5 - matchRival.size()));
|
||||
}else{
|
||||
//随机出五个真人
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class User {
|
|||
private int id;
|
||||
|
||||
@Transient
|
||||
private long expireTime;//缓存时间
|
||||
private long expireTime;//在线缓存时间
|
||||
|
||||
private PlayerManager playerManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class ServenMissionIdsType extends AbstractMissionType{
|
|||
isFinish = doingProgress >= sTaskConfig.getTaskValue()[1][0];
|
||||
}
|
||||
|
||||
if((doingProgress!=0 && finishParm<0 && ( doingProgress)>=finishParm)){
|
||||
if((doingProgress!=0 && finishParm<0 && (doingProgress)>=finishParm)){
|
||||
doingMissionIds.remove(sTaskConfig.getId());
|
||||
getFinishMissionIds().add(sTaskConfig.getId());
|
||||
MissionStateChangeInfo missionStateChangeInfo = new MissionStateChangeInfo(sTaskConfig.getId(), MissionState.FINISH,1);
|
||||
|
|
@ -109,7 +109,7 @@ public class ServenMissionIdsType extends AbstractMissionType{
|
|||
Map<GameMisionType, List<MissionStateChangeInfo>> gameMisionTypeListMap = MissionEventDistributor.threadMissionChangeList.get();
|
||||
int score = STreasureTaskConfig.sTreasureTaskConfigMap.get(missionId).getPoints();
|
||||
user.getUserMissionManager().calCumulationDataResult(user,MissionType.SENVER_HAPPY,gameMisionTypeListMap,score);
|
||||
getDoingMissionIds().remove(missionId);
|
||||
getDoingMissionIds().remove(missionId);
|
||||
getFinishMissionIds().add(missionId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -249,12 +249,12 @@ public class BuyGoodsNewLogic {
|
|||
//处理特权
|
||||
activePrivilege(user,config);
|
||||
// 校验
|
||||
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
if(config.getAccumulativeRecharge() == 1){
|
||||
//处理月卡
|
||||
activeMonthCard(user,config.getId());
|
||||
//活动
|
||||
changeActivity(user,price,info);
|
||||
changeActivity(user,price,rechargeInfo);
|
||||
}
|
||||
if(getFirstRechargeTime(uid) == 0){
|
||||
setFirstRecharge(uid);
|
||||
|
|
@ -285,7 +285,7 @@ public class BuyGoodsNewLogic {
|
|||
}
|
||||
|
||||
if(price>0 && isRmbBuy(orderId)) {
|
||||
info.addRealityRmb(price);// 记录真实充值
|
||||
rechargeInfo.addRealityRmb(price);// 记录真实充值
|
||||
}
|
||||
|
||||
// 更新入库
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ public class NewRechargeInfo extends MongoBase {
|
|||
private Map<Integer, AbstractWelfareBag> pushMap = new HashMap<>();//推送礼包
|
||||
private Map<Integer, AbstractWelfareBag> gmSingleMap = new HashMap<>();//gm单笔礼包
|
||||
private long nextPushTime; //上次推送时间
|
||||
private Map<Integer,Long>typePushTimeMap=new HashMap<>();//记录推送条件类型cd时间
|
||||
private Map<Integer,Integer> dayPushNumMap =new HashMap<>();//记录当天推送次数
|
||||
private Map<Integer,Integer> allPushNumMap =new HashMap<>();//记录历史推送次数
|
||||
private Map<Integer,Long> typePushTimeMap = new HashMap<>();//记录推送条件类型cd时间
|
||||
private Map<Integer,Integer> dayPushNumMap = new HashMap<>();//记录当天推送次数
|
||||
private Map<Integer,Integer> allPushNumMap = new HashMap<>();//记录历史推送次数
|
||||
public static int FIVESTARLIMIT = 2;//临时五星成长礼每天最多两次
|
||||
|
||||
public boolean checkOneGoodsIsOverTimeByPrivilege(int privilegeId){
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class CBean2Proto {
|
|||
.setFamilyId(playerManager.getGuildId())
|
||||
.setEnergy(0)
|
||||
.setLastUpdateEnergyTime(mapManager.getLastUpdateEnergyTime())
|
||||
.setServerTime((int) (System.currentTimeMillis() / 1000))
|
||||
.setServerTime(TimeUtils.nowInt())
|
||||
.setMaxForce(playerManager.getMaxForce())
|
||||
.setRechargeTime((int) rechargeTime)
|
||||
.setSaveAmt((rechargeInfo.getRr()))
|
||||
|
|
|
|||
Loading…
Reference in New Issue