Forráskód Böngészése

修改内广批量代码逻辑

syh 5 éve
szülő
commit
96fb28f2f3

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

@@ -195,7 +195,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         Map<String, Object> resultMap = new HashMap<>();
         //1:获取用户名密码
         Long accountId = requestJson.getLong("accountId");
-        System.out.println(accountId);
         Long userOrientationId = requestJson.getLong("userOrientationId");
         BindAccountLogin bindAccountLogin = bindAccountLoginService.selectByAccountId(accountId + "");
         if (null == bindAccountLogin) {
@@ -207,6 +206,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
             ResultMapUtils.setResultMap(resultMap, StatusCode.ACCOUNT_HAS_NOT_EXIST.getCode());
             return resultMap;
         }
+        JSONObject wordsObject = fileInfoService.getCreativeWord(token, token.getAccountId());
         String url = "https://ad.oceanengine.com/pages/login/index.html";
         System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
         ChromeOptions chromeOptions = new ChromeOptions();
@@ -221,7 +221,8 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         chromeOptions.setAcceptInsecureCerts(true);
         WebDriver webDriver = new ChromeDriver(chromeOptions);
         try {
-            webDriver.get(url);  //获取登录页面
+            //获取登录页面
+            webDriver.get(url);
             for (Cookie cookie : webDriver.manage().getCookies()) {
                 BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
                 ck.setDomain("ad.oceanengine.com");
@@ -283,10 +284,11 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                     Cookie cookie = new Cookie(ck.getName(), ck.getValue(), "." + ck.getDomain(), ck.getPath(), ck.getExpiryDate());
                     webDriver.manage().addCookie(cookie);
                 }
-
-                webDriver.get("https://ad.oceanengine.com/pages/promotion.html#/ad");//登录成功 进入推广页面
+                //登录成功 进入推广页面
+                webDriver.get("https://ad.oceanengine.com/pages/promotion.html#/ad");
                 Thread.sleep(3000);
-                webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");//创建广告组页面
+                //创建广告组页面
+                webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");
                 String templateName = requestJson.getString("templateName");
                 Map<String, Object> campaignParam = new HashMap<>();
                 String uuid = UUID.randomUUID().toString();
@@ -317,7 +319,8 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 header.put("X-CSRFToken", csrftoken);
                 header.put("X-Requested-With", "XMLHttpRequest");
                 header.put("Referer", "https://ad.oceanengine.com/pages/campaign/create.html");
-                res = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", campaignParam, header);// 创建广告组返回信息
+                // 创建广告组返回信息
+                res = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", campaignParam, header);
                 System.out.println(res);
                 Integer itratorNum = requestJson.getInteger("itratorNum");
                 JSONObject data = new JSONObject();
@@ -325,7 +328,8 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                     //循环创建广告计划
                     for (int i = 0; i < itratorNum; i++) {
                         JsonNode node = mapper.readTree(res);
-                        String campaignId = node.get("data").get("campaign_id").asText();  //广告组id
+                        //广告组id
+                        String campaignId = node.get("data").get("campaign_id").asText();
                         String url2 = "https://ad.oceanengine.com/pages/ad/create.html?campaign_id=" + campaignId + "&landing_type=3&temp_id=ADvQb";
                         webDriver.get(url2);
                         header.put("Referer", url2);
@@ -342,16 +346,19 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                         String tokenStr = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/api/v1/hl/ad/audience/estimate/", audienceParam, header);
                         JsonNode tokenNode = mapper.readTree(tokenStr);
                         Map<String, Object> planParam = new HashMap<>();
-                        planParam.put("name", templateName + "-广告计划-" + uuid.substring(1, 7) + i);//模板名称
+                        //模板名称
+                        planParam.put("name", templateName + "-广告计划-" + uuid.substring(1, 7) + i);
                         Integer deliveryRange = requestJson.getInteger("deliveryRange");
-                        planParam.put("delivery_range", deliveryRange);  //投放形式
+                        //投放形式
+                        planParam.put("delivery_range", deliveryRange);
                         if (deliveryRange == 2) {
-                            planParam.put("union_video_type", requestJson.getInteger("deliveryForm")); //投放形式 1:激励视频 2:原生
+                            //投放形式 1:激励视频 2:原生
+                            planParam.put("union_video_type", requestJson.getInteger("deliveryForm"));
                         }
-                        planParam.put("classify", requestJson.getString("adCategory")); //广告类别
-                        planParam.put("projectid", ""); //
+                        planParam.put("projectid", "");
                         Integer downloadType = requestJson.getInteger("downloadType");
-                        planParam.put("download_type", downloadType); //下载方式  1:下载包 2:h5
+                        //下载方式  1:下载包 2:h5
+                        planParam.put("download_type", downloadType);
                         Long urlId = requestJson.getLong("urlId");
                         BytedanceUrlInfo urlInfo = urlInfoMapper.selectById(urlId);
                         if (downloadType == 1) {
@@ -359,59 +366,92 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                             planParam.put("package", urlInfo.getPackageName());
                         }
                         if (downloadType == 2) {
-                            planParam.put("external_url", urlInfo.getUrl());  // 落地页链接
+                            // 落地页链接
+                            planParam.put("external_url", urlInfo.getUrl());
                         }
-                        planParam.put("delivery_range", 1);  // 投放范围
-                        planParam.put("classify", 5);  //广告类别  5 内广
+                        // 投放范围
+                        planParam.put("delivery_range", 1);
+                        //广告类别  5 内广
+                        planParam.put("classify", 5);
                         planParam.put("projectid", "");
                         planParam.put("localGeolocation", new ArrayList<String>());
 //                        planParam.put("external_action", 4);
-                        planParam.put("open_url", ""); //  应用直达链接
+                        //  应用直达链接
+                        planParam.put("open_url", "");
                         planParam.put("style_type", 0);
-                        planParam.put("location_type", 4); //受众位置类型
-                        planParam.put("hide_if_exists", 0); // 过滤已安装,当推广目标为安卓应用下载时可填,0表示不过滤,1表示过滤,默认为不过滤
-                        planParam.put("interest_tag_mode", 0); //兴趣分类
+                        //受众位置类型
+                        planParam.put("location_type", 4);
+                        // 过滤已安装,当推广目标为安卓应用下载时可填,0表示不过滤,1表示过滤,默认为不过滤
+                        planParam.put("hide_if_exists", 0);
+                        //兴趣分类
+                        planParam.put("interest_tag_mode", 0);
                         planParam.put("token", tokenNode.get("data").get("token").asText());
-                        planParam.put("toutiao", 100000005);  //头条预估数据
-                        planParam.put("aweme", 150000005); //抖音预估数据
-                        planParam.put("video_app", 40000005);//西瓜预估数据
-                        planParam.put("hotsoon", 40000005); //火山预估数据
-                        planParam.put("aweme_account_fans", 0); //账号粉丝相似人群
-                        planParam.put("auto_extend_enabled", 0);// 智能放量????
-                        planParam.put("budget_mode", requestJson.getIntValue("budgetPriceMode"));  // 广告预算类型  0 日预算  1 总预算
-                        planParam.put("budget", requestJson.getIntValue("budgetPrice")); //广告预算
+                        //头条预估数据
+                        planParam.put("toutiao", 100000005);
+                        //抖音预估数据
+                        planParam.put("aweme", 150000005);
+                        //西瓜预估数据
+                        planParam.put("video_app", 40000005);
+                        //火山预估数据
+                        planParam.put("hotsoon", 40000005);
+                        //账号粉丝相似人群
+                        planParam.put("aweme_account_fans", 0);
+                        // 智能放量????
+                        planParam.put("auto_extend_enabled", 0);
+                        // 广告预算类型  0 日预算  1 总预算
+                        planParam.put("budget_mode", requestJson.getIntValue("budgetPriceMode"));
+                        //广告预算
+                        planParam.put("budget", requestJson.getIntValue("budgetPrice"));
                         int scheduleType = requestJson.getIntValue("dateQuantum");
-                        planParam.put("schedule_type", scheduleType); //广告投放时间类型   默认1 1:不限  2:按时间???
+                        //广告投放时间类型   默认1 1:不限  2:按时间???
+                        planParam.put("schedule_type", scheduleType);
                         if (scheduleType == 2) {
-                            planParam.put("start_time", requestJson.getString("startDate")); //广告投放起始时间
-                            planParam.put("end_time", requestJson.getString("endDate"));//广告投放结束时间
+                            //广告投放起始时间
+                            planParam.put("start_time", requestJson.getString("startDate"));
+                            //广告投放结束时间
+                            planParam.put("end_time", requestJson.getString("endDate"));
                         }
-                        planParam.put("week_schedule", new ArrayList<String>());  //投放时段
-                        planParam.put("week_time", new ArrayList<ArrayList<Integer>>());//投放时段
+                        //投放时段
+                        planParam.put("week_schedule", new ArrayList<String>());
+                        //投放时段
+                        planParam.put("week_time", new ArrayList<ArrayList<Integer>>());
                         int pricing = requestJson.getIntValue("pricing");
-                        planParam.put("pricing", pricing); //计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
-                        planParam.put("cpa_phrase", 2); //出价为OCPC时,计划处于哪个阶段??
+                        //计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
+                        planParam.put("pricing", pricing);
+                        //出价为OCPC时,计划处于哪个阶段??
+                        planParam.put("cpa_phrase", 2);
                         planParam.put("is_union_slot", "");
-                        planParam.put("hide_if_converted", 1); //过滤已转化用户类型字段,只有转化为目标时可填 优化目标为转化才展示
-                        planParam.put("flow_control_mode", requestJson.getIntValue("flowControlMode")); //投放速度/投放方式使用字段
+                        //过滤已转化用户类型字段,只有转化为目标时可填 优化目标为转化才展示
+                        planParam.put("hide_if_converted", 1);
+                        //投放速度/投放方式使用字段
+                        planParam.put("flow_control_mode", requestJson.getIntValue("flowControlMode"));
                         if (pricing == 9) {
                             planParam.put("cpa_bid", requestJson.getIntValue("convertPrice"));
                         } else {
                             planParam.put("bid", requestJson.getIntValue("convertPrice"));
                         }
-                        planParam.put("smart_bid_type", requestJson.getIntValue("bidType")); //自动出价类型,OCPM支持
-                        planParam.put("adjust_cpa", 0); //是否调整自动出价   允许值: "0", "1"  默认值: 0
+                        //自动出价类型,OCPM支持
+                        planParam.put("smart_bid_type", requestJson.getIntValue("bidType"));
+                        //是否调整自动出价   允许值: "0", "1"  默认值: 0
+                        planParam.put("adjust_cpa", 0);
                         planParam.put("app_bid_ratio", new Object());
                         planParam.put("campaign_id", campaignId);
-                        String downLoadMode = requestJson.getString("downloadMode");
                         if ("IOS".equals(urlInfo.getType())) {
-                            planParam.put("app_type", 202); //app 类型 201 应用推广 安卓 201 应用推广 ios
+                            //app 类型 201 应用推广 安卓 201 应用推广 ios
+                            planParam.put("app_type", 202);
                         } else if ("android".equals(urlInfo.getType())) {
                             planParam.put("app_type", 201);
                         }
-                        Long convertId = requestJson.getLong("convertId");
-                        if (null != convertId && convertId != 0) {
-                            planParam.put("convert_id", convertId);
+                        String convertType = requestJson.getString("convertType");
+                        if (null != convertType && convertType.equals("SIMPLE")) {
+                            //普通应用下载
+                            planParam.put("external_action", requestJson.getLong("simpleDeliverytarget"));
+                        }
+                        if (null != convertType && convertType.equals("API")) {
+                            Long convertId = requestJson.getLong("convertId");
+                            if (null != convertId && convertId != 0) {
+                                planParam.put("convert_id", convertId);
+                            }
                         }
                         System.out.println(planParam);
                         String createResult = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", planParam, header);
@@ -460,15 +500,15 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                             }
 
                             //广告评论
-                            data.put("is_comment_disable ", launchTemplate.getCommentDisable());
+                            data.put("is_comment_disable", launchTemplate.getCommentDisable());
                             //创意展现方式
-                            data.put("creative_display_mode ", launchTemplate.getCreativeDisplayMode());
+                            data.put("creative_display_mode", launchTemplate.getCreativeDisplayMode());
                             //创意分类
                             JSONArray categorys = JSONArray.parseArray(launchTemplate.getThirdIndustryId());
                             String thirdIndustryId = categorys.getString(2);
                             data.put("third_industry_id", thirdIndustryId);
                             //创意标签
-                            data.put("ad_keywords", JSONArray.parseObject(launchTemplate.getAdKeywords()));
+                            data.put("ad_keywords", JSONArray.parseArray(launchTemplate.getAdKeywords()));
                             //创意标题
                             data.put("title", name + "_" + System.currentTimeMillis() + "_" + "汇创广告创意");
 
@@ -481,16 +521,18 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                                 JSONArray getCreatives = requestJson.getJSONArray("creatives");
                                 if (null != getCreatives && getCreatives.size() > 0) {
                                     getCreatives.forEach(k -> {
-                                        JSONObject createtive = (JSONObject) k;
+                                        JSONObject createtive = JSONObject.parseObject(JSONObject.toJSONString(k));
                                         JSONObject setCreatetive = new JSONObject();
                                         String imageMode = createtive.getString("typeCode");
                                         setCreatetive.put("image_mode", imageMode);
-                                        setCreatetive.put("title", createtive.getString("text"));
-                                        //TODO 添加动态词包id
+                                        String title = createtive.getString("text");
+                                        setCreatetive.put("title", title);
+                                        JSONArray ids = getCreativeWordIds(title, wordsObject);
+                                        setCreatetive.put("creative_word_ids", ids);
+                                        String videoUrl = createtive.getString("vadioUrl");
+                                        String imageUrl = createtive.getString("imageUrl");
                                         if ("CREATIVE_IMAGE_MODE_VIDEO".equals(imageMode) || "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL".equals(imageMode)) {
                                             //视频创意
-                                            String videoUrl = createtive.getString("vadioUrl");
-                                            String imageUrl = createtive.getString("imageUrl");
                                             if (null != videoUrl) {
                                                 Map<String, Object> getImageResult = fileInfoService.uploadImageToBytedance(token.getAccountId() + "", imageUrl);
                                                 JSONArray horizonVideoCoverImageArray = (JSONArray) getImageResult.get("imageIds");
@@ -503,9 +545,8 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                                             }
                                         } else {
                                             //图片创意
-                                            String imageUrl = requestJson.getString("imageUrl");
-                                            if (null != imageUrl && !"".equals(imageUrl.trim())) {
-                                                Map<String, Object> getImageResult = fileInfoService.uploadImageToBytedance(token.getAccountId() + "", imageUrl);
+                                            if (null != videoUrl && !"".equals(videoUrl.trim())) {
+                                                Map<String, Object> getImageResult = fileInfoService.uploadImageToBytedance(token.getAccountId() + "", videoUrl);
                                                 JSONArray imageArray = (JSONArray) getImageResult.get("imageIds");
                                                 setCreatetive.put("image_ids", imageArray);
                                                 creatives.add(setCreatetive);
@@ -515,19 +556,55 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                                     data.put("creatives", creatives);
                                 }
                             } else {
+                                data.put("creative_material_mode", "STATIC_ASSEMBLE");
                                 //程序化创意
                                 JSONArray titleArray = requestJson.getJSONArray("titles");
                                 if (null != titleArray && titleArray.size() > 0) {
-                                    JSONArray setTitleArray = new JSONArray();
+                                    JSONArray titleList = new JSONArray();
                                     titleArray.forEach(v -> {
-                                        JSONObject getTitleObject = (JSONObject) v;
+                                        JSONObject getTitleObject = JSONObject.parseObject(JSONObject.toJSONString(v));
+                                        ;
                                         JSONObject titleObject = new JSONObject();
                                         String getTitle = getTitleObject.getString("text");
                                         titleObject.put("title", getTitle);
-                                        ArrayList<String> wordsString = StringUtils.stringCutFromBrace(getTitle);
-                                        fileInfoService.getCreativeWords(accountId);
-                                        titleArray.add(titleObject);
+                                        JSONArray ids = getCreativeWordIds(getTitle, wordsObject);
+                                        titleObject.put("creative_word_ids", ids);
+                                        titleList.add(titleObject);
                                     });
+                                    data.put("title_list", titleList);
+                                }
+
+                                JSONArray getCreatives = requestJson.getJSONArray("creatives");
+                                if (null != getCreatives && getCreatives.size() > 0) {
+                                    JSONArray imageList = new JSONArray();
+                                    getCreatives.forEach(v -> {
+                                        JSONObject createtive = JSONObject.parseObject(JSONObject.toJSONString(v));
+                                        JSONObject setCreatetive = new JSONObject();
+                                        String imageMode = createtive.getString("typeCode");
+                                        setCreatetive.put("image_mode", imageMode);
+                                        String videoUrl = createtive.getString("vadioUrl");
+                                        String imageUrl = createtive.getString("imageUrl");
+                                        if ("CREATIVE_IMAGE_MODE_VIDEO".equals(imageMode) || "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL".equals(imageMode)) {
+                                            if (null != videoUrl) {
+                                                Map<String, Object> getImageResult = fileInfoService.uploadImageToBytedance(token.getAccountId() + "", imageUrl);
+                                                JSONArray horizonVideoCoverImageArray = (JSONArray) getImageResult.get("imageIds");
+                                                String imageId = horizonVideoCoverImageArray.getString(0);
+                                                Map<String, Object> getVideoResult = fileInfoService.uploadVideoToBytedance(token.getAccountId() + "", videoUrl);
+                                                String videoId = (String) getVideoResult.get("videoId");
+                                                setCreatetive.put("image_id", imageId);
+                                                setCreatetive.put("video_id", videoId);
+                                                imageList.add(setCreatetive);
+                                            }
+                                        } else {
+                                            if (null != videoUrl && !"".equals(videoUrl.trim())) {
+                                                Map<String, Object> getImageResult = fileInfoService.uploadImageToBytedance(token.getAccountId() + "", videoUrl);
+                                                JSONArray imageArray = (JSONArray) getImageResult.get("imageIds");
+                                                setCreatetive.put("image_ids", imageArray);
+                                                imageList.add(setCreatetive);
+                                            }
+                                        }
+                                    });
+                                    data.put("image_list", imageList);
                                 }
                             }
                             //应用下载详情页
@@ -535,6 +612,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                             //应用名
                             data.put("app_name", requestJson.getString("appName"));
                         }
+                        System.out.println(data.toJSONString());
                         resultMap = byteDanceCreativeService.creativeCreate(token.getAccountId() + "", adId, data.toJSONString());
                         Boolean createSuccess = (Boolean) resultMap.get("success");
                         if (null != createSuccess && !createSuccess) {
@@ -556,6 +634,23 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         return resultMap;
     }
 
+    public JSONArray getCreativeWordIds(String getTitle, JSONObject wordsObject) {
+        ArrayList<String> wordsString = StringUtils.stringCutFromBrace(getTitle);
+        JSONArray creativeWords = wordsObject.getJSONArray("creative_word");
+        JSONArray ids = new JSONArray();
+        wordsString.forEach(v -> {
+            creativeWords.forEach(word -> {
+                JSONObject wordObject = (JSONObject) word;
+                String name = wordObject.getString("name");
+                Integer id = wordObject.getInteger("creative_word_id");
+                if (v.equals(name)) {
+                    ids.add(id);
+                }
+            });
+        });
+        return ids;
+    }
+
 
     @Autowired
     private BytedanceCreativeLaunchTemplateMapper launchTemplateMapper;
@@ -563,8 +658,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
     private IByteDanceCreativeService byteDanceCreativeService;
     @Autowired
     private IFileInfoService fileInfoService;
-
-
     @Autowired
     private ByteDanceUserOrientationTemplateMapper userOrientationTemplateMapper;
     @Autowired

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.fileupload.controller;
 
 import cn.com.ctop.common.module.service.IFileInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -21,4 +22,9 @@ public class FileController {
     public Map<String, Object> chenckFile(String code) {
         return fileInfoService.checkFile(code);
     }
+
+    @PostMapping("file/insert")
+    public Map<String, Object> insertFile(String code, String url) {
+        return fileInfoService.insertFile(code, url);
+    }
 }

+ 27 - 29
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -2,9 +2,10 @@ package org.jeecg;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IFileInfoService;
 import cn.com.ctop.common.module.utils.OSSUtils;
+import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.toutiao.entity.ByteDanceUserOrientationTemplate;
-import cn.com.ctop.toutiao.entity.BytedanceAreaInfo;
 import cn.com.ctop.toutiao.entity.BytedanceInterestCategory;
 import cn.com.ctop.toutiao.mapper.ByteDanceUserOrientationTemplateMapper;
 import cn.com.ctop.toutiao.mapper.BytedanceAreaInfoMapper;
@@ -26,6 +27,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Map;
 
@@ -134,36 +136,32 @@ public class SampleTest {
         }
     }
 
+    @Autowired
+    private IFileInfoService fileInfoService;
+
     @Test
     public void setJSONFile() {
-        String path = "C:\\Users\\宋英豪\\Downloads\\data_20190222\\city.json";
-        String jsonString = JsonschemaUtil.readJsonFile(path);
-        JSONObject data = JSONObject.parseObject(jsonString);
-        data.forEach((k, v) -> {
-            JSONObject getData = data.getJSONObject(k);
-            BytedanceAreaInfo areaInfo = new BytedanceAreaInfo();
-            Integer level = getData.getInteger("level");
-            Long id = getData.getLong("id");
-            String name = getData.getString("name");
-            System.out.println(name);
-            String parent = getData.getString("parent");
-            areaInfo.setId(id);
-            areaInfo.setLevel(level);
-            String code = id + "";
-            if (level == 1) {
-                areaInfo.setParentCode(parent);
-                areaInfo.setCode(code);
-            } else if (level == 2) {
-                areaInfo.setParentCode(code.substring(0, 2));
-                areaInfo.setCode(code.substring(0, 4));
-            } else {
-                areaInfo.setParentCode(code.substring(0, 4));
-                areaInfo.setCode(code);
-            }
-            areaInfo.setName(name);
-            areaInfo.setCreateTime(new Date());
-            areaInfo.setUpdateTime(new Date());
-            areaInfoMapper.insert(areaInfo);
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId("93289889842");
+        JSONObject wordsObject = fileInfoService.getCreativeWord(token, token.getAccountId());
+        String getTitle = "哈哈{日期}{男人女人}";
+        JSONArray ids = getCreativeWordIds(getTitle, wordsObject);
+        System.out.println(ids);
+    }
+
+    public JSONArray getCreativeWordIds(String getTitle, JSONObject wordsObject) {
+        ArrayList<String> wordsString = StringUtils.stringCutFromBrace(getTitle);
+        JSONArray creativeWords = wordsObject.getJSONArray("creative_word");
+        JSONArray ids = new JSONArray();
+        wordsString.forEach(v -> {
+            creativeWords.forEach(word -> {
+                JSONObject wordObject = (JSONObject) word;
+                String name = wordObject.getString("name");
+                Integer id = wordObject.getInteger("creative_word_id");
+                if (v.equals(name)) {
+                    ids.add(id);
+                }
+            });
         });
+        return ids;
     }
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IFileInfoService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.common.module.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.FileInfo;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -28,4 +29,8 @@ public interface IFileInfoService extends IService<FileInfo> {
     Map<String, Object> getCreativeWords(Long accountId);
 
     public JSONObject getSiteList(Long accountId);
+
+    JSONObject getCreativeWord(CtopOauthToken token, Long advertiserId);
+
+    Map<String, Object> insertFile(String code, String url);
 }

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -161,6 +161,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         return null;
     }
 
+    @Override
     public JSONObject getCreativeWord(CtopOauthToken token, Long advertiserId) {
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/tools/creative_word/select/";
@@ -186,6 +187,23 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         return resultObject;
     }
 
+    @Override
+    public Map<String, Object> insertFile(String code, String url) {
+        Map<String, Object> resultMap = new HashMap();
+        FileInfo fileInfo = new FileInfo();
+        fileInfo.setFileName("");
+        fileInfo.setFileUrl(url);
+        fileInfo.setMd5(code);
+        fileInfo.setPath("");
+        fileInfo.setPlatformType("");
+        fileInfo.setAccountId(0L);
+        fileInfo.setFileId("");
+        fileInfo.setType("");
+        this.saveOrUpdate(fileInfo);
+        ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
+        return resultMap;
+    }
+
     public JSONObject searchIndustry(CtopOauthToken token, Integer level) {
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/tools/industry/get/";

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertisePlanServiceImpl.java

@@ -93,7 +93,7 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
 
     private Map<String, Object> getAdConvertByUrlInfo(CtopOauthToken token, BytedanceUrlInfo urlInfo) {
 
-        final Long advertiserId = token.getAccountId();
+        Long advertiserId = token.getAccountId();
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/tools/ad_convert/select/";
         // 请求参数