|
@@ -3,15 +3,21 @@ package org.jeecg.modules.ctop.service.impl;
|
|
|
import cn.com.ctop.common.module.entity.BindAccountLogin;
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.mapper.BindAccountLoginMapper;
|
|
|
+import cn.com.ctop.common.module.service.IBindAccountLoginService;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
+import cn.com.ctop.common.module.service.IFileInfoService;
|
|
|
import cn.com.ctop.common.module.utils.*;
|
|
|
import cn.com.ctop.crawler.modules.core.util.FateadmHttpUtil;
|
|
|
import cn.com.ctop.crawler.modules.core.util.FateadmUtil;
|
|
|
import cn.com.ctop.toutiao.entity.ByteDanceUserOrientationTemplate;
|
|
|
+import cn.com.ctop.toutiao.entity.BytedanceCreativeLaunchTemplate;
|
|
|
import cn.com.ctop.toutiao.entity.BytedanceUrlInfo;
|
|
|
import cn.com.ctop.toutiao.mapper.ByteDanceUserOrientationTemplateMapper;
|
|
|
+import cn.com.ctop.toutiao.mapper.BytedanceCreativeLaunchTemplateMapper;
|
|
|
import cn.com.ctop.toutiao.mapper.BytedanceUrlInfoMapper;
|
|
|
import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
|
|
|
+import cn.com.ctop.toutiao.service.IByteDanceCreativeService;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
@@ -40,13 +46,15 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
@Value("${jeecg.path.chrome-driver}")
|
|
|
private String chromeDriver;
|
|
|
@Autowired
|
|
|
+ private IBindAccountLoginService bindAccountLoginService;
|
|
|
+ @Autowired
|
|
|
private BindAccountLoginMapper bindAccountLoginMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private BytedanceUrlInfoMapper urlInfoMapper;
|
|
|
|
|
|
@Override
|
|
|
- public boolean bindLogin(String advertiserId, String accountName, String password, String loginType, String userId) {
|
|
|
+ public boolean bindLogin(String advertiserId, String accountName, String password, String loginType, String userId, String advertiserName) {
|
|
|
Map<String, Object> requestMap = new HashMap<>();
|
|
|
requestMap.put("advertiser_id", advertiserId);
|
|
|
requestMap.put("account_name", accountName);
|
|
@@ -71,6 +79,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
bindAccountLogin.setPassword(password);
|
|
|
bindAccountLogin.setAccountId(accountId);
|
|
|
bindAccountLogin.setLoginType(loginType);
|
|
|
+ bindAccountLogin.setAccountName(advertiserName);
|
|
|
bindAccountLogin.setUserId(userId);
|
|
|
int i = bindAccountLoginMapper.insert(bindAccountLogin);
|
|
|
if (i > 0) {
|
|
@@ -144,7 +153,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
param.put("captcha", resp.pred_resl);
|
|
|
orderId = resp.req_id;
|
|
|
res = HttpUtils2.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
|
|
|
- System.out.println("res:" + res);
|
|
|
jsonNode = mapper.readTree(res);
|
|
|
errorCode = jsonNode.get("error_code").asInt();
|
|
|
}
|
|
@@ -188,13 +196,18 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
//1:获取用户名密码
|
|
|
Long accountId = requestJson.getLong("accountId");
|
|
|
- System.out.println(accountId);
|
|
|
Long userOrientationId = requestJson.getLong("userOrientationId");
|
|
|
- BindAccountLogin bindAccountLogin = bindAccountLoginMapper.selectById(accountId);
|
|
|
+ BindAccountLogin bindAccountLogin = bindAccountLoginService.selectByAccountId(accountId + "");
|
|
|
if (null == bindAccountLogin) {
|
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.ACCOUNT_HAS_NOT_EXIST.getCode());
|
|
|
return resultMap;
|
|
|
}
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
|
+ if (null == token) {
|
|
|
+ ResultMapUtils.setResultMap(resultMap, StatusCode.ACCOUNT_HAS_NOT_EXIST.getCode());
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ JSONObject wordsObject = fileInfoService.getCreativeWord(token, token.getAccountId());
|
|
|
String url = "https://ad.oceanengine.com/pages/login/index.html";
|
|
|
System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
|
|
|
ChromeOptions chromeOptions = new ChromeOptions();
|
|
@@ -209,7 +222,8 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
chromeOptions.setAcceptInsecureCerts(true);
|
|
|
WebDriver webDriver = new ChromeDriver(chromeOptions);
|
|
|
try {
|
|
|
- webDriver.get(url); //获取登录页面
|
|
|
+ //获取登录页面
|
|
|
+ webDriver.get(url);
|
|
|
for (Cookie cookie : webDriver.manage().getCookies()) {
|
|
|
BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
|
|
|
ck.setDomain("ad.oceanengine.com");
|
|
@@ -271,10 +285,11 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
Cookie cookie = new Cookie(ck.getName(), ck.getValue(), "." + ck.getDomain(), ck.getPath(), ck.getExpiryDate());
|
|
|
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);
|
|
|
- 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");
|
|
|
Map<String, Object> campaignParam = new HashMap<>();
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
@@ -305,14 +320,17 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
header.put("X-CSRFToken", csrftoken);
|
|
|
header.put("X-Requested-With", "XMLHttpRequest");
|
|
|
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);
|
|
|
Integer itratorNum = requestJson.getInteger("itratorNum");
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
if (null != itratorNum && itratorNum > 0) {
|
|
|
//循环创建广告计划
|
|
|
for (int i = 0; i < itratorNum; i++) {
|
|
|
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";
|
|
|
webDriver.get(url2);
|
|
|
header.put("Referer", url2);
|
|
@@ -329,16 +347,19 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
String tokenStr = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/api/v1/hl/ad/audience/estimate/", audienceParam, header);
|
|
|
JsonNode tokenNode = mapper.readTree(tokenStr);
|
|
|
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");
|
|
|
- planParam.put("delivery_range", deliveryRange); //投放形式
|
|
|
+ //投放形式
|
|
|
+ planParam.put("delivery_range", deliveryRange);
|
|
|
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");
|
|
|
- planParam.put("download_type", downloadType); //下载方式 1:下载包 2:h5
|
|
|
+ //下载方式 1:下载包 2:h5
|
|
|
+ planParam.put("download_type", downloadType);
|
|
|
Long urlId = requestJson.getLong("urlId");
|
|
|
BytedanceUrlInfo urlInfo = urlInfoMapper.selectById(urlId);
|
|
|
if (downloadType == 1) {
|
|
@@ -346,59 +367,92 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
planParam.put("package", urlInfo.getPackageName());
|
|
|
}
|
|
|
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("localGeolocation", new ArrayList<String>());
|
|
|
// planParam.put("external_action", 4);
|
|
|
- planParam.put("open_url", ""); // 应用直达链接
|
|
|
+ // 应用直达链接
|
|
|
+ planParam.put("open_url", "");
|
|
|
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("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");
|
|
|
- planParam.put("schedule_type", scheduleType); //广告投放时间类型 默认1 1:不限 2:按时间???
|
|
|
+ //广告投放时间类型 默认1 1:不限 2:按时间???
|
|
|
+ planParam.put("schedule_type", scheduleType);
|
|
|
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");
|
|
|
- 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("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) {
|
|
|
planParam.put("cpa_bid", requestJson.getIntValue("convertPrice"));
|
|
|
} else {
|
|
|
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("campaign_id", campaignId);
|
|
|
- String downLoadMode = requestJson.getString("downloadMode");
|
|
|
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())) {
|
|
|
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);
|
|
|
String createResult = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", planParam, header);
|
|
@@ -412,20 +466,158 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
resultMap.put("success", false);
|
|
|
return resultMap;
|
|
|
}
|
|
|
+ //广告计划id
|
|
|
Long adId = result.getJSONObject("data").getLong("ad_id");
|
|
|
-
|
|
|
//修改用户定向
|
|
|
ByteDanceUserOrientationTemplate template = userOrientationTemplateMapper.selectById(userOrientationId);
|
|
|
if (null != template) {
|
|
|
- CtopOauthToken token = tokenService.getOauthTokenByAccountId(bindAccountLogin.getAccountId());
|
|
|
- if (null != token) {
|
|
|
- //获取modify_time
|
|
|
- Thread.sleep(5000L);
|
|
|
- advertiserDataService.getAdvertiserPlan(bindAccountLogin.getAccountId(), adId + "");
|
|
|
+ //获取modify_time
|
|
|
+ Thread.sleep(5000L);
|
|
|
+ advertiserDataService.getAdvertiserPlan(bindAccountLogin.getAccountId(), adId + "");
|
|
|
+ advertiserDataService.updateAd(token, adId, template);
|
|
|
+ }
|
|
|
+ Long creativeTemplateId = requestJson.getLong("creativeTemplateId");
|
|
|
+
|
|
|
+ //创建广告创意
|
|
|
+ String name = requestJson.getString("name");
|
|
|
+ data.put("title", name + "_" + System.currentTimeMillis() + "_" + "汇创广告创意");
|
|
|
+ if (i == 0) {
|
|
|
+ BytedanceCreativeLaunchTemplate launchTemplate = launchTemplateMapper.selectById(creativeTemplateId);
|
|
|
+ data.put("ad_id", adId);
|
|
|
+ String advertiseLoaction = launchTemplate.getAdvertiseLocation();
|
|
|
+ //优选广告位
|
|
|
+ if (null != advertiseLoaction && advertiseLoaction.equals("great") && null != launchTemplate.getSmartInventory() && !"".equals(launchTemplate.getSmartInventory())) {
|
|
|
+ data.put("smart_inventory", launchTemplate.getSmartInventory());
|
|
|
+ }
|
|
|
+ //按媒体指定位置
|
|
|
+ if (null != advertiseLoaction && "media".equals(advertiseLoaction)) {
|
|
|
+ String inventoryTypeStr = launchTemplate.getInventoryType();
|
|
|
+ JSONArray inventoryType = JSONArray.parseArray(inventoryTypeStr);
|
|
|
+ data.put("inventory_type", inventoryType);
|
|
|
+ }
|
|
|
+ //按场景指定位置
|
|
|
+ if (null != advertiseLoaction && "sence".equals(advertiseLoaction)) {
|
|
|
+ data.put("scene_inventory", launchTemplate.getSceneInventory());
|
|
|
+ }
|
|
|
+
|
|
|
+ //广告评论
|
|
|
+ data.put("is_comment_disable", launchTemplate.getCommentDisable());
|
|
|
+ //创意展现方式
|
|
|
+ data.put("creative_display_mode", launchTemplate.getCreativeDisplayMode());
|
|
|
+ //创意分类
|
|
|
+ JSONArray categorys = JSONArray.parseArray(launchTemplate.getThirdIndustryId());
|
|
|
+ String thirdIndustryId = categorys.getString(2);
|
|
|
+ data.put("third_industry_id", thirdIndustryId);
|
|
|
+ //创意标签
|
|
|
+ data.put("ad_keywords", JSONArray.parseArray(launchTemplate.getAdKeywords()));
|
|
|
+ //创意标题
|
|
|
+ data.put("title", name + "_" + System.currentTimeMillis() + "_" + "汇创广告创意");
|
|
|
|
|
|
- System.out.println(111);
|
|
|
- advertiserDataService.updateAd(token, adId, template);
|
|
|
+ //创意方式
|
|
|
+ String creativeType = requestJson.getString("creativeType");
|
|
|
+ if (null != creativeType && creativeType.equals("customize")) {
|
|
|
+ //自定义创意
|
|
|
+ //拼装creative参数
|
|
|
+ JSONArray creatives = new JSONArray();
|
|
|
+ JSONArray getCreatives = requestJson.getJSONArray("creatives");
|
|
|
+ if (null != getCreatives && getCreatives.size() > 0) {
|
|
|
+ getCreatives.forEach(k -> {
|
|
|
+ JSONObject createtive = JSONObject.parseObject(JSONObject.toJSONString(k));
|
|
|
+ JSONObject setCreatetive = new JSONObject();
|
|
|
+ String imageMode = createtive.getString("typeCode");
|
|
|
+ setCreatetive.put("image_mode", imageMode);
|
|
|
+ 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 (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);
|
|
|
+ creatives.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);
|
|
|
+ creatives.add(setCreatetive);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ data.put("creatives", creatives);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.put("creative_material_mode", "STATIC_ASSEMBLE");
|
|
|
+ //程序化创意
|
|
|
+ JSONArray titleArray = requestJson.getJSONArray("titles");
|
|
|
+ if (null != titleArray && titleArray.size() > 0) {
|
|
|
+ JSONArray titleList = new JSONArray();
|
|
|
+ titleArray.forEach(v -> {
|
|
|
+ JSONObject getTitleObject = JSONObject.parseObject(JSONObject.toJSONString(v));
|
|
|
+ ;
|
|
|
+ JSONObject titleObject = new JSONObject();
|
|
|
+ String getTitle = getTitleObject.getString("text");
|
|
|
+ titleObject.put("title", getTitle);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
+ //应用下载详情页
|
|
|
+ data.put("web_url", requestJson.getString("webUrl"));
|
|
|
+ //应用名
|
|
|
+ data.put("app_name", requestJson.getString("appName"));
|
|
|
+ }
|
|
|
+ System.out.println(data.toJSONString());
|
|
|
+ resultMap = byteDanceCreativeService.creativeCreate(token.getAccountId() + "", adId, data.toJSONString());
|
|
|
+ Boolean createSuccess = (Boolean) resultMap.get("success");
|
|
|
+ if (null != createSuccess && !createSuccess) {
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -443,6 +635,30 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
|
|
|
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
|
|
|
+ private BytedanceCreativeLaunchTemplateMapper launchTemplateMapper;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceCreativeService byteDanceCreativeService;
|
|
|
+ @Autowired
|
|
|
+ private IFileInfoService fileInfoService;
|
|
|
@Autowired
|
|
|
private ByteDanceUserOrientationTemplateMapper userOrientationTemplateMapper;
|
|
|
@Autowired
|