|
@@ -2,8 +2,12 @@ package cn.com.ctop.job.kuaishou.data.service.impl;
|
|
|
|
|
|
import cn.com.ctop.job.kuaishou.data.constant.KuaishouConstant;
|
|
import cn.com.ctop.job.kuaishou.data.constant.KuaishouConstant;
|
|
import cn.com.ctop.job.kuaishou.data.entity.KuaishouAccountReportDaily;
|
|
import cn.com.ctop.job.kuaishou.data.entity.KuaishouAccountReportDaily;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportConversionChart;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportFunnel;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportSummary;
|
|
import cn.com.ctop.job.kuaishou.data.mapper.KuaishouAccountReportDailyMapper;
|
|
import cn.com.ctop.job.kuaishou.data.mapper.KuaishouAccountReportDailyMapper;
|
|
import cn.com.ctop.job.kuaishou.data.service.IKuaishouAccountReportDailyService;
|
|
import cn.com.ctop.job.kuaishou.data.service.IKuaishouAccountReportDailyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.utils.Check;
|
|
import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
|
|
import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
|
|
import cn.com.ctop.job.kuaishou.data.utils.HttpUtils;
|
|
import cn.com.ctop.job.kuaishou.data.utils.HttpUtils;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -36,7 +40,7 @@ public class KuaishouAccountReportDailyServiceImpl extends ServiceImpl<KuaishouA
|
|
private String postUrl;
|
|
private String postUrl;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getAdvertiserReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page)throws Exception {
|
|
|
|
|
|
+ public void getAdvertiserReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page) throws Exception {
|
|
log.info("获取账户日报,账户id:{},开始时间:{},结束时间:{}", advertiserId, startDate, endDate);
|
|
log.info("获取账户日报,账户id:{},开始时间:{},结束时间:{}", advertiserId, startDate, endDate);
|
|
String url = postUrl + KuaishouConstant.ACCOUNT_REPORT;
|
|
String url = postUrl + KuaishouConstant.ACCOUNT_REPORT;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
@@ -50,7 +54,7 @@ public class KuaishouAccountReportDailyServiceImpl extends ServiceImpl<KuaishouA
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
- // System.err.println(resultJson);
|
|
|
|
|
|
+ // System.err.println(resultJson);
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
String message = resultJson.getString("message");
|
|
String message = resultJson.getString("message");
|
|
if (null == code || code != 0) {
|
|
if (null == code || code != 0) {
|
|
@@ -85,4 +89,81 @@ public class KuaishouAccountReportDailyServiceImpl extends ServiceImpl<KuaishouA
|
|
String result = HttpUtils.httpPostRequest(url, param, null);
|
|
String result = HttpUtils.httpPostRequest(url, param, null);
|
|
System.err.println(result);
|
|
System.err.println(result);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void effectNativeChartReport(Long accountId, String token, String beginDate, String endDate) {
|
|
|
|
+ String url = postUrl + KuaishouConstant.EFFECT_NATIVE_CHART_REPORT;
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Access-Token", token);
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
|
+ JSONObject search_param = new JSONObject();
|
|
|
|
+
|
|
|
|
+ search_param.put("report_start_day", DateUtils.timeToStamp(beginDate + " 00:00:00"));
|
|
|
|
+ search_param.put("report_end_day", DateUtils.timeToStamp(endDate + " 23:59:59"));
|
|
|
|
+ param.put("search_param", search_param);
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+// System.out.println("-------------------" + param);
|
|
|
|
+// System.out.println("");
|
|
|
|
+// System.err.println(resultJson);
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
+ log.error("获取快手获取原生效果数据整体概览接口(数据概览、分日转化数据分布、转化漏斗)异常:{},accountId:{}", message, accountId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONObject data = resultJson.getJSONObject("data");
|
|
|
|
+
|
|
|
|
+ //数据概览
|
|
|
|
+ JSONArray summary = data.getJSONArray("summary");
|
|
|
|
+ if (!Check.isNull(summary)) {
|
|
|
|
+ List<KuaishouEffectNativeChartreportSummary> sumList = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < summary.size(); i++) {
|
|
|
|
+ JSONObject sumObj = summary.getJSONObject(i);
|
|
|
|
+ KuaishouEffectNativeChartreportSummary sum = JSONObject.parseObject(sumObj.toJSONString(), KuaishouEffectNativeChartreportSummary.class);
|
|
|
|
+ sum.setStatDate(DateUtils.getDateLong(beginDate));
|
|
|
|
+ sum.setAccountId(accountId);
|
|
|
|
+
|
|
|
|
+ sumList.add(sum);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(sumList)) {
|
|
|
|
+ accountReportDailyMapper.replaceBatchSummary(sumList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //漏斗数据
|
|
|
|
+ JSONArray funnel = data.getJSONArray("funnel");
|
|
|
|
+ if (!Check.isNull(funnel)) {
|
|
|
|
+ List<KuaishouEffectNativeChartreportFunnel> funList = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < funnel.size(); i++) {
|
|
|
|
+ JSONObject funObj = funnel.getJSONObject(i);
|
|
|
|
+ KuaishouEffectNativeChartreportFunnel fun = JSONObject.parseObject(funObj.toJSONString(), KuaishouEffectNativeChartreportFunnel.class);
|
|
|
|
+ fun.setStatDate(DateUtils.getDateLong(beginDate));
|
|
|
|
+ fun.setAccountId(accountId);
|
|
|
|
+
|
|
|
|
+ funList.add(fun);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(funList)) {
|
|
|
|
+ accountReportDailyMapper.replaceBatchFunnel(funList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //转化数分日柱状图
|
|
|
|
+ JSONArray conversionChart = data.getJSONArray("conversion_chart");
|
|
|
|
+ if (!Check.isNull(conversionChart)) {
|
|
|
|
+ List<KuaishouEffectNativeChartreportConversionChart> chatList = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < conversionChart.size(); i++) {
|
|
|
|
+ JSONObject chatObj = conversionChart.getJSONObject(i);
|
|
|
|
+ KuaishouEffectNativeChartreportConversionChart chat = JSONObject.parseObject(chatObj.toJSONString(), KuaishouEffectNativeChartreportConversionChart.class);
|
|
|
|
+ chat.setDate(DateUtils.getDateLong(beginDate));
|
|
|
|
+ chat.setAccountId(accountId);
|
|
|
|
+
|
|
|
|
+ chatList.add(chat);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(chatList)) {
|
|
|
|
+ accountReportDailyMapper.replaceBatchConversionChart(chatList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|