|
|
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.Instant;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -52,11 +53,21 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<Long> queryTTErrApps() {
|
|
|
+ return bytedanceCdpProjectMapper.queryTTErrApps();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public boolean delErrApps(String type) {
|
|
|
return bytedanceCdpProjectMapper.delErrApps(type);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public boolean delTTErrApps() {
|
|
|
+ return bytedanceCdpProjectMapper.delTTErrApps();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<Long> queryAdvertiserIds(String db, String date) {
|
|
|
return bytedanceCdpProjectMapper.queryAdvertiserIds(db, date);
|
|
|
}
|
|
|
@@ -129,6 +140,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
public void getByteAppInfo(Long advertiserId) {
|
|
|
this.getByteAppInfoVo(advertiserId, "CREATE_ONLY", 1, 1);
|
|
|
this.getByteAppInfoVo(advertiserId, "SHARE_ONLY", 1, 1);
|
|
|
+ this.getByteAppLinkInfo(advertiserId);
|
|
|
}
|
|
|
|
|
|
private void getByteAppInfoVo(Long advertiserId, String searchType, Integer page, int count) {
|
|
|
@@ -186,6 +198,66 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void getByteAppLinkInfo(Long advertiserId) {
|
|
|
+ String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
+ if (Check.isNull(accessToken)) {
|
|
|
+ log.error("账户({})查询token失败", advertiserId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> ids = bytedanceCdpProjectMapper.queryAppInstanceIdList(advertiserId);
|
|
|
+ for (String id : ids) {
|
|
|
+ this.getByteAppLinkInfoVo(accessToken, advertiserId, id, 1, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getByteAppLinkInfoVo(String accessToken, Long advertiserId, String instanceId, Integer page, int count) {
|
|
|
+ try {
|
|
|
+ boolean nextPage = false;
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", advertiserId);
|
|
|
+ params.put("page", page);
|
|
|
+ params.put("page_size", 100);
|
|
|
+ JSONObject filtering = new JSONObject();
|
|
|
+ filtering.put("instance_id", Long.valueOf(instanceId));
|
|
|
+ params.put("filtering", filtering);
|
|
|
+ //获取微信小程序列表
|
|
|
+ String url = "https://api.oceanengine.com/open_api/v3.0/tools/asset_link/list/";
|
|
|
+ JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
|
|
|
+ if (!Check.isNull(obj)) {
|
|
|
+ Integer code = obj.getInteger("code");
|
|
|
+ if (code == 0) {
|
|
|
+ JSONObject data = obj.getJSONObject("data");
|
|
|
+ System.out.println(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))
|
|
|
+ if (bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfo(list) > 0)
|
|
|
+ log.info("---账户({})抖小详情信息更新成功", advertiserId);
|
|
|
+ } else {
|
|
|
+ //40110请求超频 51010 内部服务超时
|
|
|
+ if ((40110 == code || 51010 == code) && count <= 3) {
|
|
|
+ Thread.sleep(700);
|
|
|
+ getByteAppLinkInfoVo(accessToken, advertiserId, instanceId, page, count + 1);
|
|
|
+ } else {
|
|
|
+ bytedanceCdpProjectMapper.insertTTErrorAdvertiserId(advertiserId);
|
|
|
+ log.error("账户({})获取字节小程序/小游戏详情内容失败,入参:{}\n结果:{}", advertiserId, JSONObject.toJSONString(params), obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (nextPage) {
|
|
|
+ getByteAppLinkInfoVo(accessToken, advertiserId, instanceId, page + 1, count);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ bytedanceCdpProjectMapper.insertTTErrorAdvertiserId(advertiserId);
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void getWxAppInfo(Long advertiserId) {
|
|
|
this.getWxAppInfoVo(advertiserId, "CREATE_ONLY", 1, 1);
|
|
|
this.getWxAppInfoVo(advertiserId, "SHARE_ONLY", 1, 1);
|