|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|