Kaynağa Gözat

修改计划信息

yumeng 5 yıl önce
ebeveyn
işleme
7cbc0bbd48

+ 8 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java

@@ -63,19 +63,19 @@ public class ByteDanceAdvertiserPostController {
      * 2:获取广告主广告计划信息
      * @param accountId 本平台广告主id
      */
-    @RequestMapping("/advertiser/plan/get")
+   /* @RequestMapping("/advertiser/plan/get")
     public Map<String, Object> advertiserPlan(String accountId, String ids) {
         return advertiserDataService.getAdvertiserPlan(accountId, ids, null);
-    }
+    }*/
 
     /**
      * 3:修改广告计划信息状态
      * @param accountId 本平台广告主id
      */
-    @RequestMapping("/advertiser/plan/update/status")
+    /*@RequestMapping("/advertiser/plan/update/status")
     public Map<String, Object> advertiserPlanUpdateStatus(String accountId, String adIds, String optStatus) {
         return advertiserDataService.advertiserPlanUpdateStatus(accountId, adIds, optStatus);
-    }
+    }*/
 
     /**
      * 3:修改广告计划信息
@@ -93,19 +93,19 @@ public class ByteDanceAdvertiserPostController {
      * 4:修改广告计划信息状态
      * @param accountId 本平台广告主id
      */
-    @RequestMapping("/advertiser/plan/update/bid")
+   /* @RequestMapping("/advertiser/plan/update/bid")
     public Map<String, Object> advertiserPlanUpdateBid(String accountId, String adIds, String bids) {
         return advertiserDataService.advertiserPlanUpdateBid(accountId, adIds, bids);
-    }
+    }*/
 
     /**
      * 5:修改广告计划信息状态
      * @param accountId 本平台广告主id
      */
-    @RequestMapping("/advertiser/plan/update/budget")
+    /*@RequestMapping("/advertiser/plan/update/budget")
     public Map<String, Object> advertiserPlanUpdateBudget(String accountId, String adIds, String budgets) {
         return advertiserDataService.advertiserPlanUpdateBudget(accountId, adIds, budgets);
-    }
+    }*/
 
     /**
      * 6:获取广告主广告预算信息

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceMaterialsLoadJob.java

@@ -43,7 +43,7 @@ public class BytedanceMaterialsLoadJob implements Job {
                         //1:获取当日广告组数据
                         advertiserDataService.getAdvertiserCampaign(token.getAccountId() + "", "", dateString);
                         //1:获取当日广告计划数据
-                        advertiserDataService.getAdvertiserPlan(token.getAccountId() + "", "", dateString);
+                        advertiserDataService.getAdvertiserPlan(token, "", dateString);
                         //1:获取全量创意数据
                         creativeService.getAdvertiserCreative(token.getAccountId() + "", "", dateString);
                         //2:获取全量素材数据

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedancePlanLoadJob.java

@@ -38,7 +38,7 @@ public class BytedancePlanLoadJob implements Job {
                 public void run() {
                     try {
                         //1:获取当日广告计划数据
-                        advertiserDataService.getAdvertiserPlan(token.getAccountId() + "", "", null);
+                        advertiserDataService.getAdvertiserPlan(token, "", null);
                     } catch (Exception e) {
                         e.printStackTrace();
                     } finally {

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java

@@ -486,7 +486,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                         if (null != template) {
                             //获取modify_time
                             Thread.sleep(5000L);
-                            advertiserDataService.getAdvertiserPlan(bindAccountLogin.getAccountId(), adId + "", null);
+                            advertiserDataService.getAdvertiserPlan(token, adId + "", null);
                             advertiserDataService.updateAd(token, adId, template, requestJson);
                         }
                         Long creativeTemplateId = requestJson.getLong("creativeTemplateId");

+ 4 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/IByteDanceAdvertiserDataService.java

@@ -12,7 +12,7 @@ import java.util.Map;
 public interface IByteDanceAdvertiserDataService {
     Map<String, Object> getAdvertiserInfo(String accountId);
 
-    Map<String, Object> getAdvertiserPlan(String accountId, String ids, String date);
+    Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date);
 
     Map<String, Object> getAdvertiserCampaign(String accountId, String ids, String date);
 
@@ -24,11 +24,11 @@ public interface IByteDanceAdvertiserDataService {
 
     Map<String, Object> advertiserCampaignUpdate(String accountId, Long campaignId, String budgetMode, Integer budget, String campaignName);
 
-    Map<String, Object> advertiserPlanUpdateStatus(String accountId, String adIds, String optStatus);
+    Map<String, Object> advertiserPlanUpdateStatus(CtopOauthToken token, String adIds, String optStatus);
 
-    Map<String, Object> advertiserPlanUpdateBid(String accountId, String adIds, String bids);
+    Map<String, Object> advertiserPlanUpdateBid(CtopOauthToken token, String adIds, String bids);
 
-    Map<String, Object> advertiserPlanUpdateBudget(String accountId, String adIds, String budgets);
+    Map<String, Object> advertiserPlanUpdateBudget(CtopOauthToken token, String adIds, String budgets);
 
     Map<String, Object> advertiserCustomAudienceSelect(String accountId);
 

+ 26 - 31
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

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