fix charge

back_recharge
wangyuan 2019-09-19 18:57:47 +08:00
parent aad18c8bd6
commit 1615f53a15
3 changed files with 53 additions and 27 deletions

View File

@ -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<Integer, RechargeInfo> 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<Integer, Integer> buyGoodsTimes = rechargeInfo.getBuyGoodsTimes();
Integer buyCount = buyGoodsTimes.get(goodID);
if(buyCount == null){
@ -92,6 +95,7 @@ public class GmService implements RPCRequestGMIFace.Iface {
}
List<Integer> 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 {

View File

@ -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<Integer,Integer> hotGoods = new HashMap<>();
hotGoods = gson.fromJson(args[3],hotGoods.getClass());
Map<Integer,RechargeInfo> rechargeInfoMap = new HashMap<>();
Type type = new TypeToken<Map<Integer,RechargeInfo>>(){}.getType();
Map<Integer,Integer> realBuyGoodsTimes = new HashMap<>();
realBuyGoodsTimes = gson.fromJson(args[3],realBuyGoodsTimes.getClass());
Map<Integer,Integer> 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<Integer,Integer> oldBuyGoodsTimes = user.getPlayerInfoManager().getRechargeInfo().getBuyGoodsTimes();
for (Map.Entry<Integer,Integer> 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);

View File

@ -298,6 +298,10 @@ public class BuyGoodsLogic {
}
if(limit!=0){
if(buyTimes>=limit){
boolean isNew = rechargeInfo.addNewSendId(goodsId);
if(!isNew){
needChange = true;
}
continue;
}
}