tapDB数据打点接入
parent
e3ef96e6ea
commit
7c19553f53
|
|
@ -19,8 +19,11 @@ import org.apache.http.message.BasicNameValuePair;
|
|||
import util.StringUtil;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DataMessageUtils {
|
||||
|
||||
|
|
@ -36,6 +39,10 @@ public class DataMessageUtils {
|
|||
private static final String sendRoleUrl37 = "http://pvt.api.m.37.com/report/roleChangeReport/";
|
||||
|
||||
private static final String sendChatContent37 = "http://cm3.api.37.com.cn/Content/_checkContent/";
|
||||
|
||||
private static final String sendToTapDBURL = "https://e.tapdb.net/event";
|
||||
|
||||
private static final String sendOnlineURL = "https://se.tapdb.net/tapdb/online";
|
||||
//入队列
|
||||
public static void addLogQueue(Object info) {
|
||||
if(!GameLogicService.isServiceShutdown()){
|
||||
|
|
@ -108,18 +115,43 @@ public class DataMessageUtils {
|
|||
}
|
||||
|
||||
}
|
||||
public static JSONObject immediateSendPost(Object info){
|
||||
String s = gson.toJson(info);
|
||||
JSONObject jsonObject = null;
|
||||
if(info instanceof Report37CheckChat){
|
||||
Report37CheckChat info1 = (Report37CheckChat) info;
|
||||
List<BasicNameValuePair> pairList = info1.getPairList();
|
||||
try {
|
||||
jsonObject = HttpPool.sendPostForm(sendChatContent37, new UrlEncodedFormEntity(pairList, "utf-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
public static String sendRechargePost(Object info){
|
||||
String str = gson.toJson(info);
|
||||
|
||||
if (str!=null) {
|
||||
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
||||
Matcher m = p.matcher(str);
|
||||
str = m.replaceAll("");
|
||||
}
|
||||
try {
|
||||
return HttpPool.sendPost(sendToTapDBURL,urlEncode(str));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static String sendOnlinePost(Object info){
|
||||
String str = gson.toJson(info);
|
||||
|
||||
|
||||
return HttpPool.sendPost(sendOnlineURL,str);
|
||||
|
||||
}
|
||||
|
||||
private static String urlEncode(String url) throws UnsupportedEncodingException {
|
||||
if(url == null) {
|
||||
return null;
|
||||
}
|
||||
final String reserved_char = ";/?:@=&";
|
||||
String ret = "";
|
||||
for(int i=0; i < url.length(); i++) {
|
||||
String cs = String.valueOf( url.charAt(i) );
|
||||
if(reserved_char.contains(cs)){
|
||||
ret += cs;
|
||||
}else{
|
||||
ret += URLEncoder.encode(cs, "utf-8");
|
||||
}
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
return ret.replace("+", "%20");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,10 +251,10 @@ public class Report37CheckChat implements Report37Param{
|
|||
report37CheckChat.setSign(MD5Util.encrypByMd5(signSt));
|
||||
String s = gson.toJson(report37CheckChat);
|
||||
System.out.println(s);
|
||||
JSONObject jsonObject = DataMessageUtils.immediateSendPost(report37CheckChat);
|
||||
Report37Response report37Response = jsonObject.toJavaObject(Report37Response.class);
|
||||
|
||||
System.out.println(report37Response);
|
||||
// JSONObject jsonObject = DataMessageUtils.immediateSendPost(report37CheckChat);
|
||||
// Report37Response report37Response = jsonObject.toJavaObject(Report37Response.class);
|
||||
//
|
||||
// System.out.println(report37Response);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -55,37 +55,37 @@ public class Repot37EventUtil {
|
|||
break;
|
||||
}
|
||||
}
|
||||
public static <T> T hadResReport(Class<T> clazz,User user, Report37EventType eventType, Object... parm){
|
||||
switch (eventType) {
|
||||
case CHECK_CHAT_CONTENT:
|
||||
Report37CheckChat report37CheckChat = new Report37CheckChat();
|
||||
report37CheckChat.setTime((int)(TimeUtils.now()/1000));
|
||||
report37CheckChat.setChat_time(String.valueOf(TimeUtils.now()/1000));
|
||||
report37CheckChat.setUid(String.valueOf(user.getPlayerInfoManager().getOpenId()));//uid
|
||||
report37CheckChat.setActor_name(user.getPlayerInfoManager().getNickName());
|
||||
report37CheckChat.setActor_id(String.valueOf(user.getId()));
|
||||
report37CheckChat.setGid(SDK37Constans.gid);
|
||||
report37CheckChat.setPid(SDK37Constans.pid);
|
||||
report37CheckChat.setDsid(String.valueOf(GameApplication.serverId));
|
||||
report37CheckChat.setType(parm[0].toString());//类型
|
||||
report37CheckChat.setContent(parm[1].toString());//内容
|
||||
report37CheckChat.setActor_level(String.valueOf(user.getPlayerInfoManager().getLevel()));
|
||||
report37CheckChat.setActor_recharge_gold(String.valueOf(0));//充值数
|
||||
if(parm.length>2){
|
||||
report37CheckChat.setTo_uid(String.valueOf(parm[2]));
|
||||
}
|
||||
if(parm.length>3){
|
||||
report37CheckChat.setTo_actor_name(String.valueOf(parm[3]));
|
||||
}
|
||||
String signChat =SDK37Constans.chatKey+report37CheckChat.getUid()+report37CheckChat.getGid()+report37CheckChat.getDsid()+report37CheckChat.getTime()+report37CheckChat.getType();
|
||||
report37CheckChat.setSign(MD5Util.encrypByMd5(signChat));
|
||||
// System.out.println(gson.toJson(report37CheckChat));
|
||||
JSONObject jsonObject = DataMessageUtils.immediateSendPost(report37CheckChat);
|
||||
T t = jsonObject.toJavaObject(clazz);
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// public static <T> T hadResReport(Class<T> clazz,User user, Report37EventType eventType, Object... parm){
|
||||
// switch (eventType) {
|
||||
// case CHECK_CHAT_CONTENT:
|
||||
// Report37CheckChat report37CheckChat = new Report37CheckChat();
|
||||
// report37CheckChat.setTime((int)(TimeUtils.now()/1000));
|
||||
// report37CheckChat.setChat_time(String.valueOf(TimeUtils.now()/1000));
|
||||
// report37CheckChat.setUid(String.valueOf(user.getPlayerInfoManager().getOpenId()));//uid
|
||||
// report37CheckChat.setActor_name(user.getPlayerInfoManager().getNickName());
|
||||
// report37CheckChat.setActor_id(String.valueOf(user.getId()));
|
||||
// report37CheckChat.setGid(SDK37Constans.gid);
|
||||
// report37CheckChat.setPid(SDK37Constans.pid);
|
||||
// report37CheckChat.setDsid(String.valueOf(GameApplication.serverId));
|
||||
// report37CheckChat.setType(parm[0].toString());//类型
|
||||
// report37CheckChat.setContent(parm[1].toString());//内容
|
||||
// report37CheckChat.setActor_level(String.valueOf(user.getPlayerInfoManager().getLevel()));
|
||||
// report37CheckChat.setActor_recharge_gold(String.valueOf(0));//充值数
|
||||
// if(parm.length>2){
|
||||
// report37CheckChat.setTo_uid(String.valueOf(parm[2]));
|
||||
// }
|
||||
// if(parm.length>3){
|
||||
// report37CheckChat.setTo_actor_name(String.valueOf(parm[3]));
|
||||
// }
|
||||
// String signChat =SDK37Constans.chatKey+report37CheckChat.getUid()+report37CheckChat.getGid()+report37CheckChat.getDsid()+report37CheckChat.getTime()+report37CheckChat.getType();
|
||||
// report37CheckChat.setSign(MD5Util.encrypByMd5(signChat));
|
||||
//// System.out.println(gson.toJson(report37CheckChat));
|
||||
// JSONObject jsonObject = DataMessageUtils.immediateSendPost(report37CheckChat);
|
||||
// T t = jsonObject.toJavaObject(clazz);
|
||||
// return t;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
public static boolean Report37Chat(User user,Object... parm){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.ljsd.jieling.ktbeans;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/7/20
|
||||
* @discribe
|
||||
*/
|
||||
public class OnlineProp {
|
||||
|
||||
private String server;
|
||||
|
||||
private int online;
|
||||
|
||||
private long timeStamp;
|
||||
|
||||
|
||||
public OnlineProp(String server, int online, long timeStamp) {
|
||||
this.server = server;
|
||||
this.online = online;
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public int getOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
public void setOnline(int online) {
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
public long getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(long timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.ljsd.jieling.ktbeans;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/7/20
|
||||
* @discribe
|
||||
*/
|
||||
public class OnlineUserCalEvent {
|
||||
private String appid;
|
||||
|
||||
private OnlineProp[] onlines;
|
||||
|
||||
public OnlineProp[] getOnlines() {
|
||||
return onlines;
|
||||
}
|
||||
|
||||
public void setOnlines(OnlineProp[] onlines) {
|
||||
this.onlines = onlines;
|
||||
}
|
||||
|
||||
public String getAppid() {
|
||||
return appid;
|
||||
}
|
||||
|
||||
public void setAppid(String appid) {
|
||||
this.appid = appid;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.store;
|
||||
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.config.reportData.DataMessageUtils;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
|
|
@ -215,7 +216,7 @@ public class BuyGoodsLogic {
|
|||
// if(rechargeInfo.getIsFirst()==0 && firstInvest == 1){
|
||||
// ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.FirstRecharge,sRechargeCommodityConfig.getPrice());
|
||||
// SActivityRewardConfig sActivityRewardConfig = SActivityRewardConfig.getsActivityRewardConfigByActivityId(4).get(0);
|
||||
// rechargeInfo.setFirst(1);
|
||||
rechargeInfo.setFirst(1);
|
||||
// String title = SErrorCodeEerverConfig.getI18NMessage("recharge_first_title");
|
||||
// String content = SErrorCodeEerverConfig.getI18NMessage("recharge_first_txt");
|
||||
// MailLogic.getInstance().sendMail(user.getId(),title,content,ItemUtil.getMailReward(sActivityRewardConfig.getReward()),nowTime, Global.MAIL_EFFECTIVE_TIME);
|
||||
|
|
@ -356,9 +357,24 @@ public class BuyGoodsLogic {
|
|||
// Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.RECHARGE_BUY.getType(),goodsId));
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
sendGiftGooodsIndication(uid);
|
||||
onChargeSuccess(uid,sRechargeCommodityConfig.getPrice(),0);//充值成功上报
|
||||
return resultRes;
|
||||
|
||||
}
|
||||
private static void onChargeSuccess(int uid,int amount,int virtualAmount){
|
||||
RechargeEvent rechargeEvent = new RechargeEvent();
|
||||
rechargeEvent.setModule("GameAnalysis");
|
||||
rechargeEvent.setIp("");
|
||||
rechargeEvent.setName("charge");
|
||||
rechargeEvent.setIndex("wjtsq7xrwb48t2uw");
|
||||
rechargeEvent.setIdentify(String.valueOf(uid));
|
||||
rechargeEvent.setProperties(new RechargeEventProp("",amount,virtualAmount,"CNY","",""));
|
||||
String s = DataMessageUtils.sendRechargePost(rechargeEvent);
|
||||
if(s.equals("1")){
|
||||
LOGGER.info("{}充值上报成功,价格为{}",uid,amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//通知前端充值成功
|
||||
public static void notifyPaySuccessFul(int uid,int goodsId,boolean needNotify){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package com.ljsd.jieling.logic.store;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/7/20
|
||||
* @discribe
|
||||
*/
|
||||
public class RechargeEvent {
|
||||
private String module;
|
||||
|
||||
private String ip;
|
||||
|
||||
private String name;
|
||||
|
||||
private String index;
|
||||
|
||||
private String identify;
|
||||
|
||||
private RechargeEventProp properties;
|
||||
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(String index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String getIdentify() {
|
||||
return identify;
|
||||
}
|
||||
|
||||
public void setIdentify(String identify) {
|
||||
this.identify = identify;
|
||||
}
|
||||
|
||||
public RechargeEventProp getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(RechargeEventProp properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.ljsd.jieling.logic.store;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/7/20
|
||||
* @discribe
|
||||
*/
|
||||
public class RechargeEventProp {
|
||||
private String order_id;
|
||||
|
||||
private int amount;
|
||||
|
||||
private int virtual_currency_amount;
|
||||
|
||||
private String currency_type;
|
||||
|
||||
private String product;
|
||||
|
||||
private String payment;
|
||||
|
||||
public String getOrder_id() {
|
||||
return order_id;
|
||||
}
|
||||
|
||||
public void setOrder_id(String order_id) {
|
||||
this.order_id = order_id;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public int getVirtual_currency_amount() {
|
||||
return virtual_currency_amount;
|
||||
}
|
||||
|
||||
public void setVirtual_currency_amount(int virtual_currency_amount) {
|
||||
this.virtual_currency_amount = virtual_currency_amount;
|
||||
}
|
||||
|
||||
public String getCurrency_type() {
|
||||
return currency_type;
|
||||
}
|
||||
|
||||
public void setCurrency_type(String currency_type) {
|
||||
this.currency_type = currency_type;
|
||||
}
|
||||
|
||||
public String getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public void setProduct(String product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
public String getPayment() {
|
||||
return payment;
|
||||
}
|
||||
|
||||
public void setPayment(String payment) {
|
||||
this.payment = payment;
|
||||
}
|
||||
|
||||
public RechargeEventProp(String order_id, int amount, int virtual_currency_amount, String currency_type, String product, String payment) {
|
||||
this.order_id = order_id;
|
||||
this.amount = amount;
|
||||
this.virtual_currency_amount = virtual_currency_amount;
|
||||
this.currency_type = currency_type;
|
||||
this.product = product;
|
||||
this.payment = payment;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ public class ThreadManager implements IManager {
|
|||
private static MongoDataHandlerTask mongoDataHandlerTask;
|
||||
private static ItemLogTask itemLogTask;
|
||||
public static int SLEEP_INTEVAL_TIME = 60; //每1分钟检查一次
|
||||
|
||||
private static OnlineUserTapTask onlineUserTapTask;//5分钟上报一次
|
||||
|
||||
private static Set<Future<?>> scheduledFutureSets = new HashSet<>();
|
||||
|
||||
|
|
@ -41,10 +41,13 @@ public class ThreadManager implements IManager {
|
|||
mongoDataHandlerTask = ConfigurableApplicationContextManager.getBean(MongoDataHandlerTask.class);
|
||||
dataReportTask = ConfigurableApplicationContextManager.getBean(DataReportTask.class);
|
||||
itemLogTask = ConfigurableApplicationContextManager.getBean(ItemLogTask.class);
|
||||
onlineUserTapTask = ConfigurableApplicationContextManager.getBean(OnlineUserTapTask.class);
|
||||
|
||||
new RetrySendIndicationThread("retry-indi").start();
|
||||
mongoDataHandlerTask.start();
|
||||
dataReportTask.start();
|
||||
itemLogTask.start();
|
||||
onlineUserTapTask.start();
|
||||
|
||||
scheduledExecutor = new ScheduledThreadPoolExecutor(8, new ScheduleThreadFactory());
|
||||
scheduledExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ljsd.jieling.thread.task;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.config.reportData.DataMessageUtils;
|
||||
import com.ljsd.jieling.ktbeans.OnlineProp;
|
||||
import com.ljsd.jieling.ktbeans.OnlineUserCalEvent;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import util.TimeUtils;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/7/20
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class OnlineUserTapTask extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (true){
|
||||
Thread.sleep(5*60000);//5分钟上报一次
|
||||
int serverId = GameApplication.serverId;
|
||||
Set<Integer> uids = OnlineUserManager.sessionMap.keySet();
|
||||
OnlineUserCalEvent onlineUserCalEvent = new OnlineUserCalEvent();
|
||||
|
||||
onlineUserCalEvent.setAppid("wjtsq7xrwb48t2uw");
|
||||
onlineUserCalEvent.setOnlines(new OnlineProp[]{new OnlineProp(String.valueOf(serverId),uids.size(), TimeUtils.now()/1000)});
|
||||
DataMessageUtils.sendOnlinePost(onlineUserCalEvent);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ public class HttpPool {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject sendPost(String url, String info) {
|
||||
public static String sendPost(String url, String info) {
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
HttpResponse httpResponse;
|
||||
int sendTimes = 0;
|
||||
|
|
@ -99,7 +99,7 @@ public class HttpPool {
|
|||
String result = EntityUtils.toString(responseEntity,"UTF-8");
|
||||
LOGGER.debug("Http Send,第" + (sendTimes + 1) + "次调用成功,返回码为:[" + statusCode + "]");
|
||||
EntityUtils.consume(responseEntity);
|
||||
return JSONObject.parseObject(result);
|
||||
return result;
|
||||
// break;
|
||||
} else {
|
||||
LOGGER.error("Http Send,第" + (sendTimes + 1) + "次调用出错,返回码为:[" + statusCode + "]");
|
||||
|
|
|
|||
Loading…
Reference in New Issue