diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java index ef40f8f4b..d4ed00d57 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java @@ -20,10 +20,7 @@ import com.ljsd.jieling.logic.activity.ActivityType; import com.ljsd.jieling.logic.activity.ActivityTypeEnum; import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic; import com.ljsd.jieling.logic.activity.event.*; -import com.ljsd.jieling.logic.dao.Order; -import com.ljsd.jieling.logic.dao.PlayerManager; -import com.ljsd.jieling.logic.dao.UserManager; -import com.ljsd.jieling.logic.dao.VipInfo; +import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.expedition.ExpeditionLogic; import com.ljsd.jieling.logic.fight.CombatLogic; @@ -921,54 +918,6 @@ public class BuyGoodsNewLogic { } } - /** - * 发送推送礼包 - */ - public static void openPush(ISession session,User user,int type,int star){ - try { - NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo(); - List list = SPackPushConfig.findConfigByCon(type,star); - if(list == null){ - return; - } - list.sort(Comparator.comparingInt(SPackPushConfig::getPriority)); - long now = TimeUtils.now(); - int bagId = 0; - boolean push = false; - for(SPackPushConfig con : list){ - bagId = judgePushCondition(user,con); - int conditionType=con.getConditionId()[0]; - int pushId = con.getId(); - int statistics = con.getStatistics(); - int count = con.getCount(); - // todo DayPushNum和AllPuthNum可以放到redis里操作 - if (statistics >0 && info.getDayPushNum(pushId)>= statistics && count > 0 && info.getAllPuthNum(pushId)>= count){ - continue; - } - //条件成功 - if(bagId > 0 && info.getNextPushTime() < now && info.getTypePushTimeMap(conditionType) < now){ - info.setNextPushTime(now + con.getcDTime() * TimeUtils.HOUR); - info.setTypePushTimeMap(conditionType, now + con.getPrivateCD() * TimeUtils.HOUR); - info.setDayPushNum(pushId,1); - info.setAllPuthNum(pushId,1); - push = createPushBag(bagId, user); - break; - } - } - List goodsBagInfo = new ArrayList<>(SRechargeCommodityNewConfig.configMap.size()); - getGoodsBagInfo(user.getId(), goodsBagInfo); - PlayerInfoProto.AllGiftGoodsIndication goodsBuild = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build(); - MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE, goodsBuild, true); - if(bagId != 0 && push){ - PlayerInfoProto.PushWelfareResponse pushWelfareResponse = PlayerInfoProto.PushWelfareResponse.newBuilder().addId(bagId).build(); - MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.PUSH_WELFARE_RESPONSE.getNumber(), pushWelfareResponse, true); - } - }catch (Exception e){ - e.printStackTrace(); - LOGGER.error("创建推送礼包报错,uid:{},触发礼包id:{},type:{}, 异常:{}",user.getId(), star, type, e.getMessage()); - } - } - private static int judgePushCondition(User user,SPackPushConfig con){ int[] scope = con.getScopeId(); switch (scope[0]){ @@ -1085,4 +1034,188 @@ public class BuyGoodsNewLogic { MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHECK_BUY_GOODS_RESPONSE_VALUE,response); } + private static int judgePushCondition(User user,SPackPushConfig con,boolean checkCondition){ + int[] scope = con.getScopeId(); + //scope和condition条件类型复用,先检测scope + boolean result = checkPushCondition(scope,user); + if(!result){ + return -1; + } + //scope条件满足之后还要做condition条件检测 + if(checkCondition){ + int[] condition = con.getConditionId(); + result = checkPushCondition(condition,user); + if(!result){ + return -1; + } + } + //此处根据需求改成指定天数累计充值,之前的条件是历史累计充值 + double rr = user.getPlayerInfoManager().getNewRechargeInfo().GetAllRechargeNum(SSpecialConfig.getIntegerValue(SSpecialConfig.DAYS_FOR_RECHARGE_SUM)); + int index = 0; + for(int i = 1;i rr){ + index = i-1; + break; + } + } + if(con.getPersonas()[index] > rr){ + return -1; + } + return con.getPacks()[index]; + } + + private static int[] judgePushConditionMulti(User user,SPackPushConfig con,boolean checkCondition){ + int[] scope = con.getScopeId(); + //scope和condition条件类型复用,先检测scope + boolean result = checkPushCondition(scope,user); + if(!result){ + return null; + } + //scope条件满足之后还要做condition条件检测 + if(checkCondition){ + int[] condition = con.getConditionId(); + result = checkPushCondition(condition,user); + if(!result){ + return null; + } + } + //寻仙,法宝,仙豆,潜能等同时推多个礼包 + return con.getPacks(); + } + + public static boolean checkPushCondition(int[] condition,User user){ + switch (condition[0]){ + case 1://主线关卡 + int mainLevel = user.getMainLevelManager().getFightId(); + if(mainLevel < condition[1]){ + return false; + } + break; + case 2://爬塔 + int towerLevel = condition[1]; + if(towerLevel < condition[1]){ + return false; + } + break; + case 3://玩家等级 + int level = user.getPlayerInfoManager().getLevel(); + if(level < condition[1]){ + return false; + } + break; + case 7://主线关卡 + //此处根据需求改成指定天数内最大充值订单,之前的条件是历史充值最大订单 + int value = SSpecialConfig.getIntegerValue(SSpecialConfig.DAYS_FOR_RECHARGE_SINGLE); + double mxr = user.getPlayerInfoManager().getNewRechargeInfo().GetSingleMaxRechargeNum(value); + if(mxr < condition[1]){ + return false; + } + break; + case 16://法宝召唤 + case 17://寻仙召唤 + int itemId = condition[1]; + Item item = user.getItemManager().getItem(itemId); + //够10连不弹 + if(item != null && item.getItemNum() >= 10){ + return false; + } + break; + case 18://仙豆 + int xiandouId = condition[1]; + Item xiandouItem = user.getItemManager().getItem(xiandouId); + //够抽就不用弹 + if(xiandouItem!= null && xiandouItem.getItemNum() >= 1){ + return false; + } + break; + case 19://潜能(触发了直接返回礼包,由外面判断) + break; + case 20://开服天数礼包(开服指定天数登录自动触发) + int day = condition[1]; + String openTime = GameApplication.serverConfig.getOpenTime(); + long openTimeLong = TimeUtils.stringToTimeLong2(openTime); + long haveTime = System.currentTimeMillis() - openTimeLong; + int nowDay = (int)(haveTime/TimeUtils.ONE_DAY) + 1; + if(nowDay != day){ + return false; + } + break; + default:break; + } + return true; + } + + /** + * 发送推送礼包 + */ + public static void openPush(ISession session,User user,int type,int star){ + try { + NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo(); + List list = SPackPushConfig.findConfigByCon(type,star); + if(list == null){ + return; + } + list.sort(Comparator.comparingInt(SPackPushConfig::getPriority)); + long now = TimeUtils.now(); + int bagId = 0; + boolean push = false; + for(SPackPushConfig con : list){ + int conditionType=con.getConditionId()[0]; + int pushId = con.getId(); + int statistics = con.getStatistics(); + int count = con.getCount(); + //道具检测类礼包需要批量推送礼包 + if(type == PushRechargeType.FABAO_ZHOAHUAN.getType() || + type == PushRechargeType.XUNAXIAN_ZHOAHUAN.getType() || + type == PushRechargeType.XIANDOU_ZHOAHUAN.getType() || + type == PushRechargeType.QIANNENG_UP.getType()|| + type == PushRechargeType.OPEN_DAY.getType()){ + int[] bagIds = judgePushConditionMulti(user,con,true); + // todo DayPushNum和AllPuthNum可以放到redis里操作 + if (statistics >0 && info.getDayPushNum(pushId)>= statistics && count > 0 && info.getAllPuthNum(pushId)>= count){ + continue; + } + //条件成功 + if(bagIds !=null && bagIds.length > 0 && info.getNextPushTime() < now && info.getTypePushTimeMap(conditionType) < now){ + info.setNextPushTime(now + con.getcDTime() * TimeUtils.HOUR); + info.setTypePushTimeMap(conditionType, now + con.getPrivateCD() * TimeUtils.HOUR); + info.setDayPushNum(pushId,1); + info.setAllPuthNum(pushId,1); + for(int _bagId : bagIds){ + push = createPushBag(_bagId, user); + bagId = _bagId; + } + break; + } + }else{ + bagId = judgePushCondition(user,con,false); + // todo DayPushNum和AllPuthNum可以放到redis里操作 + if (statistics >0 && info.getDayPushNum(pushId)>= statistics && count > 0 && info.getAllPuthNum(pushId)>= count){ + continue; + } + //条件成功 + if(bagId > 0 && info.getNextPushTime() < now && info.getTypePushTimeMap(conditionType) < now){ + info.setNextPushTime(now + con.getcDTime() * TimeUtils.HOUR); + info.setTypePushTimeMap(conditionType, now + con.getPrivateCD() * TimeUtils.HOUR); + info.setDayPushNum(pushId,1); + info.setAllPuthNum(pushId,1); + push = createPushBag(bagId, user); + break; + } + } + } + List goodsBagInfo = new ArrayList<>(SRechargeCommodityNewConfig.configMap.size()); + getGoodsBagInfo(user.getId(), goodsBagInfo); + PlayerInfoProto.AllGiftGoodsIndication goodsBuild = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build(); + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE, goodsBuild, true); + if(bagId != 0 && push){ + PlayerInfoProto.PushWelfareResponse pushWelfareResponse = PlayerInfoProto.PushWelfareResponse.newBuilder().addId(bagId).build(); + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.PUSH_WELFARE_RESPONSE.getNumber(), pushWelfareResponse, true); + } + }catch (Exception e){ + e.printStackTrace(); + LOGGER.error("创建推送礼包报错,uid:{},触发礼包id:{},type:{}, 异常:{}",user.getId(), star, type, e.getMessage()); + } + } + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/PushRechargeType.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/PushRechargeType.java index c27995102..a8e520e00 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/PushRechargeType.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/PushRechargeType.java @@ -38,6 +38,13 @@ public enum PushRechargeType { XIANYUAN_BAOJING(13), FORE_SHILIAN(14), BAOWU_SHENYING(15), + + FABAO_ZHOAHUAN(16), + XUNAXIAN_ZHOAHUAN(17), + XIANDOU_ZHOAHUAN(18), + QIANNENG_UP(19), + //开服天数 + OPEN_DAY(20), ; private int type;