|
@@ -5,9 +5,11 @@ import cn.com.ctop.track.entity.ConvertInfo;
|
|
import cn.com.ctop.track.service.ClickInfoService;
|
|
import cn.com.ctop.track.service.ClickInfoService;
|
|
import cn.com.ctop.track.service.ConvertInfoService;
|
|
import cn.com.ctop.track.service.ConvertInfoService;
|
|
import cn.com.ctop.track.service.TaobaoNoticeService;
|
|
import cn.com.ctop.track.service.TaobaoNoticeService;
|
|
|
|
+import cn.com.ctop.track.service.impl.TaobaoNoticeServiceImpl;
|
|
import cn.com.ctop.track.utils.HttpUtils;
|
|
import cn.com.ctop.track.utils.HttpUtils;
|
|
import cn.hutool.core.date.DateUnit;
|
|
import cn.hutool.core.date.DateUnit;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import org.apache.log4j.Logger;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -23,6 +25,7 @@ import java.util.Date;
|
|
@Controller
|
|
@Controller
|
|
@RequestMapping("/")
|
|
@RequestMapping("/")
|
|
public class TrackController {
|
|
public class TrackController {
|
|
|
|
+ private static Logger logger = Logger.getLogger(TrackController.class);
|
|
@Autowired
|
|
@Autowired
|
|
private ClickInfoService clickInfoService;
|
|
private ClickInfoService clickInfoService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -33,9 +36,34 @@ public class TrackController {
|
|
@RequestMapping(value = "/convert")
|
|
@RequestMapping(value = "/convert")
|
|
public String convert(HttpServletRequest request,
|
|
public String convert(HttpServletRequest request,
|
|
HttpServletResponse response){
|
|
HttpServletResponse response){
|
|
- System.out.println(request.getQueryString());
|
|
|
|
|
|
+ logger.info(request.getQueryString());
|
|
try {
|
|
try {
|
|
String clickId = request.getParameter("click_id");
|
|
String clickId = request.getParameter("click_id");
|
|
|
|
+ String spaceId = request.getParameter("space_id");
|
|
|
|
+ String accountId = request.getParameter("account_id");
|
|
|
|
+ String os = request.getParameter("os_type");
|
|
|
|
+ String platform = request.getParameter("platform");
|
|
|
|
+ String advertisor = request.getParameter("advertisor");
|
|
|
|
+ String groupId = request.getParameter("group_id");
|
|
|
|
+ String campaignId = request.getParameter("compaign_id");
|
|
|
|
+ String creativeId = request.getParameter("creative_id");
|
|
|
|
+ String campaignName = request.getParameter("campaign_name");
|
|
|
|
+ String mac = request.getParameter("mac");
|
|
|
|
+ String macMd5 = request.getParameter("mac_md5");
|
|
|
|
+ String ts = request.getParameter("ts");
|
|
|
|
+ String ip = request.getParameter("ip");
|
|
|
|
+ String sence = request.getParameter("sence");
|
|
|
|
+ String imeiMd5 = null;
|
|
|
|
+ String idfaMd5 = null;
|
|
|
|
+ String oaid = null;
|
|
|
|
+ if(os != null){
|
|
|
|
+ if (os.equals("Android")){
|
|
|
|
+ imeiMd5 = request.getParameter("imei_md5");
|
|
|
|
+ oaid = request.getParameter("oaid");
|
|
|
|
+ }else if(os.equals("IOS")){
|
|
|
|
+ idfaMd5 = request.getParameter("idfa_md5");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
String callbackUrl = request.getParameter("callback_url");
|
|
String callbackUrl = request.getParameter("callback_url");
|
|
String transformType = request.getParameter("transformType");
|
|
String transformType = request.getParameter("transformType");
|
|
if (transformType != null){
|
|
if (transformType != null){
|
|
@@ -48,16 +76,36 @@ public class TrackController {
|
|
String result = HttpUtils.httpGetRequest(callbackUrl);
|
|
String result = HttpUtils.httpGetRequest(callbackUrl);
|
|
ConvertInfo convertInfo = new ConvertInfo();
|
|
ConvertInfo convertInfo = new ConvertInfo();
|
|
convertInfo.setCallbackUrl(callbackUrl);
|
|
convertInfo.setCallbackUrl(callbackUrl);
|
|
- convertInfo.setClickId(Long.parseLong(clickId));
|
|
|
|
|
|
+ try {
|
|
|
|
+ convertInfo.setClickId(Long.parseLong(clickId));
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+
|
|
|
|
+ }
|
|
convertInfo.setTransformType(transformType);
|
|
convertInfo.setTransformType(transformType);
|
|
convertInfo.setResponse(result);
|
|
convertInfo.setResponse(result);
|
|
- convertInfoService.save(convertInfo);
|
|
|
|
- ClickInfo clickInfo = clickInfoService.getById(Long.parseLong(clickId));
|
|
|
|
- if (clickInfo != null){
|
|
|
|
- clickInfo.setIsConvert(1);
|
|
|
|
- clickInfoService.updateById(clickInfo);
|
|
|
|
|
|
+ convertInfo.setAdvertisor(advertisor);
|
|
|
|
+ convertInfo.setCampaignId(campaignId);
|
|
|
|
+ convertInfo.setCampaignName(campaignName);
|
|
|
|
+ convertInfo.setCreativeId(creativeId);
|
|
|
|
+ convertInfo.setGroupId(groupId);
|
|
|
|
+ convertInfo.setIdfaMd5(idfaMd5);
|
|
|
|
+ convertInfo.setImeiMd5(imeiMd5);
|
|
|
|
+ convertInfo.setIp(ip);
|
|
|
|
+ convertInfo.setMac(mac);
|
|
|
|
+ convertInfo.setMacMd5(macMd5);
|
|
|
|
+ convertInfo.setOaid(oaid);
|
|
|
|
+ convertInfo.setOsType(os);
|
|
|
|
+ convertInfo.setPlatform(platform);
|
|
|
|
+ convertInfo.setSence(sence);
|
|
|
|
+ convertInfo.setSpaceId(spaceId);
|
|
|
|
+ convertInfo.setAccountId(accountId);
|
|
|
|
+ try {
|
|
|
|
+ convertInfo.setTs(new Date(Long.parseLong(ts)));
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+
|
|
}
|
|
}
|
|
- } catch (NumberFormatException e) {
|
|
|
|
|
|
+ convertInfoService.save(convertInfo);
|
|
|
|
+ } catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return "{\"code\":200,\"result\":\"success\"}";
|
|
return "{\"code\":200,\"result\":\"success\"}";
|
|
@@ -67,22 +115,14 @@ public class TrackController {
|
|
@RequestMapping(value = "/click")
|
|
@RequestMapping(value = "/click")
|
|
public String click(HttpServletRequest request,
|
|
public String click(HttpServletRequest request,
|
|
HttpServletResponse response){
|
|
HttpServletResponse response){
|
|
-// System.out.println(request.getQueryString());
|
|
|
|
try {
|
|
try {
|
|
|
|
+ logger.info(request.getQueryString());
|
|
String os = request.getParameter("os_type");
|
|
String os = request.getParameter("os_type");
|
|
-
|
|
|
|
- String platform = request.getParameter("platform");
|
|
|
|
|
|
+ String spaceId = request.getParameter("space_id");
|
|
String advertisor = request.getParameter("advertisor");
|
|
String advertisor = request.getParameter("advertisor");
|
|
- String groupId = request.getParameter("group_id");
|
|
|
|
String campaignId = request.getParameter("compaign_id");
|
|
String campaignId = request.getParameter("compaign_id");
|
|
String creativeId = request.getParameter("creative_id");
|
|
String creativeId = request.getParameter("creative_id");
|
|
String campaignName = request.getParameter("campaign_name");
|
|
String campaignName = request.getParameter("campaign_name");
|
|
- String mac = request.getParameter("mac");
|
|
|
|
- String macMd5 = request.getParameter("mac_md5");
|
|
|
|
- String ts = request.getParameter("ts");
|
|
|
|
- String ip = request.getParameter("ip");
|
|
|
|
- String sence = request.getParameter("sence");
|
|
|
|
- String callbackUrl = request.getParameter("callback_url");
|
|
|
|
String imeiMd5 = null;
|
|
String imeiMd5 = null;
|
|
String idfaMd5 = null;
|
|
String idfaMd5 = null;
|
|
String oaid = null;
|
|
String oaid = null;
|
|
@@ -94,34 +134,15 @@ public class TrackController {
|
|
idfaMd5 = request.getParameter("idfa_md5");
|
|
idfaMd5 = request.getParameter("idfa_md5");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- ClickInfo clickInfo = new ClickInfo();
|
|
|
|
- clickInfo.setAdvertisor(advertisor);
|
|
|
|
- clickInfo.setCallbackUrl(callbackUrl);
|
|
|
|
- clickInfo.setCampaignId(campaignId);
|
|
|
|
- clickInfo.setCampaignName(campaignName);
|
|
|
|
- clickInfo.setCreativeId(creativeId);
|
|
|
|
- clickInfo.setGroupId(groupId);
|
|
|
|
- clickInfo.setIdfaMd5(idfaMd5);
|
|
|
|
- clickInfo.setImeiMd5(imeiMd5);
|
|
|
|
- clickInfo.setOaid(oaid);
|
|
|
|
- clickInfo.setIsConvert(0);
|
|
|
|
- clickInfo.setIp(ip);
|
|
|
|
- clickInfo.setMac(mac);
|
|
|
|
- clickInfo.setMacMd5(macMd5);
|
|
|
|
- clickInfo.setOsType(os);
|
|
|
|
- clickInfo.setPlatform(platform);
|
|
|
|
- clickInfo.setSence(sence);
|
|
|
|
- try {
|
|
|
|
- clickInfo.setTs(new Date(Long.parseLong(ts)));
|
|
|
|
- } catch (NumberFormatException e) {
|
|
|
|
|
|
+ if(spaceId == null || spaceId.equals("")){
|
|
|
|
+ spaceId = "11709";
|
|
}
|
|
}
|
|
- clickInfoService.save(clickInfo);
|
|
|
|
if (advertisor!= null && advertisor.equals("taobao")){
|
|
if (advertisor!= null && advertisor.equals("taobao")){
|
|
try {
|
|
try {
|
|
- String convertUrl = "http://track.c-top.com.cn/convert?click_id="+clickInfo.getId()+"&callback_url="+ URLEncoder.encode(callbackUrl,"utf-8");
|
|
|
|
- taobaoNoticeService.sendNotice(campaignId,campaignName,creativeId,imeiMd5,idfaMd5,oaid,convertUrl);
|
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
|
|
|
+ String convertUrl = "https://track.c-top.com.cn/convert?"+request.getQueryString();
|
|
|
|
+ logger.info(convertUrl);
|
|
|
|
+ taobaoNoticeService.sendNotice(spaceId,campaignId,campaignName,creativeId,imeiMd5,idfaMd5,oaid,convertUrl);
|
|
|
|
+ } catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|