|
@@ -132,7 +132,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
@Override
|
|
|
public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
- getAdvertiserReportHourlyByPage(token, startDate, endDate, 1);
|
|
|
+ try {
|
|
|
+ Thread.sleep(200L);
|
|
|
+ getAdvertiserReportHourlyByPage(token, startDate, endDate, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -145,7 +151,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
param.put("advertiser_id", token.getAccountId());
|
|
|
param.put("temporal_granularity", "HOURLY");
|
|
|
- param.put("page_size", 500);
|
|
|
+ param.put("page_size", 2000);
|
|
|
param.put("page", page);
|
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
@@ -159,19 +165,20 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (null == details || details.size() <= 0) {
|
|
|
return;
|
|
|
}
|
|
|
+ List<KuaishouReportHourlyAccount> addList = new ArrayList<>();
|
|
|
for (int i = 0; i < details.size(); i++) {
|
|
|
JSONObject 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 kuaishouReportHourlyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyAccount.class);
|
|
|
+ KuaishouReportHourlyAccount kuaishouReportHourlyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyAccount.class);
|
|
|
kuaishouReportHourlyAccount.setAccountId(token.getAccountId());
|
|
|
kuaishouReportHourlyAccount.setId("" + token.getAccountId() + kuaishouReportHourlyAccount.getStatDate() + kuaishouReportHourlyAccount.getStatHour());
|
|
|
- kuaishouReportHourlyAccount.setCreateTime(new Date());
|
|
|
- kuaishouReportHourlyAccount.setUpdateTime(new Date());
|
|
|
- hourlyAccountService.saveOrUpdate(kuaishouReportHourlyAccount);
|
|
|
+ // hourlyAccountService.saveOrUpdate(kuaishouReportHourlyAccount);
|
|
|
+ addList.add(kuaishouReportHourlyAccount);
|
|
|
}
|
|
|
+ hourlyAccountService.replaceBatch(addList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -269,14 +276,19 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
- public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
- getAccountDailyReportByPage(token, startDate, endDate, 1);
|
|
|
+ public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate, String reportDims) {
|
|
|
+ try {
|
|
|
+ Thread.sleep(400L);
|
|
|
+ getAccountDailyReportByPage(token, startDate, endDate, 1, reportDims);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void getAccountDailyReportByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
+ private void getAccountDailyReportByPage(CtopOauthToken token, Date startDate, Date endDate, int page, String reportDims) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_REPORT;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
@@ -289,11 +301,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (!Check.isNull(endDate)) {
|
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
}
|
|
|
-
|
|
|
+ if (!Check.isNull(reportDims)) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ array.add(reportDims);
|
|
|
+ param.put("report_dims", array);
|
|
|
+ }
|
|
|
|
|
|
param.put("advertiser_id", token.getAccountId());
|
|
|
param.put("temporal_granularity", "DAILY");
|
|
|
- param.put("page_size", 500);
|
|
|
+ param.put("page_size", 2000);
|
|
|
param.put("page", page);
|
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
@@ -308,7 +324,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
log.info("快手广告主报表信息为空=》accountId:{}", token.getAccountId());
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ List<KuaishouReportDailyAccount> addList = new ArrayList<>();
|
|
|
for (int i = 0; i < details.size(); i++) {
|
|
|
JSONObject detailJson = details.getJSONObject(i);
|
|
|
if (!Check.isNull(detailJson)) {
|
|
@@ -316,15 +332,19 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
detailJson.put("photo_comment", detailJson.getString("comment"));
|
|
|
detailJson.put("photo_like", detailJson.getString("like"));
|
|
|
detailJson.put("photo_show", detailJson.getString("show"));
|
|
|
- var KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
|
|
|
+ KuaishouReportDailyAccount KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
|
|
|
KuaishouReportDailyAccount.setAccountId(token.getAccountId());
|
|
|
- dailyAccountMapper.insertSelective(KuaishouReportDailyAccount);
|
|
|
+ addList.add(KuaishouReportDailyAccount);
|
|
|
}
|
|
|
}
|
|
|
- getAccountDailyReportByPage(token, startDate, endDate, page + 1);
|
|
|
+ if (Check.isNull(reportDims)) {
|
|
|
+ dailyAccountMapper.replaceBatch(addList);
|
|
|
+ } else {
|
|
|
+ dailyAccountMapper.replaceBatchAdScene(addList);
|
|
|
+ }
|
|
|
+ getAccountDailyReportByPage(token, startDate, endDate, page + 1, reportDims);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
getCampaignDailyReportByPage(token, startDate, endDate, 1);
|
|
@@ -456,7 +476,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
campaigns.add(hourlyCampaign);
|
|
|
}
|
|
|
hourlyCampaignService.replaceBatch(campaigns);
|
|
|
- getAdvertiserReportHourlyByPage(token, startDate, endDate, page + 1);
|
|
|
+ getCampaignReportHourlyByPage(token, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -494,91 +514,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void getAdvertiserGroupReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
- getAdvertiserGroupReportDailyByPage(token, startDate, endDate, 1);
|
|
|
- }
|
|
|
-
|
|
|
- private void getAdvertiserGroupReportDailyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
- log.info("获取广告组日报,accountId:{},开始时间:{},结束时间:{}", token.getAccountId(), DateUtils.formatDate(startDate), DateUtils.formatDate(endDate));
|
|
|
- String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type", "application/json");
|
|
|
- headers.put("Access-Token", token.getAccessToken());
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
- if (!Check.isNull(startDate)) {
|
|
|
- param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
- }
|
|
|
-
|
|
|
- if (!Check.isNull(endDate)) {
|
|
|
- param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- detailJson.put("photo_share", detailJson.getString("share"));
|
|
|
- detailJson.put("photo_comment", detailJson.getString("comment"));
|
|
|
- detailJson.put("photo_like", detailJson.getString("like"));
|
|
|
- detailJson.put("photo_show", detailJson.getString("show"));
|
|
|
-
|
|
|
- var dailyGroup = JSONObject.toJavaObject(detailJson, KuaishouReportDailyGroup.class);
|
|
|
- dailyGroup.setAccountId(token.getAccountId());
|
|
|
- dailyGroupMapper.insertSelective(dailyGroup);
|
|
|
- }
|
|
|
- getAdvertiserGroupReportDailyByPage(token, startDate, endDate, page + 1);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public KuaishouResult<KuaishouReportDailyGroup> getGroupDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
|
|
|
- String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type", "application/json");
|
|
|
- headers.put("Access-Token", accessToken);
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
- param.put("start_date", startDate);
|
|
|
- param.put("end_date", endDate);
|
|
|
- param.put("advertiser_id", advertiserId);
|
|
|
- param.put("temporal_granularity", "DAILY");
|
|
|
- param.put("page_size", pageSize);
|
|
|
- param.put("page", pageNum);
|
|
|
- KuaishouResult<KuaishouReportDailyGroup> kuaishouResult = null;
|
|
|
- try {
|
|
|
- String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
- kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportDailyGroup>>() {
|
|
|
- });
|
|
|
- List<KuaishouReportDailyGroup> dailyGroups = kuaishouResult.getData().getDetails();
|
|
|
- dailyGroups.forEach((dailyGroup) -> {
|
|
|
- dailyGroup.setAccountId(advertiserId);
|
|
|
- // dailyGroup.setId("" + dailyGroup.getAccountId() + dailyGroup.getUnitId() + dailyGroup.getStatDate());
|
|
|
- dailyGroupMapper.insertSelective(dailyGroup);
|
|
|
- });
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return kuaishouResult;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public void getAdvertiserGroupReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
getGroupHourlyReportByPage(token, startDate, endDate, 1);
|
|
|
}
|
|
@@ -903,7 +838,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
Date getStartDate = DateUtils.addDay(endDate, -i);
|
|
|
//1: 获取广告主信息数据
|
|
|
getAdvertiserReportHourly(token, getStartDate, getStartDate);
|
|
|
- getAdvertiserReportDaily(token, getStartDate, getStartDate);
|
|
|
+ getAdvertiserReportDaily(token, getStartDate, getStartDate, "adScene");
|
|
|
//2:获取广告计划信息数据
|
|
|
// getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
|
|
|
//3:获取广告组信息数据
|
|
@@ -1121,6 +1056,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
public JSONArray getCampaignList(CtopOauthToken token, Date startDate, Date endDate, int timeFilterType) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
@@ -1219,6 +1155,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
kuaiShouCampaignService.replaceBatch(campaigns);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public JSONArray getGroupList(CtopOauthToken token, Long campaignId, Date startDate,
|
|
|
Date endDate, int time_filter_type) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
@@ -1371,10 +1308,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
group.setUnitName(unit_name);
|
|
|
group.setStatus(status);
|
|
|
group.setPutStatus(put_status);
|
|
|
+ group.setStudyStatus(detail.getInteger("study_status"));
|
|
|
group.setCreateChannel(detail.getInteger("create_channel"));
|
|
|
group.setReviewDetail(detail.getString("review_detail"));
|
|
|
group.setBidType(bid_type);
|
|
|
group.setBid(bid);
|
|
|
+ group.setStudyStatus(detail.getInteger("study_status"));
|
|
|
group.setCpaBid(cpa_bid);
|
|
|
group.setOcpxActionType(ocpx_action_type);
|
|
|
group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
|
|
@@ -1415,6 +1354,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
public JSONArray getCreativeList(CtopOauthToken token, Long unitId, Date startDate, Date endDate, int timeFilterType) {
|
|
|
Long advertiserId = token.getAccountId();
|
|
|
String accessToken = token.getAccessToken();
|
|
@@ -2615,7 +2555,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- log.error("获取账户余额失败");
|
|
|
+ log.error("获取账户余额失败," + resultJson.getString("message"));
|
|
|
}
|
|
|
} else {
|
|
|
log.error("获取账户余额返回为空");
|