Bladeren bron

修改创建

yangzian 3 jaren geleden
bovenliggende
commit
bc5cddf5f3

+ 4 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingService.java

@@ -75,4 +75,8 @@ public interface MarketingService {
     Result createAudiencePackage(CtopOauthToken token);
 
     Result getSite(CtopOauthToken token);
+
+
+    Result getCreativeComponent(CtopOauthToken token);
+
 }

+ 27 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingServiceImpl.java

@@ -344,7 +344,7 @@ public class MarketingServiceImpl implements MarketingService{
     @Override
     public  JSONObject creativeCreate(CtopOauthToken token, Long adId, JSONObject params) {
         return HttpUtils.bytedancePostRequest(token.getAccessToken(),
-                urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_create_v2_123"),
+                urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_create_v2"),
                 params);
     }
 
@@ -1230,5 +1230,31 @@ public class MarketingServiceImpl implements MarketingService{
 
     }
 
+    @Override
+    public Result getCreativeComponent(CtopOauthToken token) {
+
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("page", 1);
+        params.put("page_size", 40);
+        params.put("filtering", null);
+        params = Check.jsonRemoveEmpty(params);
+
+        JSONObject jsonObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(),
+                urlPath+ PropertiesUtils.getValue("bytedance_config", "bytedance_v2_assets_get"),params);
+        Integer code = jsonObject.getInteger("code");
+        String message = jsonObject.getString("message");
+        if (null == code || !code.equals(0)) {
+            log.info("查询组件列表接口异常==》accountId:{},message:{}", token.getAccountId(), message);
+            return Result.error(message);
+        }
+        JSONObject dataList = jsonObject.getJSONObject("data");
+        if (null == dataList || dataList.isEmpty()) {
+            log.info("查询组件列表不存在==》accountId:{},message:{}", token.getAccountId(), message);
+            return Result.error("查询组件列表不存在");
+        }
+        return Result.successMsg("查询组件列表成功",dataList.getJSONArray("list"));
+    }
+
 
 }

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

@@ -63,6 +63,7 @@ public class AiBytedanceAdvertiserStrategy{
 	private String campaignLandingType;
 	/**广告组商品类型*/
 	private String campaignDeliveryRelatedNum;
+
 	/**计划名称*/
 	private String adName;
 	/**投放范围(投放范围)*/
@@ -236,7 +237,7 @@ public class AiBytedanceAdvertiserStrategy{
 	@TableField(exist = false)
 	private String[] creativeInventoryTypes;
 	/**优选广告位*/
-	private Integer creativeSmartInventory;
+	private String creativeSmartInventory;
 	/**场景广告位*/
 	private String creativeSceneInventory;
 	/**创意方式*/
@@ -332,4 +333,18 @@ public class AiBytedanceAdvertiserStrategy{
 
 
 
+
+	/**
+	 * 营销目的
+	 */
+	private String marketingPurpose;
+	/**
+	 * 广告位大类
+	 */
+	private String inventoryCatalog;
+	/**
+	 * 组件id
+	 */
+	private String componentId;
+
 }

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

@@ -272,19 +272,56 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         }
         return videoCnt;
     }
+
     private JSONObject getCreativeParams(AiBytedanceAdvertiserStrategy strategy, Long adId,ByteDanceVideoInfo videoInfo,CtopOauthToken token) {
         JSONObject params = new JSONObject();
         params.put("advertiser_id", strategy.getAccountId());
         params.put("ad_id", adId);
 
 
+        /*基础创意*/
 
-        String sceneInventory = strategy.getCreativeSceneInventory();
-        if(!Check.isNull(sceneInventory)){
-            params.put("scene_inventory",sceneInventory);
+        //行业类别
+        String thirdIndustryId = strategy.getCreativeThirdIndustryId();
+        if(!Check.isNull(thirdIndustryId)){
+            params.put("third_industry_id",thirdIndustryId);
+        }
+
+        //关键词 添加随机关键词逻辑
+        String adKeywords = strategy.getCreativeAdKeywords();
+        if(!Check.isNull(adKeywords)){
+            String [] keywords = adKeywords.split(",");
+            if(keywords.length>0){
+                if(keywords.length<=20){
+                    params.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);
+                }
+            }
+        }
+        //广告来源
+        String source = strategy.getCreativeSource();
+        if(!Check.isNull(source)){
+            params.put("source",source);
+        }
+        //推广抖音号
+        String iesCoreUserId = strategy.getCreativeIesCoreUserId();
+        if(!Check.isNull(iesCoreUserId)){
+            params.put("ies_core_user_id",iesCoreUserId);
+        }
+        //主页作品列表隐藏广告内容
+        Integer isFeedAndFavSee = strategy.getCreativeIsFeedAndFavSee();
+        if(null!=isFeedAndFavSee&&isFeedAndFavSee!=0){
+            params.put("is_feed_and_fav_see",isFeedAndFavSee);
+        }
+        //是否开启自动生成素材
+        Integer creativeAutoGenerateSwitch = strategy.getCreativeAutoGenerateSwitch();
+        if(null!=creativeAutoGenerateSwitch&&creativeAutoGenerateSwitch!=1){
+            params.put("creative_auto_generate_switch",creativeAutoGenerateSwitch);
         }
-        //程序化创意 非dpa
-        params.put("creative_material_mode","STATIC_ASSEMBLE");
         //是否自动生成视频素材
         Integer isPresentedVideo = strategy.getCreativeIsPresentedVideo();
         if(null!=isPresentedVideo&&isPresentedVideo!=0){
@@ -295,32 +332,44 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         if(null!=generateDerivedAd&&generateDerivedAd!=0){
             params.put("generate_derived_ad",generateDerivedAd);
         }
-        //视频素材
-        JSONArray imageArray = new JSONArray();
-        JSONObject imageObject = new JSONObject();
+        //搭配试玩素材url
+        String playableUrl = strategy.getCreativePlayableUrl();
+        if(!Check.isNull(playableUrl)){
+            params.put("playable_url",playableUrl);
+        }
+        //应用名
+        String appName = strategy.getCreativeAppName();
+        if(!Check.isNull(appName)){
+            params.put("app_name",appName);
+        }
+        //Android应用下载详情页
+        String webUrl = strategy.getCreativeWebUrl();
+        if(!Check.isNull(webUrl)){
+            params.put("web_url",webUrl);
+        }
+        //落地页链接
+        if(!Check.isNull(strategy.getAdExternalUrl())){
+            params.put("external_url",strategy.getAdExternalUrl());
+        }
 
-        if ("video".equalsIgnoreCase(videoInfo.getMaterialType())){
-            //视频类型
-            //1-竖版视频 2-横版视频
-//            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL" : "CREATIVE_IMAGE_MODE_VIDEO";
-            String imageMode = strategy.getCreativeImageMode();
-            imageObject.put("image_mode",imageMode);
-            imageObject.put("video_id",videoInfo.getVid());
-            //获取视频封面id
-            String imageId = getSuggestImageId(token,videoInfo.getVid());
-            if(!Check.isNull(imageId)){
-                imageObject.put("image_id",imageId);
-            }
-        }else if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
-            //1-大图横图; 2-大图竖图
-//            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_LARGE" : "CREATIVE_IMAGE_MODE_LARGE_VERTICAL";
-            String imageMode = strategy.getCreativeImageMode();
-            imageObject.put("image_mode",imageMode);
-            imageObject.put("image_ids",new String[]{videoInfo.getId()});
+        //是否关闭评论,0为开启,1为关闭,默认值:0
+        Integer isCommentDisable = strategy.getCreativeIsCommentDisable();
+        if(!Check.isNull(isCommentDisable)&&isCommentDisable!=0){
+            params.put("is_comment_disable",isCommentDisable);
         }
+        //允许客户端下载视频功能
+        Integer adDownloadStatus = strategy.getCreativeDownloadStatus();
+        if(!Check.isNull(adDownloadStatus)&&adDownloadStatus!=0){
+            params.put("ad_download_status",adDownloadStatus);
+        }
+        //创意展现方式
+        String creativeDisplayMode = strategy.getCreativeDisplayMode();
+        if(!Check.isNull(creativeDisplayMode)){
+            params.put("creative_display_mode",creativeDisplayMode);
+        }
+        JSONObject ad_data = new JSONObject();
+        ad_data.put("ad_data",params);
 
-        imageArray.add(imageObject);
-        params.put("image_list",imageArray);
         JSONArray titleArray = new JSONArray();
         List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1);
         //使用指定文案
@@ -335,7 +384,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
                     JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
                     if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
-                        titleObject.put("creative_word_ids",creativeWordsArray);
+                        JSONObject creativeObject = new JSONObject();
+                        titleObject.put("word_list",creativeWordsArray);
                     }
                 }
                 titleArray.add(titleObject);
