Merge branch 'master_prb_gn' into master_test_gn

back_recharge
jiahuiwen 2022-02-20 10:05:13 +08:00
commit 51b0872905
6 changed files with 108 additions and 10 deletions

View File

@ -10,12 +10,14 @@ import java.util.regex.Pattern;
public class DataMessageUtils {
private static Gson gson = new Gson();
public static Gson gson = new Gson();
private static final String sendToTapDBURL = "https://e.tapdb.net/event";
private static final String sendOnlineURL = "https://se.tapdb.net/tapdb/online";
public static final String restURL = "https://log.trackingio.com/receive/tkio/payment";
public static String sendRechargePost(Object info){
String str = gson.toJson(info);

View File

@ -16,6 +16,12 @@ public class ReportBaseBean {
private int country_code;
private String idfa_sOr_imei_s;
private String network_s;
private String _androidid;
public String getAccount_id() {
return account_id;
}
@ -56,12 +62,35 @@ public class ReportBaseBean {
this.country_code = country_code;
}
public ReportBaseBean(String account_id, String distinct_id, String device_id, String ip, int country_code) {
public String getIdfa_sOr_imei_s() {
return idfa_sOr_imei_s;
}
public void setIdfa_sOr_imei_s(String idfa_sOr_imei_s) {
this.idfa_sOr_imei_s = idfa_sOr_imei_s;
}
public String getNetwork_s() {
return network_s;
}
public void setNetwork_s(String network_s) {
this.network_s = network_s;
}
public String get_androidid() {
return _androidid;
}
public ReportBaseBean(String account_id, String distinct_id, String device_id, String ip, int country_code, String idfa_sOr_imei_s, String network_s, String operator_s) {
this.account_id = account_id.isEmpty()?"DEFAULT-ACCOUNT":account_id;
this.distinct_id = distinct_id.isEmpty()?"DEFAULT-DISTINCT":distinct_id;
this.device_id = device_id.isEmpty()?"DEFAULT-DEVICE_ID":device_id;
this.ip = ip.isEmpty()?"DEFAULT-IP":ip;
this.country_code = country_code;
this.idfa_sOr_imei_s = idfa_sOr_imei_s.isEmpty() ? "DEFAULT_deviceid" : idfa_sOr_imei_s;
this.network_s = network_s.isEmpty() ? "DEFAULT_mac" : network_s;
this._androidid = operator_s.isEmpty() ? "DEFAULT_androidid" : operator_s;
}
public ReportBaseBean() {

View File

@ -32,7 +32,7 @@ public class ReportUtil {
private static final String LOG_PATH = "../reportLog_"+GameApplication.serverId;
private static Map<Integer,ReportBaseBean> baseBeanMap = new ConcurrentHashMap<>();
public static Map<Integer,ReportBaseBean> baseBeanMap = new ConcurrentHashMap<>();
private static ThinkingDataAnalytics ta = new ThinkingDataAnalytics(new ThinkingDataAnalytics.LoggerConsumer(LOG_PATH));
@ -153,7 +153,8 @@ public class ReportUtil {
}
public static void saveBaseInfo(int uid,PlayerInfoProto.LoginRequest loginRequest){
ReportBaseBean reportBaseBean = new ReportBaseBean(String.valueOf(uid),loginRequest.getDistinctId(),loginRequest.getDeviceIdS(),loginRequest.getIpS(),0);
ReportBaseBean reportBaseBean = new ReportBaseBean(String.valueOf(uid),loginRequest.getDistinctId(), loginRequest.getDeviceIdS(),loginRequest.getIpS(),
0, loginRequest.getIdfaSOrImeiS(), loginRequest.getNetworkS(), loginRequest.getOperatorS());
LOGGER.info("保存{}用户信息:{}",uid,reportBaseBean.toString());
baseBeanMap.put(uid,reportBaseBean);
}

View File

@ -70,6 +70,7 @@ public class UserManager {
if (now - addTime >= LIVE_TIME) {
userMap.remove(integerUserEntry.getId());
userMapPutTime.remove(integerUserEntry.getId());
// ReportUtil.baseBeanMap.remove(integerUserEntry.getId());
}
}
LOGGER.info("checkOffline left count={}", userMap.keySet().size());

View File

@ -1,5 +1,7 @@
package com.ljsd.jieling.logic.store;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ljsd.GameApplication;
import com.ljsd.jieling.config.reportData.DataMessageUtils;
import com.ljsd.jieling.core.VipPrivilegeType;
@ -11,6 +13,7 @@ import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.ktbeans.ReportBaseBean;
import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.GlobalDataManaager;
@ -40,6 +43,7 @@ import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.thrift.idl.Result;
import com.ljsd.jieling.util.*;
import com.ljsd.jieling.util.http.HttpPool;
import config.*;
import manager.STableManager;
import org.slf4j.Logger;
@ -152,7 +156,7 @@ public class BuyGoodsNewLogic {
public static Result sendGoods(int uid, String sdkGoodsId, String openId, String orderId, long orderTime, int amount) throws Exception {
Result resultRes = new Result();
ISession session = OnlineUserManager.getSessionByUid(uid);
LOGGER.info("send to uid={},the goods={},openID={},orderId={},orderTime={},amount={}",uid,sdkGoodsId,openId,orderId,orderTime,amount);
LOGGER.info("sendGoods to uid={},the goods={},openID={},orderId={},orderTime={},amount={}",uid,sdkGoodsId,openId,orderId,orderTime,amount);
int goodsId = 0;
SRechargeCommodityNewConfig config ;
if(isNumeric(sdkGoodsId)){
@ -165,7 +169,7 @@ public class BuyGoodsNewLogic {
if(null == config){
resultRes.setResultCode(0);
resultRes.setResultMsg("good config null");
LOGGER.error("the uid={},the goodId={},good config null",uid,goodsId);
LOGGER.error("sendGoods the uid={},the goodId={},good config null",uid,goodsId);
return resultRes;
}
goodsId = config.getId();
@ -175,7 +179,7 @@ public class BuyGoodsNewLogic {
if(amount!=-999&&!MathUtils.doubleEquals(amount,price * 100)&&!"support-order".equals(orderId)){
resultRes.setResultCode(0);
resultRes.setResultMsg("charge count error");
LOGGER.error("charge count error, uid={},the goodId={}, currentPrice={},realPrice={}",uid,goodsId, amount,price);
LOGGER.error("sendGoods charge count error, uid={},the goodId={}, currentPrice={},realPrice={}",uid,goodsId, amount,price);
return resultRes;
}
@ -184,7 +188,8 @@ public class BuyGoodsNewLogic {
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(goodsId);
if(bag == null || !bag.buy()){
LOGGER.error("购买失败bag是否为空:{}",bag == null);
LOGGER.error("sendGoods uid={} 购买失败bag是否为空:{}", uid, bag == null);
resultRes.setResultCode(1);
return resultRes;
}
Poster.getPoster().dispatchEvent(new RechargeRewardEvent(user.getId(),(int)price));
@ -259,6 +264,32 @@ public class BuyGoodsNewLogic {
user.getPlayerInfoManager().getLastDeviceId()==null?
"DEFAULT_DEVICE":user.getPlayerInfoManager().getLastDeviceId());
onChargeSuccess(user,price,0,orderId,cfgType);//充值成功上报
// 如果是开天增加REST付费上报
if ("bgsdh87l31909mvu".equals(GameApplication.serverProperties.getAppId())) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("appid", "e7ba14d6442b0ec225289bc846826092");
jsonObject.put("who", user.getPlayerInfoManager().getOpenId());
ReportBaseBean reportBaseBean = ReportUtil.baseBeanMap.get(uid);
String deviceid = (reportBaseBean != null && reportBaseBean.getIdfa_sOr_imei_s() != null && !reportBaseBean.getIdfa_sOr_imei_s().isEmpty()) ?
reportBaseBean.getIdfa_sOr_imei_s() : "DEFAULT_deviceid";
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("_deviceid", deviceid);
jsonObject2.put("_transactionid", orderId);
jsonObject2.put("_paymenttype", "alipay");
jsonObject2.put("_currencytype", "CNY");
jsonObject2.put("_currencyamount", Double.toString(price));
jsonObject2.put("_ip", reportBaseBean != null ? reportBaseBean.getIp() : "");
jsonObject2.put("_tz", "+8");
jsonObject2.put("_ryos", "Android");
jsonObject2.put("_imei", deviceid);
jsonObject2.put("_androidid", reportBaseBean != null ? reportBaseBean.get_androidid() : "DEFAULT_androidid");
jsonObject2.put("_oaid", deviceid);
jsonObject2.put("_mac", reportBaseBean != null ? reportBaseBean.getNetwork_s() : "");
jsonObject.put("context", jsonObject2);
String result = HttpPool.sendPost2(DataMessageUtils.restURL, DataMessageUtils.gson.toJson(jsonObject));
LOGGER.info("onChargeSuccess uid={} REST付费上报={} 参数={}", user.getId(), result, jsonObject);
}
}
return resultRes;
@ -318,8 +349,8 @@ public class BuyGoodsNewLogic {
rechargeEvent.setIdentify(String.valueOf(user.getPlayerInfoManager().getOpenId()));
rechargeEvent.setProperties(new RechargeEventProp(orderId,amount*100,virtualAmount,currency_type,"",""));
String s = DataMessageUtils.sendRechargePost(rechargeEvent);
if(s!=null&&s.equals("1")){
LOGGER.info("{}充值上报成功,价格为{}",user.getPlayerInfoManager().getOpenId(),amount);
if (s != null && s.equals("1")) {
LOGGER.info("{}充值上报成功,价格为{}", user.getPlayerInfoManager().getOpenId(), amount);
}
}

View File

@ -3,7 +3,9 @@ package com.ljsd.jieling.util.http;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
@ -87,4 +89,36 @@ public class HttpPool {
return null;
}
public static String sendPost2(String url, String data) {
String response = null;
try {
CloseableHttpClient httpclient = null;
CloseableHttpResponse httpresponse = null;
try {
httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);
StringEntity stringentity = new StringEntity(data,
ContentType.create("application/json", "UTF-8"));
httppost.setEntity(stringentity);
httpresponse = httpclient.execute(httppost);
response = EntityUtils
.toString(httpresponse.getEntity());
} finally {
if (httpclient != null) {
httpclient.close();
}
if (httpresponse != null) {
httpresponse.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
}