灵脉跨服发送邮件
parent
e2685214ae
commit
5776c011ba
|
@ -473,6 +473,8 @@ public class RedisKey {
|
|||
public static final String ALL_PEOPLE_WELFARE_BUY_COUNT = "ALL_PEOPLE_WELFARE_BUY_COUNT";
|
||||
// GM活动更新
|
||||
public static final String GM_ACTIVITY_UPDATE = "GM_ACTIVITY_UPDATE";
|
||||
// 邮件奖励
|
||||
public static final String MAIL_REWARD_MARK = "MAIL_REWARD_MARK";
|
||||
|
||||
public static Set<String> newAreaCacChe = new HashSet<>();//进程排行 合区统一
|
||||
|
||||
|
|
|
@ -573,7 +573,6 @@ public class ArenaLogic {
|
|||
}else{
|
||||
title = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_title");
|
||||
}
|
||||
String seasonKey = RedisUtil.getInstence().getKey(RedisKey.ARENA_RANK, Integer.toString(curSeason));
|
||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK,Integer.toString(curSeason), 0, -1);
|
||||
if(type == GlobalsDef.ARENA_SEASON_REWARD){
|
||||
curSeason=0;
|
||||
|
|
|
@ -37,61 +37,6 @@ public class CrossLingmaiLogic {
|
|||
return CrossLingmaiLogic.Instance.instance;
|
||||
}
|
||||
|
||||
public static LingMaiSecretArea getLingaMaiData(int id, int uid,int crossGroup,int group) {
|
||||
//排行榜上有数据 灵脉里没数据 说明被打下去了
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
double disappearScore = rank.getScoreById(uid, crossGroup + RedisKey.Delimiter_colon + group);
|
||||
LingMaiSecretArea lingMaiSecretArea = new LingMaiSecretArea();
|
||||
lingMaiSecretArea.setId(id);
|
||||
lingMaiSecretArea.setUid(uid);
|
||||
String serverName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
|
||||
lingMaiSecretArea.setServerName(serverName);
|
||||
//lingMaiSecretArea.setName(user.getPlayerInfoManager().getNickName());
|
||||
lingMaiSecretArea.setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
|
||||
lingMaiSecretArea.setBeginOccupyTime(TimeUtils.nowInt());
|
||||
if(disappearScore>0){
|
||||
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.class, LingMaiSecretArea.class);
|
||||
if(lingMaiMap.values().stream().noneMatch(n->n.getUid()==uid)){
|
||||
lingMaiSecretArea.setScore1((int) disappearScore);
|
||||
}
|
||||
}
|
||||
return lingMaiSecretArea;
|
||||
}
|
||||
|
||||
public static void updateLingmaiData(Map<String, LingMaiSecretArea> lingMaiMap, int crossGroup, int group) {
|
||||
int nowTime = TimeUtils.nowInt();
|
||||
String groupkey = crossGroup + RedisKey.Delimiter_colon + group;
|
||||
for (Map.Entry<String, LingMaiSecretArea> map : lingMaiMap.entrySet()) {
|
||||
try {
|
||||
User user = UserManager.getUser(map.getValue().getUid());
|
||||
if (user != null) {
|
||||
SLodeConfig config = SLodeConfig.lodeConfig.get(map.getValue().getId());
|
||||
if (config != null) {
|
||||
int occupyTime = (int) map.getValue().getGetAwardTimeOrOccupyTime();
|
||||
//分钟
|
||||
int minute = (nowTime - occupyTime) / 60;
|
||||
//秒
|
||||
int second = Math.min((nowTime - occupyTime) % 60, 60);
|
||||
//difVal =1 ;
|
||||
LOGGER.error("玩家" + map.getValue().getUid() + "原有秒:"+map.getValue().getOccupyTime()+" 获得秒:" + (minute*60+second));
|
||||
map.getValue().setOccupyTime(map.getValue().getOccupyTime() + minute*60+second);
|
||||
map.getValue().setGetAwardTimeOrOccupyTime(nowTime);
|
||||
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO, groupkey, map.getKey(), map.getValue());
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
LOGGER.error("minute:"+map.getValue().getOccupyTime()+" per:"+(config.getRewardList()[0][1]/60));
|
||||
long score = (long)map.getValue().getOccupyTime() * config.getRewardList()[0][1]/60 + map.getValue().getScore1();
|
||||
double test = rank.getScoreById(user.getId(), groupkey);
|
||||
LOGGER.error("之前是:" + test + "之后是:" + score);
|
||||
rank.addRank(user.getId(), groupkey, score);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//當前是否是搶奪日的24點
|
||||
public static List<Integer> getSendRewardWeekDay(){
|
||||
SMServerLodeSetting setting = SMServerLodeSetting.lodeConfig.get(1);
|
||||
|
@ -178,7 +123,7 @@ public class CrossLingmaiLogic {
|
|||
String title = SErrorCodeEerverConfig.getI18NMessage("LingmaikaicaiReward_mail_title");
|
||||
String content = SErrorCodeEerverConfig.getI18NMessage("LingmaikaicaiReward_mail_txt", new Object[]{minTime});
|
||||
String reward = CrossLingmaiLogic.getInstance().getReward(minTime, sLodeConfig.getRewardList());
|
||||
MailLogic.getInstance().sendMail(uid,title,content,reward,nowInt,Global.MAIL_EFFECTIVE_TIME);
|
||||
MailLogic.getInstance().sendMailToRedis(uid,title,content,reward,nowInt,Global.MAIL_EFFECTIVE_TIME);
|
||||
LOGGER.info("灵脉发送正常结束邮件:{}",uid);
|
||||
}
|
||||
|
||||
|
@ -191,7 +136,7 @@ public class CrossLingmaiLogic {
|
|||
String title = SErrorCodeEerverConfig.getI18NMessage("LingmaikaicaiReward1_mail_title");
|
||||
String content = SErrorCodeEerverConfig.getI18NMessage("LingmaikaicaiReward1_mail_txt", new Object[]{ackId,minTime});
|
||||
String reward = CrossLingmaiLogic.getInstance().getReward(minTime, sLodeConfig.getRewardList());
|
||||
MailLogic.getInstance().sendMail(uid,title,content,reward,nowInt,Global.MAIL_EFFECTIVE_TIME);
|
||||
MailLogic.getInstance().sendMailToRedis(uid,title,content,reward,nowInt,Global.MAIL_EFFECTIVE_TIME);
|
||||
LOGGER.info("灵脉发送被占领结束邮件:{}",uid);
|
||||
}
|
||||
|
||||
|
@ -201,30 +146,63 @@ public class CrossLingmaiLogic {
|
|||
if (crossGroup == -1) {
|
||||
return;
|
||||
}
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
String lockKey = "SERVER_LINGMAI_ZERO_LOCK" + RedisKey.Delimiter_colon + crossGroup;
|
||||
boolean lock = redisUtil.lock(lockKey, TimeUtils.ONE_SECOND * 60);
|
||||
if (!lock) {
|
||||
//没有拿到锁直接返回
|
||||
LOGGER.info("跨服灵脉,零点重置, key:{} 跨服分组 ={},未获取到锁",lockKey, crossGroup);
|
||||
return;
|
||||
}
|
||||
|
||||
// 清理组别1
|
||||
String groupKey1 = crossGroup + RedisKey.Delimiter_colon + 1;
|
||||
Map<String, LingMaiSecretArea> mapValues = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey1, String.class, LingMaiSecretArea.class);
|
||||
Map<String, LingMaiSecretArea> mapValues = redisUtil.getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey1, String.class, LingMaiSecretArea.class);
|
||||
for (LingMaiSecretArea value : mapValues.values()) {
|
||||
sendNormalMail(value.getUid(),value);
|
||||
}
|
||||
String key1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey1);
|
||||
RedisUtil.getInstence().del(key1);
|
||||
String key1 = redisUtil.getKey(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey1);
|
||||
redisUtil.del(key1);
|
||||
LOGGER.info("灵脉初始化,key:{}, 长度:{}",key1,mapValues.size());
|
||||
mapValues.clear();
|
||||
|
||||
// 清理组别2
|
||||
String groupKey2 = crossGroup + RedisKey.Delimiter_colon + 2;
|
||||
Map<String, LingMaiSecretArea> mapValue2 = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey1, String.class, LingMaiSecretArea.class);
|
||||
Map<String, LingMaiSecretArea> mapValue2 = redisUtil.getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey1, String.class, LingMaiSecretArea.class);
|
||||
for (LingMaiSecretArea value : mapValue2.values()) {
|
||||
sendNormalMail(value.getUid(),value);
|
||||
}
|
||||
String key2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey2);
|
||||
RedisUtil.getInstence().del(key2);
|
||||
String key2 = redisUtil.getKey(RedisKey.CROSS_LINGMAISECRET_INFO, groupKey2);
|
||||
redisUtil.del(key2);
|
||||
LOGGER.info("灵脉初始化,key:{}, 长度:{}",key2,mapValue2.size());
|
||||
mapValue2.clear();
|
||||
|
||||
//释放分布式锁
|
||||
redisUtil.del(lockKey);
|
||||
}
|
||||
|
||||
|
||||
public static LingMaiSecretArea getLingaMaiData(int id, int uid,int crossGroup,int group) {
|
||||
//排行榜上有数据 灵脉里没数据 说明被打下去了
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
double disappearScore = rank.getScoreById(uid, crossGroup + RedisKey.Delimiter_colon + group);
|
||||
LingMaiSecretArea lingMaiSecretArea = new LingMaiSecretArea();
|
||||
lingMaiSecretArea.setId(id);
|
||||
lingMaiSecretArea.setUid(uid);
|
||||
String serverName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
|
||||
lingMaiSecretArea.setServerName(serverName);
|
||||
//lingMaiSecretArea.setName(user.getPlayerInfoManager().getNickName());
|
||||
lingMaiSecretArea.setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
|
||||
lingMaiSecretArea.setBeginOccupyTime(TimeUtils.nowInt());
|
||||
if(disappearScore>0){
|
||||
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.class, LingMaiSecretArea.class);
|
||||
if(lingMaiMap.values().stream().noneMatch(n->n.getUid()==uid)){
|
||||
lingMaiSecretArea.setScore1((int) disappearScore);
|
||||
}
|
||||
}
|
||||
return lingMaiSecretArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* 占领奖励 每十分钟发放一次
|
||||
*/
|
||||
|
@ -240,6 +218,41 @@ public class CrossLingmaiLogic {
|
|||
updateLingmaiData(lingMaiMap2, crossGroup, 2);
|
||||
}
|
||||
|
||||
|
||||
public static void updateLingmaiData(Map<String, LingMaiSecretArea> lingMaiMap, int crossGroup, int group) {
|
||||
int nowTime = TimeUtils.nowInt();
|
||||
String groupkey = crossGroup + RedisKey.Delimiter_colon + group;
|
||||
for (Map.Entry<String, LingMaiSecretArea> map : lingMaiMap.entrySet()) {
|
||||
try {
|
||||
User user = UserManager.getUser(map.getValue().getUid());
|
||||
if (user != null) {
|
||||
SLodeConfig config = SLodeConfig.lodeConfig.get(map.getValue().getId());
|
||||
if (config != null) {
|
||||
int occupyTime = (int) map.getValue().getGetAwardTimeOrOccupyTime();
|
||||
//分钟
|
||||
int minute = (nowTime - occupyTime) / 60;
|
||||
//秒
|
||||
int second = Math.min((nowTime - occupyTime) % 60, 60);
|
||||
//difVal =1 ;
|
||||
LOGGER.error("玩家" + map.getValue().getUid() + "原有秒:"+map.getValue().getOccupyTime()+" 获得秒:" + (minute*60+second));
|
||||
map.getValue().setOccupyTime(map.getValue().getOccupyTime() + minute*60+second);
|
||||
map.getValue().setGetAwardTimeOrOccupyTime(nowTime);
|
||||
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO, groupkey, map.getKey(), map.getValue());
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
LOGGER.error("minute:"+map.getValue().getOccupyTime()+" per:"+(config.getRewardList()[0][1]/60));
|
||||
long score = (long)map.getValue().getOccupyTime() * config.getRewardList()[0][1]/60 + map.getValue().getScore1();
|
||||
double test = rank.getScoreById(user.getId(), groupkey);
|
||||
LOGGER.error("之前是:" + test + "之后是:" + score);
|
||||
rank.addRank(user.getId(), groupkey, score);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算奖励
|
||||
*/
|
||||
|
|
|
@ -48,7 +48,6 @@ public class Mail extends MongoBase {
|
|||
this.effectiveTime = effectiveTime ;
|
||||
this.sendName = sendName ;
|
||||
this.mailType = mailType;
|
||||
|
||||
}
|
||||
public Mail(int uid,String head,String content,String mailItem,int sendTime,int effectiveTime,String sendName,int mailType,int isTop,int markType){
|
||||
this.id = KeyGenUtils.produceIdByModule(UUIDEnum.MAIL, uid);
|
||||
|
|
|
@ -45,13 +45,22 @@ public class MailLogic {
|
|||
return MailLogic.Instance.instance;
|
||||
}
|
||||
|
||||
private void getMailToRedis(int uid){
|
||||
String key = RedisKey.MAIL_REWARD_MARK + RedisKey.Delimiter_colon + uid;
|
||||
Map<String, Mail> mailMap = RedisUtil.getInstence().getMapValues(key, String.class, Mail.class);
|
||||
if (mailMap == null || mailMap.isEmpty()){
|
||||
return;
|
||||
}
|
||||
for (Mail mail : mailMap.values()) {
|
||||
sendMail(mail);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的所有邮件
|
||||
* @param userId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<CommonProto.Mail> getAllUserMail(int userId) throws Exception {
|
||||
getMailToRedis(userId);
|
||||
List<CommonProto.Mail> mailList = new CopyOnWriteArrayList<>();
|
||||
User user = UserManager.getUser(userId);
|
||||
MailManager mailManager = user.getMailManager();
|
||||
|
@ -298,8 +307,6 @@ public class MailLogic {
|
|||
|
||||
/**
|
||||
* 有附件已领取, 无附件已读取的邮件
|
||||
* @param userId
|
||||
* @throws Exception
|
||||
*/
|
||||
public void delUserMail(int userId) throws Exception {
|
||||
User user = UserManager.getUser(userId);
|
||||
|
@ -326,7 +333,10 @@ public class MailLogic {
|
|||
}
|
||||
}
|
||||
}
|
||||
//发送邮件
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*/
|
||||
public void sendMail(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime){
|
||||
User user = UserManager.getUserNotCache(uid);
|
||||
if (user != null){
|
||||
|
@ -338,6 +348,32 @@ public class MailLogic {
|
|||
LOGGER.error("用户为空,error sendMail==>uid={},title={},reward:{}",uid,title,reward);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*/
|
||||
public void sendMail(Mail mail){
|
||||
int roleUid = mail.getRoleUid();
|
||||
User user = UserManager.getUserNotCache(roleUid);
|
||||
if (user != null){
|
||||
user.getMailManager().addMail(mail);
|
||||
LOGGER.info("领取redis标记的邮件==>uid={},mail={}",roleUid, mail);
|
||||
MessageUtil.sendRedIndication(roleUid, GlobalsDef.MAIL_RED_TYPE);
|
||||
}else {
|
||||
LOGGER.error("用户为空,error sendMail==>uid={},mail={}",roleUid,mail);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件到redis
|
||||
*/
|
||||
public void sendMailToRedis(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime){
|
||||
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);
|
||||
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 {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue