|
|
@@ -49,9 +49,12 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getProjectList(Long advertiserId, String type, String date, Integer page) {
|
|
|
- if (!Check.isNull(type))
|
|
|
- log.info("--------执行:{}", advertiserId);
|
|
|
+ public void getProjectList(Long advertiserId, String date) {
|
|
|
+ this.getProjectListVo(advertiserId, null, date, 1, 1);
|
|
|
+ this.getProjectListVo(advertiserId, "del", date, 1, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getProjectListVo(Long advertiserId, String type, String date, Integer page, int count) {
|
|
|
try {
|
|
|
boolean nextPage = false;
|
|
|
String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
@@ -72,10 +75,9 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
String url = "https://api.oceanengine.com/open_api/v3.0/project/list/";
|
|
|
String results = HttpUtils.httpGet(url, params, HttpUtils.postMHeaders(accessToken));
|
|
|
JSONObject obj = JSONObject.parseObject(results);
|
|
|
-// System.out.println("入参:" + params);
|
|
|
-// System.out.println("结果:" + obj);
|
|
|
Integer code = obj.getInteger("code");
|
|
|
if (code == 0) {
|
|
|
+ log.info("---账户({})获取项目成功", advertiserId);
|
|
|
JSONObject data = obj.getJSONObject("data");
|
|
|
Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
|
|
|
if (totalPage != 0 && totalPage > data.getJSONObject("page_info").getInteger("page")) {
|
|
|
@@ -90,14 +92,15 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
if (!Check.isNull(projectList))
|
|
|
bytedanceCdpProjectMapper.replaceBytedanceCdpProjectList(projectList);
|
|
|
} else {
|
|
|
+ //40100请求超频
|
|
|
+ if (40100 == code && count <= 3)
|
|
|
+ getProjectListVo(advertiserId, type, date, page, count + 1);
|
|
|
log.error("获取项目列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
|
- bytedanceCdpProjectMapper.insertErrorAdvertiserId(advertiserId);
|
|
|
}
|
|
|
if (nextPage) {
|
|
|
- getProjectList(advertiserId, type, date, page + 1);
|
|
|
+ getProjectListVo(advertiserId, type, date, page + 1, 1);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- bytedanceCdpProjectMapper.insertErrorAdvertiserId(advertiserId);
|
|
|
e.printStackTrace();
|
|
|
log.error(e.getMessage());
|
|
|
}
|
|
|
@@ -110,45 +113,52 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
|
|
|
private void getByteAppInfoVo(Long advertiserId, String searchType, Integer page, int count) {
|
|
|
- log.info("------执行{}", advertiserId);
|
|
|
- boolean nextPage = false;
|
|
|
- String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
- if (Check.isNull(accessToken)) {
|
|
|
- log.error("账户({})查询token失败", advertiserId);
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id", advertiserId);
|
|
|
- params.put("page", page);
|
|
|
- //页面大小,默认值为10,最大值100
|
|
|
- params.put("page_size", 100);
|
|
|
- JSONObject filtering = new JSONObject();
|
|
|
- //CREATE_ONLY本户创建,SHARE_ONLY 只查共享应用
|
|
|
- filtering.put("search_type", searchType);
|
|
|
+ try {
|
|
|
+ boolean nextPage = false;
|
|
|
+ String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
+ if (Check.isNull(accessToken)) {
|
|
|
+ log.error("账户({})查询token失败", advertiserId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", advertiserId);
|
|
|
+ params.put("page", page);
|
|
|
+ //页面大小,默认值为10,最大值100
|
|
|
+ params.put("page_size", 100);
|
|
|
+ JSONObject filtering = new JSONObject();
|
|
|
+ //CREATE_ONLY本户创建,SHARE_ONLY 只查共享应用
|
|
|
+ filtering.put("search_type", searchType);
|
|
|
// filtering.put("audit_status", "AUDIT_ACCEPTED");
|
|
|
- params.put("filtering", filtering);
|
|
|
- //获取微信小程序列表
|
|
|
- String url = "https://api.oceanengine.com/open_api/v3.0/tools/micro_app/list/";
|
|
|
- JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
|
|
|
- Integer code = obj.getInteger("code");
|
|
|
- if (code == 0) {
|
|
|
- JSONObject data = obj.getJSONObject("data");
|
|
|
- Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
|
|
|
- if (totalPage != 0 && totalPage > data.getJSONObject("page_info").getInteger("page")) {
|
|
|
- nextPage = true;
|
|
|
+ params.put("filtering", filtering);
|
|
|
+ //获取微信小程序列表
|
|
|
+ String url = "https://api.oceanengine.com/open_api/v3.0/tools/micro_app/list/";
|
|
|
+ JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
|
|
|
+ Integer code = obj.getInteger("code");
|
|
|
+ if (code == 0) {
|
|
|
+ log.info("---账户({})获取抖小信息成功", advertiserId);
|
|
|
+ JSONObject data = obj.getJSONObject("data");
|
|
|
+ Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
|
|
|
+ if (totalPage != 0 && totalPage > data.getJSONObject("page_info").getInteger("page")) {
|
|
|
+ nextPage = true;
|
|
|
+ }
|
|
|
+ JSONArray list = data.getJSONArray("list");
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
+ bytedanceCdpProjectMapper.replaceBytedanceByteAppInfo(list, advertiserId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //40110请求超频
|
|
|
+ if (40110 == code && count <= 3)
|
|
|
+ getByteAppInfoVo(advertiserId, searchType, page, count + 1);
|
|
|
+ log.error("账户({})获取抖小列表失败,入参:{}\n结果:{}", advertiserId, JSONObject.toJSONString(params), obj);
|
|
|
+ bytedanceCdpProjectMapper.insertErrorAdvertiserId(advertiserId, "tt");
|
|
|
}
|
|
|
- JSONArray list = data.getJSONArray("list");
|
|
|
- if (!Check.isNull(list)) {
|
|
|
- bytedanceCdpProjectMapper.replaceBytedanceByteAppInfo(list, advertiserId);
|
|
|
+ if (nextPage) {
|
|
|
+ getByteAppInfoVo(advertiserId, searchType, page + 1, 1);
|
|
|
}
|
|
|
- } else {
|
|
|
- //40110请求超频
|
|
|
- if (40110 == code && count <= 3)
|
|
|
- getByteAppInfoVo(advertiserId, searchType, page, count + 1);
|
|
|
- log.error("账户{}获取字节小程序列表失败,入参:{}\n结果:{}", advertiserId, JSONObject.toJSONString(params), obj);
|
|
|
- }
|
|
|
- if (nextPage) {
|
|
|
- getByteAppInfoVo(advertiserId, searchType, page + 1, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ bytedanceCdpProjectMapper.insertErrorAdvertiserId(advertiserId, "tt");
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -159,45 +169,53 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
|
|
|
private void getWxAppInfoVo(Long advertiserId, String searchType, Integer page, int count) {
|
|
|
- boolean nextPage = false;
|
|
|
- String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
- if (Check.isNull(accessToken)) {
|
|
|
- log.error("账户({})查询token失败", advertiserId);
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id", advertiserId);
|
|
|
- params.put("page", page);
|
|
|
- //页面大小,默认值为10,最大值100
|
|
|
- params.put("page_size", 100);
|
|
|
- JSONObject filtering = new JSONObject();
|
|
|
- //CREATE_ONLY本户创建,SHARE_ONLY 只查共享应用
|
|
|
- filtering.put("search_type", searchType);
|
|
|
- //状态 审核通过:AUDIT_ACCEPTED
|
|
|
+ try {
|
|
|
+ boolean nextPage = false;
|
|
|
+ String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
+ if (Check.isNull(accessToken)) {
|
|
|
+ log.error("账户({})查询token失败", advertiserId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", advertiserId);
|
|
|
+ params.put("page", page);
|
|
|
+ //页面大小,默认值为10,最大值100
|
|
|
+ params.put("page_size", 100);
|
|
|
+ JSONObject filtering = new JSONObject();
|
|
|
+ //CREATE_ONLY本户创建,SHARE_ONLY 只查共享应用
|
|
|
+ filtering.put("search_type", searchType);
|
|
|
+ //状态 审核通过:AUDIT_ACCEPTED
|
|
|
// filtering.put("audit_status", "AUDIT_ACCEPTED");
|
|
|
- params.put("filtering", filtering);
|
|
|
- //获取微信小程序列表
|
|
|
- String url = "https://api.oceanengine.com/open_api/v3.0/tools/wechat_applet/list/";
|
|
|
- JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
|
|
|
- Integer code = obj.getInteger("code");
|
|
|
- if (code == 0) {
|
|
|
- JSONObject data = obj.getJSONObject("data");
|
|
|
- Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
|
|
|
- if (totalPage != 0 && totalPage > data.getJSONObject("page_info").getInteger("page")) {
|
|
|
- nextPage = true;
|
|
|
+ params.put("filtering", filtering);
|
|
|
+ //获取微信小程序列表
|
|
|
+ String url = "https://api.oceanengine.com/open_api/v3.0/tools/wechat_applet/list/";
|
|
|
+ JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
|
|
|
+ Integer code = obj.getInteger("code");
|
|
|
+ if (code == 0) {
|
|
|
+ log.info("---账户({})获取微小信息成功", advertiserId);
|
|
|
+ JSONObject data = obj.getJSONObject("data");
|
|
|
+ Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
|
|
|
+ if (totalPage != 0 && totalPage > data.getJSONObject("page_info").getInteger("page")) {
|
|
|
+ nextPage = true;
|
|
|
+ }
|
|
|
+ JSONArray list = data.getJSONArray("list");
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
+ bytedanceCdpProjectMapper.replaceBytedanceWxAppInfo(list, advertiserId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //40110请求超频
|
|
|
+ if (40110 == code && count <= 3)
|
|
|
+ getWxAppInfoVo(advertiserId, searchType, page, count + 1);
|
|
|
+ log.error("账户({})获取微小列表失败,入参:{}\n结果:{}", advertiserId, JSONObject.toJSONString(params), obj);
|
|
|
+ bytedanceCdpProjectMapper.insertErrorAdvertiserId(advertiserId, "wx");
|
|
|
}
|
|
|
- JSONArray list = data.getJSONArray("list");
|
|
|
- if (!Check.isNull(list)) {
|
|
|
- bytedanceCdpProjectMapper.replaceBytedanceWxAppInfo(list, advertiserId);
|
|
|
+ if (nextPage) {
|
|
|
+ getWxAppInfoVo(advertiserId, searchType, page + 1, 1);
|
|
|
}
|
|
|
- } else {
|
|
|
- //40110请求超频
|
|
|
- if (40110 == code && count <= 3)
|
|
|
- getByteAppInfoVo(advertiserId, searchType, page, count + 1);
|
|
|
- log.error("账户{}获取微信小程序列表失败,入参:{}\n结果:{}", advertiserId, JSONObject.toJSONString(params), obj);
|
|
|
- }
|
|
|
- if (nextPage) {
|
|
|
- getWxAppInfoVo(advertiserId, searchType, page + 1, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ bytedanceCdpProjectMapper.insertErrorAdvertiserId(advertiserId, "wx");
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|