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