@@ -355,12 +405,18 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     String creativeWordsIds = byteDanceGeneralCopywriter.get(i).getCreativeWordIds();
                     if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
                         JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
-                        if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
-                            titleObject.put("creative_word_ids",creativeWordsArray);
+                        if(null!=creativeWordsArray && !creativeWordsArray.isEmpty()){
+                            for (Object creative : creativeWordsArray) {
+                                JSONObject creativeObject = new JSONObject();
+                                creativeObject.put("word_id",creative);
+                                creativeWordsArray.add(creativeObject);
+                            }
+                            titleObject.put("word_list",creativeWordsArray);
                         }
                     }
                     titleArray.add(titleObject);
                 }
+
             }
             // 图片 使用通用文案 最多10条
         }else if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
@@ -373,154 +429,88 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
                         JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
                         if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
-                            titleObject.put("creative_word_ids",creativeWordsArray);
+                            for (Object creative : creativeWordsArray) {
+                                JSONObject creativeObject = new JSONObject();
+                                creativeObject.put("word_id",creative);
+                                creativeWordsArray.add(creativeObject);
+                            }
+                            titleObject.put("word_list",creativeWordsArray);
                         }
                     }
                     titleArray.add(titleObject);
                 }
+
             }
         }
 
         if(!Check.isNull(titleArray)){
-            params.put("title_list",titleArray);
-        }
-        //广告来源
-        String source = strategy.getCreativeSource();
-        if(!Check.isNull(source)){
-            params.put("source",source);
-        }
-        //推广抖音号
-        String iesCoreUserId = strategy.getCreativeIesCoreUserId();
-        if(!Check.isNull(iesCoreUserId)){
-            params.put("ies_core_user_id",iesCoreUserId);
-        }
-        //主页作品列表隐藏广告内容
-        Integer isFeedAndFavSee = strategy.getCreativeIsFeedAndFavSee();
-        if(null!=isFeedAndFavSee&&isFeedAndFavSee!=0){
-            params.put("is_feed_and_fav_see",isFeedAndFavSee);
-        }
-        //是否开启自动生成素材
-        Integer creativeAutoGenerateSwitch = strategy.getCreativeAutoGenerateSwitch();
-        if(null!=creativeAutoGenerateSwitch&&creativeAutoGenerateSwitch!=1){
-            params.put("creative_auto_generate_switch",creativeAutoGenerateSwitch);
+            params.put("title_materials",titleArray);
+        }
+        JSONArray imageMaterials = new JSONArray();
+        JSONObject object = new JSONObject();
+        //类型
+
+        if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
+            //图片素材
+            object.put("image_mode",strategy.getCreativeImageMode());
+            String[] imageIds = new String[]{videoInfo.getId()};
+            JSONArray image_info = new JSONArray();
+            for (String imgId : imageIds) {
+                JSONObject imageObject = new JSONObject();
+                imageObject.put("image_id",imgId);
+                image_info.add(imageObject);
+            }
+            object.put("image_info",image_info);
+            imageMaterials.add(object);
+            params.put("image_materials",imageMaterials);
         }
-        String appName = strategy.getCreativeAppName();
-        if(!Check.isNull(appName)){
-            params.put("app_name",appName);
+
+        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);
+            }
+            object.put("image_info",imgObj);
+            object.put("video_info",videoObj);
+            imageMaterials.add(object);
+            params.put("video_materials",imageMaterials);
         }
 
+        //副标题
         String subTitle = strategy.getCreativeSubTitle();
         if(!Check.isNull(subTitle)){
-            params.put("sub_title",subTitle);
+            JSONObject titleObj = new JSONObject();
+            titleObj.put("sub_title",subTitle);
+            params.put("sub_title_material",titleObj);
         }
 
-        String webUrl = strategy.getCreativeWebUrl();
-        if(!Check.isNull(webUrl)){
-            params.put("web_url",webUrl);
+        //组件id
+       JSONArray component = new JSONArray();
+       String componentIdStr = strategy.getComponentId();
+       String[] componentId = componentIdStr.split(",");
+        for (String strId : componentId) {
+            JSONObject obj = new JSONObject();
+            obj.put("component_id",new Long(strId));
+            component.add(obj);
         }
+        params.put("component_materials",component);
 
-        String actionText = strategy.getCreativeActionText();
-        if(!Check.isNull(actionText)){
-            params.put("action_text",actionText);
-        }
-
-        //搭配试玩素材url
-        String playableUrl = strategy.getCreativePlayableUrl();
-        if(!Check.isNull(playableUrl)){
-            params.put("playable_url",playableUrl);
-        }
-
-        Integer isCommentDisable = strategy.getCreativeIsCommentDisable();
-        if(!Check.isNull(isCommentDisable)&&isCommentDisable!=0){
-            params.put("is_comment_disable",isCommentDisable);
-        }
-        String creativeDisplayMode = strategy.getCreativeDisplayMode();
-        if(!Check.isNull(creativeDisplayMode)){
-            params.put("creative_display_mode",creativeDisplayMode);
-        }
-//        允许客户端下载视频功能
-//        Integer adDownloadStatus = strategy.getCreativeAdDownloadStatus();
-//        if(!Check.isNull(adDownloadStatus)&&adDownloadStatus!=0){
-//            params.put("ad_download_status",adDownloadStatus);
-//        }
-        //商品推广卡片
-        String imageCode = strategy.getCreativeProductImageCode();
-        if(!Check.isNull(imageCode)){
-            //1:根据imageCode获取图片id
-            JSONObject promotionCard = new JSONObject();
-            String iconImageId = getBytedanceImageIdByCode(imageCode,token);
-            if(!Check.isNull(iconImageId)){
-                promotionCard.put("product_image_id",iconImageId);
-            }
-            String productSellingPoints = strategy.getCreativeProductSellingPoints();
-            if(!Check.isNull(productSellingPoints)){
-                String[] pointString = productSellingPoints.split(",");
-                if(pointString.length>0){
-                    promotionCard.put("product_selling_points",pointString);
-                }
-            }
-            String productDescription = strategy.getCreativeProductDescription();
-            if(!Check.isNull(productDescription)){
-                promotionCard.put("product_description",productDescription);
-            }
-            Boolean enableStorePack = strategy.getCreativeEnablePersonalAction();
-            if(null!=enableStorePack){
-                promotionCard.put("enable_store_pack",enableStorePack);
-            }
-            String callToAction = strategy.getCreativeCallToAction();
-            if(!Check.isNull(callToAction)){
-                promotionCard.put("call_to_action",callToAction);
-            }
-            Boolean enablePersonalAction = strategy.getCreativeEnablePersonalAction();
-            if(null!=enablePersonalAction){
-                promotionCard.put("enable_personal_action",enablePersonalAction);
-            }
-            params.put("promotion_card",promotionCard);
-        }
-        //行业类别
-        String thirdIndustryId = strategy.getCreativeThirdIndustryId();
-        if(!Check.isNull(thirdIndustryId)){
-            params.put("third_industry_id",thirdIndustryId);
-        }
-        //关键词 添加随机关键词逻辑
-        String adKeywords = strategy.getCreativeAdKeywords();
-        if(!Check.isNull(adKeywords)){
-            String [] keywords = adKeywords.split(",");
-            if(keywords.length>0){
-                if(keywords.length<=20){
-                    params.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);
-                }
-            }
-        }
-        String trackUrl = strategy.getCreativeTrackUrl();
-        if(!Check.isNull(trackUrl)){
-            params.put("track_url",trackUrl);
-        }
-        String actionTrackUrl = strategy.getCreativeActionTrackUrl();
-        if(!Check.isNull(actionTrackUrl)){
-            params.put("action_track_url",actionTrackUrl);
-        }
-        String videoPlayEffectiveTrackUrl = strategy.getCreativeVideoPlayEffectiveTrackUrl();
-        if(!Check.isNull(videoPlayEffectiveTrackUrl)){
-            params.put("video_play_effective_track_url",videoPlayEffectiveTrackUrl);
-        }
-//        String videoPlayDoneTrackUrl = strategy.getCreativeVideoPlayDoneTrackUrl();
-//        if(!Check.isNull(videoPlayDoneTrackUrl)){
-//            params.put("video_play_done_track_url",videoPlayDoneTrackUrl);
-//        }
-        String videoPlayTrackUrl = strategy.getCreativeVideoPlayTrackUrl();
-        if(!Check.isNull(videoPlayTrackUrl)){
-            params.put("video_play_track_url",videoPlayTrackUrl);
-        }
         return params;
 
     }
 
+
     private String getBytedanceImageIdByCode(String imageCode, CtopOauthToken token) {
         //1:根据code获取图片信息
         BytedanceImageInfo bytedanceImageInfo = bytedanceImageInfoService.getByParams(imageCode);
@@ -572,20 +562,29 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         params.put("name",adName);
         //竞价策略 默认优先跑量
         params.put("flow_control_mode","FLOW_CONTROL_MODE_FAST");
+
         //投放范围
         if(null!=strategy.getAdDeliveryRange()&&!"".equals(strategy.getAdDeliveryRange().trim())){
             params.put("delivery_range",strategy.getAdDeliveryRange());
-           /* if(!"UNION".equals(strategy.getAdDeliveryRange())){
+            //搜索快投
+            if(!"UNION".equals(strategy.getAdDeliveryRange())){
                 params.put("feed_delivery_search","DISABLED");
-            }*/
+            }
         }
 
-        params.put("inventory_catalog","MANUAL");
-        Integer smartInventory = strategy.getCreativeSmartInventory();
-        if(null!=smartInventory&&smartInventory!=0){
-            params.put("smart_inventory","NORMAL");
+        //点击监测链接
+        String actionTrackUrl = strategy.getCreativeActionTrackUrl();
+        if(!Check.isNull(actionTrackUrl)){
+            params.put("action_track_url",actionTrackUrl);
         }
 
+
+        //广告位大类
+         if (!Check.isNull(strategy.getInventoryCatalog())){
+            params.put("inventory_catalog",strategy.getInventoryCatalog());
+        }
+
+        //广告投放位置
         String inventoryType = strategy.getCreativeInventoryType();
         if ("CREATIVE_IMAGE_MODE_UNION_SPLASH".equalsIgnoreCase(strategy.getCreativeImageMode())) {
             params.put("inventory_type", new String[]{"INVENTORY_UNION_SPLASH_SLOT"});
@@ -597,12 +596,20 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 }
             }
         }
+        //优选广告位
+        if (!Check.isNull(strategy.getCreativeSmartInventory())){
+            params.put("smart_inventory",strategy.getCreativeSmartInventory());
+        }
 
+        // 投放形式
         if(!Check.isNull(strategy.getAdUnionVideoType())){
             params.put("union_video_type",strategy.getAdUnionVideoType());
         }
-        //投放目标
+
+        //下载方式
         params.put("download_type",strategy.getAdDownloadType());
+
+
         if(!Check.isNull(strategy.getAdDownloadUrl())){
             params.put("download_url",strategy.getAdDownloadUrl());
         }
@@ -614,9 +621,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         if(!Check.isNull(strategy.getAdQuickAppUrl())){
             params.put("quick_app_url",strategy.getAdQuickAppUrl());
         }
-        if(!Check.isNull(strategy.getAdExternalUrl())){
-            params.put("external_url",strategy.getAdExternalUrl());
-        }
+
         if(!Check.isNull(strategy.getAdAppType())){
             params.put("app_type",strategy.getAdAppType());
         }
@@ -1055,10 +1060,9 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         if(null != strategy.getCampaignDeliveryRelatedNum()&&!"".equals(strategy.getCampaignDeliveryRelatedNum().trim())){
             campaignParam.put("delivery_related_num",strategy.getCampaignDeliveryRelatedNum());
         }
+        //营销目的 --行动转化
 
         campaignParam.put("marketing_purpose","CONVERSION");
-
-        log.info("token获取失败=>accountId:{}", strategy.getAccountId());
         //创建组
         Result campaignData = marketingService.createCampaign(token, campaignParam);
         log.info("===创建组==={}",campaignData);
