From 8df67625487f744d52f472ab493e2d358c7261fa Mon Sep 17 00:00:00 2001 From: jiahuiwen Date: Tue, 13 Oct 2020 14:58:25 +0800 Subject: [PATCH] =?UTF-8?q?25=E9=97=AF=E5=85=B3=E7=A4=BC=E5=8C=85=E3=80=81?= =?UTF-8?q?26=E3=80=81=E5=BF=83=E9=AD=94=E8=AF=95=E7=82=BC=E7=A4=BC?= =?UTF-8?q?=E5=8C=85=20=E8=A7=A6=E5=8F=91=E5=92=8C=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/handler/map/MapLogic.java | 66 +++++++++++++++++++ .../jieling/logic/store/BuyGoodsLogic.java | 43 ++++++++++-- .../com/ljsd/jieling/util/MessageUtil.java | 10 +-- .../main/java/config/SMainLevelConfig.java | 6 ++ .../java/config/SRechargeCommodityConfig.java | 17 ++++- .../src/main/java/config/SSpecialConfig.java | 4 ++ 6 files changed, 134 insertions(+), 12 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index 108e8e75a..189b203e3 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -40,6 +40,7 @@ import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; import com.ljsd.jieling.logic.rank.RankContext; import com.ljsd.jieling.logic.rank.RankEnum; +import com.ljsd.jieling.logic.store.BuyGoodsLogic; import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.logic.store.StoreType; @@ -2160,6 +2161,12 @@ public class MapLogic { FightInfoProto.MainLevelFightUpdateIndication build = FightInfoProto.MainLevelFightUpdateIndication.newBuilder().setState(mainLevelManager.getState()).setFightId(mainLevelManager.getFightId()).build(); MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.MAIN_LEVEL_FIGHT_UPDATE_INDICATION_VALUE,build,true); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true); + + int integerValue = SSpecialConfig.getIntegerValue(SSpecialConfig.DISCOUNT_MAIN); + if (sMainLevelConfig.getSortId() % integerValue == 0) { + openRechargeBagIds(session, user, 25); + } + // String rankKey = RedisKey.getKey(RedisKey.MAINLEVEL_RANK, "", false); // RedisUtil.getInstence().zsetAddOne(rankKey, String.valueOf(user.getId()), sMainLevelConfig.getVirtureId()); RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(uid,"",sMainLevelConfig.getVirtureId(),user.getPlayerInfoManager().getMaxForce()); @@ -2167,6 +2174,46 @@ public class MapLogic { } + /** + * 开启礼包 + * @param session + * @param user + * @param type + * @throws Exception + */ + public void openRechargeBagIds(ISession session, User user, int type) throws Exception { + Map integerSRechargeCommodityConfigMap = SRechargeCommodityConfig.rechargeIndetions.get(type); + if (integerSRechargeCommodityConfigMap == null || integerSRechargeCommodityConfigMap.isEmpty()) { + return; + } + RechargeInfo rechargeInfo = user.getPlayerInfoManager().getRechargeInfo(); + double saveAmt = rechargeInfo.getSaveAmt(); + int sendRechargeId = 0; + long lastTime = 0; + for (SRechargeCommodityConfig sRechargeCommodityConfig : integerSRechargeCommodityConfigMap.values()) { + if (saveAmt >= sRechargeCommodityConfig.getDiscountType()[1] && saveAmt <= sRechargeCommodityConfig.getDiscountType()[2]) { + sendRechargeId = sRechargeCommodityConfig.getId(); + lastTime = sRechargeCommodityConfig.getDiscountType()[3] * 3600 * 1000L; + break; + } + } + if (sendRechargeId == 0) { + LOGGER.info("sendRechargeId indetion id==0 uid=>{} saveAmt=>{}", user.getId(), saveAmt); + } else { + if (!rechargeInfo.getBuyGoodsTimes().containsKey(sendRechargeId)) { + rechargeInfo.updateBuyGoodsTimes(sendRechargeId, 0); + rechargeInfo.putDyGoodsCanBuyTimes(sendRechargeId, 1); + } else { + rechargeInfo.putDyGoodsCanBuyTimes(sendRechargeId, rechargeInfo.getDyGoodsCanBuyTimes().get(sendRechargeId) + 1); + } + rechargeInfo.updateRefreshMapByKey(sendRechargeId, TimeUtils.now() + lastTime); + List goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size()); + BuyGoodsLogic.getGoodsBagInfo(user.getId(), goodsBagInfo, false); + PlayerInfoProto.AllGiftGoodsIndication goodsBuild = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build(); + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE, goodsBuild, true); + } + } + public void openNextMainLevel(User user,int fightId) throws Exception { int level = user.getPlayerInfoManager().getLevel(); @@ -2302,6 +2349,25 @@ public class MapLogic { user.getUserMissionManager().onGameEvent(user,GameEvent.MONSTER_ATTACK_LEVEL); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true); + String stringValue = SSpecialConfig.getStringValue(SSpecialConfig.DISCOUNT_MONSTER_LEVEL); + if (stringValue != null && !stringValue.isEmpty()) { + String[] split1 = stringValue.split("\\|"); + String[] split2 = split1[0].split("#"); + boolean ifTreer = false; + if (checkFightId > Integer.parseInt(split2[split2.length - 1])) { + if (checkFightId % Integer.parseInt(split1[1]) == 0) { + ifTreer = true; + } + } else { + List strings = Arrays.asList(split2); + if (strings.contains(Integer.toString(checkFightId))) { + ifTreer = true; + } + } + if (ifTreer) { + openRechargeBagIds(session, user, 26); + } + } List itemDrop = drop.getItemlistList(); List itemIdList = new ArrayList<>(); List itemNumList = new ArrayList<>(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java index 0f05d2cc0..3b3261e6c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java @@ -164,12 +164,33 @@ public class BuyGoodsLogic { int type = sRechargeCommodityConfig.getType(); if(limit!=0){ if(buyCount>limit){ - LOGGER.error("the uid={},the goodId={}, is over limit={}",uid,goodsId,buyCount); + LOGGER.error("sendGoods the uid={},the goodId={}, is over limit={}",uid,goodsId,buyCount); resultRes.setResultCode(0); resultRes.setResultMsg("over limit"); return resultRes; } }else { + // 25闯关礼包、26、心魔试炼礼包 + if (sRechargeCommodityConfig.getTime() == 6) { + if (!rechargeInfo.getBuyGoodsTimes().containsKey(goodsId)) { + LOGGER.error("sendGoods the uid={},the goodId={}, is not open={}",uid,goodsId,buyCount); + resultRes.setResultCode(0); + resultRes.setResultMsg("not open"); + return resultRes; + } + if (!rechargeInfo.getDyGoodsCanBuyTimes().containsKey(goodsId)) { + LOGGER.error("sendGoods the uid={},the goodId={}, is not open={}",uid,goodsId,buyCount); + resultRes.setResultCode(0); + resultRes.setResultMsg("not open"); + return resultRes; + } + if (rechargeInfo.getDyGoodsCanBuyTimes().get(goodsId) <= 0) { + LOGGER.error("sendGoods the uid={},the goodId={}, buyCount=>{}, is over limit={}",uid, goodsId, buyCount, rechargeInfo.getDyGoodsCanBuyTimes().get(goodsId)); + resultRes.setResultCode(0); + resultRes.setResultMsg("over limit"); + return resultRes; + } + } if(sRechargeCommodityConfig.getTime()==4&&(sRechargeCommodityConfig.getDiscountType().length==3||sRechargeCommodityConfig.getDiscountType().length==4)){ int[] discountType = sRechargeCommodityConfig.getDiscountType(); int temptype = discountType[0]; @@ -181,7 +202,6 @@ public class BuyGoodsLogic { resultRes.setResultMsg("over limit"); return resultRes; } - } } @@ -355,7 +375,8 @@ public class BuyGoodsLogic { ISession session = OnlineUserManager.getSessionByUid(uid); //特殊礼包次数 - if(sRechargeCommodityConfig.getTime()==4&&(sRechargeCommodityConfig.getDiscountType().length==3||sRechargeCommodityConfig.getDiscountType().length==4)){ + if((sRechargeCommodityConfig.getTime()==4 || sRechargeCommodityConfig.getTime()==6) + &&(sRechargeCommodityConfig.getDiscountType().length==3||sRechargeCommodityConfig.getDiscountType().length==4)){ int[] discountType = sRechargeCommodityConfig.getDiscountType(); int temptype = discountType[0]; int tempvalue = discountType[1]; @@ -560,6 +581,11 @@ public class BuyGoodsLogic { } for(SRechargeCommodityConfig sRechargeCommodityConfig :SRechargeCommodityConfig.rechargeCommodityConfigMap.values()){ + // 25闯关礼包、26、心魔试炼礼包 特殊处理 + if ((sRechargeCommodityConfig.getShowType() == 25 || sRechargeCommodityConfig.getShowType() == 26) + && !rechargeInfo.getBuyGoodsTimes().containsKey(sRechargeCommodityConfig.getId())) { + continue; + } int limit = sRechargeCommodityConfig.getLimit(); int goodsId = sRechargeCommodityConfig.getId(); Integer buyTimes = buyGoodsTimes.get(goodsId); @@ -761,8 +787,15 @@ public class BuyGoodsLogic { rechargeInfo.getCacheSendedTypes().put(goodsId, startTime); } } - - }else{ + } else if (time == 6) { + if (rechargeInfo.getDyGoodsCanBuyTimes().containsKey(sRechargeCommodityConfig.getId())) { + endTime = rechargeInfo.getRefreshBagMap().get(sRechargeCommodityConfig.getId()); + if (now > endTime || rechargeInfo.getDyGoodsCanBuyTimes().get(sRechargeCommodityConfig.getId()) <= 0) { + return new RechargeResult(); + } + startTime = endTime - sRechargeCommodityConfig.getDiscountType()[3] * 3600000; + } + } else { if(sRechargeCommodityConfig.getDailyUpdate()>=1){ if(!refreshBagMap.containsKey(sRechargeCommodityConfig.getId())){ Gson gson = new Gson(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/MessageUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/MessageUtil.java index a76cca1e2..d42e712bb 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/MessageUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/MessageUtil.java @@ -38,8 +38,8 @@ public class MessageUtil { backMessage = new byte[0]; } else { backMessage = generatedMessage.toByteArray(); - if (backMessage.length != 0) - LOGGER.info("wrappedBuffer uid=>{}, generatedMessage=>{}", uid, JsonFormat.printToString(generatedMessage)); +// if (backMessage.length != 0) +// LOGGER.info("wrappedBuffer uid=>{}, generatedMessage=>{}", uid, JsonFormat.printToString(generatedMessage)); } int length = PackageConstant.UID_FIELD_LEN + PackageConstant.TOKEN_LEN @@ -63,9 +63,9 @@ public class MessageUtil { } int[] secretKey = Tea.KEY; byte[] bytes1 = Tea.encrypt2(bytes, secretKey); - if (backMessage.length != 0) { - LOGGER.info("wrappedBuffer uid=>{} sendbyte=>{}", uid, bytes1.length); - } +// if (backMessage.length != 0) { +// LOGGER.info("wrappedBuffer uid=>{} sendbyte=>{}", uid, bytes1.length); +// } return bytes1; } diff --git a/tablemanager/src/main/java/config/SMainLevelConfig.java b/tablemanager/src/main/java/config/SMainLevelConfig.java index 990083184..b341726f2 100644 --- a/tablemanager/src/main/java/config/SMainLevelConfig.java +++ b/tablemanager/src/main/java/config/SMainLevelConfig.java @@ -41,6 +41,8 @@ public class SMainLevelConfig implements BaseConfig { private int virtureId; //虚拟id,关卡是自增的。 + private int sortId; + public static Map config; public static Map sMainLevelConfigByVirtureIdMap; public static Map fightPreMap; @@ -131,4 +133,8 @@ public class SMainLevelConfig implements BaseConfig { public void setVirtureId(int virtureId) { this.virtureId = virtureId; } + + public int getSortId() { + return sortId; + } } \ No newline at end of file diff --git a/tablemanager/src/main/java/config/SRechargeCommodityConfig.java b/tablemanager/src/main/java/config/SRechargeCommodityConfig.java index 6109972dd..3549586b2 100644 --- a/tablemanager/src/main/java/config/SRechargeCommodityConfig.java +++ b/tablemanager/src/main/java/config/SRechargeCommodityConfig.java @@ -61,7 +61,7 @@ public class SRechargeCommodityConfig implements BaseConfig { private int[] passiveSkill; - + private int showType; public static Map rechargeCommodityConfigMap; public static Map sdkRechargeCommodityConfigMap; @@ -70,6 +70,8 @@ public class SRechargeCommodityConfig implements BaseConfig { public static TreeMap rechargePlayerLevelMap; public static Set refreshItemInfo; + public static Map> rechargeIndetions; + @Override public void init() throws Exception { Map config = STableManager.getConfig(SRechargeCommodityConfig.class); @@ -81,6 +83,7 @@ public class SRechargeCommodityConfig implements BaseConfig { TreeMap rechargePlayerLevelTemp = new TreeMap<>(); Set refreshItemInfoTmp = new HashSet<>(); + Map> rechargeIndetionsTemp = new HashMap<>(); for(SRechargeCommodityConfig sRechargeCommodityConfig : config.values()){ sdkRechargeCommodityConfigMap.put(sRechargeCommodityConfig.getRechargeId(),sRechargeCommodityConfig); sdkRechargeCommodityConfigMap.put(sRechargeCommodityConfig.getRechargeId2(),sRechargeCommodityConfig); @@ -121,13 +124,19 @@ public class SRechargeCommodityConfig implements BaseConfig { if(!StringUtil.isEmpty(endtime)){ sRechargeCommodityConfig.setEndTimeLong(Long.parseLong(endtime)); } + if (sRechargeCommodityConfig.getShowType() == 25 || sRechargeCommodityConfig.getShowType() == 26) { + if (!rechargeIndetionsTemp.containsKey(sRechargeCommodityConfig.getShowType())) { + rechargeIndetionsTemp.put(sRechargeCommodityConfig.getShowType(), new HashMap<>()); + } + rechargeIndetionsTemp.get(sRechargeCommodityConfig.getShowType()).put(sRechargeCommodityConfig.getId(), sRechargeCommodityConfig); + } } rechargeCommodityConfigMap = config; rechargeLevelMap = rechargeLevelMapTmp; recharegeHeroTime = recharegeHeroTimeTmp; refreshItemInfo = refreshItemInfoTmp; rechargePlayerLevelMap = rechargePlayerLevelTemp; - + rechargeIndetions = rechargeIndetionsTemp; } @@ -254,4 +263,8 @@ public class SRechargeCommodityConfig implements BaseConfig { public String getRechargeId3() { return rechargeId3; } + + public int getShowType() { + return showType; + } } \ No newline at end of file diff --git a/tablemanager/src/main/java/config/SSpecialConfig.java b/tablemanager/src/main/java/config/SSpecialConfig.java index 1cac98eb8..fc594438b 100644 --- a/tablemanager/src/main/java/config/SSpecialConfig.java +++ b/tablemanager/src/main/java/config/SSpecialConfig.java @@ -77,6 +77,10 @@ public class SSpecialConfig implements BaseConfig { public static final String SKY_TREASURE_SCORE_INGIFT = "sky_treasure_score_ingift";//天宫密保购买默认获得积分 + public static final String DISCOUNT_MONSTER_LEVEL = "discount_monster_level";// 心魔试炼折扣礼包触发条件 + + public static final String DISCOUNT_MAIN = "discount_main";//关卡礼包 + @Override public void init() throws Exception {