七界和车迟斗法刷新问题

back_recharge
duhui 2023-03-21 16:42:03 +08:00
parent 8c634d7df2
commit 88821c6094
9 changed files with 196 additions and 121 deletions

View File

@ -1475,8 +1475,7 @@ public class TimeUtils {
public static int getDayOfWeekBytime(long time) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
return week;
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
}
/**

View File

@ -31,24 +31,6 @@ public class CarDelayFunction implements FunctionManager {
@Override
public void startAction(TimeControllerOfFunction timeControllerOfFunction) throws Exception {
String backName = "backup";
AbstractRank personRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_RANK.getType());
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_GUILD_RANK.getType());
String key = RedisUtil.getInstence().getKey(personRank.getRedisKey(), "");
String guildKey = RedisUtil.getInstence().getKey(guildRank.getRedisKey(), "");
String crossKey = RedisUtil.getInstence().getKey(personRank.getCrossRedisKey(), "",false);
String crossGuildKey = RedisUtil.getInstence().getKey(guildRank.getCrossRedisKey(), "",false);
String carPeopleNum = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_GUILD_FIGHT_PEOPLE_NUM,"");
String[] delKeys = {key,guildKey,crossKey,crossGuildKey,carPeopleNum};
RedisUtil.getInstence().rename(60*60*16, backName, delKeys);
// String userLevelGuild = RedisUtil.getInstence().getKey(RedisKey.USER_LEVEL_GUILD_INFO, "");
// delKeys.add(userLevelGuild);
LOGGER.error("车迟斗法备份排行榜:{}",Arrays.asList(delKeys));
MongoUtil.getLjsdMongoTemplate().lastUpdate();
}
@Override
@ -116,7 +98,15 @@ public class CarDelayFunction implements FunctionManager {
}
}
}
// 删除排行榜
String personKey = RedisUtil.getInstence().getKey(personRank.getRedisKey(), "");
String guildKey = RedisUtil.getInstence().getKey(guildRank.getRedisKey(), "");
String crossPersonKey = RedisUtil.getInstence().getKey(personRank.getCrossRedisKey(), "",false);
String crossGuildKey = RedisUtil.getInstence().getKey(guildRank.getCrossRedisKey(), "",false);
String carPeopleNum = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_GUILD_FIGHT_PEOPLE_NUM,"");
LOGGER.info("车迟斗法清空排行榜==================={}{}{}{}{}",personKey,guildKey,crossPersonKey,crossGuildKey,carPeopleNum);
RedisUtil.getInstence().del(personKey,guildKey,crossPersonKey,crossGuildKey,carPeopleNum);
MongoUtil.getLjsdMongoTemplate().lastUpdate();
// RedisUtil.getInstence().del(lockKey);
}
}

View File

@ -1,15 +1,33 @@
package com.ljsd.jieling.core.function;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.FunctionManager;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.item.ItemLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.sevenworld.SevenWorldLogic;
import config.SErrorCodeEerverConfig;
import config.SQijieRanking;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.ZSetOperations;
import util.StringUtil;
import util.TimeUtils;
import java.util.Map;
import java.util.Set;
/**
* @author lvxinran
@ -22,15 +40,61 @@ public class SevenWorldFunction implements FunctionManager {
@Override
public void closeAction(){
int crossGroup = GlobleSystemLogic.crossGroup;
String lockKey = "SEVEN_WORLD_RESET_LOCK" + RedisKey.Delimiter_colon + crossGroup;
boolean lock = RedisUtil.getInstence().lock(lockKey, TimeUtils.ONE_SECOND * 60);
if (!lock) {
//没有拿到锁直接返回
LOGGER.error("七界试炼,重置排行榜退出, key{} 跨服分组 ={},锁状态:{},未获取到锁",lockKey, crossGroup, lock);
return;
}
LOGGER.info("七界试炼活动结束,开始发奖...");
// 排行榜
String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
Set<ZSetOperations.TypedTuple<String>> range = RedisUtil.getInstence().getZsetreverseRangeWithScores(crossRedisKey,"",0,-1,false);
// 排名
int rank = 0;
for (ZSetOperations.TypedTuple<String> tuple : range) {
rank++;
int uid = Integer.parseInt(tuple.getValue());
CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid);
if (player == null){
LOGGER.error("七界发奖玩家缓存找不到uid{},排名:{}",uid,rank);
continue;
}
if (TimeUtils.now() > (player.getOffLineTime()+TimeUtils.WEEK)){
LOGGER.error("七界发奖玩家登陆时间超过七天uid{},排名:{},最后登陆时间:{},当前时间:{}",uid,rank,TimeUtils.getTimeStamp2(player.getOffLineTime()),TimeUtils.nowStr());
continue;
}
User user = UserManager.getUserNotCache(uid);
if (user == null){
continue;
}
String title = SErrorCodeEerverConfig.getI18NMessage("Qijie_mail_title");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("Qijie_mail_txt", new Object[]{rank},new int[0],"#");
// 排行奖励
Map<Integer, SQijieRanking> config = STableManager.getConfig(SQijieRanking.class);
for (SQijieRanking value : config.values()) {
// 排名区间
if (rank >= value.getMinRank() && rank <= value.getMaxRank()){
// 发邮件奖励
String reward = StringUtil.parseArrayToString(value.getRankingReward());
MailLogic.getInstance().sendMail(user.getId(),title,content,reward,TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
// 清除道具
ItemLogic.getInstance().functionEndClearItem(user.getId(), FunctionIdEnum.CrossSevenWorld.getFunctionType(), BIReason.SEVEN_WORLD_FUNCTION_END);
LOGGER.info("七界结束发送邮件并删除道具uid{},奖励:{},",user.getId(),reward);
break;
}
}
}
LOGGER.info("七界试炼发奖结束,开始清除排行榜...");
String key = RedisUtil.getInstence().getKey2(crossRedisKey, "");
RedisUtil.getInstence().del(key);
LOGGER.info("七界试炼重置结束,清理排行榜...{}",key);
}
@Override
public void startAction(TimeControllerOfFunction timeControllerOfFunction) {
// 清除排行榜信息
String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
String key = RedisUtil.getInstence().getKey(crossRedisKey, "",false);
RedisUtil.getInstence().del(key);
SevenWorldLogic.setEnd(false);
LOGGER.info("七界试炼活动开始,清理排行榜...{}:{}",key,SevenWorldLogic.isEnd());
}
}

View File

@ -458,6 +458,10 @@ public class RedisKey {
*
*/
public static final String SEVEN_WORLD_INTEGRAL_RANK = "SEVEN_WORLD_INTEGRAL_RANK";
/**
*
*/
public static final String SEVEN_WORLD_MARK = "SEVEN_WORLD_MARK";
/**
*

View File

@ -1274,7 +1274,7 @@ public class RedisUtil {
}
}
public <T> void putMapEntry(String key,String mapKey, T value){
public <T> void putMapEntry2(String key,String mapKey, T value){
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
redisTemplate.opsForHash().put(key,mapKey,gson.toJson(value));
@ -1331,7 +1331,7 @@ public class RedisUtil {
return null;
}
public <T> T getMapValue(String key, String mapKey, Class<T> clazz) {
public <T> T getMapValue2(String key, String mapKey, Class<T> clazz) {
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
String valueStr = (String) redisTemplate.opsForHash().get(key, mapKey);
@ -1466,6 +1466,10 @@ public class RedisUtil {
return getKey(type,key,true);
}
public String getKey2(String type,String key){
return getKey(type,key,false);
}
/**
* key
* @param type

View File

@ -34,10 +34,10 @@ public class AddItemHandler implements IEventHandler{
int lv = PlayerLogic.getInstance().getGodPrivilegeLv(user);
String key = RedisKey.GOD_LEVEL_UP_TIME + ":" + GameApplication.serverId + ":" + lv;
String uid = String.valueOf(user.getId());
UserGodLvVo userGodLvVo = RedisUtil.getInstence().getMapValue(key, uid, UserGodLvVo.class);
UserGodLvVo userGodLvVo = RedisUtil.getInstence().getMapValue2(key, uid, UserGodLvVo.class);
if (userGodLvVo == null){
userGodLvVo = new UserGodLvVo(user);
RedisUtil.getInstence().putMapEntry(key, uid, userGodLvVo);
RedisUtil.getInstence().putMapEntry2(key, uid, userGodLvVo);
}
}
}

View File

@ -360,13 +360,16 @@ public class MailLogic {
Mail mail = new Mail(uid,title,content,reward,sendTime, mailEffectiveTime,"system",Global.MAIL_TYPE_SYS);
String key = RedisKey.MAIL_REWARD_MARK + RedisKey.Delimiter_colon + uid;
String timeKey = String.valueOf(TimeUtils.now());
RedisUtil.getInstence().putMapEntry(key,timeKey,mail);
RedisUtil.getInstence().putMapEntry2(key,timeKey,mail);
// 有新邮件就增加30天的有效时间
RedisUtil.getInstence().expire(key,60*60*24*30);
LOGGER.info("redis邮件标记key:{}, time:{}, mail{}",key,timeKey,mail);
}
//发送邮件
public void sendSpecialMail(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime,int isTop ,int markType) throws Exception {
/**
*
*/
public void sendSpecialMail(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime,int isTop ,int markType) {
try {
User user = UserManager.getUser(uid);
Mail mail = new Mail(uid,title,content,reward,sendTime, mailEffectiveTime,"system",Global.MAIL_TYPE_SYS,isTop,markType);
@ -377,6 +380,7 @@ public class MailLogic {
LOGGER.error(e +";sendMail==>uid={},title={},reward:{}",uid,title,reward);
}
}
/**
*
*/

View File

@ -3,6 +3,7 @@ package com.ljsd.jieling.logic.sevenworld;
import com.ljsd.GameApplication;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.HandlerLogicThread;
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;
@ -70,14 +71,6 @@ public class SevenWorldLogic {
private static boolean end = false;
public static boolean isEnd() {
return end;
}
public static void setEnd(boolean end) {
SevenWorldLogic.end = end;
}
/**
*
* @param user
@ -350,10 +343,10 @@ public class SevenWorldLogic {
int ceil = (int) Math.ceil(reward[1] * (buff / 10000));
// 排行榜积分
if (reward[0] == 1241) {
if (isEnd()) {
// 规定时间不获得积分
continue;
}
// if (getEnd() == 1) {
// // 规定时间不获得积分
// continue;
// }
// 排行榜添加积分
addRank(user.getId(),reward[1] + ceil);
LOGGER.info("七界得分uid{}score{} qieji{}",user.getId(),reward[1] + ceil, stage);
@ -434,65 +427,93 @@ public class SevenWorldLogic {
return map;
}
/**
*
*/
public void sendRankReward(){
if (isTime()){
LOGGER.info("七界试炼活动结束,开始发奖...{{}}",isEnd());
SevenWorldLogic.setEnd(true);
// 排行榜
String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
Set<ZSetOperations.TypedTuple<String>> range = RedisUtil.getInstence().getZsetreverseRangeWithScores(crossRedisKey,"",0,-1,false);
// 排名
int rank = 0;
for (ZSetOperations.TypedTuple<String> tuple : range) {
rank++;
int uid = Integer.parseInt(tuple.getValue());
CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid);
if (player == null){
LOGGER.error("七界发奖玩家缓存找不到uid{},排名:{}",uid,rank);
continue;
}
if (TimeUtils.now() > (player.getOffLineTime()+TimeUtils.WEEK)){
LOGGER.error("七界发奖玩家登陆时间超过七天uid{},排名:{},最后登陆时间:{},当前时间:{}",uid,rank,TimeUtils.getTimeStamp2(player.getOffLineTime()),TimeUtils.nowStr());
continue;
}
User user = UserManager.getUserNotCache(uid);
if (user == null){
continue;
}
String title = SErrorCodeEerverConfig.getI18NMessage("Qijie_mail_title");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("Qijie_mail_txt", new Object[]{rank},new int[0],"#");
// 排行奖励
Map<Integer, SQijieRanking> config = STableManager.getConfig(SQijieRanking.class);
for (SQijieRanking value : config.values()) {
// 排名区间
if (rank >= value.getMinRank() && rank <= value.getMaxRank()){
// 发邮件奖励
String reward = StringUtil.parseArrayToString(value.getRankingReward());
MailLogic.getInstance().sendMail(user.getId(),title,content,reward,TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
// 清除道具
ItemLogic.getInstance().functionEndClearItem(user.getId(),FunctionIdEnum.CrossSevenWorld.getFunctionType(),BIReason.SEVEN_WORLD_FUNCTION_END);
LOGGER.info("七界结束发送邮件并删除道具uid{},奖励:{},",user.getId(),reward);
break;
}
}
}
LOGGER.info("七界试炼活动结束,发奖完成...{{}}",isEnd());
}
}
/**
* 2330
*/
private boolean isTime(){
int week = TimeUtils.getDayOfWeek();
int hour = TimeUtils.getHourOfDay();
int minute = TimeUtils.getMiunte();
boolean b = week == 7 && hour == 23 && minute == 30;
LOGGER.info("当前时间week:{},hour:{},minute:{},result:{}",week,hour,minute,b);
return b;
}
// public static void setEnd(int value){
// RedisUtil redisUtil = RedisUtil.getInstence();
// String key = redisUtil.getKey2(RedisKey.SEVEN_WORLD_MARK, String.valueOf(GlobleSystemLogic.crossGroup));
// redisUtil.set(key,String.valueOf(value));
// }
//
// public static int getEnd(){
// RedisUtil redisUtil = RedisUtil.getInstence();
// String key = redisUtil.getKey2(RedisKey.SEVEN_WORLD_MARK, String.valueOf(GlobleSystemLogic.crossGroup));
// Object obj = redisUtil.get(key);
// if (obj == null){
// obj = 0;
// }
// return (int)obj;
// }
//
// /**
// * 每周末的2400分重置排行榜积分
// */
// public void overSevenWorld(){
// int week = TimeUtils.getDayOfWeek();
// int hour = TimeUtils.getHourOfDay();
// int minute = TimeUtils.getMiunte();
// // 发奖时间
// boolean sendRewardTime = week == 7 && hour == 23 && minute == 30;
// if (sendRewardTime){
// LOGGER.info("七界试炼活动结束,开始发奖...{{}}", getEnd());
// SevenWorldLogic.setEnd(1);
// // 排行榜
// String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
// Set<ZSetOperations.TypedTuple<String>> range = RedisUtil.getInstence().getZsetreverseRangeWithScores(crossRedisKey,"",0,-1,false);
// // 排名
// int rank = 0;
// for (ZSetOperations.TypedTuple<String> tuple : range) {
// rank++;
// int uid = Integer.parseInt(tuple.getValue());
// CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid);
// if (player == null){
// LOGGER.error("七界发奖玩家缓存找不到uid{},排名:{}",uid,rank);
// continue;
// }
// if (TimeUtils.now() > (player.getOffLineTime()+TimeUtils.WEEK)){
// LOGGER.error("七界发奖玩家登陆时间超过七天uid{},排名:{},最后登陆时间:{},当前时间:{}",uid,rank,TimeUtils.getTimeStamp2(player.getOffLineTime()),TimeUtils.nowStr());
// continue;
// }
// User user = UserManager.getUserNotCache(uid);
// if (user == null){
// continue;
// }
// String title = SErrorCodeEerverConfig.getI18NMessage("Qijie_mail_title");
// String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("Qijie_mail_txt", new Object[]{rank},new int[0],"#");
// // 排行奖励
// Map<Integer, SQijieRanking> config = STableManager.getConfig(SQijieRanking.class);
// for (SQijieRanking value : config.values()) {
// // 排名区间
// if (rank >= value.getMinRank() && rank <= value.getMaxRank()){
// // 发邮件奖励
// String reward = StringUtil.parseArrayToString(value.getRankingReward());
// MailLogic.getInstance().sendMail(user.getId(),title,content,reward,TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
// // 清除道具
// ItemLogic.getInstance().functionEndClearItem(user.getId(),FunctionIdEnum.CrossSevenWorld.getFunctionType(),BIReason.SEVEN_WORLD_FUNCTION_END);
// LOGGER.info("七界结束发送邮件并删除道具uid{},奖励:{},",user.getId(),reward);
// break;
// }
// }
// }
// LOGGER.info("七界试炼活动结束,发奖完成...{{}}", getEnd());
// }
//
// // 重置排行榜时间
// boolean resetTime = week == 1 && hour == 0 && minute == 0;
// if (resetTime){
// int crossGroup = GlobleSystemLogic.crossGroup;
// String lockKey = "SEVEN_WORLD_RESET_LOCK" + RedisKey.Delimiter_colon + crossGroup;
// boolean lock = RedisUtil.getInstence().lock(lockKey, TimeUtils.ONE_SECOND * 60);
// if (!lock) {
// //没有拿到锁直接返回
// LOGGER.error("七界试炼,重置排行榜退出, key{} 跨服分组 ={},锁状态:{},未获取到锁",lockKey, crossGroup, lock);
// return;
// }
// // 清除排行榜信息
// String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
// String key = RedisUtil.getInstence().getKey(crossRedisKey, "",false);
// RedisUtil.getInstence().del(key);
// SevenWorldLogic.setEnd(0);
// LOGGER.info("七界试炼重置结束,清理排行榜...{}:{}",key,SevenWorldLogic.getEnd());
// }
// }
}

View File

@ -14,42 +14,37 @@ import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.SituationLogic;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.activity.event.MinuteTaskEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
import com.ljsd.jieling.logic.arena.ArenaLogic;
import com.ljsd.jieling.logic.arena.CrossLingmaiLogic;
import com.ljsd.jieling.logic.arena.CrossYuxulundaoLogic;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.explorerMap.ExplorerMapLogic;
import com.ljsd.jieling.logic.family.CrossDeathPathLogic;
import com.ljsd.jieling.logic.family.DeathPathLogic;
import com.ljsd.jieling.logic.family.GuildFightLogic;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.logic.help.HelpHeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.question.QuestionLogic;
import com.ljsd.jieling.logic.rank.CrossRankManager;
import com.ljsd.jieling.logic.rank.RankLogic;
import com.ljsd.jieling.logic.sevenworld.SevenWorldLogic;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.thread.ThreadManager;
import com.ljsd.jieling.util.AyyncWorker;
import com.ljsd.jieling.util.MessageUtil;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.TimeUtils;
import java.util.*;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
public class MinuteTask extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(MinuteTask.class);
@ -109,12 +104,6 @@ public class MinuteTask extends Thread {
LOGGER.error("Exception::=>{}",e.toString());
}
try {
SevenWorldLogic.getInstance().sendRankReward();
}catch (Exception e){
e.printStackTrace();
LOGGER.error("七界Exception::=>{}",e.toString());
}
try {
// 跨服分组
everyMondayZeroClockTask();