From 1ed8030f329eaee9e1fe6a86aa53df09fe1d8715 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Mon, 5 Jul 2021 11:26:24 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=8E=A8=E9=80=81=E7=A4=BC=E5=8C=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7ed896b78cc667ca72c3e4e43440f216ac22664d. --- .../jieling/logic/store/BuyGoodsNewLogic.java | 47 ++++++++++--------- .../newRechargeInfo/NewRechargeInfo.java | 5 ++ .../bean/AbstractWelfareBag.java | 3 -- .../newRechargeInfo/bean/PushWelfareBag.java | 12 +---- 4 files changed, 33 insertions(+), 34 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 fe1fb2293..2249b8cf9 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 @@ -460,6 +460,10 @@ public class BuyGoodsNewLogic { result = true; } }else{ + if(bag.getType() == RechargeType.push.getType() && !bag.isOpen()){ + user.getPlayerInfoManager().getNewRechargeInfo().removePush((PushWelfareBag) bag); + return true; + } if(bag.getType() == RechargeType.timeLimit.getType()){ //活动类型特殊处理 for(String[] s : configById.getCondition()){ @@ -539,15 +543,6 @@ public class BuyGoodsNewLogic { return bag; } - /** - * setPush礼包初始化数据 - */ - public static void setInitPushInfo(PushWelfareBag bag,SRechargeCommodityNewConfig config){ - bag.setStartTime(System.currentTimeMillis()); - bag.setEndTime(System.currentTimeMillis() + bag.getTime() * TimeUtils.HOUR); - bag.setOpen(true); - } - /** * 礼包到时处理 */ @@ -556,7 +551,7 @@ public class BuyGoodsNewLogic { bag.setLastBuyTime(0); bag.setBuyTimes(0); if(bag.getType() == RechargeType.push.getType()){ - clearPushBag((PushWelfareBag) bag); + user.getPlayerInfoManager().getNewRechargeInfo().removePush((PushWelfareBag) bag); } } @@ -886,26 +881,36 @@ public class BuyGoodsNewLogic { }else{ info.getTempLimitMap().put(bagId,num); } - SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(bagId); - if(info.getPushMap().get(bagId) != null){ + if(isFiveStarBag(bagId) && info.getPushMap().get(bagId) != null){ AbstractWelfareBag bag = info.getPushMap().get(bagId); - setInitPushInfo((PushWelfareBag) bag,config); - if(isFiveStarBag(bagId)){ - bag.setLimit((bag.getLimit()+num)>info.FIVESTARLIMIT?info.FIVESTARLIMIT:(bag.getLimit()+num)); - } + bag.setLimit((bag.getLimit()+num)>info.FIVESTARLIMIT?info.FIVESTARLIMIT:(bag.getLimit()+num)); + bag.setStartTime(System.currentTimeMillis()); + bag.setEndTime(bag.getStartTime() + getTime(bag) * TimeUtils.HOUR); }else{ + SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(bagId); AbstractWelfareBag bag = initUnitWF(user,config); - if(isFiveStarBag(bagId)){ - bag.setLimit(num>info.FIVESTARLIMIT?info.FIVESTARLIMIT:num); + if(num != 0 && num+hasOpen > info.FIVESTARLIMIT){ + bag.setLimit(info.FIVESTARLIMIT-hasOpen); + }else{ + bag.setLimit(num); } } return true; } /** - * 消除推送礼包 + * 推送礼包的结束时间 + * @param bag + * @return */ - private static void clearPushBag(PushWelfareBag bag){ - bag.clear(); + private static int getTime(AbstractWelfareBag bag){ + int i = 2; + for(String[] s : bag.getCondition()){ + if(s[0].equals("6")){ + i = Integer.parseInt(s[1]); + break; + } + } + return i; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/NewRechargeInfo.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/NewRechargeInfo.java index 9cad636b9..7b62d31bf 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/NewRechargeInfo.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/NewRechargeInfo.java @@ -184,6 +184,11 @@ public class NewRechargeInfo extends MongoBase { updateString("pushMap."+bag.getModId(),bag); } + public void removePush(PushWelfareBag bag){ + pushMap.remove(bag.getModId()); + removeString(getMongoKey() + ".pushMap."+bag.getModId()); + } + public int getMainLineLost() { return mainLineLost; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java index 60f460467..eb51d7f50 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java @@ -35,9 +35,6 @@ public class AbstractWelfareBag extends MongoBase{ setModId(config.getId()); setType(config.getOtype()); setLimit(config.getLimit()); - if(config.getOtype() == 4){ - setLimit(1); - } setTimeType(config.getTime()); setDailyUpdate(config.getDailyUpdate()); setContinueDays(config.getContiueDays()); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/PushWelfareBag.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/PushWelfareBag.java index d2977eeae..8e30ead3b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/PushWelfareBag.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/PushWelfareBag.java @@ -27,20 +27,12 @@ public class PushWelfareBag extends AbstractWelfareBag { public boolean buy() { setBuyTimes(getBuyTimes()+1); if(getLimit()<=getBuyTimes()){ - clear(); + setOpen(false); } return true; } - public void clear(){ - setOpen(false); - setLimit(1); - setBuyTimes(0); - setStartTime(0); - setEndTime(0); - } - - public int getTime(){ + private int getTime(){ int i = 2; for(String[] s : getCondition()){ if(s[0].equals("6")){