|
@@ -2,16 +2,14 @@ package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.MaterialInfo;
|
|
import cn.com.ctop.common.module.entity.MaterialInfo;
|
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
|
|
import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
|
|
-import cn.com.ctop.common.module.utils.Check;
|
|
|
|
-import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
|
-import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
|
-import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
|
+import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
|
+import cn.com.ctop.common.module.utils.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
import cn.com.ctop.kuaishou.modules.report.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.report.entity.*;
|
|
@@ -51,6 +49,9 @@ import java.io.IOException;
|
|
import java.lang.reflect.ParameterizedType;
|
|
import java.lang.reflect.ParameterizedType;
|
|
import java.lang.reflect.Type;
|
|
import java.lang.reflect.Type;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author
|
|
* @author
|
|
@@ -231,7 +232,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
|
|
log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ System.out.println(details.toJSONString());
|
|
for (int i = 0; i < details.size(); i++) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
var detailJson = details.getJSONObject(i);
|
|
var detailJson = details.getJSONObject(i);
|
|
var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
@@ -696,11 +697,41 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
var creative = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCreative.class);
|
|
var creative = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCreative.class);
|
|
creative.setAccountId(token.getAccountId());
|
|
creative.setAccountId(token.getAccountId());
|
|
creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
|
|
creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
|
|
|
|
+ KuaishouReportDailyCreativeStatistic statistic = setDailyStatistic(creative, token);
|
|
|
|
+ dailyCreativeStatisticService.saveOrUpdate(statistic);
|
|
dailyCreativeService.saveOrUpdate(creative);
|
|
dailyCreativeService.saveOrUpdate(creative);
|
|
}
|
|
}
|
|
getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, page + 1);
|
|
getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private KuaishouReportDailyCreativeStatistic setDailyStatistic(KuaishouReportDailyCreative creative, CtopOauthToken token) {
|
|
|
|
+ KuaishouReportDailyCreativeStatistic statistic = new KuaishouReportDailyCreativeStatistic(creative);
|
|
|
|
+ KuaiShouCreative getCreative = kuaiShouCreativeService.getById("" + token.getAccountId() + creative.getCreativeId());
|
|
|
|
+ if (null != getCreative) {
|
|
|
|
+ statistic.setCreativeName(getCreative.getCreativeName());
|
|
|
|
+ KuaiShouCampaign getCampaign = kuaiShouCampaignService.getById("" + token.getAccountId() + getCreative.getCampaignId());
|
|
|
|
+ if (null != getCampaign) {
|
|
|
|
+ statistic.setCampaignId(getCampaign.getCampaignId());
|
|
|
|
+ statistic.setCampaignName(getCampaign.getCampaignName());
|
|
|
|
+ }
|
|
|
|
+ KuaiShouGroup getGroup = kuaiShouGroupService.getById("" + token.getAccountId() + getCreative.getUnitId());
|
|
|
|
+ if (null != getGroup) {
|
|
|
|
+ statistic.setUnitId(getGroup.getUnitId());
|
|
|
|
+ statistic.setUnitName(getGroup.getUnitName());
|
|
|
|
+ }
|
|
|
|
+ KuaiShouVideoGet getVideo = kuaiShouVideoGetService.getById("" + token.getAccountId() + getCreative.getPhotoId());
|
|
|
|
+ if (null != getVideo) {
|
|
|
|
+ statistic.setSignature(getVideo.getSignature());
|
|
|
|
+ statistic.setUrl(getVideo.getUrl());
|
|
|
|
+ }
|
|
|
|
+ UserAllocation allocation = userAllocationService.getByAccountId(token.getAccountId());
|
|
|
|
+ if (null != allocation) {
|
|
|
|
+ statistic.setAccountName(allocation.getAuthName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return statistic;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public KuaishouResult<KuaishouReportDailyCreative> getCreativeDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
|
|
public KuaishouResult<KuaishouReportDailyCreative> getCreativeDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
|
|
@@ -738,6 +769,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
getAdvertiserCreativeReportHourlyByPage(token, startDate, endDate, 1);
|
|
getAdvertiserCreativeReportHourlyByPage(token, startDate, endDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private void getAdvertiserCreativeReportHourlyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
private void getAdvertiserCreativeReportHourlyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
@@ -773,11 +805,54 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
var creative = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyCreative.class);
|
|
var creative = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyCreative.class);
|
|
creative.setAccountId(token.getAccountId());
|
|
creative.setAccountId(token.getAccountId());
|
|
creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate() + creative.getStatHour());
|
|
creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate() + creative.getStatHour());
|
|
|
|
+ KuaishouReportHourlyCreativeStatistic statistic = setHourlyStatistic(creative, token);
|
|
|
|
+ hourlyCreativeStatisticService.saveOrUpdate(statistic);
|
|
hourlyCreativeService.saveOrUpdate(creative);
|
|
hourlyCreativeService.saveOrUpdate(creative);
|
|
}
|
|
}
|
|
getAdvertiserCreativeReportHourlyByPage(token, startDate, endDate, page + 1);
|
|
getAdvertiserCreativeReportHourlyByPage(token, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouCreativeService kuaiShouCreativeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouCampaignService kuaiShouCampaignService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouGroupService kuaiShouGroupService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserAllocationService userAllocationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouReportHourlyCreativeStatisticService hourlyCreativeStatisticService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouReportDailyCreativeStatisticService dailyCreativeStatisticService;
|
|
|
|
+
|
|
|
|
+ private KuaishouReportHourlyCreativeStatistic setHourlyStatistic(KuaishouReportHourlyCreative creative, CtopOauthToken token) {
|
|
|
|
+ KuaishouReportHourlyCreativeStatistic statistic = new KuaishouReportHourlyCreativeStatistic(creative);
|
|
|
|
+ KuaiShouCreative getCreative = kuaiShouCreativeService.getById("" + token.getAccountId() + creative.getCreativeId());
|
|
|
|
+ if (null != getCreative) {
|
|
|
|
+ statistic.setCreativeName(getCreative.getCreativeName());
|
|
|
|
+ KuaiShouCampaign getCampaign = kuaiShouCampaignService.getById("" + token.getAccountId() + getCreative.getCampaignId());
|
|
|
|
+ if (null != getCampaign) {
|
|
|
|
+ statistic.setCampaignId(getCampaign.getCampaignId());
|
|
|
|
+ statistic.setCampaignName(getCampaign.getCampaignName());
|
|
|
|
+ }
|
|
|
|
+ KuaiShouGroup getGroup = kuaiShouGroupService.getById("" + token.getAccountId() + getCreative.getUnitId());
|
|
|
|
+ if (null != getGroup) {
|
|
|
|
+ statistic.setUnitId(getGroup.getUnitId());
|
|
|
|
+ statistic.setUnitName(getGroup.getUnitName());
|
|
|
|
+ }
|
|
|
|
+ KuaiShouVideoGet getVideo = kuaiShouVideoGetService.getById("" + token.getAccountId() + getCreative.getPhotoId());
|
|
|
|
+ if (null != getVideo) {
|
|
|
|
+ statistic.setSignature(getVideo.getSignature());
|
|
|
|
+ statistic.setUrl(getVideo.getUrl());
|
|
|
|
+ }
|
|
|
|
+ UserAllocation allocation = userAllocationService.getByAccountId(token.getAccountId());
|
|
|
|
+ if (null != allocation) {
|
|
|
|
+ statistic.setAccountName(allocation.getAuthName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return statistic;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public KuaishouResult<KuaishouReportHourlyCreative> getCreativeHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
|
|
public KuaishouResult<KuaishouReportHourlyCreative> getCreativeHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
|
|
@@ -859,9 +934,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
/**
|
|
/**
|
|
* 创建广告计划
|
|
* 创建广告计划
|
|
*
|
|
*
|
|
- * @param accessToken token信息
|
|
|
|
- * @param advertiserId 广告主id
|
|
|
|
- * @param requestJson 请求参数拼装
|
|
|
|
|
|
+ * @param accessToken token信息
|
|
|
|
+ * @param advertiserId 广告主id
|
|
|
|
+ * @param requestJson 请求参数拼装
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> campaignCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
|
|
public Map<String, Object> campaignCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
|
|
@@ -977,6 +1052,42 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
return returnMap;
|
|
return returnMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void getCampaignList(CtopOauthToken token) {
|
|
|
|
+ getCampaignListByPage(token.getAccessToken(), token.getAccountId(), 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void getCampaignListByPage(String accessToken, Long accountId, int page) {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
|
+ param.put("page", page);
|
|
|
|
+ param.put("page_size", 200);
|
|
|
|
+
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
|
+ log.error("获取广告计划信息返回结果异常,advertiserId:{}", accountId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ log.error("获取广告计划信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
|
+ JSONArray details = dataJson.getJSONArray("details");
|
|
|
|
+ if (Check.isNull(details)) {
|
|
|
|
+ log.info("获取广告计划信息返回结果为空,advertiserId:{}", accountId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ addCampaign(accountId, details);
|
|
|
|
+ getCampaignListByPage(accessToken, accountId, page + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取广告计划信息
|
|
* 获取广告计划信息
|
|
*
|
|
*
|
|
@@ -986,12 +1097,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void getCampaignList(String accessToken, Long advertiserId, Integer page) {
|
|
public void getCampaignList(String accessToken, Long advertiserId, Integer page) {
|
|
- // 第一次请求删除历史数据
|
|
|
|
- if (page == 1) {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("account_id", advertiserId);
|
|
|
|
- campaignMapper.deleteByMap(map);
|
|
|
|
- }
|
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Access-Token", accessToken);
|
|
@@ -1061,22 +1166,109 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private void addCampaign(Long advertiserId, JSONArray details) {
|
|
private void addCampaign(Long advertiserId, JSONArray details) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
JSONObject detail = JSONObject.parseObject(details.get(i).toString());
|
|
JSONObject detail = JSONObject.parseObject(details.get(i).toString());
|
|
if (!Check.isNull(detail)) {
|
|
if (!Check.isNull(detail)) {
|
|
KuaiShouCampaign campaign = new KuaiShouCampaign();
|
|
KuaiShouCampaign campaign = new KuaiShouCampaign();
|
|
|
|
+ campaign.setId("" + advertiserId + detail.getLong("campaign_id"));
|
|
campaign.setAccountId(advertiserId);
|
|
campaign.setAccountId(advertiserId);
|
|
campaign.setCampaignId(detail.getLong("campaign_id"));
|
|
campaign.setCampaignId(detail.getLong("campaign_id"));
|
|
campaign.setCampaignName(detail.getString("campaign_name"));
|
|
campaign.setCampaignName(detail.getString("campaign_name"));
|
|
campaign.setDayBudget(detail.getLong("day_budget"));
|
|
campaign.setDayBudget(detail.getLong("day_budget"));
|
|
campaign.setStatus(detail.getInteger("status"));
|
|
campaign.setStatus(detail.getInteger("status"));
|
|
- campaignMapper.insert(campaign);
|
|
|
|
|
|
+ kuaiShouCampaignService.saveOrUpdate(campaign);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void getGroupList(CtopOauthToken token) {
|
|
|
|
+ getGroupListByPage(token, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
|
+ static ExecutorService executorService = null;
|
|
|
|
+ static CountDownLatch countDownLatch = null; //线程计数器 如果不用执行完后统一走流程,可以不要这个
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void loadData() throws InterruptedException {
|
|
|
|
+ Date getDate = DateUtils.addDay(new Date(), -1);
|
|
|
|
+// Date getDate = new Date();
|
|
|
|
+ List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
|
|
|
|
+ if (null == tokens || tokens.size() <= 0) {
|
|
|
|
+ log.info("定时获取头条数据异常:为获取到可用的token");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ int times = tokens.size();
|
|
|
|
+ executorService = Executors.newFixedThreadPool(5);
|
|
|
|
+ countDownLatch = new CountDownLatch(times);
|
|
|
|
+ for (CtopOauthToken token : tokens) {
|
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ //1:获取全量广告计划数据
|
|
|
|
+ getCampaignList(token);
|
|
|
|
+ //1:获取全量广告组数据
|
|
|
|
+ getGroupList(token);
|
|
|
|
+ //1:获取全量创意数据
|
|
|
|
+ getCreativeList(token);
|
|
|
|
+ //2:获取全量视频素材数据
|
|
|
|
+ getVideoList(token);
|
|
|
|
+ countDownLatch.countDown();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ countDownLatch.await();
|
|
|
|
+ //关掉线程池
|
|
|
|
+ executorService.shutdown();
|
|
|
|
+
|
|
|
|
+ executorService = Executors.newFixedThreadPool(5);
|
|
|
|
+ countDownLatch = new CountDownLatch(times);
|
|
|
|
+ for (CtopOauthToken token : tokens) {
|
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ getAdvertiserCreativeReportHourly(token, getDate, getDate);
|
|
|
|
+ countDownLatch.countDown();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ countDownLatch.await();
|
|
|
|
+ //关掉线程池
|
|
|
|
+ executorService.shutdown();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void getGroupListByPage(CtopOauthToken token, int page) {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
|
+ param.put("advertiser_id", token.getAccountId());
|
|
|
|
+ param.put("page_size", 200);
|
|
|
|
+ param.put("page", page);
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
|
+ log.error("获取广告组接口异常,advertiserId:{}", token.getAccountId());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ log.error("获取广告组返回结果异常,advertiserId:{},异常信息:{}", token.getAccountId(), resultJson);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
|
+ if (Check.isNull(details)) {
|
|
|
|
+ log.info("获取广告组返回结果为空,advertiserId:{}", token.getAccountId());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ addGroup(token.getAccountId(), details);
|
|
|
|
+ getGroupListByPage(token, page + 1);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取广告组信息 全量
|
|
* 获取广告组信息 全量
|
|
@@ -1174,7 +1366,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private void addGroup(Long advertiserId, JSONArray details) {
|
|
private void addGroup(Long advertiserId, JSONArray details) {
|
|
if (!Check.isNull(details)) {
|
|
if (!Check.isNull(details)) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
@@ -1190,6 +1381,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
group.setCampaignId(detail.getLong("campaign_id"));
|
|
group.setCampaignId(detail.getLong("campaign_id"));
|
|
Long unitId = detail.getLong("unit_id");
|
|
Long unitId = detail.getLong("unit_id");
|
|
group.setUnitId(unitId);
|
|
group.setUnitId(unitId);
|
|
|
|
+ group.setId("" + advertiserId + unitId);
|
|
group.setUnitName(detail.getString("unit_name"));
|
|
group.setUnitName(detail.getString("unit_name"));
|
|
group.setBidType(detail.getInteger("bid_type"));
|
|
group.setBidType(detail.getInteger("bid_type"));
|
|
group.setReviewDetail(detail.getString("review_detail"));
|
|
group.setReviewDetail(detail.getString("review_detail"));
|
|
@@ -1202,7 +1394,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
group.setUrlType(detail.getInteger("url_type"));
|
|
group.setUrlType(detail.getInteger("url_type"));
|
|
group.setAppId(detail.getLong("app_id"));
|
|
group.setAppId(detail.getLong("app_id"));
|
|
group.setAppIconUrl(detail.getString("app_icon_url"));
|
|
group.setAppIconUrl(detail.getString("app_icon_url"));
|
|
- groupMapper.insert(group);
|
|
|
|
|
|
+ kuaiShouGroupService.saveOrUpdate(group);
|
|
// 添加应用信息
|
|
// 添加应用信息
|
|
JSONObject diverseJson = detail.getJSONObject("diverse_data");
|
|
JSONObject diverseJson = detail.getJSONObject("diverse_data");
|
|
if (!Check.isNull(diverseJson)) {
|
|
if (!Check.isNull(diverseJson)) {
|
|
@@ -1235,6 +1427,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void getCreativeList(CtopOauthToken token) {
|
|
|
|
+ getCreativeListByPage(token.getAccessToken(), token.getAccountId(), 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
public void getCreativeListByPage(String accessToken, Long advertiserId, Integer page) {
|
|
public void getCreativeListByPage(String accessToken, Long advertiserId, Integer page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
@@ -1266,7 +1463,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
if (!Check.isNull(detailJson)) {
|
|
if (!Check.isNull(detailJson)) {
|
|
KuaiShouCreative creative = new KuaiShouCreative();
|
|
KuaiShouCreative creative = new KuaiShouCreative();
|
|
- creative.setId(detailJson.getLong("creative_id"));
|
|
|
|
|
|
+ creative.setId("" + advertiserId + detailJson.getLong("creative_id"));
|
|
creative.setAccountId(advertiserId);
|
|
creative.setAccountId(advertiserId);
|
|
creative.setStatus(detailJson.getInteger("status"));
|
|
creative.setStatus(detailJson.getInteger("status"));
|
|
creative.setCampaignId(detailJson.getLong("campaign_id"));
|
|
creative.setCampaignId(detailJson.getLong("campaign_id"));
|
|
@@ -1324,7 +1521,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
videoGet.setAccountId(advertiserId);
|
|
videoGet.setAccountId(advertiserId);
|
|
videoGet.setWidth(detailJson.getInteger("width"));
|
|
videoGet.setWidth(detailJson.getInteger("width"));
|
|
videoGet.setHeight(detailJson.getInteger("height"));
|
|
videoGet.setHeight(detailJson.getInteger("height"));
|
|
- videoGet.setUrl(detailJson.getLong("unit_id"));
|
|
|
|
|
|
+ videoGet.setUrl(detailJson.getString("url"));
|
|
videoGet.setCoverUrl(detailJson.getString("creative_name"));
|
|
videoGet.setCoverUrl(detailJson.getString("creative_name"));
|
|
videoGet.setPhotoId(detailJson.getString("photo_id"));
|
|
videoGet.setPhotoId(detailJson.getString("photo_id"));
|
|
//videoGet.setSignature(UUID.randomUUID().toString());
|
|
//videoGet.setSignature(UUID.randomUUID().toString());
|
|
@@ -1374,7 +1571,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
if (!Check.isNull(detailJson)) {
|
|
if (!Check.isNull(detailJson)) {
|
|
KuaiShouCreative creative = new KuaiShouCreative();
|
|
KuaiShouCreative creative = new KuaiShouCreative();
|
|
- creative.setId(detailJson.getLong("creative_id"));
|
|
|
|
|
|
+ creative.setId("" + advertiserId + detailJson.getLong("creative_id"));
|
|
creative.setAccountId(advertiserId);
|
|
creative.setAccountId(advertiserId);
|
|
creative.setStatus(detailJson.getInteger("status"));
|
|
creative.setStatus(detailJson.getInteger("status"));
|
|
creative.setCampaignId(detailJson.getLong("campaign_id"));
|
|
creative.setCampaignId(detailJson.getLong("campaign_id"));
|