|
@@ -38,7 +38,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
@Autowired
|
|
|
private CTopOauthTokenMapper cTopOauthTokenMapper;
|
|
|
|
|
|
- private CTopOauthToken getOAuthTokenByAccountId(String accountId){
|
|
|
+ private CTopOauthToken getOAuthTokenByAccountId(String accountId) {
|
|
|
QueryWrapper<CTopOauthToken> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("advertiser_id", accountId).orderByDesc("create_time");
|
|
|
CTopOauthToken cTopOauthToken = cTopOauthTokenMapper.selectOne(queryWrapper);
|
|
@@ -47,29 +47,29 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getAdvertiserInfo(String accountId) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_advertiser_info");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
- TreeMap<String,Object>params = new TreeMap<>();
|
|
|
- params.put("advertiser_ids","["+cTopOauthToken.getAccountId()+"]");
|
|
|
- String result = HttpUtils.httpGetRequest(url,headers,params);
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_advertiser_info");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
+ TreeMap<String, Object> params = new TreeMap<>();
|
|
|
+ params.put("advertiser_ids", "[" + cTopOauthToken.getAccountId() + "]");
|
|
|
+ String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("获取广告主信息接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","获取广告主信息接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("获取广告主信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "获取广告主信息接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONArray data = jsonObject.getJSONArray("data");
|
|
|
- if(null==data||data.size()<=0){
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","广告主信息不存在");
|
|
|
+ if (null == data || data.size() <= 0) {
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告主信息不存在");
|
|
|
return resultMap;
|
|
|
}
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
@@ -79,46 +79,46 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
advertiserMapper.deleteById(advertiser.getId());
|
|
|
advertiserMapper.insert(advertiser);
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告主信息成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告主信息成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
private void getAdvertiserPlanByPageNumber(String accountId, Integer pageNumber, String ids) {
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_ad_get");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
-
|
|
|
- TreeMap<String,Object>params = new TreeMap<>();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("page",pageNumber+"");
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
+
|
|
|
+ TreeMap<String, Object> params = new TreeMap<>();
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("page", pageNumber + "");
|
|
|
JSONObject filtering = new JSONObject();
|
|
|
- if(null!=ids&&!"".equals(ids.trim())){
|
|
|
+ if (null != ids && !"".equals(ids.trim())) {
|
|
|
String[] idsArray = ids.split(",");
|
|
|
JSONArray filterIdsArray = new JSONArray();
|
|
|
for (int i = 0; i < idsArray.length; i++) {
|
|
|
Long id = Long.parseLong(idsArray[i]);
|
|
|
filterIdsArray.add(id);
|
|
|
}
|
|
|
- filtering.put("ids",filterIdsArray);
|
|
|
+ filtering.put("ids", filterIdsArray);
|
|
|
}
|
|
|
- params.put("filtering",filtering.toJSONString());
|
|
|
+ params.put("filtering", filtering.toJSONString());
|
|
|
|
|
|
- String result = HttpUtils.httpGetRequest(url,headers,params);
|
|
|
+ String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("获取广告主广告计划信息接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- return ;
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("获取广告主广告计划信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ return;
|
|
|
}
|
|
|
JSONArray data = jsonObject.getJSONObject("data").getJSONArray("list");
|
|
|
- if(null==data||data.size()<=0){
|
|
|
- logger.info("获取广告主广告计划信息不存在==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- return ;
|
|
|
+ if (null == data || data.size() <= 0) {
|
|
|
+ logger.info("获取广告主广告计划信息不存在==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ return;
|
|
|
}
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
JSONObject dataObject = data.getJSONObject(i);
|
|
@@ -127,7 +127,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
advertisePlanMapper.deleteById(advertisePlan.getId());
|
|
|
advertisePlanMapper.insert(advertisePlan);
|
|
|
}
|
|
|
- getAdvertiserPlanByPageNumber(accountId,pageNumber+1,ids);
|
|
|
+ getAdvertiserPlanByPageNumber(accountId, pageNumber + 1, ids);
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -135,49 +135,49 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getAdvertiserPlan(String accountId, String ids) {
|
|
|
- getAdvertiserPlanByPageNumber(accountId,1,ids);
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告计划信息成功");
|
|
|
+ getAdvertiserPlanByPageNumber(accountId, 1, ids);
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告计划信息成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getAdvertiserCampaign(String accountId, String ids) {
|
|
|
- getAdvertiserCampaignByPageNumber(accountId,1,ids);
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告組信息成功");
|
|
|
+ getAdvertiserCampaignByPageNumber(accountId, 1, ids);
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告組信息成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getAdvertiserBudget(String accountId) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_campaign_get");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
-
|
|
|
- TreeMap<String,Object>params = new TreeMap<>();
|
|
|
- params.put("advertiser_ids","["+cTopOauthToken.getAccountId()+"]");
|
|
|
- String result = HttpUtils.httpGetRequest(url,headers,params);
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
+
|
|
|
+ TreeMap<String, Object> params = new TreeMap<>();
|
|
|
+ params.put("advertiser_ids", "[" + cTopOauthToken.getAccountId() + "]");
|
|
|
+ String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("获取广告预算信息接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","获取广告预算信息接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("获取广告预算信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "获取广告预算信息接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONArray data = jsonObject.getJSONArray("data");
|
|
|
- if(null==data||data.size()<=0){
|
|
|
- logger.info("广告主预算信息不存在==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告主预算信息完成");
|
|
|
+ if (null == data || data.size() <= 0) {
|
|
|
+ logger.info("广告主预算信息不存在==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告主预算信息完成");
|
|
|
return resultMap;
|
|
|
}
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
@@ -187,48 +187,48 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
advertiserBudgetMapper.deleteById(advertiserBudget.getId());
|
|
|
advertiserBudgetMapper.insert(advertiserBudget);
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告预算信息完成");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告预算信息完成");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getAdvertiserCreative(String accountId, String ids) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
- getAdvertiserCreativeByPageNumber(accountId,1,ids);
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告主广告创意信息完成");
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ getAdvertiserCreativeByPageNumber(accountId, 1, ids);
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告主广告创意信息完成");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getAdvertiserCreativeMaterial(String accountId, String creativeIds) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_creative_material_get");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
-
|
|
|
- TreeMap<String,Object>params = new TreeMap<>();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("creative_ids","["+creativeIds+"]");
|
|
|
- String result = HttpUtils.httpGetRequest(url,headers,params);
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_material_get");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
+
|
|
|
+ TreeMap<String, Object> params = new TreeMap<>();
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("creative_ids", "[" + creativeIds + "]");
|
|
|
+ String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("获取广告主创意素材信息接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","获取广告主创意素材信息接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("获取广告主创意素材信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "获取广告主创意素材信息接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONArray data = jsonObject.getJSONArray("data");
|
|
|
- if(null==data||data.size()<=0){
|
|
|
- logger.info("广告主创意素材信息不存在==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告主预算信息完成");
|
|
|
+ if (null == data || data.size() <= 0) {
|
|
|
+ logger.info("广告主创意素材信息不存在==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告主预算信息完成");
|
|
|
return resultMap;
|
|
|
}
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
@@ -238,44 +238,44 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
creativeMaterialMapper.deleteById(material.getId());
|
|
|
creativeMaterialMapper.insert(material);
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","获取广告主预算信息完成");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告主预算信息完成");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> advertiserCampaignCreate(String accountId, String campaignName, String budgetMode, Integer budget, String landingType) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
CTopOauthToken token = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
JSONObject params = new JSONObject();
|
|
|
params.put("advertiser_id", token.getAccountId());
|
|
|
- params.put("campaign_name",campaignName);
|
|
|
- params.put("budget_mode",budgetMode);
|
|
|
- params.put("budget",budget);
|
|
|
- params.put("landing_type",landingType);
|
|
|
+ params.put("campaign_name", campaignName);
|
|
|
+ params.put("budget_mode", budgetMode);
|
|
|
+ params.put("budget", budget);
|
|
|
+ params.put("landing_type", landingType);
|
|
|
JSONObject result = createCampaign(params, token.getAccessToken());
|
|
|
Integer code = result.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
logger.info("创建广告组接口异常==》accountId:{},message:{}", accountId, result.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","创建广告组接口异常");
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "创建广告组接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONObject data = result.getJSONObject("data");
|
|
|
- if(null==data){
|
|
|
+ if (null == data) {
|
|
|
logger.info("广告组创建异常==》accountId:{},message:{}", accountId, result.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","广告组创建异常");
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告组创建异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- Long id = data.getLong("campaign_id");
|
|
|
+ Long id = data.getLong("campaign_id");
|
|
|
ByteDanceCampaign campaign = new ByteDanceCampaign(id, token, campaignName, budgetMode, budget, landingType);
|
|
|
//清除清数据,插入新数据
|
|
|
campaignMapper.insert(campaign);
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","广告组创建成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告组创建成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
@@ -326,317 +326,317 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> advertiserCampaignUpdateStatus(String accountId, String campaignIds, String optStatus) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
JSONArray ids = new JSONArray();
|
|
|
- String [] getIds = campaignIds.split(",");
|
|
|
- if(null!=getIds&&getIds.length>0){
|
|
|
+ String[] getIds = campaignIds.split(",");
|
|
|
+ if (null != getIds && getIds.length > 0) {
|
|
|
for (int i = 0; i < getIds.length; i++) {
|
|
|
ids.add(Long.parseLong(getIds[i]));
|
|
|
}
|
|
|
}
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_campaign_update_status");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_update_status");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("campaign_ids",ids);
|
|
|
- params.put("opt_status",optStatus);
|
|
|
- String result = HttpUtils.httpPostRequest(url,params,headers);
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("campaign_ids", ids);
|
|
|
+ params.put("opt_status", optStatus);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("广告组更新状态接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","广告组更新状态接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("广告组更新状态接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告组更新状态接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
- if(null==data){
|
|
|
- logger.info("广告组更新状态异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","广告组更新状态异常");
|
|
|
+ if (null == data) {
|
|
|
+ logger.info("广告组更新状态异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告组更新状态异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- JSONArray getCampaignIds = data.getJSONArray("campaign_ids");
|
|
|
- if(null!=getCampaignIds&&getCampaignIds.size()>0){
|
|
|
+ JSONArray getCampaignIds = data.getJSONArray("campaign_ids");
|
|
|
+ if (null != getCampaignIds && getCampaignIds.size() > 0) {
|
|
|
for (int i = 0; i < getCampaignIds.size(); i++) {
|
|
|
Long id = getCampaignIds.getLong(i);
|
|
|
ByteDanceCampaign campaign = campaignMapper.selectById(id);
|
|
|
- if(null!=campaign){
|
|
|
+ if (null != campaign) {
|
|
|
campaign.setOptStatus(optStatus);
|
|
|
}
|
|
|
campaignMapper.updateById(campaign);
|
|
|
}
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","广告组状态修改成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告组状态修改成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> advertiserCampaignUpdate(String accountId, Long campaignId, String budgetMode, Integer budget, String campaignName) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
ByteDanceCampaign campaign = campaignMapper.selectById(campaignId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_campaign_update");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_update");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("campaign_id",campaignId);
|
|
|
- params.put("modify_time",campaign.getModifyTime());
|
|
|
- params.put("campaign_id",campaignId);
|
|
|
- if(null!=campaignName&&!"".equals(campaignName.trim())){
|
|
|
- params.put("campaign_name",campaignName);
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("campaign_id", campaignId);
|
|
|
+ params.put("modify_time", campaign.getModifyTime());
|
|
|
+ params.put("campaign_id", campaignId);
|
|
|
+ if (null != campaignName && !"".equals(campaignName.trim())) {
|
|
|
+ params.put("campaign_name", campaignName);
|
|
|
}
|
|
|
- if(null!=budgetMode&&!"".equals(budgetMode.trim())){
|
|
|
- params.put("budget_mode",budgetMode);
|
|
|
+ if (null != budgetMode && !"".equals(budgetMode.trim())) {
|
|
|
+ params.put("budget_mode", budgetMode);
|
|
|
}
|
|
|
- if(null!=budget){
|
|
|
- params.put("budget",budget);
|
|
|
+ if (null != budget) {
|
|
|
+ params.put("budget", budget);
|
|
|
}
|
|
|
- String result = HttpUtils.httpPostRequest(url,params,headers);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("广告组更新接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","广告组更新接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("广告组更新接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告组更新接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
- if(null==data){
|
|
|
- logger.info("广告组更新异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","广告组更新异常");
|
|
|
+ if (null == data) {
|
|
|
+ logger.info("广告组更新异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告组更新异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- if(null!=campaignName&&!"".equals(campaignName.trim())){
|
|
|
+ if (null != campaignName && !"".equals(campaignName.trim())) {
|
|
|
campaign.setName(campaignName);
|
|
|
}
|
|
|
- if(null!=budgetMode&&!"".equals(budgetMode.trim())){
|
|
|
- params.put("budget_mode",budgetMode);
|
|
|
+ if (null != budgetMode && !"".equals(budgetMode.trim())) {
|
|
|
+ params.put("budget_mode", budgetMode);
|
|
|
campaign.setBudgetMode(budgetMode);
|
|
|
}
|
|
|
- if(null!=budget){
|
|
|
+ if (null != budget) {
|
|
|
campaign.setBudget(new BigDecimal(budget));
|
|
|
}
|
|
|
campaignMapper.updateById(campaign);
|
|
|
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","广告组信息修改成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告组信息修改成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> advertiserPlanUpdateStatus(String accountId, String adIds, String optStatus) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
JSONArray ids = new JSONArray();
|
|
|
- String [] getIds = adIds.split(",");
|
|
|
- if(null!=getIds&&getIds.length>0){
|
|
|
+ String[] getIds = adIds.split(",");
|
|
|
+ if (null != getIds && getIds.length > 0) {
|
|
|
for (int i = 0; i < getIds.length; i++) {
|
|
|
ids.add(Long.parseLong(getIds[i]));
|
|
|
}
|
|
|
}
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_ad_update_status");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("ad_ids",ids.toJSONString());
|
|
|
- params.put("opt_status",optStatus);
|
|
|
- String result = HttpUtils.httpPostRequest(url,params,headers);
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("ad_ids", ids.toJSONString());
|
|
|
+ params.put("opt_status", optStatus);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("广告计划更新状态接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","广告计划更新状态接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("广告计划更新状态接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告计划更新状态接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
- if(null==data){
|
|
|
- logger.info("广告计划更新状态异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","广告计划更新状态异常");
|
|
|
+ if (null == data) {
|
|
|
+ logger.info("广告计划更新状态异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告计划更新状态异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- JSONArray getAdIds = data.getJSONArray("ad_ids");
|
|
|
- if(null!=getAdIds&&getAdIds.size()>0){
|
|
|
+ JSONArray getAdIds = data.getJSONArray("ad_ids");
|
|
|
+ if (null != getAdIds && getAdIds.size() > 0) {
|
|
|
//获取广告计划信息
|
|
|
- getAdvertiserPlan(accountId,adIds);
|
|
|
+ getAdvertiserPlan(accountId, adIds);
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","广告组状态修改成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告组状态修改成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> advertiserPlanUpdateBid(String accountId, String adIds, String bids) {
|
|
|
//TODO 校验数据是否完整
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
JSONArray data = new JSONArray();
|
|
|
- String [] getadIds = adIds.split(",");
|
|
|
- String [] getBids = bids.split(",");
|
|
|
- if(null!=getadIds&&getadIds.length>0){
|
|
|
+ String[] getadIds = adIds.split(",");
|
|
|
+ String[] getBids = bids.split(",");
|
|
|
+ if (null != getadIds && getadIds.length > 0) {
|
|
|
for (int i = 0; i < getadIds.length; i++) {
|
|
|
JSONObject object = new JSONObject();
|
|
|
Long ad_id = Long.parseLong(getadIds[i]);
|
|
|
Long bid = Long.parseLong(getBids[i]);
|
|
|
- object.put("ad_id",ad_id);
|
|
|
- object.put("bid",bid);
|
|
|
+ object.put("ad_id", ad_id);
|
|
|
+ object.put("bid", bid);
|
|
|
data.add(object);
|
|
|
}
|
|
|
}
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_ad_update_bid");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_bid");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("data",data.toJSONString());
|
|
|
- String result = HttpUtils.httpPostRequest(url,params,headers);
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("data", data.toJSONString());
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("修改计划出价接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","修改计划出价接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("修改计划出价接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "修改计划出价接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONObject getData = jsonObject.getJSONObject("data");
|
|
|
- if(null==getData){
|
|
|
- logger.info("修改计划出价异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","修改计划出价异常");
|
|
|
+ if (null == getData) {
|
|
|
+ logger.info("修改计划出价异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "修改计划出价异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
|
- if(null!=getAdIds&&getAdIds.size()>0){
|
|
|
+ if (null != getAdIds && getAdIds.size() > 0) {
|
|
|
//获取广告计划信息
|
|
|
- getAdvertiserPlan(accountId,adIds);
|
|
|
+ getAdvertiserPlan(accountId, adIds);
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","修改计划出价成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "修改计划出价成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> advertiserPlanUpdateBudget(String accountId, String adIds, String budgets) {
|
|
|
//TODO 校验数据是否完整
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
JSONArray data = new JSONArray();
|
|
|
- String [] getadIds = adIds.split(",");
|
|
|
- String [] getBudgets = budgets.split(",");
|
|
|
- if(null!=getadIds&&getadIds.length>0){
|
|
|
+ String[] getadIds = adIds.split(",");
|
|
|
+ String[] getBudgets = budgets.split(",");
|
|
|
+ if (null != getadIds && getadIds.length > 0) {
|
|
|
for (int i = 0; i < getadIds.length; i++) {
|
|
|
JSONObject object = new JSONObject();
|
|
|
Long ad_id = Long.parseLong(getadIds[i]);
|
|
|
Long budget = Long.parseLong(getBudgets[i]);
|
|
|
- object.put("ad_id",ad_id);
|
|
|
- object.put("budget",budget);
|
|
|
+ object.put("ad_id", ad_id);
|
|
|
+ object.put("budget", budget);
|
|
|
data.add(object);
|
|
|
}
|
|
|
}
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_ad_update_budget");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_budget");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("data",data.toJSONString());
|
|
|
- String result = HttpUtils.httpPostRequest(url,params,headers);
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("data", data.toJSONString());
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("修改计划预算接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","修改计划预算接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("修改计划预算接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "修改计划预算接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONObject getData = jsonObject.getJSONObject("data");
|
|
|
- if(null==getData){
|
|
|
- logger.info("修改计划预算异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","修改计划预算异常");
|
|
|
+ if (null == getData) {
|
|
|
+ logger.info("修改计划预算异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "修改计划预算异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
|
- if(null!=getAdIds&&getAdIds.size()>0){
|
|
|
+ if (null != getAdIds && getAdIds.size() > 0) {
|
|
|
//获取广告计划信息
|
|
|
- getAdvertiserPlan(accountId,adIds);
|
|
|
+ getAdvertiserPlan(accountId, adIds);
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","修改计划预算成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "修改计划预算成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> advertiserCreativeUpdateStatus(String accountId, String creativeIds, String optStatus) {
|
|
|
- Map<String,Object>resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
JSONArray ids = new JSONArray();
|
|
|
- String [] getCreativeIds = creativeIds.split(",");
|
|
|
- if(null!=getCreativeIds&&getCreativeIds.length>0){
|
|
|
+ String[] getCreativeIds = creativeIds.split(",");
|
|
|
+ if (null != getCreativeIds && getCreativeIds.length > 0) {
|
|
|
for (int i = 0; i < getCreativeIds.length; i++) {
|
|
|
ids.add(Long.parseLong(getCreativeIds[i]));
|
|
|
}
|
|
|
}
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_creative_update_status");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_update_status");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("creative_ids",ids.toJSONString());
|
|
|
- params.put("opt_status",optStatus);
|
|
|
- String result = HttpUtils.httpPostRequest(url,params,headers);
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("creative_ids", ids.toJSONString());
|
|
|
+ params.put("opt_status", optStatus);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("修改创意状态接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","修改创意状态接口异常");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("修改创意状态接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "修改创意状态接口异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
- if(null==data){
|
|
|
- logger.info("修改创意状态异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- resultMap.put("code",-1);
|
|
|
- resultMap.put("message","修改创意状态异常");
|
|
|
+ if (null == data) {
|
|
|
+ logger.info("修改创意状态异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "修改创意状态异常");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- JSONArray returnCreativeIds = data.getJSONArray("creative_ids");
|
|
|
- if(null!=returnCreativeIds&&returnCreativeIds.size()>0){
|
|
|
+ JSONArray returnCreativeIds = data.getJSONArray("creative_ids");
|
|
|
+ if (null != returnCreativeIds && returnCreativeIds.size() > 0) {
|
|
|
//TODO 获取广告计划信息 需要注意这里的逻辑 有漏洞,后期修改
|
|
|
- getAdvertiserCreative(accountId,creativeIds);
|
|
|
+ getAdvertiserCreative(accountId, creativeIds);
|
|
|
}
|
|
|
- resultMap.put("code",0);
|
|
|
- resultMap.put("message","广告创意状态修改成功");
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告创意状态修改成功");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
@@ -679,7 +679,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
resultMap.put("code", -1);
|
|
|
return resultMap;
|
|
|
}
|
|
|
- System.out.println(data.toJSONString());
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
JSONObject dataObject = data.getJSONObject(i);
|
|
|
ByteDanceCustomAudience audience = new ByteDanceCustomAudience(token, dataObject);
|
|
@@ -740,37 +739,37 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
private void getAdvertiserCreativeByPageNumber(String accountId, Integer pageNumber, String ids) {
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_creative_get");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_get");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
- TreeMap<String,Object>params = new TreeMap<>();
|
|
|
+ TreeMap<String, Object> params = new TreeMap<>();
|
|
|
JSONObject filtering = new JSONObject();
|
|
|
- if(null!=ids&&!"".equals(ids.trim())){
|
|
|
+ if (null != ids && !"".equals(ids.trim())) {
|
|
|
String[] idsArray = ids.split(",");
|
|
|
JSONArray filterIdsArray = new JSONArray();
|
|
|
for (int i = 0; i < idsArray.length; i++) {
|
|
|
Long id = Long.parseLong(idsArray[i]);
|
|
|
filterIdsArray.add(id);
|
|
|
}
|
|
|
- filtering.put("ids",filterIdsArray);
|
|
|
+ filtering.put("ids", filterIdsArray);
|
|
|
}
|
|
|
- params.put("filtering",filtering.toJSONString());
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("page",pageNumber+"");
|
|
|
- String result = HttpUtils.httpGetRequest(url,headers,params);
|
|
|
+ params.put("filtering", filtering.toJSONString());
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("page", pageNumber + "");
|
|
|
+ String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("获取广告主广告创意信息接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- return ;
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("获取广告主广告创意信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ return;
|
|
|
}
|
|
|
JSONArray data = jsonObject.getJSONObject("data").getJSONArray("list");
|
|
|
- if(null==data||data.size()<=0){
|
|
|
- logger.info("广告主广告创意信息不存在==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- return ;
|
|
|
+ if (null == data || data.size() <= 0) {
|
|
|
+ logger.info("广告主广告创意信息不存在==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ return;
|
|
|
}
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
JSONObject dataObject = data.getJSONObject(i);
|
|
@@ -779,7 +778,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
creativeMapper.deleteById(creative.getId());
|
|
|
creativeMapper.insert(creative);
|
|
|
}
|
|
|
- getAdvertiserCreativeByPageNumber(accountId,pageNumber+1,ids);
|
|
|
+ getAdvertiserCreativeByPageNumber(accountId, pageNumber + 1, ids);
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -790,37 +789,37 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
private void getAdvertiserCampaignByPageNumber(String accountId, Integer pageNumber, String ids) {
|
|
|
CTopOauthToken cTopOauthToken = getOAuthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config","bytedance_api_url")+PropertiesUtils.getValue("bytedance_config","bytedance_v2_campaign_get");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- headers.put("Access-Token",cTopOauthToken.getAccessToken());
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
|
|
|
|
- TreeMap<String,Object> params = new TreeMap<>();
|
|
|
+ TreeMap<String, Object> params = new TreeMap<>();
|
|
|
JSONObject filtering = new JSONObject();
|
|
|
- if(null!=ids&&!"".equals(ids.trim())){
|
|
|
+ if (null != ids && !"".equals(ids.trim())) {
|
|
|
String[] idsArray = ids.split(",");
|
|
|
JSONArray filterIdsArray = new JSONArray();
|
|
|
for (int i = 0; i < idsArray.length; i++) {
|
|
|
Long id = Long.parseLong(idsArray[i]);
|
|
|
filterIdsArray.add(id);
|
|
|
}
|
|
|
- filtering.put("ids",filterIdsArray);
|
|
|
+ filtering.put("ids", filterIdsArray);
|
|
|
}
|
|
|
- params.put("filtering",filtering.toJSONString());
|
|
|
- params.put("advertiser_id",cTopOauthToken.getAccountId());
|
|
|
- params.put("page",pageNumber+"");
|
|
|
- String result = HttpUtils.httpGetRequest(url,headers,params);
|
|
|
+ params.put("filtering", filtering.toJSONString());
|
|
|
+ params.put("advertiser_id", cTopOauthToken.getAccountId());
|
|
|
+ params.put("page", pageNumber + "");
|
|
|
+ String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
|
- if(null==code||!code.equals(0)){
|
|
|
- logger.info("获取广告主广告组信息接口异常==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- return ;
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ logger.info("获取广告主广告组信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ return;
|
|
|
}
|
|
|
JSONArray data = jsonObject.getJSONObject("data").getJSONArray("list");
|
|
|
- if(null==data||data.size()<=0){
|
|
|
- logger.info("获取广告主广告组信息不存在==》accountId:{},message:{}",accountId,jsonObject.getString("message"));
|
|
|
- return ;
|
|
|
+ if (null == data || data.size() <= 0) {
|
|
|
+ logger.info("获取广告主广告组信息不存在==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
|
|
|
+ return;
|
|
|
}
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
JSONObject dataObject = data.getJSONObject(i);
|
|
@@ -829,7 +828,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
campaignMapper.deleteById(campaign.getId());
|
|
|
campaignMapper.insert(campaign);
|
|
|
}
|
|
|
- getAdvertiserCampaignByPageNumber(accountId,pageNumber+1,ids);
|
|
|
+ getAdvertiserCampaignByPageNumber(accountId, pageNumber + 1, ids);
|
|
|
}
|
|
|
|
|
|
@Autowired
|