From 7225ca8ab41f503dd468498e6d1820eb2c8230c7 Mon Sep 17 00:00:00 2001 From: zhangshanxue Date: Wed, 17 Jun 2020 09:40:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?TASK=20=E3=80=90ID1006352=E3=80=91=E3=80=90?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E9=9C=80=E6=B1=82=E3=80=91=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E7=A4=BC=E5=8C=85=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ljsd/fight/CheckFight.java | 2 - .../eventhandler/LeveGiftEventHander.java | 86 ++++++++++++++++++ .../ljsd/jieling/logic/dao/RechargeInfo.java | 21 ++++- .../ljsd/jieling/logic/hero/HeroLogic.java | 2 + .../jieling/logic/store/BuyGoodsLogic.java | 91 +++++++++++++------ .../java/config/SRechargeCommodityConfig.java | 4 +- .../src/main/java/config/SSpecialConfig.java | 2 +- 7 files changed, 176 insertions(+), 32 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/LeveGiftEventHander.java diff --git a/fightmanager/src/main/java/com/ljsd/fight/CheckFight.java b/fightmanager/src/main/java/com/ljsd/fight/CheckFight.java index 6a72eb61f..22031225a 100644 --- a/fightmanager/src/main/java/com/ljsd/fight/CheckFight.java +++ b/fightmanager/src/main/java/com/ljsd/fight/CheckFight.java @@ -48,8 +48,6 @@ public class CheckFight { //init(); LOGGER.info("the luahotfix done"); hotFixVersion.set(luaHotFixBean.getVersion()); - //tofix 不是原子操作 - this.localTransCoderObj = new ThreadLocal(); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/LeveGiftEventHander.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/LeveGiftEventHander.java new file mode 100644 index 000000000..dad1d0568 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/LeveGiftEventHander.java @@ -0,0 +1,86 @@ +package com.ljsd.jieling.logic.activity.eventhandler; + +import com.ljsd.jieling.core.SimpleTransaction; +import com.ljsd.jieling.logic.OnlineUserManager; +import com.ljsd.jieling.logic.activity.IEventHandler; +import com.ljsd.jieling.logic.activity.event.HeroFiveStarGetEvent; +import com.ljsd.jieling.logic.activity.event.IEvent; +import com.ljsd.jieling.logic.activity.event.UserLevelEvent; +import com.ljsd.jieling.logic.dao.CumulationData; +import com.ljsd.jieling.logic.dao.RechargeInfo; +import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.store.BuyGoodsLogic; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.CommonProto; +import com.ljsd.jieling.protocols.MessageTypeProto; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import config.SRechargeCommodityConfig; +import config.SSpecialConfig; +import manager.STableManager; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Description: 等级礼包 + * Author: zsx + * CreateDate: 2020/6/15 11:51 + */ +public class LeveGiftEventHander implements IEventHandler { + + @Override + public void onEvent(IEvent event) throws Exception { + + if(event instanceof UserLevelEvent){ + int[] onceArrayValue = SSpecialConfig.getOnceArrayValue(SSpecialConfig.DISCOUNT_LEVEL); + int start = onceArrayValue[0]; + int inter = onceArrayValue[1]; + if(((UserLevelEvent) event).getLevel() entry = SRechargeCommodityConfig.rechargePlayerLevelMap.floorEntry(saveAmt); + SRechargeCommodityConfig orDefault = STableManager.getConfig(SRechargeCommodityConfig.class).getOrDefault(entry.getValue(), null); + if(orDefault==null){ + return; + } + + if(rechargeInfo.getLevelAndMoneyBagMap().containsKey(entry.getKey())){ + long lasttime = rechargeInfo.getLevelAndMoneyBagMap().get(entry.getKey()); + long i = orDefault.getDiscountType()[3] * 3600*1000; + if(System.currentTimeMillis()-lasttime goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size()); + BuyGoodsLogic.getGoodsBagInfo(user.getId(), goodsBagInfo,false); + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + if(session!=null){ + if(null!= SimpleTransaction.current()){ + //获得多个英雄进行协议合并 + PlayerInfoProto.AllGiftGoodsIndication.Builder build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo); + SimpleTransaction.current().dealWhileCommit(new SimpleTransaction.SendTask(build.build(), MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE)); + } + } + } + + + + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java index ae68af292..2d838b62c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java @@ -20,7 +20,8 @@ public class RechargeInfo extends MongoBase{ @Transient private volatile Set cacheSendedIds = new ConcurrentSet<>(); - private Map levelBagMap = new HashMap<>(); + private Map levelBagMap = new HashMap<>();//等级开启 + private Map levelAndMoneyBagMap = new HashMap<>();//等级礼包开启 private Map refreshBagMap = new HashMap<>(); @@ -259,4 +260,22 @@ public class RechargeInfo extends MongoBase{ this.smonthSaveAmt = smonthSaveAmt; updateString("smonthSaveAmt",smonthSaveAmt); } + + public Map getLevelAndMoneyBagMap() { + return levelAndMoneyBagMap; + } + + public void putLevelAndMoneyBagMap(Integer type,Long value) { + this.levelAndMoneyBagMap.put(type,value ); + cacheSendedIds.remove(type); + updateString("levelAndMoneyBagMap",levelAndMoneyBagMap); + } + + public void removeLevelAndMoneyBagMap(Integer type) { + this.levelAndMoneyBagMap.remove(type); + cacheSendedIds.remove(type); + updateString("levelAndMoneyBagMap",levelAndMoneyBagMap); + } + + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 7521afaea..62a2eeba2 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -16,6 +16,7 @@ import com.ljsd.jieling.globals.Global; import com.ljsd.jieling.logic.activity.event.*; import com.ljsd.jieling.logic.activity.eventhandler.HeroFiveStarGetEventHandler; +import com.ljsd.jieling.logic.activity.eventhandler.LeveGiftEventHander; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.expedition.ExpeditionLogic; @@ -52,6 +53,7 @@ public class HeroLogic{ private HeroLogic(){ //英雄事件监听 Poster.getPoster().listenEvent(new HeroFiveStarGetEventHandler(), HeroFiveStarGetEvent.class); + Poster.getPoster().listenEvent(new LeveGiftEventHander(), UserLevelEvent.class); } 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 f23f64bad..1a2b41178 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 @@ -99,6 +99,22 @@ public class BuyGoodsLogic { resultRes.setResultMsg("over limit"); return resultRes; } + }else { + if(sRechargeCommodityConfig.getTime()==4&&(sRechargeCommodityConfig.getDiscountType().length==3||sRechargeCommodityConfig.getDiscountType().length==4)){ + int[] discountType = sRechargeCommodityConfig.getDiscountType(); + int temptype = discountType[0]; + if(temptype == 4||temptype==3){ + int dytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(goodsId,0)-1; + if(dytime <0){ + LOGGER.error("the uid={},the goodId={}, is over limit",uid,goodsId); + resultRes.setResultCode(0); + resultRes.setResultMsg("over limit"); + return resultRes; + } + + } + } + } int nowTime =(int) (TimeUtils.now()/1000); @@ -243,39 +259,45 @@ public class BuyGoodsLogic { } rechargeInfo.updateBuyGoodsTimes(goodsId,buyCount); + + ISession session = OnlineUserManager.getSessionByUid(uid); + //特殊礼包次数 + if(sRechargeCommodityConfig.getTime()==4&&(sRechargeCommodityConfig.getDiscountType().length==3||sRechargeCommodityConfig.getDiscountType().length==4)){ + int[] discountType = sRechargeCommodityConfig.getDiscountType(); + int temptype = discountType[0]; + int tempvalue = discountType[1]; + if(temptype == 4||temptype==3){ + + int dytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(goodsId,0)-1; + if(dytime <=0){ + if (rechargeInfo.getTypeBagMap().containsKey(tempvalue)){ + rechargeInfo.removeTypeBagMap(tempvalue); + } + if (rechargeInfo.getLevelAndMoneyBagMap().containsKey(tempvalue)){ + rechargeInfo.removeLevelAndMoneyBagMap(tempvalue); + } + if (rechargeInfo.getCacheSendedTypes().containsKey(tempvalue)){ + rechargeInfo.getCacheSendedTypes().remove(tempvalue); + } + rechargeInfo.putDyGoodsCanBuyTimes(goodsId,dytime); + }else { + rechargeInfo.putDyGoodsCanBuyTimes(goodsId,dytime); + } +// List goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size()); +// BuyGoodsLogic.getGoodsBagInfo(uid, goodsBagInfo,false); +// PlayerInfoProto.AllGiftGoodsIndication build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build(); +// MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true); + } + } + //直购礼包 if(type == GiftGoodsType.DIRECTBAG){ CommonProto.Drop.Builder drop = ItemUtil.drop(user, sRechargeCommodityConfig.getBaseReward(), BIReason.DIRECT_BUY); - ISession session = OnlineUserManager.getSessionByUid(uid); + if(session!=null){ PlayerInfoProto.DirectBuyIndication build = PlayerInfoProto.DirectBuyIndication.newBuilder().setDrop(drop).build(); MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.DIRECT_BUY_GOODS_INDICATION_VALUE,build,true); } - if(sRechargeCommodityConfig.getTime()==4&&sRechargeCommodityConfig.getDiscountType().length==3){ - int[] discountType = sRechargeCommodityConfig.getDiscountType(); - int temptype = discountType[0]; - int tempvalue = discountType[1]; - if(temptype == 4){ - - int dytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(goodsId,0)-1; - if(dytime <=0){ - if (rechargeInfo.getTypeBagMap().containsKey(tempvalue)){ - rechargeInfo.removeTypeBagMap(tempvalue); - } - if (rechargeInfo.getCacheSendedTypes().containsKey(tempvalue)){ - rechargeInfo.getCacheSendedTypes().remove(tempvalue); - } - }else { - rechargeInfo.putDyGoodsCanBuyTimes(goodsId,dytime); - } - - List goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size()); - BuyGoodsLogic.getGoodsBagInfo(uid, goodsBagInfo,false); - PlayerInfoProto.AllGiftGoodsIndication build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build(); - MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true); - } - } - }else{ String title = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_title"); @@ -390,6 +412,7 @@ public class BuyGoodsLogic { long now = TimeUtils.now(); Map buyGoodsTimes = rechargeInfo.getBuyGoodsTimes(); Map levelBagMap = rechargeInfo.getLevelBagMap(); + Map levelAndMoneyBagMap = rechargeInfo.getLevelAndMoneyBagMap(); Map typeBagMap = rechargeInfo.getTypeBagMap(); Map refreshBagMap = rechargeInfo.getRefreshBagMap(); Map goodsOrder = new HashMap<>(6); @@ -424,6 +447,7 @@ public class BuyGoodsLogic { if(time == 4){ int type = discountType[0]; int value = discountType[1]; + //等级商店 if(type == 2){ if(!levelBagMap.containsKey(value)){ continue; @@ -435,9 +459,24 @@ public class BuyGoodsLogic { } endTime = startTime + value*3600*1000; } + //等级礼包 if(type==3){ + if(!levelAndMoneyBagMap.containsKey(value)){ + continue; + } + startTime = levelAndMoneyBagMap.get(value); + long i = discountType[3] * 3600*1000; + if(now-startTime>=i){ + //超过2小时重置动态购买次数 + rechargeInfo.removeDyGoodsCanBuyTimes(goodsId); + continue; + } + endTime = startTime + discountType[3]*3600*1000; } + + + //成长礼 if(type == 4){ //4#妖灵师星级#持续时间 if(!typeBagMap.containsKey(value)){ diff --git a/tablemanager/src/main/java/config/SRechargeCommodityConfig.java b/tablemanager/src/main/java/config/SRechargeCommodityConfig.java index 82c9aa0ae..89d396e7d 100644 --- a/tablemanager/src/main/java/config/SRechargeCommodityConfig.java +++ b/tablemanager/src/main/java/config/SRechargeCommodityConfig.java @@ -79,8 +79,8 @@ public class SRechargeCommodityConfig implements BaseConfig { int level = discountType[1]; rechargeLevelMapTmp.put(level,sRechargeCommodityConfig); } - if(discountType!=null && discountType.length>0 &&sRechargeCommodityConfig.getTime()==4&&sRechargeCommodityConfig.getDiscountType().length==3) { - if (discountType[0] == 4) { + if(discountType!=null && discountType.length>0 &&sRechargeCommodityConfig.getTime()==4) { + if (discountType[0] == 4&&sRechargeCommodityConfig.getDiscountType().length==3) { recharegeHeroTimeTmp.put(discountType[1], sRechargeCommodityConfig.getId()); } else if (discountType[0] == 3) { rechargePlayerLevelTemp.put(discountType[1], sRechargeCommodityConfig.getId()); diff --git a/tablemanager/src/main/java/config/SSpecialConfig.java b/tablemanager/src/main/java/config/SSpecialConfig.java index 7bacceb56..7d794dd61 100644 --- a/tablemanager/src/main/java/config/SSpecialConfig.java +++ b/tablemanager/src/main/java/config/SSpecialConfig.java @@ -64,7 +64,7 @@ public class SSpecialConfig implements BaseConfig { public static final String LOTTERY_ENERGY_COST = "lottery_energy_cost";//钻石抽积攒仙缘能量(原非酋气息)抽奖消耗 public static final String EXPEDITION_REBORN = "expedition_reborn";// 大闹天宫复活道具id public static final String REWARD_OF_WORSHIP = "reward_of_worship";//膜拜获得金币奖励 - + public static final String DISCOUNT_LEVEL= "discount_level";//限时折扣推送等级#推送间隔等级 @Override public void init() throws Exception { From c9f8fe80995e0821552fbaacee4bcd686c4f7943 Mon Sep 17 00:00:00 2001 From: zhangshanxue Date: Wed, 17 Jun 2020 14:45:45 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=88=98=E6=96=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luafight/BattleMain.lua | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/luafight/BattleMain.lua b/luafight/BattleMain.lua index 72cb4955f..80dfecc72 100644 --- a/luafight/BattleMain.lua +++ b/luafight/BattleMain.lua @@ -1,6 +1,7 @@ +-- windows package.path = package.path ..';luafight/?.lua'; -- linux --- package.path = package.path ..';../luafight/?.lua'; +package.path = package.path ..';../luafight/?.lua'; require("Modules.Battle.Logic.Misc.BattleDefine") require("Modules.Battle.Logic.Misc.BattleUtil") @@ -20,6 +21,12 @@ require("Modules.Battle.Logic.Base.Passivity") require("Modules.Battle.Logic.BattleLogic") require("Modules.Battle.Logic.RoleLogic") +require("Modules.Battle.Logic.SkillManager") +require("Modules.Battle.Logic.RoleManager") +require("Modules.Battle.Logic.OutDataManager") +require("Modules.Battle.Logic.BattleLogManager") + + local BattleMain = {} local BattleLogic = BattleLogic local Random = Random @@ -291,7 +298,25 @@ function BattleMain.Execute(args, fightData, optionData) os.date("%H"), os.date("%M"), os.date("%S")) - local file = io.open("luafight/LogError/"..time..".txt", "a") + local file + local platform + -- linux + if not file then + file = io.open("../luafight/LogError/"..time..".txt", "a") + platform = "Linux" + end + -- local window server + if not file then + file = io.open("luafight/LogError/"..time..".txt", "a") + platform = "Local Windows Server" + end + -- local + if not file then + file = io.open("LogError/"..time..".txt", "a") + platform = "Local" + end + + file:write(platform..":\n\n\n") file:write(errorCache) file:write("seed:\n"..tostring(args.seed).."\n") file:write("type:\n"..tostring(args.type).."\n") From cad5b5bc2603ad08c9ac15db3029b64849d9c3cc Mon Sep 17 00:00:00 2001 From: zhangshanxue Date: Wed, 17 Jun 2020 14:48:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?TASK=E3=80=90ID1006397=E3=80=91=E3=80=90?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E4=BC=98=E5=8C=96=E3=80=91=E6=88=90=E9=95=BF?= =?UTF-8?q?=E7=A4=BC=E9=87=91=E6=B4=BB=E5=8A=A8=E9=82=AE=E4=BB=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 1a2b41178..3fe6f58c0 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 @@ -90,6 +90,8 @@ public class BuyGoodsLogic { } int price =sRechargeCommodityConfig.getPrice(); buyCount=buyCount+1; + + //time check int limit = sRechargeCommodityConfig.getLimit(); int type = sRechargeCommodityConfig.getType(); if(limit!=0){ @@ -311,7 +313,10 @@ public class BuyGoodsLogic { title = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_title",new Object[]{sRechargeCommodityConfig.getName()}); content = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_txt",new Object[]{sRechargeCommodityConfig.getName()}); } - MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr,nowTime, Global.MAIL_EFFECTIVE_TIME); + if(!rewardStr.isEmpty()){ + MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr,nowTime, Global.MAIL_EFFECTIVE_TIME); + } + } if(sRechargeCommodityConfig.getTime() ==5){ rechargeInfo.updateRefreshMapByKey(sRechargeCommodityConfig.getId(),TimeUtils.now()+sRechargeCommodityConfig.getDailyUpdate()*TimeUtils.DAY);