From 1615f53a1584fd1b3522629ea384a275dfd645a0 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Thu, 19 Sep 2019 18:57:47 +0800 Subject: [PATCH] fix charge --- .../src/main/java/com/ljsd/GmService.java | 55 ++++++++++++------- .../com/ljsd/jieling/kefu/Cmd_changename.java | 21 +++++-- .../jieling/logic/store/BuyGoodsLogic.java | 4 ++ 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/GmService.java b/serverlogic/src/main/java/com/ljsd/GmService.java index 6832cfdc2..72df185d6 100644 --- a/serverlogic/src/main/java/com/ljsd/GmService.java +++ b/serverlogic/src/main/java/com/ljsd/GmService.java @@ -1,6 +1,7 @@ package com.ljsd; +import com.google.gson.Gson; import com.ljsd.jieling.core.HandlerLogicThread; import com.ljsd.jieling.db.mongo.MongoUtil; import com.ljsd.jieling.db.redis.RedisKey; @@ -60,27 +61,29 @@ public class GmService implements RPCRequestGMIFace.Iface { if (obj instanceof GmRoleAbstract) { //todo - File file = new File("../conf/BuyGoodsLogic.log"); - BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); Map rechargeInfoMap = new HashMap<>(); - String readLine = null; - while ( (readLine= bufferedReader.readLine())!=null){ - if(readLine.contains("class")){ - continue; - } - String[] split = readLine.split(","); - String uidStr = split[0].split("=")[1]; - int uid = Integer.parseInt(uidStr); - RechargeInfo rechargeInfo = rechargeInfoMap.get(uid); - if( rechargeInfo == null){ - rechargeInfo = new RechargeInfo(); - rechargeInfoMap.put(uid,rechargeInfo); - } - String goodStr = split[1].split("=")[1]; - int goodID = Integer.parseInt(goodStr); - if(goodID == 8 || goodID == 7){ - rechargeInfo.setHadBuyFound(1); - }else{ + if(cmd.contains("recharge")){ + File file = new File("conf/BuyGoodsLogic.log"); + BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); + + String readLine = null; + while ( (readLine= bufferedReader.readLine())!=null){ + if(readLine.contains("class")){ + continue; + } + String[] split = readLine.split(","); + String uidStr = split[0].split("=")[1]; + int uid = Integer.parseInt(uidStr); + RechargeInfo rechargeInfo = rechargeInfoMap.get(uid); + if( rechargeInfo == null){ + rechargeInfo = new RechargeInfo(); + rechargeInfoMap.put(uid,rechargeInfo); + } + String goodStr = split[1].split("=")[1]; + int goodID = Integer.parseInt(goodStr); + if(goodID == 8 || goodID == 7){ + rechargeInfo.setHadBuyFound(1); + } Map buyGoodsTimes = rechargeInfo.getBuyGoodsTimes(); Integer buyCount = buyGoodsTimes.get(goodID); if(buyCount == null){ @@ -92,6 +95,7 @@ public class GmService implements RPCRequestGMIFace.Iface { } + List sendIds = new LinkedList<>(); if (obj instanceof GmGlobleAbstract) { for (ISession session : OnlineUserManager.sessionMap.values()) { @@ -107,7 +111,9 @@ public class GmService implements RPCRequestGMIFace.Iface { } sendIds.add(user1.getId()); } - }else{ + }else if(cmd.contains("recharge")){ + sendIds.addAll(rechargeInfoMap.keySet()); + } else{ String[] ids = parameters[0].split("#"); for (String id : ids) { sendIds.add(Integer.valueOf(id)); @@ -116,7 +122,14 @@ public class GmService implements RPCRequestGMIFace.Iface { } int randomTime = sendIds.size() * 1; //两分钟内发完所有协议 + Gson gson = new Gson(); String[] parameters2 = java.util.Arrays.copyOfRange(parameters, 1, parameters.length); + if(cmd.contains("recharge") ){ + if(!rechargeInfoMap.isEmpty()){ + parameters2[3] = gson.toJson(rechargeInfoMap); + } + } + InnerMessageUtil.broadcastWithRandom(new AyyncWorker() { @Override public void work(User user) throws Exception { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_changename.java b/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_changename.java index 27942d7a3..99a68010d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_changename.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_changename.java @@ -1,6 +1,7 @@ package com.ljsd.jieling.kefu; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.ljsd.jieling.config.SErrorCodeEerverConfig; import com.ljsd.jieling.config.SGameSetting; import com.ljsd.jieling.config.SRechargeCommodityConfig; @@ -27,6 +28,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.PlayerInfoProto; import com.ljsd.jieling.util.*; +import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; @@ -73,17 +75,23 @@ public class Cmd_changename extends GmRoleAbstract { if("recharge".equals(args[2])){ Gson gson = new Gson(); - Map hotGoods = new HashMap<>(); - hotGoods = gson.fromJson(args[3],hotGoods.getClass()); + Map rechargeInfoMap = new HashMap<>(); + Type type = new TypeToken>(){}.getType(); Map realBuyGoodsTimes = new HashMap<>(); - realBuyGoodsTimes = gson.fromJson(args[3],realBuyGoodsTimes.getClass()); - + Map hotGoods = new HashMap<>(); + rechargeInfoMap= gson.fromJson(args[3],type); + RechargeInfo rechargeInfoFile = rechargeInfoMap.get(user.getId()); + if(rechargeInfoFile == null){ + return false; + } + realBuyGoodsTimes = rechargeInfoFile.getBuyGoodsTimes(); + hotGoods=new HashMap<>(realBuyGoodsTimes); Map oldBuyGoodsTimes = user.getPlayerInfoManager().getRechargeInfo().getBuyGoodsTimes(); for (Map.Entry entry:oldBuyGoodsTimes.entrySet() ) { if(realBuyGoodsTimes.containsKey(entry.getKey())){ - int finalvalue = realBuyGoodsTimes.get(entry.getKey())-entry.getValue() + int finalvalue = realBuyGoodsTimes.get(entry.getKey())-entry.getValue(); if(finalvalue==0){ realBuyGoodsTimes.remove(entry.getKey()); @@ -108,7 +116,7 @@ public class Cmd_changename extends GmRoleAbstract { } boolean mulvip =false; - if((realBuyGoodsTimes.containsKey(9)&&realBuyGoodsTimes.get(9)>1)||(realBuyGoodsTimes.containsKey(10)&&realBuyGoodsTimes.get(10)>1)||(realBuyGoodsTimes.containsKey(11)&&realBuyGoodsTimes.get(11)>1)){ + if((realBuyGoodsTimes.containsKey(9)&&realBuyGoodsTimes.get(9)>=1)||(realBuyGoodsTimes.containsKey(10)&&realBuyGoodsTimes.get(10)>=1)||(realBuyGoodsTimes.containsKey(11)&&realBuyGoodsTimes.get(11)>=1)){ mulvip =true; } @@ -124,6 +132,7 @@ public class Cmd_changename extends GmRoleAbstract { rechargeInfo.setSaveAmt(hotRechargeMoney+saveAmt); ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.RechargeTotal,rechargeInfo.getSaveAmt()); ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.RECHARGE_NUM,hotRechargeMoney); + rechargeInfo.setHadBuyFound(rechargeInfoFile.getHadBuyFound()); user.getPlayerInfoManager().getRechargeInfo().setBuyGoodsTimes(hotGoods); LOGGER.info("cmd_________recharge:hotRechargeMoney"+hotRechargeMoney+"重复月卡:"+mulvip); 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 8a7cadc5c..065d85272 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 @@ -298,6 +298,10 @@ public class BuyGoodsLogic { } if(limit!=0){ if(buyTimes>=limit){ + boolean isNew = rechargeInfo.addNewSendId(goodsId); + if(!isNew){ + needChange = true; + } continue; } }