yuxu
parent
f8f0fdef33
commit
e76bf84c7d
|
|
@ -323,6 +323,9 @@ public class RedisKey {
|
|||
public static final String CROSS_YUXULUNDAO_RECORD = "CROSS_YUXULUNDAO_RECORD";//战斗回放
|
||||
public static final String CROSS_SERVER_USER = "CROSS_SERVER_USER";//redis存储个人基本信息
|
||||
|
||||
public static final String CROSS_YUXULUNDAO_DEAL_MARK = "CROSS_YUXULUNDAO_DEAL_MARK";//玉虚异常处理标记
|
||||
public static final String CROSS_YUXULUNDAO_DEAL_SERVER = "CROSS_YUXULUNDAO_DEAL_SERVER";//玉虚异常需要处理的服务器标识,无记录则不处理,不影响正常渠道
|
||||
|
||||
//跨服 灵脉秘境
|
||||
public static final String CROSS_LINGMAISECRET_INFO= "CROSS_LINGMAISECRET_INFO";//灵脉所有的占领信息
|
||||
public static final String CROSS_LINGMAISECRET_RECORD = "CROSS_LINGMAISECRET_RECORD";//灵脉记录
|
||||
|
|
|
|||
|
|
@ -1388,6 +1388,8 @@ public class RedisUtil {
|
|||
predefinedKeys.add(RedisKey.CROSS_YUXULUNDAO_ROBOT_INFO);
|
||||
predefinedKeys.add(RedisKey.CROSS_YUXULUNDAO_RECORD);
|
||||
predefinedKeys.add(RedisKey.CROSS_YUXULUNDAO_RANK_PERSON);
|
||||
predefinedKeys.add(RedisKey.CROSS_YUXULUNDAO_DEAL_MARK);
|
||||
predefinedKeys.add(RedisKey.CROSS_YUXULUNDAO_DEAL_SERVER);
|
||||
predefinedKeys.add(RedisKey.CROSS_LINGMAISECRET_INFO);
|
||||
predefinedKeys.add(RedisKey.CROSS_LINGMAISECRET_RECORD);
|
||||
predefinedKeys.add(RedisKey.CROSS_LINGMAI_RANK_PERSON);
|
||||
|
|
|
|||
|
|
@ -472,4 +472,6 @@ public interface BIReason {
|
|||
int EVERYDAY_DISCOUNT_CLEAN_MISSION_COUNT = 1357;//天天折扣清零次数
|
||||
|
||||
int TRAINGING_SPEED_ITEM_COST = 1358;//特训加速道具消耗
|
||||
|
||||
int YUXU_DEAL = 1359;//玉虚奖励修正
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
|||
import com.ljsd.jieling.logic.activity.event.HeroUpStarEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
|
||||
import com.ljsd.jieling.logic.arena.CrossYuxulundaoLogic;
|
||||
import com.ljsd.jieling.logic.arena.LuofuLogic;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||
|
|
@ -152,6 +153,8 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
if(dropShow != null && !dropShow.isEmpty()){
|
||||
dropShow.clear();
|
||||
}
|
||||
//玉虚异常奖励处理
|
||||
CrossYuxulundaoLogic.getInstance().dealYuxuError(user,iSession);
|
||||
|
||||
//问卷状态
|
||||
int questState =-1;
|
||||
|
|
|
|||
|
|
@ -2,29 +2,39 @@ package com.ljsd.jieling.logic.arena;
|
|||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.fight.ArenaRecord;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
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.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.ArenaEnemy;
|
||||
import com.ljsd.jieling.logic.dao.ArenaManager;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.item.ItemLog;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import config.SArenaRobotConfig;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
import config.SMServerRankConfig;
|
||||
import config.SMServerRankReward;
|
||||
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.PushRechargeType;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.ToolsUtil;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import org.springframework.util.StringUtils;
|
||||
import rpc.protocols.CommonProto;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -34,6 +44,7 @@ import java.util.stream.Collectors;
|
|||
public class CrossYuxulundaoLogic {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArenaLogic.class);
|
||||
private Map<Integer,Integer> dealServers = null;
|
||||
|
||||
public CrossYuxulundaoLogic() {
|
||||
}
|
||||
|
|
@ -114,8 +125,11 @@ public class CrossYuxulundaoLogic {
|
|||
try {
|
||||
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("MsRankContent",new Object[]{(i + 1)},new int[0],"#");
|
||||
if (config != null) {
|
||||
MailLogic.getInstance().sendMail(arenaRankfilt.get(i), title, content,
|
||||
StringUtil.parseArrayToString(config.getSeasonReward()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
//模拟发20遍,临时用
|
||||
for(int j = 0;j<20;j++){
|
||||
MailLogic.getInstance().sendMail(arenaRankfilt.get(i), title, content,
|
||||
StringUtil.parseArrayToString(config.getSeasonReward()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -328,6 +342,10 @@ public class CrossYuxulundaoLogic {
|
|||
|
||||
}
|
||||
|
||||
public void dealUserYuxuGift(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static CommonProto.crossYxldPlayerRecordInfo getCrossYxldPlayerRecordInfo(int uid,ArenaRecord arenaRecord,boolean isSend) throws Exception {
|
||||
CommonProto.FightData fightDataProto1 ;
|
||||
|
|
@ -392,5 +410,275 @@ public class CrossYuxulundaoLogic {
|
|||
.addAllYxldDefForce(arenaRecord.getYxldDefForce()).setPracticeLevel(arenaRecord.getPracticeLevel())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理玉虚结算异常的奖励问题,并修复
|
||||
* @param user
|
||||
*/
|
||||
public void dealYuxuError(User user, ISession session) throws Exception {
|
||||
Map<Integer,Integer> dealServers = this.dealServers;
|
||||
//为null首次加载
|
||||
if(dealServers == null){
|
||||
dealServers = new HashMap<>();
|
||||
String key = RedisUtil.getInstence().getKeyLocal(RedisKey.CROSS_YUXULUNDAO_DEAL_SERVER, "");
|
||||
String servers = (String)RedisUtil.getInstence().get(key);
|
||||
if(StringUtils.isEmpty(servers)){
|
||||
this.dealServers = dealServers;
|
||||
return;
|
||||
}
|
||||
String[] sers = servers.split(",");
|
||||
if(sers.length == 0){
|
||||
this.dealServers = dealServers;
|
||||
return;
|
||||
}
|
||||
for(String id : sers){
|
||||
int serverId = Integer.parseInt(id);
|
||||
dealServers.put(serverId,serverId);
|
||||
this.dealServers = dealServers;
|
||||
}
|
||||
}
|
||||
//不需要处理
|
||||
if(dealServers.isEmpty()){
|
||||
return;
|
||||
}
|
||||
//不在处理范围内
|
||||
if(!dealServers.containsKey(GameApplication.serverId)){
|
||||
return;
|
||||
}
|
||||
String dealKey = RedisUtil.getInstence().getKeyLocal(RedisKey.CROSS_YUXULUNDAO_DEAL_MARK, String.valueOf(user.getId()));
|
||||
String deal = (String)RedisUtil.getInstence().get(dealKey);
|
||||
//已经处理过了
|
||||
if(deal != null && "1".equals(deal)){
|
||||
return;
|
||||
}
|
||||
MongoTemplate otherMonogTemplate = MongoUtil.getInstence().getMonogTemplate(GameApplication.serverId);
|
||||
if(otherMonogTemplate == null){
|
||||
return;
|
||||
}
|
||||
int score = 0;
|
||||
int getNum = 0;
|
||||
//查询玉虚论道货币获取记录
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("uid").is(user.getId()));
|
||||
query.addCriteria(Criteria.where("type").is(0));
|
||||
query.addCriteria(Criteria.where("reason").is(16));
|
||||
query.addCriteria(Criteria.where("itemId").is(107));
|
||||
List<ItemLog> list = otherMonogTemplate.find(query,ItemLog.class);
|
||||
if(list != null && list.size() > 0){
|
||||
for(ItemLog log : list){
|
||||
//记录当时获取的货币积分
|
||||
score = (int)log.getItemNum();
|
||||
getNum++;
|
||||
}
|
||||
}
|
||||
//记录要删除的邮件id
|
||||
List<String> removeList = new ArrayList<>();
|
||||
//领取数量小于20说明可能有未领取的邮件
|
||||
if(getNum <20){
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("MsRankTitle");
|
||||
List<CommonProto.Mail> mailList = MailLogic.getInstance().getAllUserMail(user.getId());
|
||||
for(CommonProto.Mail mail : mailList){
|
||||
//不是玉虚论道奖励
|
||||
if(!title.equals(mail.getHead())){
|
||||
continue;
|
||||
}
|
||||
// 包装邮件奖励
|
||||
StringBuilder mailItem = new StringBuilder(mail.getMailItem());
|
||||
if(mailItem.length()==0){
|
||||
continue;
|
||||
}
|
||||
// 转换二维数组
|
||||
long[][] itemArr = StringUtil.parseFiledLong2(mailItem.toString());
|
||||
for(long[] items : itemArr){
|
||||
int itemId = (int)items[0];
|
||||
//不是玉虚货币跳过
|
||||
if(itemId != 107){
|
||||
continue;
|
||||
}
|
||||
int num = (int)items[1];
|
||||
//道具日志里没有领取记录,记录邮件的货币积分为当时发奖的积分
|
||||
if(score == 0){
|
||||
score = num;
|
||||
}
|
||||
removeList.add(mail.getMailId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//删除未领取的异常邮件
|
||||
if(removeList.size() > 0){
|
||||
MailLogic.getInstance().deleteForceMail(session,removeList);
|
||||
}
|
||||
//修正货币数量
|
||||
//有记录再处理
|
||||
if(score >0){
|
||||
int overGet = getNum - 1;
|
||||
//额外获取的总分数
|
||||
int total = score * overGet;
|
||||
//获取异常期间使用掉的积分
|
||||
int used = this.getUsedScore(user,otherMonogTemplate);
|
||||
//获取已有的道具数量
|
||||
int have = 0;
|
||||
Item item = user.getItemManager().getItem(107);
|
||||
if(item != null){
|
||||
have = (int)item.getItemNum();
|
||||
}
|
||||
//修正
|
||||
int trueNum = have + used - total;
|
||||
//用掉的比获取的多,添加差价分数,有部分用掉的积分是正常获取的
|
||||
if(trueNum > have){
|
||||
long add = trueNum - have;
|
||||
Map<Long,Long> adds = new HashMap<>();
|
||||
adds.put(107l,add);
|
||||
long[][] items = ToolsUtil.getTwoArrayLong(adds);
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
ItemUtil.dropByMail(user, items, dropBuilder, BIReason.YUXU_DEAL);
|
||||
}else{
|
||||
int cost = have - trueNum;
|
||||
if(cost > 0){
|
||||
//扣除道具
|
||||
Map<Integer,Integer> removes = new HashMap<>();
|
||||
removes.put(107,cost);
|
||||
int[][] items = ToolsUtil.getTwoArrayInt(removes);
|
||||
ItemUtil.itemCost(user, items, BIReason.YUXU_DEAL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//清除礼物
|
||||
this.dealGiftEquip(user);
|
||||
//刷新商店
|
||||
this.dealStore(user);
|
||||
//标记为已处理
|
||||
String mark = RedisKey.CROSS_YUXULUNDAO_DEAL_MARK + RedisKey.Delimiter_colon + user.getId();
|
||||
RedisUtil.getInstence().set(mark, "1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取使用掉的积分,只要兑换的礼物都返还
|
||||
* @param user
|
||||
* @param otherMonogTemplate
|
||||
* @return
|
||||
*/
|
||||
public int getUsedScore(User user, MongoTemplate otherMonogTemplate){
|
||||
int num = 0;
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("uid").is(user.getId()));
|
||||
query.addCriteria(Criteria.where("type").is(1));
|
||||
query.addCriteria(Criteria.where("reason").is(1018));
|
||||
query.addCriteria(Criteria.where("itemId").is(107));
|
||||
List<ItemLog> list = otherMonogTemplate.find(query,ItemLog.class);
|
||||
if(list != null && list.size() > 0){
|
||||
for(ItemLog log : list){
|
||||
num += (int)log.getItemNum();
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空玉虚礼物
|
||||
* @param user
|
||||
*/
|
||||
public void dealGiftEquip(User user) throws Exception {
|
||||
List<Integer> playerGiftList = new ArrayList<>();
|
||||
playerGiftList.add(5100078);
|
||||
playerGiftList.add(51000781);
|
||||
playerGiftList.add(5100088);
|
||||
playerGiftList.add(51000881);
|
||||
playerGiftList.add(5100098);
|
||||
playerGiftList.add(51000981);
|
||||
List<Integer> heroGiftList = new ArrayList<>();
|
||||
heroGiftList.add(5200058);
|
||||
heroGiftList.add(52000581);
|
||||
heroGiftList.add(52000582);
|
||||
heroGiftList.add(52000583);
|
||||
heroGiftList.add(5200068);
|
||||
heroGiftList.add(52000681);
|
||||
heroGiftList.add(52000682);
|
||||
heroGiftList.add(52000683);
|
||||
heroGiftList.add(5200078);
|
||||
heroGiftList.add(52000781);
|
||||
heroGiftList.add(52000782);
|
||||
heroGiftList.add(52000783);
|
||||
//处理主角礼物
|
||||
Set<Integer> playerGifts = user.getPlayerInfoManager().getPlayerGiftEquipList();
|
||||
Set<Integer> removePlayerGifts = new HashSet<>();
|
||||
for(int giftId : playerGiftList){
|
||||
if (playerGifts.contains(giftId)){
|
||||
removePlayerGifts.add(giftId);
|
||||
}
|
||||
}
|
||||
if(removePlayerGifts.size() > 0){
|
||||
playerGifts.removeAll(removePlayerGifts);
|
||||
user.getPlayerInfoManager().setPlayerGiftEquipList(playerGifts);
|
||||
}
|
||||
//处理英雄礼物
|
||||
// 英雄礼物
|
||||
for(Hero hero:user.getHeroManager().getHeroMap().values()){
|
||||
Set<Integer> heroGifts = hero.getHeroGiftEquipList();
|
||||
Set<Integer> removeHeroGifts = new HashSet<>();
|
||||
for(int giftId : heroGiftList){
|
||||
if (heroGifts.contains(giftId)){
|
||||
removeHeroGifts.add(giftId);
|
||||
}
|
||||
}
|
||||
if(removeHeroGifts.size() > 0){
|
||||
heroGifts.removeAll(removeHeroGifts);
|
||||
hero.setHeroGiftEquipList(heroGifts);
|
||||
}
|
||||
}
|
||||
//处理背包上的礼物
|
||||
Map<Integer,Integer> removeList = new HashMap<>();
|
||||
for(int itemId : playerGiftList){
|
||||
Item item = user.getItemManager().getItem(itemId);
|
||||
if(item == null){
|
||||
continue;
|
||||
}
|
||||
int itemNum = (int)item.getItemNum();
|
||||
if(itemNum <= 0){
|
||||
continue;
|
||||
}
|
||||
removeList.put(itemId,itemNum);
|
||||
}
|
||||
for(int itemId : heroGiftList){
|
||||
Item item = user.getItemManager().getItem(itemId);
|
||||
if(item == null){
|
||||
continue;
|
||||
}
|
||||
int itemNum = (int)item.getItemNum();
|
||||
if(itemNum <= 0){
|
||||
continue;
|
||||
}
|
||||
removeList.put(itemId,itemNum);
|
||||
}
|
||||
//删除背包里的礼物
|
||||
if(removeList.size() > 0){
|
||||
int[][] items = ToolsUtil.getTwoArrayInt(removeList);
|
||||
ItemUtil.itemCost(user, items, BIReason.YUXU_DEAL ,1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新玉虚商店
|
||||
* @param user
|
||||
*/
|
||||
public void dealStore(User user){
|
||||
Map<Integer,StoreInfo> infos = user.getStoreManager().getStoreInfoMap();
|
||||
if(infos.containsKey(80)){
|
||||
int type = 80;
|
||||
StoreInfo info = infos.get(type);
|
||||
if(info != null){
|
||||
Map<Integer, List<SStoreConfig>> configMap = SStoreConfig.getSstoreConfigBuyStore();
|
||||
List<SStoreConfig> sStoreConfigs = configMap.get(type);
|
||||
for(SStoreConfig config:sStoreConfigs){
|
||||
Map<Integer, Integer> itemNumMap = info.getItemNumMap();
|
||||
itemNumMap.put(config.getId(),0);
|
||||
user.getStoreManager().getStoreInfoMap().get(type).setItemNumMap(itemNumMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -475,4 +475,31 @@ public class MailLogic {
|
|||
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.MAIL_DELETE_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制删除邮件
|
||||
* @param session
|
||||
* @param mailIds
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deleteForceMail(ISession session,List<String> mailIds) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
MailManager mailManager = user.getMailManager();
|
||||
Map<String, Mail> mailMap = mailManager.getMailMap();
|
||||
List<String> delMailIds = new CopyOnWriteArrayList<>();
|
||||
for(String mailId:mailIds){
|
||||
if(!mailMap.containsKey(mailId)){
|
||||
continue;
|
||||
}
|
||||
Mail cMail = mailMap.get(mailId);
|
||||
delMailIds.add(mailId);
|
||||
LOGGER.info("玩家{}手动删除了邮件:{}",user.getId(),cMail);
|
||||
}
|
||||
if (!delMailIds.isEmpty()) {
|
||||
for (String mailId : delMailIds) {
|
||||
mailManager.removeMail(mailId);
|
||||
}
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.MAIL_DELETE_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,6 +150,27 @@ public class ToolsUtil {
|
|||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* map转二维数组
|
||||
*/
|
||||
public static long[][] getTwoArrayLong(Map<Long, Long> map) {
|
||||
long[][] object = null;
|
||||
if (map != null && !map.isEmpty()) {
|
||||
int size = map.size();
|
||||
object = new long[size][2];
|
||||
|
||||
Iterator<Map.Entry<Long, Long>> iterator = map.entrySet().iterator();
|
||||
for (int i = 0; i < size; i++) {
|
||||
Map.Entry<Long, Long> entry = iterator.next();
|
||||
long key = entry.getKey();
|
||||
long value = entry.getValue();
|
||||
object[i][0] = key;
|
||||
object[i][1] = value;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public static int findKeyWithMaxValueLessThanB(Map<Integer, Integer> a, int b) {
|
||||
int maxKey = -1;
|
||||
int maxValue = Integer.MIN_VALUE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue