Procházet zdrojové kódy

定时任务调整 && 创意标签白名单

yumeng před 4 roky
rodič
revize
1fa083ac69

+ 31 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -2409,4 +2409,35 @@ public class BatchController {
     }
 
 
+    /**
+     * 获取创意标签白名单
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getCategoryWhite")
+    public Result<JSONObject> getCategoryWhite(Long accountId) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject data = batchService.getCategoryWhite(accountId, oauthToken.getAccessToken());
+            result.setSuccess(true);
+            result.setResult(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setResult(null);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
 }

+ 8 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java

@@ -172,4 +172,12 @@ public interface IBatchService {
 
     Map<String, Object> batchCreateCreative(JSONObject requestJson) throws Exception;
 
+    /**
+     * 获取创意分类白名单
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONObject getCategoryWhite(Long accountId, String accessToken);
 }

+ 28 - 21
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -788,9 +788,7 @@ public class BatchServiceImpl implements IBatchService {
                     } else {
                         unitJson.put("begin_time", group.getBeginTime());
                     }
-
                 }
-
                 // 优先从系统应用商店下载
                 if (!Check.isNull(group.getUseAppMarket())) {
                     unitJson.put("use_app_market", group.getUseAppMarket());
@@ -836,8 +834,6 @@ public class BatchServiceImpl implements IBatchService {
                 if (!Check.isNull(group.getSpeed())) {
                     unitJson.put("speed", group.getSpeed());
                 }
-
-
                 QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
                 targetQueryWrapper.eq("account_id", group.getAccountId());
                 targetQueryWrapper.eq("unit_id", group.getUnitId());
@@ -966,8 +962,6 @@ public class BatchServiceImpl implements IBatchService {
 
                     unitJson.put("target", targetJson);
                 }
-
-
                 // 出价
                 if (!Check.isNull(group.getBid())) {
                     unitJson.put("bid", group.getBid());
@@ -1194,7 +1188,6 @@ public class BatchServiceImpl implements IBatchService {
                         creativeJson.put("site_id", creative.getSiteId());
                     }
 
-
                     if (creativeMaterialType == 4) {
                         creativeJson.put("image_tokens", JSONArray.parseArray(creative.getImageTokens()));
                         creativeJson.put("short_slogan", creative.getShortSlogan());
@@ -1214,8 +1207,6 @@ public class BatchServiceImpl implements IBatchService {
                             creativeJson.put("click_track_url", click_track_url);
                         }
                     }
-
-
                 }
                 // 安卓下载中间页
                 Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1);
@@ -1279,12 +1270,10 @@ public class BatchServiceImpl implements IBatchService {
         if (Check.isNull(oauthToken)) {
             throw new Exception("未获取到账户信息");
         }
-
         Long unitId = requestJson.getLong("unitId");
         if (Check.isNull(unitId)) {
             throw new Exception("请选择广告组");
         }
-
         JSONObject creativeJson = new JSONObject();
         creativeJson.put("advertiser_id", accountId);
         creativeJson.put("unit_id", unitId);
@@ -1296,18 +1285,14 @@ public class BatchServiceImpl implements IBatchService {
         String site_id = requestJson.getString("siteId");
         Integer creativeCategory = requestJson.getInteger("creativeCategory");// 创意分类
         JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
-
         JSONObject returnJson = new JSONObject();
         JSONArray successArr = new JSONArray();
         JSONArray failArr = new JSONArray();
         JSONArray dataJsons = requestJson.getJSONArray("dataJson");
-
         Integer content = requestJson.getInteger("content");
-
         if (!Check.isNull(dataJsons)) {
             for (int i = 0; i < dataJsons.size(); i++) {
                 JSONObject dataJson = dataJsons.getJSONObject(i);
-
                 String creativeMaterialType = dataJson.getString("creativeMaterialType");
                 String shortSlogan = dataJson.getString("shortSlogan");
                 String overlayType = dataJson.getString("overlayType");
@@ -1436,19 +1421,13 @@ public class BatchServiceImpl implements IBatchService {
         creativeJson.put("unit_id", unitId);
         String click_track_url = requestJson.getString("clickTrackUrl");
         String actionbar_click_url = requestJson.getString("actionbarClickUrl");
-
-
         // 素材类型
-
         String action_bar_text = requestJson.getString("actionBarText");
         String site_id = requestJson.getString("siteId");
         Integer creativeCategory = requestJson.getInteger("creativeCategory");// 创意分类
         JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
-
-
         JSONArray dataJsons = requestJson.getJSONArray("dataJson");
         Integer content = requestJson.getInteger("content");
-
         if (!Check.isNull(dataJsons)) {
             JSONArray creatives = new JSONArray();
             for (int i = 0; i < dataJsons.size(); i++) {
@@ -1539,6 +1518,34 @@ public class BatchServiceImpl implements IBatchService {
         return returnUnitMap;
     }
 
+    @Override
+    public JSONObject getCategoryWhite(Long accountId, String accessToken) {
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/white_list";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", accessToken);
+            Map<String, Object> param = new HashMap<String, Object>();
+            param.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        return data;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+
+
+    }
+
 
     /**
      * 获取创意信息

+ 3 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java

@@ -67,6 +67,9 @@ public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouAction
                     Integer campaign_type = data.getInteger("campaign_type");
                     JSONArray action_bar_text = data.getJSONArray("action_bar_text");
                     if (!Check.isNull(action_bar_text)) {
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("type", campaign_type);
+                        actionBarTextMapper.deleteByMap(deleteMap);
                         for (int j = 0; j < action_bar_text.size(); j++) {
                             String actionBarText = action_bar_text.getString(j);
                             KuaiShouActionBarText kuaiShouActionBarText = new KuaiShouActionBarText();

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java

@@ -235,7 +235,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         QueryWrapper<KuaiShouGroupTemplate> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("task_status", 0);
         queryWrapper.orderByAsc("create_time");
-        queryWrapper.last("limit 30");
+        queryWrapper.last("limit 45");
         List<KuaiShouGroupTemplate> list = this.list(queryWrapper);
         if (Check.isNull(list)) {
             log.error("暂未未创建的组");