|
@@ -12,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 头条项目列Service业务层处理
|
|
* 头条项目列Service业务层处理
|
|
@@ -53,7 +50,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<Long> queryPageAdvertiserIds() {
|
|
|
|
|
|
|
+ public List<JSONObject> queryPageAdvertiserIds() {
|
|
|
return bytedanceCdpProjectMapper.queryPageAdvertiserIds();
|
|
return bytedanceCdpProjectMapper.queryPageAdvertiserIds();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -438,14 +435,15 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getAdqCreatives(Long advertiserId, String date) {
|
|
|
|
|
|
|
+ public void getAdqCreatives(Long advertiserId, String startDate,String endDate) {
|
|
|
try {
|
|
try {
|
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
|
if (Check.isNull(accessToken)) {
|
|
if (Check.isNull(accessToken)) {
|
|
|
log.error("账户({})accessToken is null", advertiserId);
|
|
log.error("账户({})accessToken is null", advertiserId);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- this.rebackadqCreativesVo(advertiserId, accessToken, date, 1, true, 1);
|
|
|
|
|
|
|
+ this.rebackadqCreativesVo(advertiserId, accessToken, startDate, endDate, 1, true, 1);
|
|
|
|
|
+ this.rebackadqCreativesVo(advertiserId, accessToken, startDate, endDate, 1, false, 1);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
log.error("账户({})获取动态创意异常", e.getMessage());
|
|
log.error("账户({})获取动态创意异常", e.getMessage());
|
|
@@ -453,9 +451,8 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- private void rebackadqCreativesVo(Long accountId, String accessToken, String date, Integer page, Boolean isDeleted, int count) throws Exception {
|
|
|
|
|
|
|
+ private void rebackadqCreativesVo(Long accountId, String accessToken, String startDate, String endDate, Integer page, Boolean isDeleted, int count) throws Exception {
|
|
|
boolean nextPage = false;
|
|
boolean nextPage = false;
|
|
|
- JSONObject returnJson = new JSONObject();
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
|
param.put("timestamp", String.valueOf(timestamp));
|
|
param.put("timestamp", String.valueOf(timestamp));
|
|
@@ -464,29 +461,36 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
param.put("account_id", accountId);
|
|
param.put("account_id", accountId);
|
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
|
param.put("page_size", 100);
|
|
param.put("page_size", 100);
|
|
|
- if (!Check.isNull(date)) {
|
|
|
|
|
- JSONArray filtering = new JSONArray();
|
|
|
|
|
|
|
+ JSONArray filtering = new JSONArray();
|
|
|
|
|
+ if (!Check.isNull(startDate)) {
|
|
|
JSONObject greObj = new JSONObject();
|
|
JSONObject greObj = new JSONObject();
|
|
|
- greObj.put("field", "created_time");
|
|
|
|
|
|
|
+ greObj.put("field", "last_modified_time");
|
|
|
greObj.put("operator", "GREATER_EQUALS");
|
|
greObj.put("operator", "GREATER_EQUALS");
|
|
|
JSONArray startDateVls = new JSONArray();
|
|
JSONArray startDateVls = new JSONArray();
|
|
|
- startDateVls.add(String.valueOf(DateUtils.dt2milli(date + " 00:00:00")));
|
|
|
|
|
|
|
+ startDateVls.add(String.valueOf(DateUtils.dt2milli(startDate + " 00:00:00")));
|
|
|
greObj.put("values", startDateVls);
|
|
greObj.put("values", startDateVls);
|
|
|
filtering.add(greObj);
|
|
filtering.add(greObj);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!Check.isNull(endDate)) {
|
|
|
JSONObject lesObj = new JSONObject();
|
|
JSONObject lesObj = new JSONObject();
|
|
|
- lesObj.put("field", "created_time");
|
|
|
|
|
|
|
+ lesObj.put("field", "last_modified_time");
|
|
|
lesObj.put("operator", "LESS_EQUALS");
|
|
lesObj.put("operator", "LESS_EQUALS");
|
|
|
JSONArray endDateVls = new JSONArray();
|
|
JSONArray endDateVls = new JSONArray();
|
|
|
- endDateVls.add(String.valueOf(DateUtils.dt2milli(date + " 23:59:59")));
|
|
|
|
|
|
|
+ endDateVls.add(String.valueOf(DateUtils.dt2milli(endDate + " 23:59:59")));
|
|
|
lesObj.put("values", endDateVls);
|
|
lesObj.put("values", endDateVls);
|
|
|
filtering.add(lesObj);
|
|
filtering.add(lesObj);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!Check.isNull(filtering)) {
|
|
|
param.put("filtering", filtering);
|
|
param.put("filtering", filtering);
|
|
|
}
|
|
}
|
|
|
-// param.put("is_deleted", isDeleted);
|
|
|
|
|
|
|
+ param.put("is_deleted", isDeleted);
|
|
|
JSONArray fields = new JSONArray();
|
|
JSONArray fields = new JSONArray();
|
|
|
fields.add("adgroup_id");
|
|
fields.add("adgroup_id");
|
|
|
fields.add("dynamic_creative_id");
|
|
fields.add("dynamic_creative_id");
|
|
|
fields.add("creative_components");
|
|
fields.add("creative_components");
|
|
|
|
|
+ fields.add("created_time");
|
|
|
|
|
+ fields.add("last_modified_time");
|
|
|
param.put("fields", fields);
|
|
param.put("fields", fields);
|
|
|
String result = HttpUtils.httpGet("https://api.e.qq.com/v3.0/dynamic_creatives/get", param, new HashMap<>());
|
|
String result = HttpUtils.httpGet("https://api.e.qq.com/v3.0/dynamic_creatives/get", param, new HashMap<>());
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
@@ -518,26 +522,26 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
} else {
|
|
} else {
|
|
|
if (count <= 4) {
|
|
if (count <= 4) {
|
|
|
Thread.sleep(500);
|
|
Thread.sleep(500);
|
|
|
- rebackadqCreativesVo(accountId, accessToken, date, page, isDeleted, count + 1);
|
|
|
|
|
|
|
+ rebackadqCreativesVo(accountId, accessToken, startDate, endDate, page, isDeleted, count + 1);
|
|
|
} else {
|
|
} else {
|
|
|
log.error("账户({})获取动态创意失败,入参:{}\n,结果:{}", accountId, JSONObject.toJSONString(param), obj);
|
|
log.error("账户({})获取动态创意失败,入参:{}\n,结果:{}", accountId, JSONObject.toJSONString(param), obj);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (nextPage) {
|
|
if (nextPage) {
|
|
|
- rebackadqCreativesVo(accountId, accessToken, date, page + 1, isDeleted, 1);
|
|
|
|
|
|
|
+ rebackadqCreativesVo(accountId, accessToken, startDate ,endDate, page + 1, isDeleted, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getAdqWechatPages(Long advertiserId) {
|
|
|
|
|
|
|
+ public void getAdqWechatPages(Long advertiserId,Long pageId) {
|
|
|
try {
|
|
try {
|
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
|
if (Check.isNull(accessToken)) {
|
|
if (Check.isNull(accessToken)) {
|
|
|
log.error("账户({})accessToken is null", advertiserId);
|
|
log.error("账户({})accessToken is null", advertiserId);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- this.getAdqWechatPagesVo(advertiserId, accessToken, 1, true, 1);
|
|
|
|
|
|
|
+ this.getAdqWechatPagesVo(advertiserId,pageId, accessToken, 1, true, 1);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
log.error("账户({})获取原生落地页异常", e.getMessage());
|
|
log.error("账户({})获取原生落地页异常", e.getMessage());
|
|
@@ -545,9 +549,8 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- private void getAdqWechatPagesVo(Long accountId, String accessToken, Integer page, Boolean isDeleted, int count) throws Exception {
|
|
|
|
|
|
|
+ private void getAdqWechatPagesVo(Long accountId,Long pageId, String accessToken, Integer page, Boolean isDeleted, int count) throws Exception {
|
|
|
boolean nextPage = false;
|
|
boolean nextPage = false;
|
|
|
- JSONObject returnJson = new JSONObject();
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
|
param.put("timestamp", String.valueOf(timestamp));
|
|
param.put("timestamp", String.valueOf(timestamp));
|
|
@@ -561,9 +564,15 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
greObj.put("field", "page_type");
|
|
greObj.put("field", "page_type");
|
|
|
greObj.put("operator", "EQUALS");
|
|
greObj.put("operator", "EQUALS");
|
|
|
greObj.put("values", "PAGE_TYPE_WECHAT_CANVAS");
|
|
greObj.put("values", "PAGE_TYPE_WECHAT_CANVAS");
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject pageFilter = new JSONObject();
|
|
|
|
|
+ pageFilter.put("field", "page_id");
|
|
|
|
|
+ pageFilter.put("operator", "EQUALS");
|
|
|
|
|
+ pageFilter.put("values", Collections.singletonList(String.valueOf(pageId)));
|
|
|
filtering.add(greObj);
|
|
filtering.add(greObj);
|
|
|
|
|
+ filtering.add(pageFilter);
|
|
|
|
|
|
|
|
-// param.put("filtering", filtering);
|
|
|
|
|
|
|
+ param.put("filtering", filtering);
|
|
|
String result = HttpUtils.httpGet("https://api.e.qq.com/v3.0/wechat_pages/get", param, new HashMap<>());
|
|
String result = HttpUtils.httpGet("https://api.e.qq.com/v3.0/wechat_pages/get", param, new HashMap<>());
|
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
JSONObject obj = JSONObject.parseObject(result);
|
|
|
if (!Check.isNull(obj)) {
|
|
if (!Check.isNull(obj)) {
|
|
@@ -594,14 +603,14 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
} else {
|
|
} else {
|
|
|
if (count <= 4) {
|
|
if (count <= 4) {
|
|
|
Thread.sleep(500);
|
|
Thread.sleep(500);
|
|
|
- getAdqWechatPagesVo(accountId, accessToken, page, isDeleted, count + 1);
|
|
|
|
|
|
|
+ getAdqWechatPagesVo(accountId,pageId, accessToken, page, isDeleted, count + 1);
|
|
|
} else {
|
|
} else {
|
|
|
log.error("账户({})获取动态创意失败,入参:{}\n,结果:{}", accountId, JSONObject.toJSONString(param), obj);
|
|
log.error("账户({})获取动态创意失败,入参:{}\n,结果:{}", accountId, JSONObject.toJSONString(param), obj);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (nextPage) {
|
|
if (nextPage) {
|
|
|
- getAdqWechatPagesVo(accountId, accessToken, page + 1, isDeleted, 1);
|
|
|
|
|
|
|
+ getAdqWechatPagesVo(accountId,pageId, accessToken, page + 1, isDeleted, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|