|
@@ -79,8 +79,8 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
|
|
|
|
- public void getAd(String accountId, int pageNum, String ids, String date) {
|
|
|
|
- CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
|
|
|
+
|
|
|
|
+ public void getAd(CtopOauthToken token, int pageNum, String ids, String date) {
|
|
JSONArray getIds = null;
|
|
JSONArray getIds = null;
|
|
if (null != ids && !ids.equals("")) {
|
|
if (null != ids && !ids.equals("")) {
|
|
String[] idString = ids.split(StringUtils.COMMA);
|
|
String[] idString = ids.split(StringUtils.COMMA);
|
|
@@ -111,25 +111,25 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
|
|
JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
|
|
Integer code = resultObject.getInteger("code");
|
|
Integer code = resultObject.getInteger("code");
|
|
if (null == code || !code.equals(0)) {
|
|
if (null == code || !code.equals(0)) {
|
|
- log.error("获取广告计划信息接口异常==》accountId:{},message:{}", accountId, resultObject.getString("message"));
|
|
|
|
|
|
+ log.error("获取广告计划信息接口异常==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
|
|
JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
|
|
if (null == data || data.size() <= 0) {
|
|
if (null == data || data.size() <= 0) {
|
|
- log.error("获取广告计划信息不存在==》accountId:{},message:{}", accountId, resultObject.getString("message"));
|
|
|
|
|
|
+ log.error("获取广告计划信息不存在==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
for (int i = 0; i < data.size(); i++) {
|
|
for (int i = 0; i < data.size(); i++) {
|
|
JSONObject dataObject = data.getJSONObject(i);
|
|
JSONObject dataObject = data.getJSONObject(i);
|
|
- ByteDanceAdvertisePlan advertisePlan = new ByteDanceAdvertisePlan(dataObject, accountId);
|
|
|
|
|
|
+ ByteDanceAdvertisePlan advertisePlan = new ByteDanceAdvertisePlan(dataObject, String.valueOf(token.getAccountId()));
|
|
advertisePlanService.saveOrUpdate(advertisePlan);
|
|
advertisePlanService.saveOrUpdate(advertisePlan);
|
|
}
|
|
}
|
|
- getAd(accountId, pageNum + 1, ids, date);
|
|
|
|
|
|
+ getAd(token, pageNum + 1, ids, date);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String, Object> getAdvertiserPlan(String accountId, String ids, String date) {
|
|
|
|
- getAd(accountId, 1, ids, date);
|
|
|
|
|
|
+ public Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date) {
|
|
|
|
+ getAd(token, 1, ids, date);
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
resultMap.put("code", 0);
|
|
resultMap.put("code", 0);
|
|
resultMap.put("message", "获取广告计划信息成功");
|
|
resultMap.put("message", "获取广告计划信息成功");
|
|
@@ -339,7 +339,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String, Object> advertiserPlanUpdateStatus(String accountId, String adIds, String optStatus) {
|
|
|
|
|
|
+ public Map<String, Object> advertiserPlanUpdateStatus(CtopOauthToken token, String adIds, String optStatus) {
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
JSONArray ids = new JSONArray();
|
|
JSONArray ids = new JSONArray();
|
|
String[] getIds = adIds.split(StringUtils.COMMA);
|
|
String[] getIds = adIds.split(StringUtils.COMMA);
|
|
@@ -348,15 +348,14 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
ids.add(Long.parseLong(getIds[i]));
|
|
ids.add(Long.parseLong(getIds[i]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status");
|
|
String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status");
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
- headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
- params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
params.put("ad_ids", ids.toJSONString());
|
|
params.put("ad_ids", ids.toJSONString());
|
|
params.put("opt_status", optStatus);
|
|
params.put("opt_status", optStatus);
|
|
String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
@@ -364,14 +363,14 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
Integer code = jsonObject.getInteger("code");
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
if (null == code || !code.equals(0)) {
|
|
if (null == code || !code.equals(0)) {
|
|
- log.error("广告计划更新状态接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
|
|
|
+ log.error("广告计划更新状态接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
resultMap.put("code", -1);
|
|
resultMap.put("code", -1);
|
|
resultMap.put("message", "广告计划更新状态接口异常");
|
|
resultMap.put("message", "广告计划更新状态接口异常");
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
if (null == data) {
|
|
if (null == data) {
|
|
- log.info("广告计划更新状态异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
|
|
|
+ log.info("广告计划更新状态异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
resultMap.put("code", -1);
|
|
resultMap.put("code", -1);
|
|
resultMap.put("message", "广告计划更新状态异常");
|
|
resultMap.put("message", "广告计划更新状态异常");
|
|
return resultMap;
|
|
return resultMap;
|
|
@@ -379,7 +378,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
JSONArray getAdIds = data.getJSONArray("ad_ids");
|
|
JSONArray getAdIds = data.getJSONArray("ad_ids");
|
|
if (null != getAdIds && getAdIds.size() > 0) {
|
|
if (null != getAdIds && getAdIds.size() > 0) {
|
|
//获取广告计划信息
|
|
//获取广告计划信息
|
|
- getAdvertiserPlan(accountId, adIds, null);
|
|
|
|
|
|
+ getAdvertiserPlan(token, adIds, null);
|
|
}
|
|
}
|
|
resultMap.put("code", 0);
|
|
resultMap.put("code", 0);
|
|
resultMap.put("message", "广告组状态修改成功");
|
|
resultMap.put("message", "广告组状态修改成功");
|
|
@@ -387,7 +386,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String, Object> advertiserPlanUpdateBid(String accountId, String adIds, String bids) {
|
|
|
|
|
|
+ public Map<String, Object> advertiserPlanUpdateBid(CtopOauthToken token, String adIds, String bids) {
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
JSONArray data = new JSONArray();
|
|
JSONArray data = new JSONArray();
|
|
String[] getadIds = adIds.split(StringUtils.COMMA);
|
|
String[] getadIds = adIds.split(StringUtils.COMMA);
|
|
@@ -402,29 +401,28 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
data.add(object);
|
|
data.add(object);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_bid");
|
|
String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_bid");
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
- headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
- params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
params.put("data", data.toJSONString());
|
|
params.put("data", data.toJSONString());
|
|
String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
Integer code = jsonObject.getInteger("code");
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
if (null == code || !code.equals(0)) {
|
|
if (null == code || !code.equals(0)) {
|
|
- log.info("修改计划出价接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
|
|
|
+ log.info("修改计划出价接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
resultMap.put("code", -1);
|
|
resultMap.put("code", -1);
|
|
resultMap.put("message", "修改计划出价接口异常");
|
|
resultMap.put("message", "修改计划出价接口异常");
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
JSONObject getData = jsonObject.getJSONObject("data");
|
|
JSONObject getData = jsonObject.getJSONObject("data");
|
|
if (null == getData) {
|
|
if (null == getData) {
|
|
- log.info("修改计划出价异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
|
|
|
+ log.info("修改计划出价异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
resultMap.put("code", -1);
|
|
resultMap.put("code", -1);
|
|
resultMap.put("message", "修改计划出价异常");
|
|
resultMap.put("message", "修改计划出价异常");
|
|
return resultMap;
|
|
return resultMap;
|
|
@@ -432,7 +430,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
if (null != getAdIds && getAdIds.size() > 0) {
|
|
if (null != getAdIds && getAdIds.size() > 0) {
|
|
//获取广告计划信息
|
|
//获取广告计划信息
|
|
- getAdvertiserPlan(accountId, adIds, null);
|
|
|
|
|
|
+ getAdvertiserPlan(token, adIds, null);
|
|
}
|
|
}
|
|
resultMap.put("code", 0);
|
|
resultMap.put("code", 0);
|
|
resultMap.put("message", "修改计划出价成功");
|
|
resultMap.put("message", "修改计划出价成功");
|
|
@@ -440,7 +438,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String, Object> advertiserPlanUpdateBudget(String accountId, String adIds, String budgets) {
|
|
|
|
|
|
+ public Map<String, Object> advertiserPlanUpdateBudget(CtopOauthToken token, String adIds, String budgets) {
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
JSONArray data = new JSONArray();
|
|
JSONArray data = new JSONArray();
|
|
String[] getadIds = adIds.split(StringUtils.COMMA);
|
|
String[] getadIds = adIds.split(StringUtils.COMMA);
|
|
@@ -455,28 +453,27 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
data.add(object);
|
|
data.add(object);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_budget");
|
|
String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_budget");
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
- headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
- params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
params.put("data", data.toJSONString());
|
|
params.put("data", data.toJSONString());
|
|
String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
Integer code = jsonObject.getInteger("code");
|
|
Integer code = jsonObject.getInteger("code");
|
|
if (null == code || !code.equals(0)) {
|
|
if (null == code || !code.equals(0)) {
|
|
- log.info("修改计划预算接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
|
|
|
+ log.info("修改计划预算接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
resultMap.put("code", -1);
|
|
resultMap.put("code", -1);
|
|
resultMap.put("message", "修改计划预算接口异常");
|
|
resultMap.put("message", "修改计划预算接口异常");
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
JSONObject getData = jsonObject.getJSONObject("data");
|
|
JSONObject getData = jsonObject.getJSONObject("data");
|
|
if (null == getData) {
|
|
if (null == getData) {
|
|
- log.info("修改计划预算异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
|
|
|
+ log.info("修改计划预算异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
resultMap.put("code", -1);
|
|
resultMap.put("code", -1);
|
|
resultMap.put("message", "修改计划预算异常");
|
|
resultMap.put("message", "修改计划预算异常");
|
|
return resultMap;
|
|
return resultMap;
|
|
@@ -484,7 +481,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
if (null != getAdIds && getAdIds.size() > 0) {
|
|
if (null != getAdIds && getAdIds.size() > 0) {
|
|
//获取广告计划信息
|
|
//获取广告计划信息
|
|
- getAdvertiserPlan(accountId, adIds, null);
|
|
|
|
|
|
+ getAdvertiserPlan(token, adIds, null);
|
|
}
|
|
}
|
|
resultMap.put("code", 0);
|
|
resultMap.put("code", 0);
|
|
resultMap.put("message", "修改计划预算成功");
|
|
resultMap.put("message", "修改计划预算成功");
|
|
@@ -904,8 +901,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
private void getAdvertiserCampaignByPageNumber(String accountId, Integer pageNumber, String ids, String date) {
|
|
private void getAdvertiserCampaignByPageNumber(String accountId, Integer pageNumber, String ids, String date) {
|
|
CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
//2: 根据token以及用户id获取用户信息数据
|