|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.ctop.track.controller;
|
|
|
|
|
|
+import cn.com.ctop.track.entity.TrackRta;
|
|
|
import cn.com.ctop.track.service.ClickInfoService;
|
|
|
import cn.com.ctop.track.service.ConvertInfoService;
|
|
|
import cn.com.ctop.track.service.TaobaoNoticeService;
|
|
@@ -7,8 +8,13 @@ import cn.com.ctop.track.utils.Check;
|
|
|
import cn.com.ctop.track.utils.HttpUtils;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
@@ -35,6 +41,8 @@ public class TrackController {
|
|
|
static ExecutorService click2ExecutorService = Executors.newFixedThreadPool(15);
|
|
|
static ExecutorService back1ExecutorService = Executors.newFixedThreadPool(15);
|
|
|
static ExecutorService back2ExecutorService = Executors.newFixedThreadPool(15);
|
|
|
+ @Autowired
|
|
|
+ private MongoTemplate mongoTemplate;
|
|
|
|
|
|
// 老链接 屏蔽5
|
|
|
@RequestMapping(value = "/click1")
|
|
@@ -128,6 +136,12 @@ public class TrackController {
|
|
|
String action = "click"; // ⾏为类型 // 点击
|
|
|
String imei = request.getParameter("imei");
|
|
|
String oaidmd5 = request.getParameter("oaidmd5");
|
|
|
+ if (Check.isNull(oaidmd5) && Check.isNull(imei)) {
|
|
|
+ returnJson.put("code", 500);
|
|
|
+ returnJson.put("success", false);
|
|
|
+ return returnJson;
|
|
|
+ }
|
|
|
+
|
|
|
String accountid = request.getParameter("accountid"); //⼴告账户ID
|
|
|
String adid = request.getParameter("adid"); //⼴告计划ID
|
|
|
String campaignid = request.getParameter("campaignid"); // ⼴告组ID
|
|
@@ -139,12 +153,12 @@ public class TrackController {
|
|
|
params.put("requestFrom", "huichuang");
|
|
|
params.put("pid", "2088821582878450");
|
|
|
params.put("partnerId", "tab3huichuangapkhuichuang");
|
|
|
- if (!Check.isNull(imei)) {
|
|
|
- params.put("imei", imei);
|
|
|
- }
|
|
|
if (!Check.isNull(oaidmd5)) {
|
|
|
params.put("oaidmd5", oaidmd5);
|
|
|
+ } else if (!Check.isNull(imei)) {
|
|
|
+ params.put("imei", imei);
|
|
|
}
|
|
|
+
|
|
|
if (!Check.isNull(accountid)) {
|
|
|
params.put("accountid", accountid);
|
|
|
}
|
|
@@ -157,10 +171,19 @@ public class TrackController {
|
|
|
if (!Check.isNull(cid)) {
|
|
|
params.put("cid", cid);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
if (!Check.isNull(callback)) {
|
|
|
String callbackUrl = "https://track.tjyourong.com.cn/convert/back2?kuaishouCallback=" + callback;
|
|
|
+ if (!Check.isNull(oaidmd5)) {
|
|
|
+ callbackUrl += "&id=" + oaidmd5;
|
|
|
+ } else if (!Check.isNull(imei)) {
|
|
|
+ callbackUrl += "&id=" + imei;
|
|
|
+ }
|
|
|
params.put("callback", callbackUrl);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
click2ExecutorService.submit(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -190,6 +213,15 @@ public class TrackController {
|
|
|
if (isRtaAccount) {
|
|
|
String s = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
logger.info("新沉流快手点击监测上报客户返回结果:" + s);
|
|
|
+ JSONObject mongoVo = new JSONObject();
|
|
|
+ if (!Check.isNull(oaidmd5)) {
|
|
|
+ mongoVo.put("_id", oaidmd5);
|
|
|
+ } else if (!Check.isNull(imei)) {
|
|
|
+ mongoVo.put("_id", imei);
|
|
|
+ }
|
|
|
+ long timestamp = System.currentTimeMillis() / 1000;
|
|
|
+ mongoVo.put("timestamp", timestamp);
|
|
|
+ mongoTemplate.save(mongoVo, "trackRta");
|
|
|
} else {
|
|
|
logger.info("新沉流客户rta返回策略列表未命中:tab3xcl,停止上报数据,返回数据:" + json);
|
|
|
}
|
|
@@ -264,6 +296,7 @@ public class TrackController {
|
|
|
try {
|
|
|
String url = request.getParameter("kuaishouCallback");
|
|
|
String transformtype = request.getParameter("transformtype");
|
|
|
+ String id = request.getParameter("id");
|
|
|
if ("8".equals(transformtype)) {
|
|
|
returnJson.put("code", 200);
|
|
|
returnJson.put("success", true);
|
|
@@ -276,8 +309,25 @@ public class TrackController {
|
|
|
back2ExecutorService.submit(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- String s = HttpUtils.backHttpGetRequest(url, headers, event_type);
|
|
|
- logger.info("新沉流回传媒体唤起结果返回结果:" + s);
|
|
|
+
|
|
|
+ Criteria criteria = new Criteria();
|
|
|
+ criteria = Criteria.where("_id").is(id);
|
|
|
+ Query query = new Query(criteria);
|
|
|
+ TrackRta one = mongoTemplate.findOne(query, TrackRta.class);
|
|
|
+ if (Check.isNull(one)) {
|
|
|
+ logger.error("客户回传信息未在mongodb中查到,跳过此回传");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long timestamp = one.getTimestamp();
|
|
|
+ long nowTamp = System.currentTimeMillis() / 1000;
|
|
|
+ if (nowTamp - timestamp <= 1800) {
|
|
|
+ String s = HttpUtils.backHttpGetRequest(url, headers, event_type);
|
|
|
+ logger.info("新沉流回传媒体唤起结果返回结果:" + s);
|
|
|
+ } else {
|
|
|
+ logger.error("客户回传信息超过30分钟时限,跳过此回传,返回id:" + id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
returnJson.put("code", 200);
|
|
@@ -292,6 +342,11 @@ public class TrackController {
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Long timestamp = 1728625744L;
|
|
|
+ long nowTamp = System.currentTimeMillis() / 1000;
|
|
|
+ System.err.println(nowTamp - timestamp);
|
|
|
+ }
|
|
|
|
|
|
/*@ResponseBody
|
|
|
@RequestMapping(value = "/convert")
|