Browse Source

修改创意参数

yangzian 3 years ago
parent
commit
aa6f381d32

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/AiBytedanceAdvertiserStrategy.java

@@ -252,7 +252,7 @@ public class AiBytedanceAdvertiserStrategy{
 	private String creativeImageMode;
 	/**广告来源*/
 	private String creativeSource;
-	/**品牌主页*/
+	/**品牌主页 使用抖音号*/
 	private String creativeIesCoreUserId;
 	/**作品页隐藏广告内容*/
 	private Integer creativeIsFeedAndFavSee;

+ 42 - 36
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -280,11 +280,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
 
 
         /*基础创意*/
-
+        JSONObject ad_data = new JSONObject();
         //行业类别
         String thirdIndustryId = strategy.getCreativeThirdIndustryId();
         if(!Check.isNull(thirdIndustryId)){
-            params.put("third_industry_id",thirdIndustryId);
+            ad_data.put("third_industry_id",thirdIndustryId);
         }
 
         //关键词 添加随机关键词逻辑
@@ -293,82 +293,83 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             String [] keywords = adKeywords.split(",");
             if(keywords.length>0){
                 if(keywords.length<=20){
-                    params.put("ad_keywords",keywords);
+                    ad_data.put("ad_keywords",keywords);
                 }else {
                     List<String>keywordList = Arrays.asList(keywords);
                     Collections.shuffle(keywordList);
                     List<String> getKeyWords = keywordList.subList(0,20);
-                    params.put("ad_keywords",getKeyWords);
+                    ad_data.put("ad_keywords",getKeyWords);
                 }
             }
         }
         //广告来源
         String source = strategy.getCreativeSource();
         if(!Check.isNull(source)){
-            params.put("source",source);
+            ad_data.put("source",source);
         }
         //推广抖音号
         String iesCoreUserId = strategy.getCreativeIesCoreUserId();
         if(!Check.isNull(iesCoreUserId)){
-            params.put("ies_core_user_id",iesCoreUserId);
+            ad_data.put("ies_core_user_id",iesCoreUserId);
         }
         //主页作品列表隐藏广告内容
         Integer isFeedAndFavSee = strategy.getCreativeIsFeedAndFavSee();
         if(null!=isFeedAndFavSee&&isFeedAndFavSee!=0){
-            params.put("is_feed_and_fav_see",isFeedAndFavSee);
+            ad_data.put("is_feed_and_fav_see",isFeedAndFavSee);
         }
         //是否开启自动生成素材
         Integer creativeAutoGenerateSwitch = strategy.getCreativeAutoGenerateSwitch();
         if(null!=creativeAutoGenerateSwitch&&creativeAutoGenerateSwitch!=1){
-            params.put("creative_auto_generate_switch",creativeAutoGenerateSwitch);
+            ad_data.put("creative_auto_generate_switch",creativeAutoGenerateSwitch);
         }
         //是否自动生成视频素材
         Integer isPresentedVideo = strategy.getCreativeIsPresentedVideo();
         if(null!=isPresentedVideo&&isPresentedVideo!=0){
-            params.put("is_presented_video",isPresentedVideo);
+            ad_data.put("is_presented_video",isPresentedVideo);
         }
         //是否开启衍生计划
         Integer generateDerivedAd = strategy.getCreativeGenerateDerivedAd();
         if(null!=generateDerivedAd&&generateDerivedAd!=0){
-            params.put("generate_derived_ad",generateDerivedAd);
+            ad_data.put("generate_derived_ad",generateDerivedAd);
         }
         //搭配试玩素材url
         String playableUrl = strategy.getCreativePlayableUrl();
         if(!Check.isNull(playableUrl)){
-            params.put("playable_url",playableUrl);
+            ad_data.put("playable_url",playableUrl);
         }
         //应用名
         String appName = strategy.getCreativeAppName();
         if(!Check.isNull(appName)){
-            params.put("app_name",appName);
+            ad_data.put("app_name",appName);
         }
         //Android应用下载详情页
         String webUrl = strategy.getCreativeWebUrl();
         if(!Check.isNull(webUrl)){
-            params.put("web_url",webUrl);
+            ad_data.put("web_url",webUrl);
         }
         //落地页链接
         if(!Check.isNull(strategy.getAdExternalUrl())){
-            params.put("external_url",strategy.getAdExternalUrl());
+            ad_data.put("external_url",strategy.getAdExternalUrl());
         }
 
         //是否关闭评论,0为开启,1为关闭,默认值:0
         Integer isCommentDisable = strategy.getCreativeIsCommentDisable();
         if(!Check.isNull(isCommentDisable)&&isCommentDisable!=0){
-            params.put("is_comment_disable",isCommentDisable);
+            ad_data.put("is_comment_disable",isCommentDisable);
         }
         //允许客户端下载视频功能
         Integer adDownloadStatus = strategy.getCreativeDownloadStatus();
         if(!Check.isNull(adDownloadStatus)&&adDownloadStatus!=0){
-            params.put("ad_download_status",adDownloadStatus);
+            ad_data.put("ad_download_status",adDownloadStatus);
         }
         //创意展现方式
         String creativeDisplayMode = strategy.getCreativeDisplayMode();
         if(!Check.isNull(creativeDisplayMode)){
-            params.put("creative_display_mode",creativeDisplayMode);
+            ad_data.put("creative_display_mode",creativeDisplayMode);
         }
-        JSONObject ad_data = new JSONObject();
-        ad_data.put("ad_data",params);
+        params.put("ad_data",ad_data);
+
+        JSONObject creObj = new JSONObject();
 
         JSONArray titleArray = new JSONArray();
         List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1);
@@ -384,7 +385,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
                     JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
                     if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
-                        JSONObject creativeObject = new JSONObject();
+                        for (Object creative : creativeWordsArray) {
+                            JSONObject creativeObject = new JSONObject();
+                            creativeObject.put("word_id",creative);
+                            creativeWordsArray.add(creativeObject);
+                        }
                         titleObject.put("word_list",creativeWordsArray);
                     }
                 }
@@ -444,7 +449,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         }
 
         if(!Check.isNull(titleArray)){
-            params.put("title_materials",titleArray);
+            creObj.put("title_materials",titleArray);
         }
         JSONArray imageMaterials = new JSONArray();
         JSONObject object = new JSONObject();
@@ -462,29 +467,26 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             }
             object.put("image_info",image_info);
             imageMaterials.add(object);
-            params.put("image_materials",imageMaterials);
+            creObj.put("image_materials",imageMaterials);
         }
 
         if ("video".equalsIgnoreCase(videoInfo.getMaterialType())){
             //视频
             object.put("image_mode",strategy.getCreativeImageMode());
             JSONObject videoObj = new JSONObject();
-            JSONObject vidIdObj = new JSONObject();
-            vidIdObj.put("video_id",videoInfo.getVid());
-            videoObj.put("video_info",vidIdObj);
             //视频封面
             JSONObject imgObj = new JSONObject();
             //获取视频封面id
             String imageId = getSuggestImageId(token,videoInfo.getVid());
             if(!Check.isNull(imageId)){
-                JSONObject imgId = new JSONObject();
-                imgId.put("image_id",imageId);
-                imgObj.put("image_info",imgId);
+                imgObj.put("image_id",imageId);
             }
             object.put("image_info",imgObj);
             object.put("video_info",videoObj);
+
             imageMaterials.add(object);
-            params.put("video_materials",imageMaterials);
+
+            creObj.put("video_materials",imageMaterials);
         }
 
         //副标题
@@ -492,9 +494,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         if(!Check.isNull(subTitle)){
             JSONObject titleObj = new JSONObject();
             titleObj.put("sub_title",subTitle);
-            params.put("sub_title_material",titleObj);
+            creObj.put("sub_title_material",titleObj);
         }
-
         //组件id
        JSONArray component = new JSONArray();
        String componentIdStr = strategy.getComponentId();
@@ -504,8 +505,9 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             obj.put("component_id",new Long(strId));
             component.add(obj);
         }
-        params.put("component_materials",component);
+        creObj.put("component_materials",component);
 
+        params.put("creative",creObj);
         return params;
 
     }
@@ -575,14 +577,16 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         //点击监测链接
         String actionTrackUrl = strategy.getCreativeActionTrackUrl();
         if(!Check.isNull(actionTrackUrl)){
-            params.put("action_track_url",actionTrackUrl);
+            params.put("action_track_url",new String[]{actionTrackUrl});
         }
 
 
         //广告位大类
          if (!Check.isNull(strategy.getInventoryCatalog())){
             params.put("inventory_catalog",strategy.getInventoryCatalog());
-        }
+        }else{
+             params.put("inventory_catalog","MANUAL");
+         }
 
         //广告投放位置
         String inventoryType = strategy.getCreativeInventoryType();
@@ -599,6 +603,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         //优选广告位
         if (!Check.isNull(strategy.getCreativeSmartInventory())){
             params.put("smart_inventory",strategy.getCreativeSmartInventory());
+        }else{
+            params.put("smart_inventory","NORMAL");
         }
 
         // 投放形式
@@ -1520,11 +1526,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         aiBytedanceAdvertiserStrategy.setStatus(0);
 
         //添加素材信息
-        MaterialImageInfo imageInfo = new MaterialImageInfo();
+       /* MaterialImageInfo imageInfo = new MaterialImageInfo();
         imageInfo.setUrl(aiBytedanceAdvertiserStrategy.getImageUrl());
         imageInfo.setUserId(aiBytedanceAdvertiserStrategy.getUserId());
         materialImageInfoService.initImageCode(imageInfo);
-
+*/
 
 
         aiBytedanceAdvertiserStrategyMapper.insert(aiBytedanceAdvertiserStrategy);