From b5a179b74b457f6051b2d94d6eb870c54d8e2b04 Mon Sep 17 00:00:00 2001 From: grimm <1769111741@qq.com> Date: Mon, 3 Jun 2024 11:24:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jieling/logic/store/BuyGoodsNewLogic.java | 75 ++++++++++--------- 1 file changed, 40 insertions(+), 35 deletions(-) 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 3587a0507..29ba0bccd 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 @@ -887,43 +887,48 @@ public class BuyGoodsNewLogic { /** * 发送推送礼包 */ - public static void openPush(ISession session,User user,int type,int star) throws Exception{ - 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; + 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; } - //条件成功 - 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.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); + 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()); } }