@@ -1798,4 +1802,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
     }
 
 
+
+
+
 }

+ 8 - 1
jeecg-boot-bytedance/src/main/resources/bytedance_config.properties

@@ -63,7 +63,8 @@ bytedance_v2_creative_material_get=/2/creative/material/read/
 #\u521B\u610F\u8BE6\u7EC6\u4FE1\u606F
 bytedance_v2_creative_read=/2/creative/read_v2/
 #\u521B\u5EFA\u5E7F\u544A\u521B\u610F
-bytedance_v2_creative_create_v2=/2/creative/create_v2/
+#bytedance_v2_creative_create_v2=/2/creative/create_v2/
+bytedance_v2_creative_create_v2=/2/creative/custom_creative/create/
 #\u83B7\u53D6\u521B\u610F\u5217\u8868
 bytedance_v2_creative_get=/2/creative/get/
 #\u4FEE\u6539\u521B\u610F\u4FE1\u606F
@@ -96,3 +97,9 @@ bytedance_v2_campaign_report_get=/2/report/campaign/get/
 bytedance_v2_ad_report_get=/2/report/ad/get/
 bytedance_v2_ad_creative_get=/2/report/creative/get/
 
+
+
+
+
+#\u67E5\u8BE2\u7EC4\u4EF6\u5217\u8868
+bytedance_v2_assets_get=/2/assets/creative_component/get/

+ 75 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/AiBytedanceAdvertiserStrategyController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.bytedance.advertise.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -30,10 +31,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -513,6 +511,79 @@ public class AiBytedanceAdvertiserStrategyController {
 
 
 
+	@ApiOperation(value="获取组件列表", notes="获取组件列表")
+	@GetMapping(value = "/getCreativeComponent")
+	public Result getCreativeComponent(@RequestParam("accountId") String accountId) {
+		try {
+			CtopOauthToken token = tokenService.getTokenByAccountId(new Long(accountId));
+			return marketingService.getCreativeComponent(token);
+		}catch (Exception e){
+			log.error("获取组件列表异常",e);
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+
+
+	@ApiOperation(value="创建组件", notes="创建组件")
+	@PostMapping(value = "/creativeComponent")
+	public Result creativeComponent(@RequestParam("accountId") String accountId) {
+		try {
+
+			CtopOauthToken token = tokenService.getTokenByAccountId(new Long(accountId));
+
+			JSONObject params = new JSONObject();
+			params.put("advertiser_id", token.getAccountId());
+
+
+			JSONObject info = new JSONObject();
+
+			info.put("component_type","VOTE_MAGNET");
+			info.put("component_name","测试组件名称");
+
+			JSONObject date = new JSONObject();
+			date.put("title","测试主标题");
+			date.put("sub_title","测试副标题测试副标题测试副标题测试副标题测试副标题");
+			date.put("vote_card_web_url","测试组件名称");
+			date.put("click_text","测试显示文案");
+
+			Map map1= new HashMap();
+			map1.put("button_text", "测试按钮1");
+			Map map2 = new HashMap();
+			map2.put("button_text", "测试按钮2");
+			List list = new ArrayList();
+			list.add(map1);
+			list.add(map2);
+			date.put("button_list",list);
+
+			info.put("component_data",date);
+			params.put("component_info", info);
+
+			params = Check.jsonRemoveEmpty(params);
+
+			JSONObject jsonObject = HttpUtils.bytedancePostRequest(token.getAccessToken(),
+					"https://ad.oceanengine.com/open_api/2/assets/creative_component/create/" ,params);
+			Integer code = jsonObject.getInteger("code");
+			String message = jsonObject.getString("message");
+			if (null == code || !code.equals(0)) {
+				log.info("创建组件失败异常==》accountId:{},message:{}", token.getAccountId(), message);
+				return Result.error(message);
+			}
+			JSONObject dataList = jsonObject.getJSONObject("data");
+			if (null == dataList || dataList.isEmpty()) {
+				log.info("创建组件失败==》accountId:{},message:{}", token.getAccountId(), message);
+				return Result.error("创建组件失败");
+			}
+		}catch (Exception e){
+			log.error("创建组件异常",e);
+			return Result.error("请求失败,请联系开发人员!");
+		}
+		return null;
+	}
+
+
+
+