|
@@ -183,7 +183,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
private void getVideoListByPage(CtopOauthToken token, String startDate, String endDate, int page) {
|
|
|
try {
|
|
|
- log.info("获取视频数据,accountId:{}", token.getAccountId());
|
|
|
+ // log.info("获取视频数据,accountId:{}", token.getAccountId());
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
@@ -2771,7 +2771,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void getPopulationList(Long accountId, String accessToken) {
|
|
|
+ public void getPopulationList(Long accountId, String accessToken, Integer page) {
|
|
|
try {
|
|
|
log.info("获取人群包列表,accountId:{}", accountId);
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.POPULATION_LIST;
|
|
@@ -2781,7 +2781,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
JSONObject requestJson = new JSONObject();
|
|
|
requestJson.put("advertiser_id", accountId);
|
|
|
requestJson.put("status", 4);
|
|
|
- requestJson.put("page", 1);
|
|
|
+ requestJson.put("page", page);
|
|
|
requestJson.put("page_size", 500);
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
@@ -2789,37 +2789,37 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
Integer code = resultJson.getInteger("code");
|
|
|
if (code == 0) {
|
|
|
JSONObject dataDetailJson = resultJson.getJSONObject("data");
|
|
|
- if (!Check.isNull(dataDetailJson)) {
|
|
|
- Map<String, Object> deleteMap = new HashMap<>();
|
|
|
+ if (Check.isNull(dataDetailJson)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray details = dataDetailJson.getJSONArray("details");
|
|
|
+ if (Check.isNull(details)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- JSONArray details = dataDetailJson.getJSONArray("details");
|
|
|
- if (Check.isNull(details)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- deleteMap.put("account_id", accountId);
|
|
|
- populationService.removeByMap(deleteMap);
|
|
|
- for (int i = 0; i < details.size(); i++) {
|
|
|
- JSONObject dataJson = details.getJSONObject(i);
|
|
|
- if (!Check.isNull(dataJson)) {
|
|
|
- KuaishouPopulation population = new KuaishouPopulation();
|
|
|
- population.setOrientationId(dataJson.getLong("orientation_id"));
|
|
|
- population.setOrientationName(dataJson.getString("orientation_name"));
|
|
|
- population.setType(dataJson.getInteger("type"));
|
|
|
- population.setPopulationType(dataJson.getInteger("population_type"));
|
|
|
- population.setRecordSize(dataJson.getLong("record_size"));
|
|
|
- population.setMatchSize(dataJson.getLong("match_size"));
|
|
|
- population.setCoverNum(dataJson.getLong("cover_num"));
|
|
|
- population.setStatus(dataJson.getInteger("status"));
|
|
|
- population.setPutTime(dataJson.getDate("create_time"));
|
|
|
- population.setThirdPlatformCode(dataJson.getLong("third_platform_code"));
|
|
|
- population.setAccountId(accountId);
|
|
|
- populationService.save(population);
|
|
|
+ List<KuaishouPopulation> addList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ JSONObject dataJson = details.getJSONObject(i);
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
+ KuaishouPopulation population = new KuaishouPopulation();
|
|
|
+ population.setOrientationId(dataJson.getLong("orientation_id"));
|
|
|
+ population.setOrientationName(dataJson.getString("orientation_name"));
|
|
|
+ population.setType(dataJson.getInteger("type"));
|
|
|
+ population.setPopulationType(dataJson.getInteger("population_type"));
|
|
|
+ population.setRecordSize(dataJson.getLong("record_size"));
|
|
|
+ population.setMatchSize(dataJson.getLong("match_size"));
|
|
|
+ population.setCoverNum(dataJson.getLong("cover_num"));
|
|
|
+ population.setStatus(dataJson.getInteger("status"));
|
|
|
+ population.setPutTime(dataJson.getDate("create_time"));
|
|
|
+ population.setThirdPlatformCode(dataJson.getLong("third_platform_code"));
|
|
|
+ population.setAccountId(accountId);
|
|
|
+ addList.add(population);
|
|
|
+ // populationService.save(population);
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ populationService.replaceBatch(addList);
|
|
|
+ getPopulationList(accountId, accessToken, page + 1);
|
|
|
} else {
|
|
|
log.error("获取人群包管理返回数据为空,accountId:{}", accountId);
|
|
|
|
|
@@ -3340,37 +3340,34 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (!Check.isNull(resultJson)) {
|
|
|
Integer code = resultJson.getInteger("code");
|
|
|
if (code == 0) {
|
|
|
- if (page == 1) { //分页保存数据,如果页数为1,删除之前的数据重新入库
|
|
|
- Map<String, Object> deleteMap = new HashMap<>();
|
|
|
- deleteMap.put("account_id", advertiserId);
|
|
|
- appListMapper.deleteByMap(deleteMap);
|
|
|
- }
|
|
|
JSONObject data = resultJson.getJSONObject("data");
|
|
|
- if (!Check.isNull(data)) {
|
|
|
- Integer totalCount = data.getInteger("total_count");
|
|
|
- JSONArray dataArr = data.getJSONArray("details");
|
|
|
- for (int i = 0; i < dataArr.size(); i++) {
|
|
|
- JSONObject dataJson = JSONObject.parseObject(dataArr.get(i).toString());
|
|
|
- if (!Check.isNull(dataJson)) {
|
|
|
- KuaiShouAppList appList = new KuaiShouAppList();
|
|
|
- appList.setAccountId(advertiserId);
|
|
|
- appList.setPlatform(dataJson.getInteger("platform"));
|
|
|
- appList.setUrl(dataJson.getString("url"));
|
|
|
- appList.setAppId(dataJson.getLong("app_id"));
|
|
|
- appList.setAppVersion(dataJson.getString("app_version"));
|
|
|
- appList.setAppName(dataJson.getString("app_name"));
|
|
|
- appList.setAppIconUrl(dataJson.getString("app_icon_url"));
|
|
|
- appList.setImageToken(dataJson.getString("image_token"));
|
|
|
- appList.setPackageName(dataJson.getString("package_name"));
|
|
|
- appList.setReturnTime(DateUtils.timeStamp2Date(dataJson.getTimestamp("update_time")));
|
|
|
- appListMapper.insert(appList);
|
|
|
- }
|
|
|
- }
|
|
|
- Integer totalPage = (totalCount - 1) / pageSize + 1;
|
|
|
- if (page < totalPage) {
|
|
|
- getAppList2ByPage(advertiserId, accessToken, page + 1, pageSize);
|
|
|
+ if (Check.isNull(data)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray dataArr = data.getJSONArray("details");
|
|
|
+ if (Check.isNull(dataArr)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<KuaiShouAppList> addList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < dataArr.size(); i++) {
|
|
|
+ JSONObject dataJson = JSONObject.parseObject(dataArr.get(i).toString());
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
+ KuaiShouAppList appList = new KuaiShouAppList();
|
|
|
+ appList.setAccountId(advertiserId);
|
|
|
+ appList.setPlatform(dataJson.getInteger("platform"));
|
|
|
+ appList.setUrl(dataJson.getString("url"));
|
|
|
+ appList.setAppId(dataJson.getLong("app_id"));
|
|
|
+ appList.setAppVersion(dataJson.getString("app_version"));
|
|
|
+ appList.setAppName(dataJson.getString("app_name"));
|
|
|
+ appList.setAppIconUrl(dataJson.getString("app_icon_url"));
|
|
|
+ appList.setImageToken(dataJson.getString("image_token"));
|
|
|
+ appList.setPackageName(dataJson.getString("package_name"));
|
|
|
+ appList.setReturnTime(DateUtils.timeStamp2Date(dataJson.getTimestamp("update_time")));
|
|
|
+ addList.add(appList);
|
|
|
}
|
|
|
}
|
|
|
+ appListMapper.replaceBatch(addList);
|
|
|
+ getAppList2ByPage(advertiserId, accessToken, page + 1, pageSize);
|
|
|
} else {
|
|
|
log.error("获取应用列表失败,返回信息:{}", resultJson);
|
|
|
}
|