back_recharge
parent
d3dc23884e
commit
68aa9fc53d
|
@ -1,16 +1,37 @@
|
|||
package com.ljsd.jieling.db.mongo;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.config.json.ServerProperties;
|
||||
import com.ljsd.jieling.core.CoreLogic;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType;
|
||||
import com.ljsd.jieling.dataReport.reportBeans_37.Repot37EventUtil;
|
||||
import com.ljsd.jieling.db.mongo.core.ServerAreaInfo;
|
||||
import com.ljsd.jieling.db.mongo.core.ServerAreaInfoManager;
|
||||
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.Global;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.PlayerInfoCache;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.ShieldedWordUtils;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
|
@ -187,49 +208,179 @@ public class AreaManager {
|
|||
*/
|
||||
public void task() throws Exception {
|
||||
|
||||
|
||||
|
||||
|
||||
LOGGER.info("the server={} exec task server work,start", GameApplication.serverId);
|
||||
|
||||
//合并排行榜
|
||||
Set<String> keys =new HashSet<>();
|
||||
Cursor<String> cursor =RedisUtil.getInstence().scan( GameApplication.serverId+ "*" + "RANK*", 200);
|
||||
while (cursor.hasNext()){
|
||||
//找到一次就添加一次
|
||||
keys.add(cursor.next());
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
keys.forEach(k->{
|
||||
|
||||
Set<ZSetOperations.TypedTuple<String>> set= RedisUtil.getInstence().getAllZsetRange(k);
|
||||
String newKey = k;
|
||||
if(k.startsWith(String.valueOf(GameApplication.serverId))){
|
||||
int length =k.length();
|
||||
newKey = newAreaId+k.substring(String.valueOf(GameApplication.serverId).length(),length);
|
||||
}
|
||||
if(null != set){
|
||||
for(ZSetOperations.TypedTuple<String> item : set){
|
||||
String id = item.getValue();
|
||||
Double score = item.getScore();
|
||||
RedisUtil.getInstence().zsetAddOne(newKey,id,score);
|
||||
}
|
||||
}
|
||||
LOGGER.info("合并排行榜"+k+" --> "+newKey);
|
||||
});
|
||||
|
||||
|
||||
//合并集合缓存、
|
||||
|
||||
// Map<Integer, PlayerInfoCache> players = RedisUtil.getInstence().getMapValues(RedisKey.PLAYER_INFO_CACHE, "", Integer.class, PlayerInfoCache.class);
|
||||
|
||||
processAllRank();
|
||||
|
||||
//合并玩家名称、
|
||||
processChangeName();
|
||||
|
||||
//合并玩家名称、
|
||||
processChangeGuildName();
|
||||
|
||||
|
||||
LOGGER.info("the server={} exec task server work,done", GameApplication.serverId);
|
||||
}
|
||||
|
||||
private void processAllRank(){
|
||||
try {
|
||||
//合并排行榜
|
||||
|
||||
//查找本服所有排行榜
|
||||
Set<String> keys =new HashSet<>();
|
||||
Cursor<String> cursor =RedisUtil.getInstence().scan( GameApplication.serverId+ "*" + "RANK*", 200);
|
||||
while (cursor.hasNext()){
|
||||
//找到一次就添加一次
|
||||
keys.add(cursor.next());
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
keys.forEach(k->{
|
||||
|
||||
Set<ZSetOperations.TypedTuple<String>> set= RedisUtil.getInstence().getAllZsetRange(k);
|
||||
String newKey = k;
|
||||
if(k.startsWith(String.valueOf(GameApplication.serverId))){
|
||||
int length =k.length();
|
||||
newKey = newAreaId+k.substring(String.valueOf(GameApplication.serverId).length(),length);
|
||||
}
|
||||
if(null != set){
|
||||
for(ZSetOperations.TypedTuple<String> item : set){
|
||||
String id = item.getValue();
|
||||
Double score = item.getScore();
|
||||
RedisUtil.getInstence().zsetAddOne(newKey,id,score);
|
||||
}
|
||||
}
|
||||
LOGGER.info("合并排行榜"+k+" --> "+newKey);
|
||||
});
|
||||
}catch (Exception e){
|
||||
LOGGER.info("合并排行榜异常" + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void processChangeName(){
|
||||
|
||||
try {
|
||||
//合并名称
|
||||
|
||||
//查找本服所有名称
|
||||
Set<String> keys =new HashSet<>();
|
||||
Cursor<String> cursor2 =RedisUtil.getInstence().scan( GameApplication.serverId+ ":" + RedisKey.C_User_Name_Key+"*", 200);
|
||||
while (cursor2.hasNext()){
|
||||
keys.add(cursor2.next());
|
||||
}
|
||||
cursor2.close();
|
||||
|
||||
keys.forEach(k->{
|
||||
|
||||
Object oldUserId = RedisUtil.getInstence().get(k);
|
||||
if (oldUserId == null){
|
||||
return;
|
||||
}
|
||||
int oldUid = Integer.parseInt(oldUserId.toString());
|
||||
|
||||
String newKey = k;
|
||||
if(k.startsWith(String.valueOf(GameApplication.serverId))){
|
||||
int length =k.length();
|
||||
newKey = newAreaId+k.substring(String.valueOf(GameApplication.serverId).length(),length);
|
||||
}
|
||||
Object extUserId = RedisUtil.getInstence().get(newKey);
|
||||
String tempName = newKey;
|
||||
if(extUserId!=null){
|
||||
int i=0;
|
||||
while (i<1000&&extUserId!=null){
|
||||
i++;
|
||||
tempName = newKey+"_S"+i;
|
||||
extUserId = RedisUtil.getInstence().get(tempName);
|
||||
}
|
||||
try {
|
||||
//修改玩家名称 发送邮件
|
||||
User oldUser = UserManager.getUser(oldUid);
|
||||
if (null == oldUser) {
|
||||
return ;
|
||||
}
|
||||
PlayerManager playerInfoManager = oldUser.getPlayerInfoManager();
|
||||
playerInfoManager.setNickName(playerInfoManager.getNickName()+"_S"+i);
|
||||
//sendmail
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("hefugaiming_mail_geren_title");
|
||||
String content = SErrorCodeEerverConfig.getI18NMessage("hefugaiming_mail_geren_txt");
|
||||
int[][] values = new int[1][2];
|
||||
values[0][0] = Global.CHANGENAME;
|
||||
values[0][1] = 1;
|
||||
String mailReward = ItemUtil.getMailReward(values);
|
||||
int nowTime = (int) (TimeUtils.now() / 1000);
|
||||
MailLogic.getInstance().sendMail(oldUid, title, content, mailReward, nowTime, Global.MAIL_EFFECTIVE_TIME);
|
||||
}catch (Exception e){
|
||||
LOGGER.info("合并命名异常" + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
RedisUtil.getInstence().set(tempName, String.valueOf(oldUid),RedisKey.REDIS_OVER_FOREVER);
|
||||
|
||||
});
|
||||
}catch (Exception e){
|
||||
LOGGER.info("合并命名异常" + e.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void processChangeGuildName(){
|
||||
|
||||
try {
|
||||
//合并名称
|
||||
|
||||
|
||||
//查找本服所有名称
|
||||
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
|
||||
for(Map.Entry<Integer, GuildInfo> entry:guildInfoMap.entrySet()) {
|
||||
|
||||
String newKey = RedisKey.getKey(RedisKey.C_Family_Name_Key, entry.getValue().getName(), true);
|
||||
Object extFamilyId = RedisUtil.getInstence().get(newKey);
|
||||
|
||||
String tempName = newKey;
|
||||
if (extFamilyId != null) {
|
||||
int i = 0;
|
||||
while (i < 1000 && extFamilyId != null) {
|
||||
i++;
|
||||
tempName = newKey + "_S" + i;
|
||||
extFamilyId = RedisUtil.getInstence().get(tempName);
|
||||
}
|
||||
|
||||
try {
|
||||
entry.getValue().setName(entry.getValue().getName());
|
||||
|
||||
Set<Integer> chairmans = entry.getValue().getMembers().get(GlobalsDef.CHAIRMAN);
|
||||
|
||||
for (Integer userId : chairmans) {
|
||||
//sendmail
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("hefugaiming_mail_gonghui_title");
|
||||
String content = SErrorCodeEerverConfig.getI18NMessage("hefugaiming_mail_gonghui_txt");
|
||||
int[][] values = new int[1][2];
|
||||
values[0][0] = Global.GEM;
|
||||
values[0][1] = 100;
|
||||
String mailReward = ItemUtil.getMailReward(values);
|
||||
int nowTime = (int) (TimeUtils.now() / 1000);
|
||||
MailLogic.getInstance().sendMail(userId, title, content, mailReward, nowTime, Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("合并命名异常" + e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
RedisUtil.getInstence().set(tempName, String.valueOf(extFamilyId),RedisKey.REDIS_OVER_FOREVER);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("合并命名异常" + e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void serverStateReset() {
|
||||
areaId = newAreaId;
|
||||
resetMaster();
|
||||
|
|
|
@ -81,6 +81,7 @@ public class RedisKey {
|
|||
public static final String NEED_VICTORY_AFTER = "NEED_VICTORY_AFTER";
|
||||
|
||||
public static final String C_User_Name_Key = "C_User_Name_Key";
|
||||
public static final String C_Family_Name_Key = "C_Family_Name_Key";
|
||||
|
||||
/**
|
||||
* 过期事件
|
||||
|
@ -371,5 +372,8 @@ public class RedisKey {
|
|||
return GameApplication.serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue