From 6c5f1accd29927fd5633505f4e51fd41f6bbfb6e 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?=E6=8E=A8=E9=80=81=E7=A4=BC=E5=8C=85=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jieling/logic/store/BuyGoodsNewLogic.java | 77 ++++++++++--------- 1 file changed, 41 insertions(+), 36 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 862036698..128df21f9 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 @@ -309,7 +309,7 @@ public class BuyGoodsNewLogic { // 全部礼包状态推送 sendGiftGoodsWithoutJudge(uid); // 推送礼包 - openPush(session,user, PushRechargeType.point_recharge.getType(),goodsId); + openPush(session, user, PushRechargeType.point_recharge.getType(), goodsId); // 基础掉落 List list = bag.getDropByBag(); // 购买礼包额外补助 @@ -925,43 +925,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()); } }