|
|
@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.service.IBytedanceProjectService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.CorpWexinUtils;
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
+import cn.com.ctop.common.module.utils.RateLimitUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -31,6 +32,9 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
|
|
|
@Resource
|
|
|
BytedanceProjectMapper projectListMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RateLimitUtil rateLimitUtil;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
@@ -49,7 +53,11 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
|
|
|
JSONObject filtering = new JSONObject();
|
|
|
filtering.put("ids", ids);
|
|
|
param.put("filtering", filtering);
|
|
|
- JSONObject resultObject = HttpUtils.bytedanceGetRequest(token, url, param);
|
|
|
+
|
|
|
+ JSONObject resultObject = new JSONObject();
|
|
|
+ if (rateLimitUtil.acquire("1635316529903624", url)) {
|
|
|
+ resultObject = HttpUtils.bytedanceGetRequest(token, url, param);
|
|
|
+ }
|
|
|
if (Check.isNull(resultObject)) {
|
|
|
log.error("获取广告列表异常==》accountId:{},调用结果为null", accountId);
|
|
|
return;
|
|
|
@@ -315,7 +323,12 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
|
|
|
filtering.put("ids", new ArrayList<>(ids));
|
|
|
}
|
|
|
param.put("filtering", filtering);
|
|
|
- JSONObject resultObject = HttpUtils.bytedanceGetRequest(accessToken, url, param);
|
|
|
+
|
|
|
+ JSONObject resultObject = new JSONObject();
|
|
|
+ if (rateLimitUtil.acquire("1635316529903624", url)) {
|
|
|
+ resultObject = HttpUtils.bytedanceGetRequest(accessToken, url, param);
|
|
|
+ }
|
|
|
+
|
|
|
if (Check.isNull(resultObject)) {
|
|
|
log.error("checkAdvertiserProject异常==》accountId:{},结果为null", accountId);
|
|
|
return returnMap;
|
|
|
@@ -375,7 +388,12 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
|
|
|
list.add(data);
|
|
|
params.put("data", list);
|
|
|
String url = bytedanceApiUrl + "/v3.0/project/status/update/";
|
|
|
- JSONObject object = HttpUtils.bytedancePostRequest(token, url, params);
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ if (rateLimitUtil.acquire("1635316529903624", url)) {
|
|
|
+ object = HttpUtils.bytedancePostRequest(token, url, params);
|
|
|
+ }
|
|
|
+
|
|
|
if (!Check.isNull(object)) {
|
|
|
Integer code = object.getInteger("code");
|
|
|
if (code == 0) {
|