yumeng 4 éve
szülő
commit
51d0e4ef61

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

@@ -2325,6 +2325,11 @@ public class BatchController {
     }
 
 
+    /**
+     * 贴纸类型
+     * @param accountId
+     * @return
+     */
     @GetMapping(value = "/getCreativeWordStyles")
     public Result<JSONArray> getCreativeWordStyles(Long accountId) {
         Result<JSONArray> result = new Result<>();
@@ -2349,4 +2354,38 @@ public class BatchController {
 
         return result;
     }
+
+    /**
+     * 创意分类
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getCreativeCategory")
+    public Result<JSONArray> getCreativeCategory(Long accountId) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            JSONArray data = batchService.getCreativeCategory(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;
+    }
+
+
+
+
 }

+ 4 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java

@@ -58,7 +58,6 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "广告创意ID")
     private Long creativeId;
 
-
     /**
      * 素材类型
      */
@@ -221,4 +220,8 @@ public class KuaiShouCreative {
 
 
     private String photoIds;
+
+    private Integer creativeCategory;
+    private String creativeTag;
+
 }

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -37,6 +37,8 @@
         actionbar_click_url,
         creative_create_time,
         creative_update_time,
+        creative_category,
+        creative_tag,
         create_time,
         update_time)
         values
@@ -76,6 +78,8 @@
             #{creative.actionbarClickUrl},
             #{creative.creativeCreateTime},
             #{creative.creativeUpdateTime},
+            #{creative.creativeCategory},
+            #{creative.creativeTag},
             #{creative.createTime},
             #{creative.updateTime})
         </foreach>

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

@@ -158,4 +158,12 @@ public interface IBatchService {
      * @return
      */
     JSONArray getCreativeWordStyles(Long accountId, String accessToken);
+
+    /**
+     * 获取创意分类
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONArray getCreativeCategory(Long accountId, String accessToken);
 }

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

@@ -1099,7 +1099,13 @@ public class BatchServiceImpl implements IBatchService {
                     creativeJson.put("actionbar_click_url", creative.getActionbarClickUrl());
                 }
 
-
+                /**
+                 * 创意标签
+                 */
+                if (!Check.isNull(creative.getCreativeCategory()) && !Check.isNull(!Check.isNull(creative.getCreativeTag()))) {
+                    creativeJson.put("creative_category", creative.getCreativeCategory());
+                    creativeJson.put("creative_tag", JSONArray.parseArray(creative.getCreativeTag()));
+                }
                 if (!Check.isNull(otherJson)) {
                     Boolean isUpdate = otherJson.getBoolean("isUpdate"); // 是否修改落地页
                     if (isUpdate) {
@@ -1276,6 +1282,9 @@ public class BatchServiceImpl implements IBatchService {
         String action_bar_text = requestJson.getString("actionBarText");
         String click_track_url = requestJson.getString("clickTrackUrl");
         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();
@@ -1291,8 +1300,6 @@ public class BatchServiceImpl implements IBatchService {
                 String shortSlogan = dataJson.getString("shortSlogan");
                 String overlayType = dataJson.getString("overlayType");
                 String stickerTitle = dataJson.getString("stickerTitle");
-
-
                 if (!Check.isNull(dataJsons)) {
                     String description = dataJson.getString("description");
                     String photo_id = dataJson.getString("photoId");
@@ -1321,11 +1328,16 @@ public class BatchServiceImpl implements IBatchService {
                                 if (!Check.isNull(stickerTitle)) {
                                     creativeJson.put("sticker_title", stickerTitle);
                                 }
+
+                                if (!Check.isNull(creativeCategory) && !Check.isNull(creativeTag)) {
+                                    creativeJson.put("creative_category", creativeCategory);
+                                    creativeJson.put("creative_tag", creativeTag);
+                                }
+
                                 if (creativeMaterialType.equals("4")) {
                                     if (!Check.isNull("shortSlogan")) {
                                         creativeJson.put("short_slogan", shortSlogan);
                                     }
-
                                 }
                                 String imageToken = null;
                                 String signature = imageJson.getString("signature");
@@ -1801,25 +1813,97 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONArray getCreativeWordStyles(Long accountId, String accessToken) {
-        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/creative_word/styles";
-        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) {
-                return resultJson.getJSONArray("data");
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/creative_word/styles";
+            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) {
+                    return resultJson.getJSONArray("data");
+                }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 
+
+    /**
+     * 获取创意分类
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    @Override
+    public JSONArray getCreativeCategory(Long accountId, String accessToken) {
+
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/creative/creative_category/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)) {
+                        JSONArray details = data.getJSONArray("details");
+                        if (!Check.isNull(details)) {
+                            JSONArray returnArr = new JSONArray();
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject jsonObject = details.getJSONObject(i);
+
+                                String level = jsonObject.getString("level");
+                                if ("1".equals(level)) {
+                                    JSONArray LevelArr = getSubLevel(jsonObject.getInteger("category_id"), details);
+                                    jsonObject.put("child", LevelArr);
+                                    returnArr.add(jsonObject);
+                                }
+                            }
+                            return returnArr;
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
         return null;
     }
 
 
+    private JSONArray getSubLevel(Integer categoryId, JSONArray details) {
+
+        JSONArray secondArr = new JSONArray();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject secondJson = details.getJSONObject(i);
+            if ("2".equals(secondJson.getString("level")) && categoryId.equals(secondJson.getInteger("parent_id"))) {
+                JSONArray thirdArr = new JSONArray();
+                for (int j = 0; j < details.size(); j++) {
+                    JSONObject thirdJson = details.getJSONObject(j);
+                    if ("3".equals(thirdJson.getString("level")) && secondJson.getInteger("category_id").equals(thirdJson.getInteger("parent_id"))) {
+                        thirdArr.add(thirdJson);
+                    }
+                }
+                secondJson.put("child", thirdArr);
+                secondArr.add(secondJson);
+            }
+        }
+        return secondArr;
+    }
+
 }
 
 

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

@@ -149,6 +149,10 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
                     creative.setDescription(displayInfoJson.getString("description"));
                     creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
                 }
+                creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                    creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                }
                 creative.setCreateTime(new java.util.Date());
                 creative.setUpdateTime(new java.util.Date());
                 creative.setSiteId(detailJson.getLong("site_id"));

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

@@ -222,6 +222,10 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                         creative.setDescription(displayInfoJson.getString("description"));
                         creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
                     }
+                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                    }
                     creative.setCreateTime(new Date());
                     creative.setUpdateTime(new Date());
                     creative.setSiteId(detailJson.getLong("site_id"));

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

@@ -1336,7 +1336,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
                         creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
                     }
-
                     if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
                         creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
                     }
@@ -1359,6 +1358,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
                     creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
                     creative.setShortSlogan(detailJson.getString("short_slogan"));
+                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                    }
                     creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                     if (!Check.isNull(displayInfoJson)) {
@@ -1542,6 +1545,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     creative.setShortSlogan(detailJson.getString("short_slogan"));
                                     creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
+
+                                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                                    }
+
                                     if (!Check.isNull(displayInfoJson)) {
                                         creative.setDescription(displayInfoJson.getString("description"));
                                         creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
@@ -3066,6 +3075,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
                                         creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
                                     }
+
+                                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                                    }
+
                                     creative.setStatus(detailJson.getInteger("status"));
                                     creative.setPutStatus(detailJson.getInteger("put_status"));
                                     creative.setCreateChannel(detailJson.getInteger("create_channel"));