优化回传
This commit is contained in:
+34
-2
@@ -18,6 +18,7 @@ import com.fangjia.core.util.DataUtil;
|
||||
import com.fangjia.core.util.DingDingMessageUtil;
|
||||
import com.fangjia.core.util.HttpRequest;
|
||||
import com.fangjia.core.util.HttpRequestException;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@@ -34,9 +35,12 @@ import com.fangjia.service.common.CookieName;
|
||||
import com.fangjia.service.fangjia.NewsResourceService;
|
||||
import com.fangjia.service.fangjia.SaleLeadsService;
|
||||
import com.fangjia.service.mongo.fangjia.ServerAreaService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SaleLeadsController {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SaleLeadsController.class);
|
||||
|
||||
private SaleLeadsService saleLeadsService;
|
||||
private ServerAreaService serverAreaService;
|
||||
private NewsResourceService newsResourceService;
|
||||
@@ -144,8 +148,12 @@ public class SaleLeadsController {
|
||||
+ "手机:" + saleLeads.getMobile() + "\n\n"
|
||||
+ "邮箱:" + saleLeads.getEmail() + "\n\n"
|
||||
+ "公司名称:" + saleLeads.getCompany() + "\n\n"
|
||||
+ "行业性质:" + saleLeads.getIndustryNature() + "\n\n"
|
||||
+ "线索来源:房价网" ;
|
||||
+ "行业性质:" + saleLeads.getIndustryNature() + "\n\n";
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(refUrl) && refUrl.contains("bd_vid")) {
|
||||
body += "线索来源:百度";
|
||||
} else {
|
||||
body += "线索来源:房价网";
|
||||
}
|
||||
try {
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("msgtype", "markdown");
|
||||
@@ -163,6 +171,30 @@ public class SaleLeadsController {
|
||||
}
|
||||
saleLeadsService.save(saleLeads);
|
||||
|
||||
// 对于百度广告过来的信息,进行回传
|
||||
try {
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(refUrl) && refUrl.contains("bd_vid")) {
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
final String baiduUrl = "https://ocpc.baidu.com/ocpcapi/api/uploadConvertData";
|
||||
Map<String, String> bdHeaders = new HashMap<String, String>();
|
||||
bdHeaders.put("Content-Type", "application/json; charset=utf-8");
|
||||
|
||||
JSONObject requestBody = new JSONObject();
|
||||
// https://fengchao.baidu.com/fc/toolscenter/optimize/track/user/27002539
|
||||
requestBody.put("token", "EZGISwlOClRMEZErT2ThZTEjpLAzs2wE@9POwrGLqpRtQeGhvvCug1N3OK1tq3skk");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject contentJson = new JSONObject();
|
||||
contentJson.put("logidUrl", refUrl);
|
||||
contentJson.put("newType", "3");
|
||||
jsonArray.add(contentJson);
|
||||
requestBody.put("conversionTypes", jsonArray);
|
||||
String result = httpRequest.postWithBody(baiduUrl, requestBody, bdHeaders, "UTF-8");
|
||||
LOG.info("百度回传成功:" + result);
|
||||
}
|
||||
} catch (HttpRequestException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(saleLeads.getBusiness()) && saleLeads.getBusiness().contains("_")){
|
||||
String[] businessArray = saleLeads.getBusiness().split("_");
|
||||
for(String s : businessArray){
|
||||
|
||||
-25
@@ -24,31 +24,6 @@ public class SolutionController {
|
||||
* @return
|
||||
*/
|
||||
public Object apiAction(FangjiaModel model, HttpServletRequest request) {
|
||||
// 对于百度广告过来的信息,进行回传
|
||||
try {
|
||||
String queryString = request.getQueryString();
|
||||
if (StringUtils.isNotBlank(queryString) && queryString.contains("bd_vid")) {
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
final String baiduUrl = "https://ocpc.baidu.com/ocpcapi/api/uploadConvertData";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("Content-Type", "application/json; charset=utf-8");
|
||||
|
||||
JSONObject requestBody = new JSONObject();
|
||||
// https://fengchao.baidu.com/fc/toolscenter/optimize/track/user/27002539
|
||||
requestBody.put("token", "EZGISwlOClRMEZErT2ThZTEjpLAzs2wE@9POwrGLqpRtQeGhvvCug1N3OK1tq3skk");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject contentJson = new JSONObject();
|
||||
contentJson.put("logidUrl", request.getRequestURL().append("?" + request.getQueryString()).toString());
|
||||
contentJson.put("newType", "1");
|
||||
jsonArray.add(contentJson);
|
||||
requestBody.put("conversionTypes", jsonArray);
|
||||
String result = httpRequest.postWithBody(baiduUrl, requestBody, headers, "UTF-8");
|
||||
System.out.println(result);
|
||||
}
|
||||
} catch (HttpRequestException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user