开天增加充值上报
parent
4af6f92c99
commit
5ec60747ef
|
|
@ -16,6 +16,8 @@ public class DataMessageUtils {
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ public class ReportBaseBean {
|
|||
|
||||
private int country_code;
|
||||
|
||||
private String idfa_sOr_imei_s;
|
||||
|
||||
private String network_s;
|
||||
|
||||
public String getAccount_id() {
|
||||
return account_id;
|
||||
}
|
||||
|
|
@ -56,12 +60,30 @@ 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 ReportBaseBean(String account_id, String distinct_id, String device_id, String ip, int country_code, String idfa_sOr_imei_s, String network_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;
|
||||
this.network_s = network_s;
|
||||
}
|
||||
|
||||
public ReportBaseBean() {
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
LOGGER.info("保存{}用户信息:{}",uid,reportBaseBean.toString());
|
||||
baseBeanMap.put(uid,reportBaseBean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.store;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.config.reportData.DataMessageUtils;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
|
|
@ -11,6 +12,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 +42,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;
|
||||
|
|
@ -259,6 +262,31 @@ 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", openId);
|
||||
ReportBaseBean reportBaseBean = ReportUtil.baseBeanMap.get(uid);
|
||||
JSONObject jsonObject2 = new JSONObject();
|
||||
jsonObject2.put("_deviceid", reportBaseBean != null ? reportBaseBean.getIdfa_sOr_imei_s() : "");
|
||||
jsonObject2.put("_transactionid", orderId);
|
||||
jsonObject2.put("_paymenttype", "alipay");
|
||||
jsonObject2.put("_currencytype", "CNY");
|
||||
jsonObject2.put("_currencyamount", amount);
|
||||
jsonObject2.put("_ip", session.getChannel().getRemoteAddress());
|
||||
jsonObject2.put("_tz", "+8");
|
||||
jsonObject2.put("_ryos", "Android");
|
||||
jsonObject2.put("_imei", reportBaseBean != null ? reportBaseBean.getDevice_id() : "");
|
||||
jsonObject2.put("_androidid", reportBaseBean != null ? reportBaseBean.getIdfa_sOr_imei_s() : "");
|
||||
jsonObject2.put("_oaid", "");
|
||||
jsonObject2.put("_mac", reportBaseBean != null ? reportBaseBean.getNetwork_s() : "");
|
||||
|
||||
jsonObject.put("context", jsonObject2);
|
||||
String result = HttpPool.doPost(DataMessageUtils.restURL, jsonObject);
|
||||
LOGGER.info("onChargeSuccess uid={} REST付费上报={} money={}", user.getId(), result, amount);
|
||||
}
|
||||
}
|
||||
|
||||
return resultRes;
|
||||
|
|
@ -318,8 +346,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,29 @@
|
|||
package com.ljsd.jieling.util.http;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpPool {
|
||||
private static PoolingHttpClientConnectionManager poolConnection = new PoolingHttpClientConnectionManager();
|
||||
|
|
@ -87,4 +98,75 @@ public class HttpPool {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组装Post请求路径
|
||||
* @param url
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public static String doPost(String url, JSONObject jsonObject) {
|
||||
CloseableHttpClient httpClient = null;
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
String result = "";
|
||||
// 创建httpClient实例
|
||||
httpClient = HttpClients.createDefault();
|
||||
// 创建httpPost远程连接实例
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
// 配置请求参数实例
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(35000)// 设置连接主机服务超时时间
|
||||
.setConnectionRequestTimeout(35000)// 设置连接请求超时时间
|
||||
.setSocketTimeout(60000)// 设置读取数据连接超时时间
|
||||
.build();
|
||||
// 为httpPost实例设置配置
|
||||
httpPost.setConfig(requestConfig);
|
||||
// 设置请求头
|
||||
httpPost.addHeader("Content-Type", "application/json");
|
||||
// 封装post请求参数
|
||||
if (jsonObject.size() > 0){
|
||||
List<NameValuePair> nvps = new ArrayList<>();
|
||||
Iterator<Map.Entry<String, Object>> iterator = jsonObject.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Object> mapEntry = iterator.next();
|
||||
nvps.add(new BasicNameValuePair(mapEntry.getKey(), mapEntry.getValue().toString()));
|
||||
}
|
||||
// 为httpPost设置封装好的请求参数
|
||||
try {
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
// httpClient对象执行post请求,并返回响应参数对象
|
||||
httpResponse = httpClient.execute(httpPost);
|
||||
// 从响应对象中获取响应内容
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
result = EntityUtils.toString(entity);
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
if (null != httpResponse) {
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != httpClient) {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue