|
@@ -77,6 +77,75 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public void getpromotionList(Long advertiserId, String date) {
|
|
|
|
|
+ this.getpromotionListVo(advertiserId, date, 1, 1);
|
|
|
|
|
+// this.getProjectListVo(advertiserId, "del", date, 1, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void getpromotionListVo(Long advertiserId, String date, Integer page, int count) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ boolean nextPage = false;
|
|
|
|
|
+ String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
|
|
+ if (Check.isNull(accessToken)) {
|
|
|
|
|
+ log.error("账户({})查询token失败", advertiserId);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+ params.put("advertiser_id", advertiserId);
|
|
|
|
|
+ JSONObject filtering = new JSONObject();
|
|
|
|
|
+// filtering.put("promotion_modify_time", date);
|
|
|
|
|
+// params.put("filtering", filtering);
|
|
|
|
|
+ params.put("page", page);
|
|
|
|
|
+ params.put("page_size", 20);//最大100
|
|
|
|
|
+ String url = "https://api.oceanengine.com/open_api/v3.0/promotion/list/";
|
|
|
|
|
+ String results = HttpUtils.httpGet(url, params, HttpUtils.postMHeaders(accessToken));
|
|
|
|
|
+ JSONObject obj = JSONObject.parseObject(results);
|
|
|
|
|
+ if (!Check.isNull(obj)) {
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONArray array = data.getJSONArray("list");
|
|
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
|
|
+ checkPromotionInfo(array.getJSONObject(i));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!Check.isNull(array))
|
|
|
|
|
+ if (bytedanceCdpProjectMapper.replaceBytedancePromotionList(array) > 0)
|
|
|
|
|
+ log.info("---账户({})广告更新成功", advertiserId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //40100请求超频
|
|
|
|
|
+ if (40100 == code && count <= 5) {
|
|
|
|
|
+ Thread.sleep(800);
|
|
|
|
|
+ getpromotionListVo(advertiserId, date, page, count + 1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("获取广告列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (nextPage) {
|
|
|
|
|
+ getpromotionListVo(advertiserId, date, page + 1, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void checkPromotionInfo(JSONObject entity) {
|
|
|
|
|
+ JSONObject promotionMaterials = entity.getJSONObject("promotion_materials");
|
|
|
|
|
+ if (!Check.isNull(promotionMaterials)) {
|
|
|
|
|
+ JSONObject miniProgramInfo = promotionMaterials.getJSONObject("mini_program_info");
|
|
|
|
|
+ entity.put("params", miniProgramInfo.getString("params"));
|
|
|
|
|
+ entity.put("app_id", miniProgramInfo.getString("app_id"));
|
|
|
|
|
+ entity.put("url", miniProgramInfo.getString("url"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public void getProjectList(Long advertiserId, String date) {
|
|
public void getProjectList(Long advertiserId, String date) {
|
|
|
this.getProjectListVo(advertiserId, null, date, 1, 1);
|
|
this.getProjectListVo(advertiserId, null, date, 1, 1);
|
|
|
// this.getProjectListVo(advertiserId, "del", date, 1, 1);
|
|
// this.getProjectListVo(advertiserId, "del", date, 1, 1);
|