|
@@ -3723,5 +3723,66 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void getAdvertiserCreativeReportDailyV2(Long campaignId, CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
|
+ getAdvertiserCreativeReportDailyByPageV2(campaignId, token, startDate, endDate, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void getAdvertiserCreativeReportDailyByPageV2(Long campaignId, CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
|
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
+ Map<String, Object> param = new HashMap<String, Object>();
|
|
|
|
+ if (!Check.isNull(startDate)) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(endDate)) {
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
+ jsonArray.add(campaignId);
|
|
|
|
+ param.put("campaign_ids", jsonArray);
|
|
|
|
+ param.put("advertiser_id", token.getAccountId());
|
|
|
|
+ param.put("temporal_granularity", "DAILY");
|
|
|
|
+ param.put("page_size", 500);
|
|
|
|
+ param.put("page", page);
|
|
|
|
+
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ log.error("获取快手广告创意分天报表异常:{},accountId:{}", message, token.getAccountId());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
|
+ log.info("快手广告创意分天报表信息为空=》accountId:{}", token.getAccountId());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ var detailJson = details.getJSONObject(i);
|
|
|
|
+ var show = detailJson.getLong("show");
|
|
|
|
+ detailJson.put("photo_show", show);
|
|
|
|
+ var like = detailJson.getLong("like");
|
|
|
|
+ detailJson.put("photo_like", like);
|
|
|
|
+ var creative = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCreative.class);
|
|
|
|
+ creative.setAccountId(token.getAccountId());
|
|
|
|
+ creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
|
|
|
|
+
|
|
|
|
+ // 取得MD5
|
|
|
|
+ String signature = creativeService.getCodeByCreativeId(creative.getCreativeId());
|
|
|
|
+ if (!Check.isNull(signature)) {
|
|
|
|
+ creative.setSignature(signature);
|
|
|
|
+ }
|
|
|
|
+ KuaishouReportDailyCreativeStatistic statistic = setDailyStatistic(creative, token);
|
|
|
|
+ dailyCreativeStatisticService.saveOrUpdate(statistic);
|
|
|
|
+ dailyCreativeService.saveOrUpdate(creative);
|
|
|
|
+ }
|
|
|
|
+ getAdvertiserCreativeReportDailyByPageV2(campaignId, token, startDate, endDate, page + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|