Преглед изворни кода

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java
songyh пре 4 година
родитељ
комит
f3de139d35

+ 166 - 119
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/marketing.java

@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
 import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
 import org.jeecg.modules.bytedance.advertise.vo.ByteDanceSearchVo;
 import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
+import org.jeecg.modules.bytedance.common.constant.BytedanceConstant;
 import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
 import org.jeecg.modules.bytedance.common.utils.Check;
 import org.jeecg.modules.bytedance.common.utils.HttpUtils;
@@ -234,14 +236,12 @@ public class marketing {
     /**
      *
      * @description: 创建广告组
-     *
      * @param token
      * @param campaignName 广告组名称
      * @param budgetMode 广告组预算类型
      *          //BUDGET_MODE_INFINITE 不限
      *         //BUDGET_MODE_DAY 日预算
      *         //BUDGET_MODE_TOTAL 总预算
-     *
      * @param budget 广告组预算
      *               取值范围: ≥ 0
      *               当budget_mode为"BUDGET_MODE_DAY"时,必填,且日预算不少于300元
@@ -249,7 +249,7 @@ public class marketing {
      *         "LINK","APP","DPA","GOODS","STORE","SHOP","AWEME"
      * @return: org.jeecg.common.api.vo.Result
      */
-    public static Result createCampaign(CtopOauthToken token,String campaignName,String budgetMode, String budget,String landingType) {
+    public static Result createCampaign(CtopOauthToken token,String campaignName,String budgetMode, Integer budget,String landingType) {
         JSONObject param = new JSONObject();
         //广告主id
         param.put("advertiser_id",token.getAccountId());
@@ -258,11 +258,15 @@ public class marketing {
         //广告组状态 "enable","disable"默认值:enable开启状态
         param.put("operation","enable");
         //广告组预算类型 BUDGET_MODE_INFINITE-不限  BUDGET_MODE_DAY-日预算  BUDGET_MODE_TOTAL-总预算
-        param.put("budget_mode", "BUDGET_MODE_INFINITE");
+        param.put("budget_mode", budgetMode);
         //广告组预算
-        //param.put("budget",budget);
+        param.put("budget",budget);
         //广告组推广目的
         param.put("landing_type",landingType);
+        //移除key 为空的 json
+        param = Check.jsonRemoveEmpty(param);
+
+        // api创建组
         JSONObject data = HttpUtils.bytedancePostRequest(token.getAccessToken(),
                 urlPath+PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_create"),
                 param);
@@ -289,64 +293,64 @@ public class marketing {
      * @description: 创建广告计划
      *
      * @param token
-     * @param landingType 推广目的
-     * @param byteDanceAdvertisePlan 创建计划所需要的参数
+     * @param campaignId 广告组id
+     * @param strategy 入参
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
-    public static Result createAdvertiserPlan(CtopOauthToken token, String landingType, ByteDanceAdvertisePlan byteDanceAdvertisePlan) {
+    public static Result createAdvertiserPlan(CtopOauthToken token, Long campaignId, AiBytedanceAdvertiserStrategy strategy) {
 
         JSONObject params = new JSONObject();
         //广告主ID
-        params.put("advertiser_id", byteDanceAdvertisePlan.getAccountId());
+        params.put("advertiser_id", strategy.getAccountId());
         //广告组ID
-        params.put("campaign_id", byteDanceAdvertisePlan.getCampaignId());
+        params.put("campaign_id", campaignId);
         //广告计划名称,长度为1-100个字符,其中1个中文字符算2位。名称不可重复,否则会报错
-        params.put("name", byteDanceAdvertisePlan.getName());
+        params.put("name", strategy.getAdName());
         //计划状态 默认值: "enable"开启状态 允许值: "enable"开启,"disable"关闭
-        params.put("operation", byteDanceAdvertisePlan.getOperation() == null ? "enable" : byteDanceAdvertisePlan.getOperation());
+        params.put("operation", BytedanceConstant.OPERATION_ENABLE);
         // 投放范围  "DEFAULT"默认, "UNION"穿山甲
-        params.put("delivery_range", byteDanceAdvertisePlan.getDeliveryRange() == null ? "DEFAULT" : byteDanceAdvertisePlan.getDeliveryRange());
+        params.put("delivery_range", strategy.getAdDeliveryRange() == null ? "DEFAULT" : strategy.getAdDeliveryRange());
         //投放形式(穿山甲视频创意类型) 当delivery_range为"UNION"时必填
         // 允许值: "ORIGINAL_VIDEO"原生, "REWARDED_VIDEO"激励视频,"SPLASH_VIDEO"开屏
        // params.put("union_video_type", byteDanceAdvertisePlan.getUnionVideoType() == null ? "ORIGINAL_VIDEO" : byteDanceAdvertisePlan.getUnionVideoType());
         //投放内容
         //推广目的 为应用推广(landing_type=APP)时投放目标参数
-        if ("APP".equals(landingType)) {
+        if ("APP".equals(strategy.getCampaignLandingType())) {
             //下载方式  可选值:DOWNLOAD_URL下载链接,QUICK_APP_URL快应用+下载链接,EXTERNAL_URL落地页链接
-            params.put("download_type", byteDanceAdvertisePlan.getDownloadType());
+            params.put("download_type", strategy.getAdDownloadType());
             //下载链接
             // 类型为下载链接
-            if ("DOWNLOAD_URL".equals(byteDanceAdvertisePlan.getDownloadType())){
-                params.put("download_url", byteDanceAdvertisePlan.getDownloadUrl());
+            if ("DOWNLOAD_URL".equals(strategy.getAdDownloadType())){
+                params.put("download_url", strategy.getAdDownloadUrl());
                 //下载的应用类型,当download_type为DOWNLOAD_URL时必填
                 //允许值: "APP_ANDROID"Android APP, "APP_IOS"IOS APP
-                params.put("app_type", byteDanceAdvertisePlan.getAppType());
-                params.put("package", byteDanceAdvertisePlan.getToutiaoPackage());
+                params.put("app_type", strategy.getAdAppType());
+                params.put("package", strategy.getAdPackage());
             }
             // 类型为 快应用+下载链接
-            if ("QUICK_APP_URL".equals(byteDanceAdvertisePlan.getDownloadType())){
-                params.put("quick_app_url", byteDanceAdvertisePlan.getDownloadUrl());
+            if ("QUICK_APP_URL".equals(strategy.getAdDownloadType())){
+                params.put("quick_app_url", strategy.getAdDownloadUrl());
             }
             // 类型为下载链接
-            if ("EXTERNAL_URL".equals(byteDanceAdvertisePlan.getDownloadType())){
-                params.put("external_url", byteDanceAdvertisePlan.getDownloadUrl());
+            if ("EXTERNAL_URL".equals(strategy.getAdDownloadType())){
+                params.put("external_url", strategy.getAdDownloadUrl());
             }
         }
         //转化目标
-        params.put("convert_id", byteDanceAdvertisePlan.getConvertId());
+        params.put("convert_id", strategy.getAdConvertId());
         //直达链接(点击唤起APP)
-        params.put("open_url", byteDanceAdvertisePlan.getOpenUrl());
+        params.put("open_url", strategy.getAdOpenUrl());
         //搜索快投功能,允许值:HAS_OPEN:启用,DISABLED:不启用
         params.put("feed_delivery_search", "搜索快投");
         //用户定向
         //允许值: "CITY"省市, "COUNTY"区县, "BUSINESS_DISTRICT"商圈,"NONE"不限
-        params.put("district", byteDanceAdvertisePlan.getScheduleType());
+        params.put("district", strategy.getAdScheduleType());
         //性别 允许值: "GENDER_FEMALE", "GENDER_MALE", "NONE"
-        params.put("gender", byteDanceAdvertisePlan.getGender());
+        params.put("gender", strategy.getAdGender());
         //允许值: "AGE_BETWEEN_18_23", "AGE_BETWEEN_24_30","AGE_BETWEEN_31_40", "AGE_BETWEEN_41_49", "AGE_ABOVE_50"
         //年龄不限 不传该字段
-        //params.put("age", byteDanceAdvertisePlan.getAge());
+        //params.put("age", strategy.getAge());
        //自定义人群 不限 不传该字段
         // 定向人群包列表(自定义人群)
         //params.put("retargeting_tags_include", );
@@ -361,29 +365,29 @@ public class marketing {
         //网络
         //params.put("ac", byteDanceAdvertisePlan.getAc());
         //过滤已安装  当推广目标为安卓应用下载时可填 0表示不限,1表示过滤,2表示定向。默认为不限
-        params.put("hide_if_exists", byteDanceAdvertisePlan.getHideIfExists());
+        params.put("hide_if_exists", strategy.getAdHideIfExists());
         //过滤已转化用户 NO_EXCLUDE-不过滤;AD-广告计划(默认);CAMPAIGN-广告组; ADVERTISER-广告账户; APP-APP; CUSTOMER-公司账户
-        params.put("hide_if_converted", byteDanceAdvertisePlan.getHideIfConverted());
+        params.put("hide_if_converted", strategy.getAdHideIfConverted());
         //是否启用智能放量 0、1。缺省为 0
-        params.put("auto_extend_enabled", byteDanceAdvertisePlan.getAutoExtendEnabled());
+        params.put("auto_extend_enabled", strategy.getAdAutoExtendEnabled());
         //预算与出价
         //投放场景 允许值: 常规投放"SMART_BID_CUSTOM", 放量投放"SMART_BID_CONSERVATIVE"
         params.put("smart_bid_type", "投放场景");
         //预算类型 "BUDGET_MODE_DAY"日预算, "BUDGET_MODE_TOTAL"总预算
-        params.put("budget_mode", byteDanceAdvertisePlan.getBudgetMode());
+        params.put("budget_mode", strategy.getAdBudgetMode());
         //预算 出价方式为CPC、CPM、CPV时,不少于100元;出价方式为OCPM、OCPC时,不少于300元
-        params.put("budget", byteDanceAdvertisePlan.getBudget());
+        params.put("budget", strategy.getAdBudget());
         //投放时间类型 允许值: "SCHEDULE_FROM_NOW"从今天起长期投放, "SCHEDULE_START_END"设置开始和结束日期
-        params.put("schedule_type", byteDanceAdvertisePlan.getScheduleType());
+        params.put("schedule_type", strategy.getAdScheduleType());
         //投放时段,默认全时段投放
-        params.put("schedule_time", byteDanceAdvertisePlan.getScheduleTime());
+        params.put("schedule_time", strategy.getAdScheduleTime());
         //付费方式(计划出价类型) 决定投放目标的类型,比如CPC表示点击量,OCPM表示转化量
-        params.put("pricing", byteDanceAdvertisePlan.getPricing());
+        params.put("pricing", strategy.getAdPricing());
         //目标转化出价/预期成本, 当pricing为"OCPM"、"OCPC"出价方式时必填)
         //pricing为"OCPC"时取值范围:0.1-10000元;
         //pricing为"OCPM"时取值范围:0.1-10000元;
         //出价不能大于预算否则会报错
-        params.put("cpa_bid", byteDanceAdvertisePlan.getCpaBid());
+        params.put("cpa_bid", strategy.getAdCpaBid());
 
         JSONObject jsonObject = HttpUtils.bytedancePostRequest(token.getAccessToken(),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_create"), params);
@@ -393,8 +397,8 @@ public class marketing {
             Result.error(jsonObject.getString("message"));
 
         }
-        byteDanceAdvertisePlan.setId(jsonObject.getJSONObject("data").getLong("ad_id"));
-        return Result.successMsg("广告计划创建成功",byteDanceAdvertisePlan);
+        //strategy.setId(jsonObject.getJSONObject("data").getLong("ad_id"));
+        return Result.successMsg("广告计划创建成功",jsonObject.getJSONObject("data").getLong("ad_id"));
     }
 
 
@@ -405,57 +409,55 @@ public class marketing {
      * 创建广告创意
      * @param
      * @param adId 广告计划id
-     * @param data 创意入参
+     * @param strategy 创意入参
      * @return
      */
-    public static Result creativeCreate(CtopOauthToken token, Long adId, JSONObject data) {
-        Map<String, Object> resultMap = new HashMap<>();
+    public static Result creativeCreate(CtopOauthToken token, Long adId, AiBytedanceAdvertiserStrategy strategy) {
+        JSONObject params = new JSONObject();
+
         //广告主ID
-        data.put("advertiser_id", token.getAccountId());
+        params.put("advertiser_id", token.getAccountId());
         //广告计划ID
-        data.put("ad_id", adId);
+        params.put("ad_id", adId);
         //广告 投放位置 三选一
-        if (!data.getString("smart_inventory").isEmpty()){
-            //优选广告位,0表示不使用优选,1表示使用
-            data.put("smart_inventory", data.getString("smart_inventory"));
-        }
-        if (!data.getString("inventory_type").isEmpty()){
-            //广告位置(按媒体指定位置)
-            data.put("inventory_type", data.getString("inventory_type"));
-        }
-        if (!data.getString("scene_inventory").isEmpty()){
-            //场景广告位
-            data.put("scene_inventory", data.getString("scene_inventory"));
-        }
-        //监测链接
-        data.put("action_track_url", data.getString("action_track_url"));
+        //广告位置(按媒体指定位置)
+        params.put("inventory_type", strategy.getCreativeInventoryType());
+        //优选广告位,0表示不使用优选,1表示使用
+        params.put("smart_inventory", strategy.getCreativeSmartInventory());
+        //场景广告位
+        params.put("scene_inventory", strategy.getCreativeSceneInventory());
+
+        //展示(监测链接)
+        params.put("track_url", strategy.getCreativeTrackUrl());
+        //点击(监测链接)
+        params.put("action_track_url", strategy.getCreativeActionTrackUrl());
         //创意方式,当值为"STATIC_ASSEMBLE"表示程序化创意,其他情况不传字段
-        data.put("creative_material_mode", data.getString("creative_material_mode"));
+        params.put("creative_material_mode", strategy.getCreativeMaterialMode());
         //标题信息
-        data.put("image_list", data.getJSONArray("image_list"));
+        params.put("image_list", "");
         //行动号召
-        data.put("action_text", data.getString("action_text"));
+        params.put("action_text", strategy.getCreativeCallToAction());
         //是否使用智能优选,true为使用,false为不使用
-        data.put("enable_personal_action", data.getString("enable_personal_action"));
+        params.put("enable_personal_action", strategy.getCreativeEnablePersonalAction());
         //卡片标题
-        data.put("product_description", data.getString("product_description"));
+        params.put("product_description", strategy.getCreativeProductDescription());
         //推广卖点 长度6-9个字,最多可填10个卖点
-        data.put("product_selling_points", data.getString("product_selling_points"));
+        params.put("product_selling_points", strategy.getCreativeProductSellingPoints());
         //来源
-        data.put("source", data.getString("source"));
+        params.put("source", strategy.getCreativeSource());
         //创意分类
-        data.put("third_industry_id", data.getString("third_industry_id"));
+        params.put("third_industry_id", strategy.getCreativeThirdIndustryId());
         //创意标签 创意标签。最多20个标签,且每个标签长度不超过10个字符
-        data.put("ad_keywords", data.getString("ad_keywords"));
+        params.put("ad_keywords", strategy.getCreativeAdKeywords());
         JSONObject result = HttpUtils.bytedancePostRequest(token.getAccessToken(),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_create_v2"),
-                data);
+                params);
         Integer code = result.getInteger("code");
         String message = result.getString("message");
         if (null == code || code != 0) {
             return Result.error("广告计划("+adId+"):创建创意信息异常--->>>"+message);
         }
-        return Result.successMsg("广告计划("+adId+"):"+"创意创建成功",null);
+        return Result.successMsg("广告计划("+adId+"):"+"创意创建成功",result.get("data"));
     }
 
 
@@ -648,10 +650,12 @@ public class marketing {
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
-    public static Result getPlanList(CtopOauthToken token, List<PlanSearchVo> planSearchVoList) {
+    public static Result getPlanList(CtopOauthToken token, List<PlanSearchVo> planSearchVoList,Integer pageNo, Integer pageSize) {
         JSONObject params = new JSONObject();
         params.put("advertiser_id", token.getAccountId());
         params.put("filtering", planSearchVoList);
+        params.put("page", pageNo);
+        params.put("page_size", pageSize);
         JSONObject jsonObject = HttpUtils.bytedancePostRequest(token.getAccessToken(),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get_plan"),
                 params);
@@ -702,13 +706,14 @@ public class marketing {
      * @description: 获取广告组
      *
      * @param token
+     * @param accountId 广告主id
      * @param adGroupSearchVoList 广告组 入参
      * @param page
      * @param pageSize
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
-    public static Result getCampaignGroupList(CtopOauthToken token,List<AdGroupSearchVo> adGroupSearchVoList,int page,int pageSize) {
+    public static Result getCampaignGroupList(CtopOauthToken token,String accountId,List<AdGroupSearchVo> adGroupSearchVoList,int page,int pageSize) {
 
         JSONObject params = new JSONObject();
         params.put("advertiser_id", token.getAccountId());
@@ -745,7 +750,7 @@ public class marketing {
      * @param budget 广告组预算
      * @return: org.jeecg.common.api.vo.Result
      */
-    public static Result updateCampaign(CtopOauthToken token, Long campaignId, String modifyTime, String campaignName,String budgetMode, Integer budget) {
+    public static Result updateCampaign(CtopOauthToken token, String campaignId, String modifyTime, String campaignName,String budgetMode, String budget) {
         JSONObject params = new JSONObject();
         //广告主id
         params.put("advertiser_id", token.getAccountId());
@@ -760,10 +765,10 @@ public class marketing {
         //预算
         params.put("budget", budget);
         // value 为空 则 移除
-        JSONObject jParams = Check.jsonRemoveEmpty(params);
+        params = Check.jsonRemoveEmpty(params);
         JSONObject jsonObject = HttpUtils.bytedancePostRequest(token.getAccessToken(),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_update"),
-                jParams);
+                params);
         Integer code = jsonObject.getInteger("code");
         if (null == code || !code.equals(0)) {
             log.info("广告组更新接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
@@ -774,7 +779,7 @@ public class marketing {
             log.info("广告组更新异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             return Result.error("广告组更新异常"+jsonObject.getString("message"));
         }
-        return Result.successMsg("广告组信息修改成功。", null);
+        return Result.successMsg("广告组信息修改成功。", data.getString("campaign_id"));
     }
 
 
@@ -783,104 +788,106 @@ public class marketing {
      * @description: 修改广告计划
      *
      * @param token
-     * @param landingType 推广目的类型
-     * @param byteDanceAdvertisePlan 广告计划 入参
+     * @param planId 计划id
+     * @param modifyTime 计划时间戳
+     * @param strategy
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
-    public static Result updateAdvertiserPlan(CtopOauthToken token, String landingType, ByteDanceAdvertisePlan byteDanceAdvertisePlan) {
+    public static Result updateAdvertiserPlan(CtopOauthToken token, String planId,String modifyTime,AiBytedanceAdvertiserStrategy strategy) {
+
+
 
         JSONObject params = new JSONObject();
         //广告主ID
-        params.put("advertiser_id", byteDanceAdvertisePlan.getAccountId());
+        params.put("advertiser_id", strategy.getAccountId());
         //广告计划ID
-        params.put("ad_id", "广告计划id");
-        params.put("modify_time", "修改时间戳");
+        params.put("ad_id", planId);
+        params.put("modify_time", modifyTime);
         //广告计划名称
-        params.put("name", byteDanceAdvertisePlan.getName());
+        params.put("name", strategy.getAdName());
         //计划状态 默认值: "enable"开启状态 允许值: "enable"开启,"disable"关闭
-        params.put("operation", byteDanceAdvertisePlan.getOperation() == null ? "enable" : byteDanceAdvertisePlan.getOperation());
+        params.put("operation", BytedanceConstant.OPERATION_ENABLE);
         // 投放范围  "DEFAULT"默认, "UNION"穿山甲
-        params.put("delivery_range", byteDanceAdvertisePlan.getDeliveryRange() == null ? "DEFAULT" : byteDanceAdvertisePlan.getDeliveryRange());
+        params.put("delivery_range", strategy.getAdDeliveryRange() == null ? "DEFAULT" : strategy.getAdDeliveryRange());
         //投放形式(穿山甲视频创意类型) 当delivery_range为"UNION"时必填
         // 允许值: "ORIGINAL_VIDEO"原生, "REWARDED_VIDEO"激励视频,"SPLASH_VIDEO"开屏
         // params.put("union_video_type", byteDanceAdvertisePlan.getUnionVideoType() == null ? "ORIGINAL_VIDEO" : byteDanceAdvertisePlan.getUnionVideoType());
         //投放内容
         //推广目的 为应用推广(landing_type=APP)时投放目标参数
-        if ("APP".equals(landingType)) {
+        if ("APP".equalsIgnoreCase(strategy.getCampaignLandingType())) {
             //下载方式  可选值:DOWNLOAD_URL下载链接,QUICK_APP_URL快应用+下载链接,EXTERNAL_URL落地页链接
-            params.put("download_type", byteDanceAdvertisePlan.getDownloadType());
+            params.put("download_type", strategy.getAdDownloadType());
             //下载链接
             // 类型为下载链接
-            if ("DOWNLOAD_URL".equals(byteDanceAdvertisePlan.getDownloadType())){
-                params.put("download_url", byteDanceAdvertisePlan.getDownloadUrl());
+            if ("DOWNLOAD_URL".equals(strategy.getAdDownloadType())){
+                params.put("download_url", strategy.getAdDownloadUrl());
                 //下载的应用类型,当download_type为DOWNLOAD_URL时必填
                 //允许值: "APP_ANDROID"Android APP, "APP_IOS"IOS APP
-                params.put("app_type", byteDanceAdvertisePlan.getAppType());
-                params.put("package", byteDanceAdvertisePlan.getToutiaoPackage());
+                params.put("app_type", strategy.getAdAppType());
+                params.put("package", strategy.getAdPackage());
             }
             // 类型为 快应用+下载链接
-            if ("QUICK_APP_URL".equals(byteDanceAdvertisePlan.getDownloadType())){
-                params.put("quick_app_url", byteDanceAdvertisePlan.getDownloadUrl());
+            if ("QUICK_APP_URL".equals(strategy.getAdDownloadType())){
+                params.put("quick_app_url", strategy.getAdDownloadUrl());
             }
             // 类型为下载链接
-            if ("EXTERNAL_URL".equals(byteDanceAdvertisePlan.getDownloadType())){
-                params.put("external_url", byteDanceAdvertisePlan.getDownloadUrl());
+            if ("EXTERNAL_URL".equals(strategy.getAdDownloadType())){
+                params.put("external_url", strategy.getAdDownloadUrl());
             }
         }
         //转化目标
-        params.put("convert_id", byteDanceAdvertisePlan.getConvertId());
+        params.put("convert_id", strategy.getAdConvertId());
         //直达链接(点击唤起APP)
-        params.put("open_url", byteDanceAdvertisePlan.getOpenUrl());
+        params.put("open_url", strategy.getAdOpenUrl());
         //搜索快投功能,允许值:HAS_OPEN:启用,DISABLED:不启用
         params.put("feed_delivery_search", "搜索快投");
         //用户定向
         //允许值: "CITY"省市, "COUNTY"区县, "BUSINESS_DISTRICT"商圈,"NONE"不限
-        params.put("district", byteDanceAdvertisePlan.getScheduleType());
+        params.put("district", strategy.getAdScheduleType());
         //性别 允许值: "GENDER_FEMALE", "GENDER_MALE", "NONE"
-        params.put("gender", byteDanceAdvertisePlan.getGender());
+        params.put("gender", strategy.getAdGender());
         //允许值: "AGE_BETWEEN_18_23", "AGE_BETWEEN_24_30","AGE_BETWEEN_31_40", "AGE_BETWEEN_41_49", "AGE_ABOVE_50"
         //年龄不限 不传该字段
-        params.put("age", byteDanceAdvertisePlan.getAge());
+        params.put("age", strategy.getAdAge());
         //自定义人群 不限 不传该字段
         // 定向人群包列表(自定义人群)
-        params.put("retargeting_tags_include","");
+        params.put("retargeting_tags_include",strategy.getAdRetargetingTagsInclude());
         //排除人群包列表(自定义人群)
-        params.put("retargeting_tags_exclude","");
+        params.put("retargeting_tags_exclude",strategy.getAdRetargetingTagsExclude());
         //媒体定向
-        params.put("superior_popularity_type", byteDanceAdvertisePlan.getSuperiorPopularityType());
+        params.put("superior_popularity_type", strategy.getAdSuperiorPopularityType());
         //平台
-        params.put("platform", byteDanceAdvertisePlan.getPlatform());
+        params.put("platform", strategy.getAdPlatform());
         //最低安卓版本
-        params.put("android_osv", "安卓版本");
+        params.put("android_osv", strategy.getAdAndroidOsv());
         //网络
-        params.put("ac", byteDanceAdvertisePlan.getAc());
+        params.put("ac", strategy.getAdAc());
         //过滤已安装  当推广目标为安卓应用下载时可填 0表示不限,1表示过滤,2表示定向。默认为不限
-        params.put("hide_if_exists", byteDanceAdvertisePlan.getHideIfExists());
+        params.put("hide_if_exists", strategy.getAdHideIfExists());
         //过滤已转化用户 NO_EXCLUDE-不过滤;AD-广告计划(默认);CAMPAIGN-广告组; ADVERTISER-广告账户; APP-APP; CUSTOMER-公司账户
-        params.put("hide_if_converted", byteDanceAdvertisePlan.getHideIfConverted());
+        params.put("hide_if_converted", strategy.getAdHideIfConverted());
         //是否启用智能放量 0、1。缺省为 0
-        params.put("auto_extend_enabled", byteDanceAdvertisePlan.getAutoExtendEnabled());
+        params.put("auto_extend_enabled", strategy.getAdAutoExtendEnabled());
         //预算与出价
         //投放场景 允许值: 常规投放"SMART_BID_CUSTOM", 放量投放"SMART_BID_CONSERVATIVE"
-        params.put("smart_bid_type", "投放场景");
+        params.put("smart_bid_type", strategy.getAdSmartBidType());
         //预算类型 "BUDGET_MODE_DAY"日预算, "BUDGET_MODE_TOTAL"总预算
-        params.put("budget_mode", byteDanceAdvertisePlan.getBudgetMode());
+        params.put("budget_mode", strategy.getAdBudgetMode());
         //预算 出价方式为CPC、CPM、CPV时,不少于100元;出价方式为OCPM、OCPC时,不少于300元
-        params.put("budget", byteDanceAdvertisePlan.getBudget());
+        params.put("budget", strategy.getAdBudget());
         //投放时间类型 允许值: "SCHEDULE_FROM_NOW"从今天起长期投放, "SCHEDULE_START_END"设置开始和结束日期
-        params.put("schedule_type", byteDanceAdvertisePlan.getScheduleType());
+        params.put("schedule_type", strategy.getAdScheduleType());
         //投放时段,默认全时段投放
-        params.put("schedule_time", byteDanceAdvertisePlan.getScheduleTime());
+        params.put("schedule_time", strategy.getAdScheduleTime());
         //付费方式(计划出价类型) 决定投放目标的类型,比如CPC表示点击量,OCPM表示转化量
-        params.put("pricing", byteDanceAdvertisePlan.getPricing());
+        params.put("pricing", strategy.getAdPricing());
         //目标转化出价/预期成本, 当pricing为"OCPM"、"OCPC"出价方式时必填)
         //pricing为"OCPC"时取值范围:0.1-10000元;
         //pricing为"OCPM"时取值范围:0.1-10000元;
         //出价不能大于预算否则会报错
-        params.put("cpa_bid", byteDanceAdvertisePlan.getCpaBid());
+        params.put("cpa_bid", strategy.getAdCpaBid());
         params = Check.jsonRemoveEmpty(params);
-
         JSONObject jsonObject = HttpUtils.bytedancePostRequest(token.getAccessToken(),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update"), params);
         Integer code = jsonObject.getInteger("code");
@@ -888,8 +895,8 @@ public class marketing {
             log.error("广告计划修改失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             Result.error(jsonObject.getString("message"));
         }
-        byteDanceAdvertisePlan.setId(jsonObject.getJSONObject("data").getLong("ad_id"));
-        return Result.successMsg("广告计划修改成功成功",byteDanceAdvertisePlan);
+        //byteDanceAdvertisePlan.setId(jsonObject.getJSONObject("data").getLong("ad_id"));
+        return Result.successMsg("广告计划修改成功成功",jsonObject.getString("data"));
     }
 
 
@@ -904,7 +911,7 @@ public class marketing {
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
-    public static Result creativeUpdate(CtopOauthToken token, Long adId, String modifyTime,JSONObject data) {
+    public static Result creativeUpdate(CtopOauthToken token, String adId, String modifyTime,JSONObject data) {
        //广告主ID
         data.put("advertiser_id", token.getAccountId());
         //广告计划ID
@@ -944,6 +951,7 @@ public class marketing {
         data.put("third_industry_id", data.getString("third_industry_id"));
         //创意标签 创意标签。最多20个标签,且每个标签长度不超过10个字符
         data.put("ad_keywords", data.getString("ad_keywords"));
+        data = Check.jsonRemoveEmpty(data);
         JSONObject result = HttpUtils.bytedancePostRequest(token.getAccessToken(),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_update_v2"),
                 data);
@@ -958,4 +966,43 @@ public class marketing {
 
 
 
+
+
+
+    /**
+     *
+     * @description: 获取行业列表
+     *
+     * @param token
+     * @param type  "ADVERTISER"为原有广告3.0行业, "AGENT"为代理商行业获取,代理商行业level都为1
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    public static Result getToolIndustryList(CtopOauthToken token,String type) {
+
+        JSONObject params = new JSONObject();
+        params.put("type", type);
+        params.put("level",type.equalsIgnoreCase(BytedanceConstant.LEVEL_AGENT) ? 1 : "");
+        params = Check.jsonRemoveEmpty(params);
+        JSONObject jsonObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(),
+                PropertiesUtils.getValue("bytedance_config", "bytedance_v2_tools_industry_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);
+        }
+        JSONArray data = jsonObject.getJSONObject("data").getJSONArray("custom_audience_list");
+        if (null == data || data.isEmpty()) {
+            log.info("行业类别信息不存在==》accountId:{},message:{}", token.getAccountId(), message);
+            return Result.error("人群包信息不存在");
+        }
+        return Result.successMsg("行业类别信息获取成功",data);
+    }
+
+
+
+
+
 }

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

@@ -200,7 +200,7 @@ public class AiBytedanceAdvertiserStrategy{
 	/**目标转化出价*/
 	private java.math.BigDecimal adCpaBid;
 	/**深度优化方式*/
-	private Object adDeepBidType;
+	private String adDeepBidType;
 	/**深度优化出价*/
 	private BigDecimal adDeepCpabid;
 	/**鲁班目标ROI出价策略系数*/

+ 56 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IAiBytedanceAdvertiserStrategyService.java

@@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
 import org.jeecg.modules.bytedance.advertise.entity.UpdAdStaOrCpaOrBudget;
+import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
+import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
+
+import java.util.List;
 
 /**
  * 头条智能投放账户配置信息表
@@ -15,6 +19,23 @@ public interface IAiBytedanceAdvertiserStrategyService extends IService<AiByteda
     //创建创意创建
     Long createCreative(AiBytedanceAdvertiserStrategy strategy,Integer createType, Long videoCnt);
 
+    /**
+     *  创建 广告 组-计划-创意
+     * @param strategy
+     * @return
+     */
+    Result createADCreative(AiBytedanceAdvertiserStrategy strategy);
+
+
+    /**
+     * 修改 广告 组-计划-创意
+     * @param strategy
+     * @param groupModifyTime 广告组 修改时间戳
+     * @param planModifyTime  计划 修改时间戳
+     * @return
+     */
+    Result updateADCreative(AiBytedanceAdvertiserStrategy strategy,String groupModifyTime,String planModifyTime);
+
 
     /**
      * 头条 - 配置信息 修改 状态
@@ -30,4 +51,39 @@ public interface IAiBytedanceAdvertiserStrategyService extends IService<AiByteda
      */
     Result updStaOrCpaOrBudgetById(UpdAdStaOrCpaOrBudget updAdStaOrCpaOrBudget);
 
+    /**
+     * 获取行业列表
+     * @param type
+     * @return
+     */
+    Result getIndustryList(String accountId,String type);
+
+    /**
+     *  获取广告组
+     * @param accountId 广告主id
+     * @param adGroupSearchVoList
+     * @param pageNo
+     * @param pageSize
+     * @return
+     */
+    Result getCampaignGroup(String accountId,List<AdGroupSearchVo> adGroupSearchVoList, Integer pageNo, Integer pageSize);
+
+    /**
+     *  获取广告组计划
+     * @param accountId 广告主id
+     * @param planSearchVoList
+     * @param pageNo
+     * @param pageSize
+     * @return
+     */
+    Result getCampaignPlan(String accountId, List<PlanSearchVo> planSearchVoList, Integer pageNo, Integer pageSize);
+
+    /**
+     * @description: 获取创意详细信息
+     * @param accountId 广告主id
+     * @param adId 计划id
+     * @return: org.jeecg.common.api.vo.Result
+     */
+    Result creativeReadInfo(String accountId, String adId);
+
 }

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

@@ -3,17 +3,12 @@ package org.jeecg.modules.bytedance.advertise.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.bytedance.advertise.dockapi.marketing;
 import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
-import org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo;
 import org.jeecg.modules.bytedance.advertise.entity.UpdAdStaOrCpaOrBudget;
-import org.jeecg.modules.bytedance.advertise.enums.BytedanceCreativeMatTypeEnum;
 import org.jeecg.modules.bytedance.advertise.mapper.AiBytedanceAdvertiserStrategyMapper;
 import org.jeecg.modules.bytedance.advertise.service.IAiBytedanceAdvertiserStrategyService;
-import org.jeecg.modules.bytedance.advertise.service.IByteDanceVideoInfoService;
 import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
-import org.jeecg.modules.bytedance.common.entity.UserAllocation;
 import org.jeecg.modules.bytedance.common.service.ICtopOauthTokenService;
 import org.jeecg.modules.bytedance.common.service.IUserAllocationService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -115,7 +110,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(updAdStaOrCpaOrBudget.getAccountId());
         List<Map<String,Object>> priceList = updAdStaOrCpaOrBudget.getData();
         //1-修改出价
-        if ("1".equals(updAdStaOrCpaOrBudget.getType())) {
+        if (BytedanceConstant.UPDTYPE_BID.equals(updAdStaOrCpaOrBudget.getType())) {
             // api 更新计划出价
             updResult = marketing.updatePlanBid(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
             if (!"200".equals(updResult.getCode())){
@@ -127,7 +122,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             });
         }
         //2-修改预算
-        if ("2".equals(updAdStaOrCpaOrBudget.getType())) {
+        if (BytedanceConstant.UPDTYPE_BUDGET.equals(updAdStaOrCpaOrBudget.getType())) {
             // api 修改计划 预算
             updResult = marketing.updatePlanBudget(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
             if (!"200".equals(updResult.getCode())){
@@ -138,11 +133,176 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 aiBytedanceAdvertiserStrategyMapper.updBudgetById(updAdStaOrCpaOrBudget.getId(),map.get("budget").toString());
             });
         }
-        return Result.successMsg("修改"+("1".equals(updAdStaOrCpaOrBudget.getType()) ? "出价" : "预算")+"成功。", updResult.getResult());
+        return Result.successMsg("修改"+(BytedanceConstant.UPDTYPE_BID.equals(updAdStaOrCpaOrBudget.getType()) ? "出价" : "预算")+"成功。", updResult.getResult());
     }
 
 
 
+    /**
+     *
+     * @description: 获取行业类别
+     *
+     * @param accountId 广告主id
+     * @param type 行业类别
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    public Result getIndustryList(String accountId,String type) {
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+        if (null == token) {
+            log.info("token获取失败=>accountId:{}", token.getAccountId());
+            return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
+        }
+        // 获取行业列表
+        Result industryList = marketing.getToolIndustryList(token,type);
+        log.error("行业列表=======>>>>>>>>>>>", industryList.getResult());
+        return Result.successMsg("获取行业列表成功。", industryList.getResult());
+    }
+
+
+    /**
+     *
+     * @description: 获取广告组
+     *
+     * @param accountId 广告主id
+     * @param adGroupSearchVoList
+     * @param pageNo
+     * @param pageSize
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    public Result getCampaignGroup(String accountId,List<AdGroupSearchVo> adGroupSearchVoList, Integer pageNo, Integer pageSize) {
+
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+        if (null == token) {
+            log.info("token获取失败=>accountId:{}", token.getAccountId());
+            return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
+        }
+        // 获取广告组
+        Result industryList = marketing.getCampaignGroupList(token,accountId,adGroupSearchVoList,pageNo,pageSize);
+        log.error("获取广告组=======>>>>>>>>>>>", industryList.getResult());
+        return Result.successMsg("获取广告组成功。", industryList.getResult());
+    }
+
+
+
+    /**
+     *
+     * @description: 获取广告计划
+     *
+     * @param accountId 广告主id
+     * @param adGroupSearchVoList
+     * @param pageNo
+     * @param pageSize
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    public Result getCampaignPlan(String accountId, List<PlanSearchVo> adGroupSearchVoList, Integer pageNo, Integer pageSize) {
+
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+        if (null == token) {
+            log.info("token获取失败=>accountId:{}", token.getAccountId());
+            return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
+        }
+        // 获取计划
+        Result industryList = marketing.getPlanList(token,adGroupSearchVoList,pageNo,pageSize);
+        log.error("获取广告计划=======>>>>>>>>>>>", industryList.getResult());
+        return Result.successMsg("获取广告计划成功。", industryList.getResult());
+    }
+
+    /**
+     *
+     * @description: 获取创意详细信息
+     *
+     * @param accountId 广告主id
+     * @param adId 计划id
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    public Result creativeReadInfo(String accountId, String adId) {
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+        if (null == token) {
+            log.info("token获取失败=>accountId:{}", token.getAccountId());
+            return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
+        }
+        // 获取 创意详细信息
+        Result industryList = marketing.creativeRead(token,accountId,adId);
+        log.error("获取创意详细信息=======>>>>>>>>>>>", industryList.getResult());
+        return Result.successMsg("获取创意详细信息成功。", industryList.getResult());
+    }
+
+
+
+
+
+
+    /**
+     * 创建 广告 组-计划-创意
+     * @param strategy
+     * @return
+     */
+    public Result createADCreative(AiBytedanceAdvertiserStrategy strategy) {
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(strategy.getAccountId()+"");
+        if (null == token) {
+            log.info("token获取失败=>accountId:{}", token.getAccountId());
+            return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
+        }
+        // 1:创建广告组
+        Result resultCampaign = marketing.createCampaign(token,
+                strategy.getCampaignName(),
+                strategy.getAdBudgetMode() == null ? BytedanceConstant.BUDGET_MODE_INFINITE : strategy.getAdBudgetMode(),
+                strategy.getAdBudget(),
+                strategy.getCampaignLandingType());
+        //广告组id
+        Long campaignId = (Long) resultCampaign.getResult();
+        // 2:创建广告计划
+        Result resultPlan = marketing.createAdvertiserPlan(token,campaignId,strategy);
+        //计划id
+        Long planId = (Long) resultPlan.getResult();
+        //3:创建创意
+        Result creativeInfo = marketing.creativeCreate(token, planId, strategy);
+
+        log.error("创意创建=======>>>>>>>>>>>", creativeInfo.getResult());
+        //数据入库
+        aiBytedanceAdvertiserStrategyMapper.insert(strategy);
+        return Result.successMsg("创建成功", strategy);
+    }
+
+
+
+
+    /**
+     *
+     * @description: 修改 广告 组-计划-创意
+     *
+     * @param strategy
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    public Result updateADCreative(AiBytedanceAdvertiserStrategy strategy,String groupModifyTime,String planModifyTime) {
+
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(strategy.getAccountId()+"");
+        if (null == token) {
+            log.info("token获取失败=>accountId:{}", token.getAccountId());
+            return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
+        }
+        // 1:修改广告组
+        Result resultCampaign = marketing.updateCampaign(token,
+                "广告组id",groupModifyTime,
+                strategy.getCampaignName(),strategy.getCampaignBudgetMode(),strategy.getCampaignLandingType());
+        //广告组id
+        Long campaignId = (Long) resultCampaign.getResult();
+        // 2:修改广告计划
+        Result resultPlan = marketing.updateAdvertiserPlan(token,"计划id",planModifyTime,strategy);
+        //计划id
+        Object planId = resultPlan.getResult();
+        //3:修改创意 TODO 拼接创意参数
+        Result creativeInfo = marketing.creativeUpdate(token, "计划id","创意时间戳",null);
+        //数据修改
+        aiBytedanceAdvertiserStrategyMapper.updateById(strategy);
+        return Result.successMsg("修改成功", strategy);
+    }
+
 
 
 

+ 43 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/constant/BytedanceConstant.java

@@ -10,5 +10,48 @@ public class BytedanceConstant {
     //角色编码  管理员
     public static final String COMMON_ROLE_CODE_ADMIN = "admin";
 
+    //修改出价 类型
+    public static final String UPDTYPE_BID = "1";
+    //修改预算 类型
+    public static final String UPDTYPE_BUDGET = "2";
 
+
+    /**
+     * 预算类型
+     */
+    //不限
+    public static final String BUDGET_MODE_INFINITE = "BUDGET_MODE_INFINITE";
+    //日预算
+    public static final String BUDGET_MODE_DAY = "BUDGET_MODE_DAY";
+    //总预算
+    public static final String BUDGET_MODE_TOTAL = "BUDGET_MODE_TOTAL";
+
+
+    /**
+     * 计划状态
+     */
+    //开启
+    public static final String OPERATION_ENABLE = "enable";
+    //关闭
+    public static final String OPERATION_DISABLE = "disable";
+
+    /**
+     * 投放范围
+     */
+    //默认
+    public static final String DELIVERY_RANGE_DEFAULT = "DEFAULT";
+    //只投放到资讯联盟(穿山甲)
+    public static final String DELIVERY_RANGE_UNION = "UNION";
+    //通投智选
+    public static final String DELIVERY_RANGE_UNIVERSAL = "UNIVERSAL";
+
+
+    /**
+     * 行业类型
+     */
+    //为原有广告3.0行业
+    public static final String LEVEL_ADVERTISER = "ADVERTISER";
+
+    //为代理商行业获取,代理商行业level都为1
+    public static final String LEVEL_AGENT = "AGENT";
 }

+ 3 - 0
jeecg-boot-bytedance/src/main/resources/bytedance_config.properties

@@ -65,6 +65,9 @@ bytedance_v2_creative_get=/2/creative/get/
 bytedance_v2_creative_update_v2=/2/creative/update_v2/
 
 
+#»ñÈ¡ÐÐÒµÁбí
+bytedance_v2_tools_industry_get=/2/tools/industry/get/
+
 bytedance_v2_advertiser_report_get=/2/report/advertiser/get/
 bytedance_v2_campaign_report_get=/2/report/campaign/get/
 bytedance_v2_ad_report_get=/2/report/ad/get/

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

@@ -3,7 +3,6 @@ package org.jeecg.modules.bytedance.advertise.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import io.lettuce.core.dynamic.annotation.Param;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -14,6 +13,8 @@ import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
 import org.jeecg.modules.bytedance.advertise.entity.UpdAdStaOrCpaOrBudget;
 import org.jeecg.modules.bytedance.advertise.service.IAiBytedanceAdvertiserStrategyService;
+import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
+import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
 import org.jeecg.modules.bytedance.common.constant.BytedanceConstant;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,7 +23,6 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 头条智能投放账户配置信息表
@@ -92,6 +92,8 @@ public class AiBytedanceAdvertiserStrategyController {
 		return result;
 	}
 
+
+
 	/**
 	  *  编辑
 	 * @param aiBytedanceAdvertiserStrategy
@@ -172,19 +174,112 @@ public class AiBytedanceAdvertiserStrategyController {
 	@ApiOperation(value="头条智能投放账户配置信息-修改状态(0开-1关)", notes="头条智能投放账户配置信息-修改状态(0开-1关)")
 	@PutMapping(value = "/updStaById")
 	public Result updStaById(@RequestParam("id") String id, @RequestParam("state") String state) {
-		return aiBytedanceAdvertiserStrategyService.updStaById(id,state);
+		try {
+			return aiBytedanceAdvertiserStrategyService.updStaById(id,state);
+		}catch (Exception e){
+			log.error("修改状态(0开-1关)失败",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
 
 	}
 
 	@ApiOperation(value="头条智能投放账户配置信息-修改出价;预算", notes="头条智能投放账户配置信息-修改出价;预算")
 	@PutMapping(value = "/updStaOrCpaOrBudgetById")
 	public Result updStaOrCpaOrBudgetById(UpdAdStaOrCpaOrBudget updAdStaOrCpaOrBudget) {
-		return aiBytedanceAdvertiserStrategyService.updStaOrCpaOrBudgetById(updAdStaOrCpaOrBudget);
+		try {
+			if (updAdStaOrCpaOrBudget.getData().size() > 100){
+				return Result.error("批量修改数量不能超过闭区间[1~100]");
+			}
+			return aiBytedanceAdvertiserStrategyService.updStaOrCpaOrBudgetById(updAdStaOrCpaOrBudget);
+		}catch (Exception e){
+			log.error("修改出价-预算失败",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
 
 	}
 
 
 
+	@ApiOperation(value="头条智能投放账户配置-获取行业类别", notes="头条智能投放账户配置-获取行业类别")
+	@PostMapping(value = "/getIndustryList")
+	public Result getIndustryList(@RequestParam("accountId") String accountId, @RequestParam("type") String type) {
+		try {
+			return aiBytedanceAdvertiserStrategyService.getIndustryList(accountId,type);
+		}catch (Exception e){
+			log.error("创建失败",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+
+	@ApiOperation(value="头条智能投放账户配置-获取广告组", notes="头条智能投放账户配置-获取广告组")
+	@PostMapping(value = "/getCampaignGroupList")
+	public Result getCampaignGroup(List<AdGroupSearchVo> adGroupSearchVoList,
+								   @RequestParam("accountId") String accountId,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
+		try {
+			return aiBytedanceAdvertiserStrategyService.getCampaignGroup(accountId,adGroupSearchVoList,pageNo,pageSize);
+		}catch (Exception e){
+			log.error("获取广告组异常。",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+	@ApiOperation(value="头条智能投放账户配置-获取广告计划", notes="头条智能投放账户配置-获取广告计划")
+	@PostMapping(value = "/getCampaignPlanList")
+	public Result getCampaignPlanList(List<PlanSearchVo> planSearchVoList,
+								   @RequestParam("accountId") String accountId,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
+		try {
+			return aiBytedanceAdvertiserStrategyService.getCampaignPlan(accountId,planSearchVoList,pageNo,pageSize);
+		}catch (Exception e){
+			log.error("获取广告组异常。",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+	@ApiOperation(value="头条智能投放账户配置-获取创意详细信息", notes="头条智能投放账户配置-获取创意详细信息")
+	@PostMapping(value = "/creativeReadInfo")
+	public Result creativeReadInfo(@RequestParam("accountId") String accountId,@RequestParam("adId") String adId) {
+		try {
+			return aiBytedanceAdvertiserStrategyService.creativeReadInfo(accountId,adId);
+		}catch (Exception e){
+			log.error("获取广告组异常。",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+
+	@ApiOperation(value="头条智能投放账户配置-新建账户配置", notes="头条智能投放账户配置-新建账户配置")
+	@PostMapping(value = "/createADCreative")
+	public Result createADCreative(@RequestBody AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
+		try {
+			return aiBytedanceAdvertiserStrategyService.createADCreative(aiBytedanceAdvertiserStrategy);
+		}catch (Exception e){
+			log.error("创建失败",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+
+	@ApiOperation(value="头条智能投放账户配置-修改账户配置", notes="头条智能投放账户配置-修改账户配置")
+	@PostMapping(value = "/updateADCreative")
+	public Result updateADCreative(AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy,
+								   @RequestParam("groupModifyTime") String groupModifyTime,
+								   @RequestParam("planModifyTime") String planModifyTime) {
+		try {
+			return aiBytedanceAdvertiserStrategyService.updateADCreative(aiBytedanceAdvertiserStrategy,groupModifyTime,planModifyTime);
+		}catch (Exception e){
+			log.error("修改失败",e.getMessage());
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+
+
+