|
@@ -52,67 +52,84 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
@Autowired
|
|
@Autowired
|
|
private IAiKuaiShouAppInfoService appInfoService;
|
|
private IAiKuaiShouAppInfoService appInfoService;
|
|
|
|
|
|
|
|
+ String getReplaceStringByCreateType(AiKuaishouAdvertiserStrategy strategy, Integer createType) {
|
|
|
|
+ String replaceString;
|
|
|
|
+ if (createType == 2) {
|
|
|
|
+ replaceString = "历史高质量";
|
|
|
|
+ } else if (createType == 3) {
|
|
|
|
+ replaceString = "素材上新";
|
|
|
|
+ } else {
|
|
|
|
+ replaceString = "素材上新";
|
|
|
|
+ }
|
|
|
|
+ if (strategy.getUnitType() == 7) {
|
|
|
|
+ replaceString = "程序化" + replaceString;
|
|
|
|
+ }
|
|
|
|
+ return replaceString;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建自定义创意
|
|
* 创建自定义创意
|
|
- * @param strategy
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param strategy 账户配置信息
|
|
|
|
+ * @param createType 创意创建类型 1:素材上新 2:历史高质量 3:历史遗漏素材
|
|
|
|
+ * @param params 需要拼装的参数
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void autoCreateCreative(AiKuaishouAdvertiserStrategy strategy){
|
|
|
|
|
|
+ public void autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, JSONObject params) {
|
|
strategy.setUnitType(4);
|
|
strategy.setUnitType(4);
|
|
- String replaceString = "素材上新";
|
|
|
|
|
|
+ String replaceString = getReplaceStringByCreateType(strategy, createType);
|
|
Long accountId = strategy.getAccountId();
|
|
Long accountId = strategy.getAccountId();
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
- if(null == token){
|
|
|
|
- log.info("token获取失败=>accountId:{}",accountId);
|
|
|
|
|
|
+ if (null == token) {
|
|
|
|
+ log.info("token获取失败=>accountId:{}", accountId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//1:获取视频信息
|
|
//1:获取视频信息
|
|
- kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(),DateUtils.date2Str());
|
|
|
|
|
|
+ kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
int timeStart = -10;
|
|
int timeStart = -10;
|
|
int timeEnd = -5;
|
|
int timeEnd = -5;
|
|
Long now = System.currentTimeMillis();
|
|
Long now = System.currentTimeMillis();
|
|
- String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
|
|
|
|
- String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ String startTime = DateUtils.formatDate(new Date(now + timeStart * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String endTime = DateUtils.formatDate(new Date(now + timeEnd * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
//2:判定账户是否单一应用
|
|
//2:判定账户是否单一应用
|
|
Integer singleAppid = strategy.getSingleAppid();
|
|
Integer singleAppid = strategy.getSingleAppid();
|
|
- if(null!=singleAppid&&singleAppid==0){
|
|
|
|
|
|
+ if (null != singleAppid && singleAppid == 0) {
|
|
//非单一应用
|
|
//非单一应用
|
|
String appidString = strategy.getAppIdArray();
|
|
String appidString = strategy.getAppIdArray();
|
|
JSONArray appIdArray = JSONArray.parseArray(appidString);
|
|
JSONArray appIdArray = JSONArray.parseArray(appidString);
|
|
- if(null!=appIdArray&&!appIdArray.isEmpty()){
|
|
|
|
- for(int i=0;i<appIdArray.size();i++){
|
|
|
|
- AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(),appIdArray.getLong(i));
|
|
|
|
- if(null == appInfo){
|
|
|
|
- log.info("账户:{},appid({}) 数据不存在",accountId, appIdArray.getLong(i));
|
|
|
|
|
|
+ if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
|
|
+ for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
|
+ AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
|
|
|
|
+ if (null == appInfo) {
|
|
|
|
+ log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(null!=strategy.getGeneralTrack()&&strategy.getGeneralTrack() == 0){
|
|
|
|
|
|
+ if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
}
|
|
}
|
|
- replaceString = appInfo.getAppVersion()+replaceString;
|
|
|
|
- //1:查询通用素材
|
|
|
|
- List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy,startTime,endTime,appInfo);
|
|
|
|
- if(null == allVideos||allVideos.isEmpty()){
|
|
|
|
|
|
+ replaceString = appInfo.getAppVersion() + replaceString;
|
|
|
|
+ //1:查询素材
|
|
|
|
+ List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType);
|
|
|
|
+ if (null == allVideos || allVideos.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy,token,replaceString,"ALL_CAMPAIGN");
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN");
|
|
|
|
|
|
//开始创建组+创意
|
|
//开始创建组+创意
|
|
- String timestamp = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
|
|
|
- String unitNamePrefix = strategy.getGroupName().replace("自定义",replaceString)+ timestamp;
|
|
|
|
|
|
+ String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
+ String unitNamePrefix = strategy.getGroupName().replace("自定义", replaceString) + timestamp;
|
|
int unitCnt = 0;
|
|
int unitCnt = 0;
|
|
- for(KuaiShouVideoGet videoItem: allVideos) {
|
|
|
|
|
|
+ for (KuaiShouVideoGet videoItem : allVideos) {
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
if (null != overrunInfo) {
|
|
if (null != overrunInfo) {
|
|
- log.info("该账户创意创建已超限=>accountId:{}",accountId);
|
|
|
|
|
|
+ log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
unitCnt++;
|
|
unitCnt++;
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName,appInfo.getAppId());
|
|
|
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -133,23 +150,23 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
//单一应用
|
|
//单一应用
|
|
- List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId,startTime,endTime,strategy.getChannelType(),null,null);
|
|
|
|
- if (null == newVideos ||newVideos.isEmpty()){
|
|
|
|
- log.info("账户:{},{} 到 {} 这段时间没有上新素材",accountId, startTime, endTime);
|
|
|
|
|
|
+ List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId, startTime, endTime, strategy.getChannelType(), null, null);
|
|
|
|
+ if (null == newVideos || newVideos.isEmpty()) {
|
|
|
|
+ log.info("账户:{},{} 到 {} 这段时间没有上新素材", accountId, startTime, endTime);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy,token,replaceString,"TODAY");
|
|
|
|
- if(null== newCampaignId){
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY");
|
|
|
|
+ if (null == newCampaignId) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
//3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
- String timestamp = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
|
|
|
- String unitNamePrefix = strategy.getGroupName().replace("自定义",replaceString)+ timestamp;
|
|
|
|
|
|
+ String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
+ String unitNamePrefix = strategy.getGroupName().replace("自定义", replaceString) + timestamp;
|
|
int unitCnt = 0;
|
|
int unitCnt = 0;
|
|
- for(KuaiShouVideoGet videoItem: newVideos) {
|
|
|
|
|
|
+ for (KuaiShouVideoGet videoItem : newVideos) {
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
if (null != overrunInfo) {
|
|
if (null != overrunInfo) {
|
|
return;
|
|
return;
|
|
@@ -157,7 +174,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitCnt++;
|
|
unitCnt++;
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName,appId);
|
|
|
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -181,56 +198,58 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建程序化创意
|
|
* 创建程序化创意
|
|
|
|
+ *
|
|
* @param strategy
|
|
* @param strategy
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void autoCreateProgramCreative(AiKuaishouAdvertiserStrategy strategy){
|
|
|
|
|
|
+ public void autoCreateProgramCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, JSONObject params) {
|
|
strategy.setUnitType(7);
|
|
strategy.setUnitType(7);
|
|
- String replaceString = "程序化自动上新";
|
|
|
|
|
|
+ String replaceString = getReplaceStringByCreateType(strategy, createType);
|
|
|
|
+ ;
|
|
Long accountId = strategy.getAccountId();
|
|
Long accountId = strategy.getAccountId();
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
- if(null == token){
|
|
|
|
- log.info("token获取失败=>accountId:{}",accountId);
|
|
|
|
|
|
+ if (null == token) {
|
|
|
|
+ log.info("token获取失败=>accountId:{}", accountId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//1:获取视频信息
|
|
//1:获取视频信息
|
|
- kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(),DateUtils.date2Str());
|
|
|
|
|
|
+ kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
int timeStart = -10;
|
|
int timeStart = -10;
|
|
int timeEnd = -5;
|
|
int timeEnd = -5;
|
|
Long now = System.currentTimeMillis();
|
|
Long now = System.currentTimeMillis();
|
|
- String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
|
|
|
|
- String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ String startTime = DateUtils.formatDate(new Date(now + timeStart * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String endTime = DateUtils.formatDate(new Date(now + timeEnd * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
//2:判定账户是否单一应用
|
|
//2:判定账户是否单一应用
|
|
Integer singleAppid = strategy.getSingleAppid();
|
|
Integer singleAppid = strategy.getSingleAppid();
|
|
- if(null!=singleAppid&&singleAppid==0){
|
|
|
|
|
|
+ if (null != singleAppid && singleAppid == 0) {
|
|
//非单一应用
|
|
//非单一应用
|
|
String appidString = strategy.getAppIdArray();
|
|
String appidString = strategy.getAppIdArray();
|
|
JSONArray appIdArray = JSONArray.parseArray(appidString);
|
|
JSONArray appIdArray = JSONArray.parseArray(appidString);
|
|
- if(null!=appIdArray&&!appIdArray.isEmpty()){
|
|
|
|
- for(int i=0;i<appIdArray.size();i++){
|
|
|
|
- AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(),appIdArray.getLong(i));
|
|
|
|
- if(null == appInfo){
|
|
|
|
- log.info("账户:{},appid({}) 数据不存在",accountId, appIdArray.getLong(i));
|
|
|
|
|
|
+ if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
|
|
+ for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
|
+ AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
|
|
|
|
+ if (null == appInfo) {
|
|
|
|
+ log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
//判定是否通用监测链接
|
|
//判定是否通用监测链接
|
|
- if(null!=strategy.getGeneralTrack()&&strategy.getGeneralTrack() == 0){
|
|
|
|
|
|
+ if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
}
|
|
}
|
|
- replaceString = appInfo.getAppVersion()+replaceString;
|
|
|
|
|
|
+ replaceString = appInfo.getAppVersion() + replaceString;
|
|
//1:查询可用素材
|
|
//1:查询可用素材
|
|
- List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy,startTime,endTime,appInfo);
|
|
|
|
- if(null == allVideos){
|
|
|
|
|
|
+ List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType);
|
|
|
|
+ if (null == allVideos) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy,token,replaceString,"ALL_CAMPAIGN");
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN");
|
|
//创建组
|
|
//创建组
|
|
- String timestamp = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
|
|
|
- String unitNamePrefix = strategy.getGroupName().replace("自定义",replaceString)+ timestamp;
|
|
|
|
|
|
+ String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
+ String unitNamePrefix = strategy.getGroupName().replace("自定义", replaceString) + timestamp;
|
|
String unitName = unitNamePrefix + "-" + timestamp;
|
|
String unitName = unitNamePrefix + "-" + timestamp;
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName,appInfo.getAppId());
|
|
|
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -240,37 +259,37 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
//创意
|
|
//创意
|
|
- List<List<KuaiShouVideoGet>> splitVideos = new ListUtils<KuaiShouVideoGet>().split(allVideos,allVideos.size()/5);
|
|
|
|
- for(int j=1;j<splitVideos.size()+1;j++) {
|
|
|
|
|
|
+ List<List<KuaiShouVideoGet>> splitVideos = new ListUtils<KuaiShouVideoGet>().split(allVideos, allVideos.size() / 5);
|
|
|
|
+ for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
if (null != overrunInfo) {
|
|
if (null != overrunInfo) {
|
|
- log.info("该账户创意创建已超限=>accountId:{}",accountId);
|
|
|
|
|
|
+ log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j-1), strategy,j);
|
|
|
|
|
|
+ JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j);
|
|
createProgramCreative(token, creativeParams);
|
|
createProgramCreative(token, creativeParams);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
//单一应用
|
|
//单一应用
|
|
- List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId,startTime,endTime,strategy.getChannelType(),null,150);
|
|
|
|
- if (null == newVideos ||newVideos.isEmpty()){
|
|
|
|
- log.info("账户:{},{} 到 {} 这段时间没有上新素材",accountId, startTime, endTime);
|
|
|
|
|
|
+ List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId, startTime, endTime, strategy.getChannelType(), null, 150);
|
|
|
|
+ if (null == newVideos || newVideos.isEmpty()) {
|
|
|
|
+ log.info("账户:{},{} 到 {} 这段时间没有上新素材", accountId, startTime, endTime);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- Long newCampaignId = getCampaignId(strategy,token,replaceString,"TODAY");
|
|
|
|
- if(null== newCampaignId){
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY");
|
|
|
|
+ if (null == newCampaignId) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
//3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
- String timestamp = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
|
|
|
|
- String unitNamePrefix = strategy.getGroupName().replace("自定义",replaceString)+ timestamp;
|
|
|
|
|
|
+ String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
+ String unitNamePrefix = strategy.getGroupName().replace("自定义", replaceString) + timestamp;
|
|
int unitCnt = 0;
|
|
int unitCnt = 0;
|
|
- for(KuaiShouVideoGet videoItem: newVideos) {
|
|
|
|
|
|
+ for (KuaiShouVideoGet videoItem : newVideos) {
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
if (null != overrunInfo) {
|
|
if (null != overrunInfo) {
|
|
return;
|
|
return;
|
|
@@ -278,7 +297,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitCnt++;
|
|
unitCnt++;
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName,appId);
|
|
|
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -314,7 +333,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
String message = resultJson.getString("message");
|
|
String message = resultJson.getString("message");
|
|
- if (null==code||code!=0) {
|
|
|
|
|
|
+ if (null == code || code != 0) {
|
|
log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", token.getAccountId(), message, creativeParams);
|
|
log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", token.getAccountId(), message, creativeParams);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -322,37 +341,37 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy,Integer creativeCnt) {
|
|
|
|
|
|
+ private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt) {
|
|
JSONObject programJson = new JSONObject();
|
|
JSONObject programJson = new JSONObject();
|
|
programJson.put("advertiser_id", token.getAccountId());
|
|
programJson.put("advertiser_id", token.getAccountId());
|
|
programJson.put("unit_id", unitId);
|
|
programJson.put("unit_id", unitId);
|
|
- programJson.put("package_name", "程序化创意"+creativeCnt);
|
|
|
|
|
|
+ programJson.put("package_name", "程序化创意" + creativeCnt);
|
|
JSONArray horizontalPhotoIds = new JSONArray();
|
|
JSONArray horizontalPhotoIds = new JSONArray();
|
|
JSONArray verticalPhotoIds = new JSONArray();
|
|
JSONArray verticalPhotoIds = new JSONArray();
|
|
JSONArray coverImageTokens = new JSONArray();
|
|
JSONArray coverImageTokens = new JSONArray();
|
|
- for(KuaiShouVideoGet videoGet:list){
|
|
|
|
|
|
+ for (KuaiShouVideoGet videoGet : list) {
|
|
List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoGet.getSignature());
|
|
List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoGet.getSignature());
|
|
- if (null!=cutFrameList&&!cutFrameList.isEmpty()){
|
|
|
|
|
|
+ if (null != cutFrameList && !cutFrameList.isEmpty()) {
|
|
MaterialCutFrame cutFrame = cutFrameList.get(0);
|
|
MaterialCutFrame cutFrame = cutFrameList.get(0);
|
|
- String imageToken = getImageToken(cutFrame.getUrl(),cutFrame.getSignature(), token.getAccountId(), token.getAccessToken());
|
|
|
|
|
|
+ String imageToken = getImageToken(cutFrame.getUrl(), cutFrame.getSignature(), token.getAccountId(), token.getAccessToken());
|
|
if (!Check.isNull(imageToken)) {
|
|
if (!Check.isNull(imageToken)) {
|
|
coverImageTokens.add(imageToken);
|
|
coverImageTokens.add(imageToken);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(videoGet.getMaterialType() == 2){
|
|
|
|
|
|
+ if (videoGet.getMaterialType() == 2) {
|
|
horizontalPhotoIds.add(videoGet.getPhotoId());
|
|
horizontalPhotoIds.add(videoGet.getPhotoId());
|
|
}
|
|
}
|
|
- if(videoGet.getMaterialType() == 1){
|
|
|
|
|
|
+ if (videoGet.getMaterialType() == 1) {
|
|
verticalPhotoIds.add(videoGet.getPhotoId());
|
|
verticalPhotoIds.add(videoGet.getPhotoId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!horizontalPhotoIds.isEmpty()){
|
|
|
|
|
|
+ if (!horizontalPhotoIds.isEmpty()) {
|
|
programJson.put("horizontal_photo_ids", horizontalPhotoIds);
|
|
programJson.put("horizontal_photo_ids", horizontalPhotoIds);
|
|
}
|
|
}
|
|
- if(!verticalPhotoIds.isEmpty()){
|
|
|
|
|
|
+ if (!verticalPhotoIds.isEmpty()) {
|
|
programJson.put("vertical_photo_ids", verticalPhotoIds);
|
|
programJson.put("vertical_photo_ids", verticalPhotoIds);
|
|
}
|
|
}
|
|
- if(coverImageTokens.size()>=5){
|
|
|
|
|
|
+ if (coverImageTokens.size() >= 5) {
|
|
coverImageTokens.remove(0);
|
|
coverImageTokens.remove(0);
|
|
}
|
|
}
|
|
if (!Check.isNull(strategy.getSiteId())) {
|
|
if (!Check.isNull(strategy.getSiteId())) {
|
|
@@ -385,41 +404,74 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
return programJson;
|
|
return programJson;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy,String startTime,String endTime,AiKuaiShouAppInfo appInfo) {
|
|
|
|
- List<KuaiShouVideoGet> generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(),startTime,endTime,strategy.getChannelType(),null,null);
|
|
|
|
|
|
+ private List<KuaiShouVideoGet> getNewVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
|
|
|
|
+ List<KuaiShouVideoGet> generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), null, null);
|
|
//2:查询特定素材
|
|
//2:查询特定素材
|
|
- List<KuaiShouVideoGet> customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(),startTime,endTime,strategy.getChannelType(),appInfo.getAppVersion(),null);
|
|
|
|
- if(null == generalVideos||generalVideos.isEmpty()||null == customVideos||customVideos.isEmpty()){
|
|
|
|
- log.info("账户:{},appId({}){}到{}这段时间没有上新素材",strategy.getAccountId(),appInfo.getAppId(),startTime, endTime);
|
|
|
|
|
|
+ List<KuaiShouVideoGet> customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
|
|
|
|
+ if (null == generalVideos || generalVideos.isEmpty() || null == customVideos || customVideos.isEmpty()) {
|
|
|
|
+ log.info("账户:{},appId({}){}到{}这段时间没有上新素材", strategy.getAccountId(), appInfo.getAppId(), startTime, endTime);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
-
|
|
|
|
//合并
|
|
//合并
|
|
- if(null == generalVideos||generalVideos.isEmpty()){
|
|
|
|
|
|
+ if (null == generalVideos || generalVideos.isEmpty()) {
|
|
return customVideos;
|
|
return customVideos;
|
|
- }else if(null == customVideos||customVideos.isEmpty()){
|
|
|
|
|
|
+ } else if (null == customVideos || customVideos.isEmpty()) {
|
|
return generalVideos;
|
|
return generalVideos;
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
generalVideos.addAll(customVideos);
|
|
generalVideos.addAll(customVideos);
|
|
return generalVideos;
|
|
return generalVideos;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy,CtopOauthToken token,String replaceString,String checkType) {
|
|
|
|
|
|
+ private List<KuaiShouVideoGet> getRelateZeroVideoList(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
|
|
|
|
+ Integer channelType = null;
|
|
|
|
+ if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
|
|
+ channelType = strategy.getChannelType();
|
|
|
|
+ }
|
|
|
|
+ return videoGetService.getZeroVideoByParams(strategy.getAccountId(), startTime, endTime, 100, appInfo.getAppVersion(), channelType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<KuaiShouVideoGet> getHistoryTopVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
|
|
|
|
+ Integer channelType = null;
|
|
|
|
+ if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
|
|
+ channelType = strategy.getChannelType();
|
|
|
|
+ }
|
|
|
|
+ return videoGetService.getHistoryTopVideoByParams(strategy.getAccountId(), startTime, endTime, 100, appInfo.getAppVersion(), channelType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 创建自定义创意
|
|
|
|
+ *
|
|
|
|
+ * @param strategy 账户配置信息
|
|
|
|
+ * @param createType 创意创建类型 1:素材上新 2:历史高质量 3:历史遗漏素材
|
|
|
|
+ * @param startTime 开始时间
|
|
|
|
+ * @param endTime 结束时间
|
|
|
|
+ */
|
|
|
|
+ private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer createType) {
|
|
|
|
+ if (createType == 1) {
|
|
|
|
+ return getNewVideoListByParams(strategy, startTime, endTime, appInfo);
|
|
|
|
+ } else if (createType == 2) {
|
|
|
|
+ return getHistoryTopVideoListByParams(strategy, startTime, endTime, appInfo);
|
|
|
|
+ } else {
|
|
|
|
+ return getRelateZeroVideoList(strategy, startTime, endTime, appInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType) {
|
|
JSONArray campaignList = null;
|
|
JSONArray campaignList = null;
|
|
Date campaignDate = new Date();
|
|
Date campaignDate = new Date();
|
|
String timestamp = "";
|
|
String timestamp = "";
|
|
- if(null!=checkType&&checkType.equals("ALL_CAMPAIGN")){
|
|
|
|
- campaignList = kuaishouInterfaceService.getCampaignList(token, null, null,1);
|
|
|
|
- }else{
|
|
|
|
- timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
|
|
|
|
- campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(),1);
|
|
|
|
|
|
+ if (null != checkType && checkType.equals("ALL_CAMPAIGN")) {
|
|
|
|
+ campaignList = kuaishouInterfaceService.getCampaignList(token, null, null, 1);
|
|
|
|
+ } else {
|
|
|
|
+ timestamp = DateUtils.formatDate(campaignDate, "yyyyMMddHHmmss");
|
|
|
|
+ campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(), 1);
|
|
}
|
|
}
|
|
Long newCampaignId = 0L;
|
|
Long newCampaignId = 0L;
|
|
- if (null!=campaignList&&campaignList.size()>0){
|
|
|
|
- for(int i = 0;i<campaignList.size();i++){
|
|
|
|
|
|
+ if (null != campaignList && campaignList.size() > 0) {
|
|
|
|
+ for (int i = 0; i < campaignList.size(); i++) {
|
|
JSONObject jsonObject = campaignList.getJSONObject(i);
|
|
JSONObject jsonObject = campaignList.getJSONObject(i);
|
|
- if (jsonObject.getString("campaign_name").contains(replaceString)){
|
|
|
|
|
|
+ if (jsonObject.getString("campaign_name").contains(replaceString)) {
|
|
newCampaignId = jsonObject.getLong("campaign_id");
|
|
newCampaignId = jsonObject.getLong("campaign_id");
|
|
return newCampaignId;
|
|
return newCampaignId;
|
|
}
|
|
}
|
|
@@ -427,18 +479,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
// 不存在“上新”计划,则创建一个计划
|
|
// 不存在“上新”计划,则创建一个计划
|
|
JSONObject campaignParams = new JSONObject();
|
|
JSONObject campaignParams = new JSONObject();
|
|
- campaignParams.put("advertiser_id",token.getAccountId());
|
|
|
|
- String campaignName = strategy.getCampaignName().replace("自定义",replaceString)+timestamp;
|
|
|
|
- campaignParams.put("campaign_name",campaignName);
|
|
|
|
- campaignParams.put("type",strategy.getCampaignType());
|
|
|
|
|
|
+ campaignParams.put("advertiser_id", token.getAccountId());
|
|
|
|
+ String campaignName = strategy.getCampaignName().replace("自定义", replaceString) + timestamp;
|
|
|
|
+ campaignParams.put("campaign_name", campaignName);
|
|
|
|
+ campaignParams.put("type", strategy.getCampaignType());
|
|
//TODO 目前设定为不限
|
|
//TODO 目前设定为不限
|
|
- campaignParams.put("day_budget",0L);
|
|
|
|
|
|
+ campaignParams.put("day_budget", 0L);
|
|
Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
|
|
Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
|
|
Integer code = (Integer) campaignCreateResult.get("code");
|
|
Integer code = (Integer) campaignCreateResult.get("code");
|
|
String message = (String) campaignCreateResult.get("message");
|
|
String message = (String) campaignCreateResult.get("message");
|
|
- if(code != 0 ){
|
|
|
|
|
|
+ if (code != 0) {
|
|
//TODO 写入日志信息表
|
|
//TODO 写入日志信息表
|
|
- log.info("计划创建失败=>message:{}",message);
|
|
|
|
|
|
+ log.info("计划创建失败=>message:{}", message);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
newCampaignId = (Long) campaignCreateResult.get("campaignId");
|
|
newCampaignId = (Long) campaignCreateResult.get("campaignId");
|
|
@@ -446,39 +498,39 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, AiKuaishouAdvertiserStrategy strategy,
|
|
|
|
- String unitName,Long appId) {
|
|
|
|
|
|
+ private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, AiKuaishouAdvertiserStrategy strategy,
|
|
|
|
+ String unitName, Long appId) {
|
|
// 拼装创建组的入参 json
|
|
// 拼装创建组的入参 json
|
|
JSONObject unitParams = new JSONObject();
|
|
JSONObject unitParams = new JSONObject();
|
|
Integer unitType = strategy.getUnitType();
|
|
Integer unitType = strategy.getUnitType();
|
|
//创意制作方式
|
|
//创意制作方式
|
|
- unitParams.put("unit_type",unitType);
|
|
|
|
- unitParams.put("advertiser_id",token.getAccountId());
|
|
|
|
- unitParams.put("campaign_id",campaignId);
|
|
|
|
|
|
+ unitParams.put("unit_type", unitType);
|
|
|
|
+ unitParams.put("advertiser_id", token.getAccountId());
|
|
|
|
+ unitParams.put("campaign_id", campaignId);
|
|
unitParams.put("unit_name", unitName);
|
|
unitParams.put("unit_name", unitName);
|
|
//出价类型
|
|
//出价类型
|
|
- unitParams.put("bid_type",strategy.getBidType());
|
|
|
|
|
|
+ unitParams.put("bid_type", strategy.getBidType());
|
|
// 优先从系统应用商店下载
|
|
// 优先从系统应用商店下载
|
|
- if(null!=strategy.getUseAppMarket()){
|
|
|
|
- unitParams.put("use_app_market",strategy.getUseAppMarket());
|
|
|
|
|
|
+ if (null != strategy.getUseAppMarket()) {
|
|
|
|
+ unitParams.put("use_app_market", strategy.getUseAppMarket());
|
|
}
|
|
}
|
|
//应用商店列表
|
|
//应用商店列表
|
|
- if(null!=strategy.getAppStore()&&!"".equals(strategy.getAppStore())){
|
|
|
|
- unitParams.put("app_store",JSONArray.parseArray(strategy.getAppStore()));
|
|
|
|
|
|
+ if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
|
|
|
|
+ unitParams.put("app_store", JSONArray.parseArray(strategy.getAppStore()));
|
|
}
|
|
}
|
|
- unitParams.put("ocpx_action_type",strategy.getOcpxActionType());
|
|
|
|
|
|
+ unitParams.put("ocpx_action_type", strategy.getOcpxActionType());
|
|
|
|
|
|
|
|
|
|
// 在本策略中,都是 OCPM 的出价方式
|
|
// 在本策略中,都是 OCPM 的出价方式
|
|
//出价
|
|
//出价
|
|
- if (null!=strategy.getBid()&&strategy.getBid()!=0) {
|
|
|
|
|
|
+ if (null != strategy.getBid() && strategy.getBid() != 0) {
|
|
unitParams.put("bid", strategy.getBid());
|
|
unitParams.put("bid", strategy.getBid());
|
|
}
|
|
}
|
|
- if (null!=strategy.getCpaBid()&&strategy.getCpaBid()!=0) {
|
|
|
|
|
|
+ if (null != strategy.getCpaBid() && strategy.getCpaBid() != 0) {
|
|
unitParams.put("cpa_bid", strategy.getCpaBid());
|
|
unitParams.put("cpa_bid", strategy.getCpaBid());
|
|
}
|
|
}
|
|
//优先低成本
|
|
//优先低成本
|
|
- if (null!=strategy.getSmartBid()&&strategy.getSmartBid()!=0) {
|
|
|
|
|
|
+ if (null != strategy.getSmartBid() && strategy.getSmartBid() != 0) {
|
|
unitParams.put("smart_bid", strategy.getSmartBid());
|
|
unitParams.put("smart_bid", strategy.getSmartBid());
|
|
}
|
|
}
|
|
//优化目标
|
|
//优化目标
|
|
@@ -500,7 +552,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
//资源位置
|
|
//资源位置
|
|
Integer sceneId = null;
|
|
Integer sceneId = null;
|
|
String scenceIdString = strategy.getSceneId();
|
|
String scenceIdString = strategy.getSceneId();
|
|
- if (null!=scenceIdString&&!scenceIdString.trim().equals(scenceIdString)&&Check.isNull(JSONArray.parseArray(scenceIdString))) {
|
|
|
|
|
|
+ if (null != scenceIdString && !scenceIdString.trim().equals(scenceIdString) && Check.isNull(JSONArray.parseArray(scenceIdString))) {
|
|
sceneId = JSONArray.parseArray(strategy.getSceneId()).getInteger(0);
|
|
sceneId = JSONArray.parseArray(strategy.getSceneId()).getInteger(0);
|
|
unitParams.put("scene_id", JSONArray.parseArray(strategy.getSceneId()));
|
|
unitParams.put("scene_id", JSONArray.parseArray(strategy.getSceneId()));
|
|
}
|
|
}
|
|
@@ -601,77 +653,76 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if (sceneId != 5) {
|
|
if (sceneId != 5) {
|
|
unitParams.put("template_id", strategy.getTemplateId()); //定向模板id
|
|
unitParams.put("template_id", strategy.getTemplateId()); //定向模板id
|
|
} else { // 联盟广告位 需要根据模板id 获取定向数据
|
|
} else { // 联盟广告位 需要根据模板id 获取定向数据
|
|
- JSONObject unionJson = groupTemplateService.getUnionJson(Long.parseLong(strategy.getTemplateId()+""));
|
|
|
|
|
|
+ JSONObject unionJson = groupTemplateService.getUnionJson(Long.parseLong(strategy.getTemplateId() + ""));
|
|
Integer code = unionJson.getInteger("code");
|
|
Integer code = unionJson.getInteger("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
JSONObject target = unionJson.getJSONObject("target");
|
|
JSONObject target = unionJson.getJSONObject("target");
|
|
unitParams.put("target", target);
|
|
unitParams.put("target", target);
|
|
} else {
|
|
} else {
|
|
- log.info("组创建异常=》accountId({})联盟广告位定向模板错误",strategy.getAccountId());
|
|
|
|
|
|
+ log.info("组创建异常=》accountId({})联盟广告位定向模板错误", strategy.getAccountId());
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- JSONObject target = getTarget(sceneId,strategy);
|
|
|
|
|
|
+ JSONObject target = getTarget(sceneId, strategy);
|
|
// 定向数据
|
|
// 定向数据
|
|
unitParams.put("target", target);
|
|
unitParams.put("target", target);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
// 设置定向内容
|
|
// 设置定向内容
|
|
JSONObject targetJsonObject = new JSONObject();
|
|
JSONObject targetJsonObject = new JSONObject();
|
|
- if(null!=strategy.getRegion()&&!"".equals(strategy.getRegion())){
|
|
|
|
- targetJsonObject.put("region",JSONArray.parseArray(strategy.getRegion()));
|
|
|
|
|
|
+ if (null != strategy.getRegion() && !"".equals(strategy.getRegion())) {
|
|
|
|
+ targetJsonObject.put("region", JSONArray.parseArray(strategy.getRegion()));
|
|
}
|
|
}
|
|
- if(null!=strategy.getAgesRange()&&!"".equals(strategy.getAgesRange())){
|
|
|
|
- targetJsonObject.put("ages_range",JSONArray.parseArray(strategy.getAgesRange()));
|
|
|
|
|
|
+ if (null != strategy.getAgesRange() && !"".equals(strategy.getAgesRange())) {
|
|
|
|
+ targetJsonObject.put("ages_range", JSONArray.parseArray(strategy.getAgesRange()));
|
|
}
|
|
}
|
|
- if(null!=strategy.getGender()){
|
|
|
|
- targetJsonObject.put("gender",strategy.getGender());
|
|
|
|
|
|
+ if (null != strategy.getGender()) {
|
|
|
|
+ targetJsonObject.put("gender", strategy.getGender());
|
|
}
|
|
}
|
|
- if(null!=strategy.getPlatformOs()){
|
|
|
|
- targetJsonObject.put("platform_os",strategy.getPlatformOs());
|
|
|
|
|
|
+ if (null != strategy.getPlatformOs()) {
|
|
|
|
+ targetJsonObject.put("platform_os", strategy.getPlatformOs());
|
|
}
|
|
}
|
|
- if(null!=strategy.getAndroidOsv()){
|
|
|
|
- targetJsonObject.put("android_osv",strategy.getAndroidOsv());
|
|
|
|
|
|
+ if (null != strategy.getAndroidOsv()) {
|
|
|
|
+ targetJsonObject.put("android_osv", strategy.getAndroidOsv());
|
|
}
|
|
}
|
|
- if(null!=strategy.getIosOsv()){
|
|
|
|
- targetJsonObject.put("ios_osv",strategy.getIosOsv());
|
|
|
|
|
|
+ if (null != strategy.getIosOsv()) {
|
|
|
|
+ targetJsonObject.put("ios_osv", strategy.getIosOsv());
|
|
}
|
|
}
|
|
- if(null!=strategy.getDeviceBrand()&&!"".equals(strategy.getDeviceBrand())&&!"[]".equals(strategy.getDeviceBrand())){
|
|
|
|
- targetJsonObject.put("device_brand",JSONArray.parseArray(strategy.getDeviceBrand()));
|
|
|
|
|
|
+ if (null != strategy.getDeviceBrand() && !"".equals(strategy.getDeviceBrand()) && !"[]".equals(strategy.getDeviceBrand())) {
|
|
|
|
+ targetJsonObject.put("device_brand", JSONArray.parseArray(strategy.getDeviceBrand()));
|
|
}
|
|
}
|
|
- if(null!=strategy.getDevicePrice()&&!"".equals(strategy.getDevicePrice())&&!"[]".equals(strategy.getDevicePrice())){
|
|
|
|
- targetJsonObject.put("device_price",JSONArray.parseArray(strategy.getDevicePrice()));
|
|
|
|
|
|
+ if (null != strategy.getDevicePrice() && !"".equals(strategy.getDevicePrice()) && !"[]".equals(strategy.getDevicePrice())) {
|
|
|
|
+ targetJsonObject.put("device_price", JSONArray.parseArray(strategy.getDevicePrice()));
|
|
}
|
|
}
|
|
- if(null!=strategy.getPopulation()&&!"".equals(strategy.getPopulation())){
|
|
|
|
|
|
+ if (null != strategy.getPopulation() && !"".equals(strategy.getPopulation())) {
|
|
JSONArray population = JSONArray.parseArray(strategy.getPopulation());
|
|
JSONArray population = JSONArray.parseArray(strategy.getPopulation());
|
|
- targetJsonObject.put("population",population);
|
|
|
|
|
|
+ targetJsonObject.put("population", population);
|
|
}
|
|
}
|
|
- if(null!=strategy.getFilterConvertedLevel()&&strategy.getFilterConvertedLevel()!=0){
|
|
|
|
- targetJsonObject.put("filter_converted_level",strategy.getFilterConvertedLevel());
|
|
|
|
|
|
+ if (null != strategy.getFilterConvertedLevel() && strategy.getFilterConvertedLevel() != 0) {
|
|
|
|
+ targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
|
|
}
|
|
}
|
|
- if(null!=strategy.getExcludePopulation()&&!"".equals(strategy.getExcludePopulation())){
|
|
|
|
|
|
+ if (null != strategy.getExcludePopulation() && !"".equals(strategy.getExcludePopulation())) {
|
|
JSONArray excludePopulation = JSONArray.parseArray(strategy.getExcludePopulation());
|
|
JSONArray excludePopulation = JSONArray.parseArray(strategy.getExcludePopulation());
|
|
- targetJsonObject.put("exclude_population",excludePopulation);
|
|
|
|
|
|
+ targetJsonObject.put("exclude_population", excludePopulation);
|
|
}
|
|
}
|
|
//是否开启智能扩量
|
|
//是否开启智能扩量
|
|
- if(null!=strategy.getIsOpen()&&strategy.getIsOpen().equals(1)){
|
|
|
|
|
|
+ if (null != strategy.getIsOpen() && strategy.getIsOpen().equals(1)) {
|
|
JSONObject intelliExtend = new JSONObject();
|
|
JSONObject intelliExtend = new JSONObject();
|
|
- intelliExtend.put("is_open",1);
|
|
|
|
- if(null!=strategy.getNoAgeBreak()&&strategy.getNoAgeBreak().equals(1)){
|
|
|
|
- intelliExtend.put("no_age_break",1);
|
|
|
|
|
|
+ intelliExtend.put("is_open", 1);
|
|
|
|
+ if (null != strategy.getNoAgeBreak() && strategy.getNoAgeBreak().equals(1)) {
|
|
|
|
+ intelliExtend.put("no_age_break", 1);
|
|
}
|
|
}
|
|
- if(null!=strategy.getNoGenderBreak()&&strategy.getNoGenderBreak().equals(1)){
|
|
|
|
- intelliExtend.put("no_gender_break",1);
|
|
|
|
|
|
+ if (null != strategy.getNoGenderBreak() && strategy.getNoGenderBreak().equals(1)) {
|
|
|
|
+ intelliExtend.put("no_gender_break", 1);
|
|
}
|
|
}
|
|
- if(null!=strategy.getNoAreaBreak()&&strategy.getNoAreaBreak().equals(1)){
|
|
|
|
- intelliExtend.put("no_area_break",1);
|
|
|
|
|
|
+ if (null != strategy.getNoAreaBreak() && strategy.getNoAreaBreak().equals(1)) {
|
|
|
|
+ intelliExtend.put("no_area_break", 1);
|
|
}
|
|
}
|
|
- targetJsonObject.put("intelli_extend",intelliExtend);
|
|
|
|
|
|
+ targetJsonObject.put("intelli_extend", intelliExtend);
|
|
}
|
|
}
|
|
- unitParams.put("target",targetJsonObject);
|
|
|
|
|
|
+ unitParams.put("target", targetJsonObject);
|
|
return unitParams;
|
|
return unitParams;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -682,24 +733,24 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
* @param strategy
|
|
* @param strategy
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private JSONObject getTarget(Integer sceneId,AiKuaishouAdvertiserStrategy strategy) {
|
|
|
|
|
|
+ private JSONObject getTarget(Integer sceneId, AiKuaishouAdvertiserStrategy strategy) {
|
|
JSONObject target = new JSONObject();
|
|
JSONObject target = new JSONObject();
|
|
// 地域
|
|
// 地域
|
|
String regionString = strategy.getRegion();
|
|
String regionString = strategy.getRegion();
|
|
- if (null!=regionString&&!"".equals(regionString.trim())) {
|
|
|
|
|
|
+ if (null != regionString && !"".equals(regionString.trim())) {
|
|
target.put("region", JSONArray.parseArray(regionString));
|
|
target.put("region", JSONArray.parseArray(regionString));
|
|
}
|
|
}
|
|
String districtIdString = strategy.getDistrictIds();
|
|
String districtIdString = strategy.getDistrictIds();
|
|
// 商圈定向
|
|
// 商圈定向
|
|
- if (null!=districtIdString&&!"".equals(districtIdString.trim())) {
|
|
|
|
|
|
+ if (null != districtIdString && !"".equals(districtIdString.trim())) {
|
|
target.put("district_ids", JSONArray.parseArray(districtIdString));
|
|
target.put("district_ids", JSONArray.parseArray(districtIdString));
|
|
}
|
|
}
|
|
// 用户类型
|
|
// 用户类型
|
|
- if (null!=strategy.getUserType()) {
|
|
|
|
|
|
+ if (null != strategy.getUserType()) {
|
|
target.put("user_type", strategy.getUserType());
|
|
target.put("user_type", strategy.getUserType());
|
|
}
|
|
}
|
|
//自定义年龄段
|
|
//自定义年龄段
|
|
- if (null!=strategy.getAgeMin() || null!=strategy.getAgeMax()) {
|
|
|
|
|
|
+ if (null != strategy.getAgeMin() || null != strategy.getAgeMax()) {
|
|
JSONObject age = new JSONObject();
|
|
JSONObject age = new JSONObject();
|
|
age.put("min", strategy.getAgeMin());
|
|
age.put("min", strategy.getAgeMin());
|
|
age.put("max", strategy.getAgeMax());
|
|
age.put("max", strategy.getAgeMax());
|
|
@@ -707,66 +758,66 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
// 固定年龄段
|
|
// 固定年龄段
|
|
String ageRangeString = strategy.getAgesRange();
|
|
String ageRangeString = strategy.getAgesRange();
|
|
- if (null!=ageRangeString&&!"".equals(ageRangeString.trim())) {
|
|
|
|
|
|
+ if (null != ageRangeString && !"".equals(ageRangeString.trim())) {
|
|
target.put("ages_range", JSONArray.parseArray(ageRangeString));
|
|
target.put("ages_range", JSONArray.parseArray(ageRangeString));
|
|
}
|
|
}
|
|
// 性别
|
|
// 性别
|
|
- if (null!=strategy.getGender()) {
|
|
|
|
|
|
+ if (null != strategy.getGender()) {
|
|
target.put("gender", strategy.getGender());
|
|
target.put("gender", strategy.getGender());
|
|
}
|
|
}
|
|
// 操作系统
|
|
// 操作系统
|
|
- if (null!=strategy.getPlatformOs()) {
|
|
|
|
|
|
+ if (null != strategy.getPlatformOs()) {
|
|
target.put("platform_os", strategy.getPlatformOs());
|
|
target.put("platform_os", strategy.getPlatformOs());
|
|
}
|
|
}
|
|
// Android版本
|
|
// Android版本
|
|
- if (null!=strategy.getAndroidOsv()) {
|
|
|
|
|
|
+ if (null != strategy.getAndroidOsv()) {
|
|
target.put("android_osv", strategy.getAndroidOsv());
|
|
target.put("android_osv", strategy.getAndroidOsv());
|
|
}
|
|
}
|
|
// Android版本
|
|
// Android版本
|
|
- if (null!=strategy.getIosOsv()) {
|
|
|
|
|
|
+ if (null != strategy.getIosOsv()) {
|
|
target.put("ios_osv", strategy.getIosOsv());
|
|
target.put("ios_osv", strategy.getIosOsv());
|
|
}
|
|
}
|
|
// 网络环境
|
|
// 网络环境
|
|
- if (null!=strategy.getNetwork()) {
|
|
|
|
- target.put("network",strategy.getNetwork());
|
|
|
|
|
|
+ if (null != strategy.getNetwork()) {
|
|
|
|
+ target.put("network", strategy.getNetwork());
|
|
}
|
|
}
|
|
// 设备品牌
|
|
// 设备品牌
|
|
String deviceBrandString = strategy.getDeviceBrand();
|
|
String deviceBrandString = strategy.getDeviceBrand();
|
|
- if (null != deviceBrandString&&!"".equals(deviceBrandString.trim())) {
|
|
|
|
|
|
+ if (null != deviceBrandString && !"".equals(deviceBrandString.trim())) {
|
|
target.put("device_brand", JSONArray.parseArray(deviceBrandString));
|
|
target.put("device_brand", JSONArray.parseArray(deviceBrandString));
|
|
}
|
|
}
|
|
// 设备价格
|
|
// 设备价格
|
|
String devicePriceString = strategy.getDevicePrice();
|
|
String devicePriceString = strategy.getDevicePrice();
|
|
- if (null != devicePriceString&&!"".equals(devicePriceString.trim())) {
|
|
|
|
|
|
+ if (null != devicePriceString && !"".equals(devicePriceString.trim())) {
|
|
target.put("device_price", JSONArray.parseArray(devicePriceString));
|
|
target.put("device_price", JSONArray.parseArray(devicePriceString));
|
|
}
|
|
}
|
|
if (sceneId != 5) {
|
|
if (sceneId != 5) {
|
|
// 商业兴趣类型
|
|
// 商业兴趣类型
|
|
- if (null!=strategy.getBusinessInterestType()) {
|
|
|
|
|
|
+ if (null != strategy.getBusinessInterestType()) {
|
|
target.put("business_interest_type", strategy.getBusinessInterestType());
|
|
target.put("business_interest_type", strategy.getBusinessInterestType());
|
|
}
|
|
}
|
|
// 商业兴趣
|
|
// 商业兴趣
|
|
String businessInterestString = strategy.getBusinessInterest();
|
|
String businessInterestString = strategy.getBusinessInterest();
|
|
- if (null != businessInterestString&&!"".equals(businessInterestString.trim())) {
|
|
|
|
|
|
+ if (null != businessInterestString && !"".equals(businessInterestString.trim())) {
|
|
target.put("business_interest", JSONArray.parseArray(businessInterestString));
|
|
target.put("business_interest", JSONArray.parseArray(businessInterestString));
|
|
}
|
|
}
|
|
// 网红粉丝
|
|
// 网红粉丝
|
|
String fansStarString = strategy.getFansStar();
|
|
String fansStarString = strategy.getFansStar();
|
|
- if (null != fansStarString&&!"".equals(fansStarString.trim())) {
|
|
|
|
|
|
+ if (null != fansStarString && !"".equals(fansStarString.trim())) {
|
|
target.put("fans_star", JSONArray.parseArray(fansStarString));
|
|
target.put("fans_star", JSONArray.parseArray(fansStarString));
|
|
}
|
|
}
|
|
// 兴趣视频用户
|
|
// 兴趣视频用户
|
|
String interestVideoString = strategy.getInterestVideo();
|
|
String interestVideoString = strategy.getInterestVideo();
|
|
- if (null != interestVideoString&&!"".equals(interestVideoString.trim())) {
|
|
|
|
|
|
+ if (null != interestVideoString && !"".equals(interestVideoString.trim())) {
|
|
target.put("interest_video", JSONArray.parseArray(interestVideoString));
|
|
target.put("interest_video", JSONArray.parseArray(interestVideoString));
|
|
}
|
|
}
|
|
// 过滤已转化人群
|
|
// 过滤已转化人群
|
|
- if (null!=strategy.getFilterConvertedLevel()) {
|
|
|
|
|
|
+ if (null != strategy.getFilterConvertedLevel()) {
|
|
target.put("filter_converted_level", strategy.getFilterConvertedLevel());
|
|
target.put("filter_converted_level", strategy.getFilterConvertedLevel());
|
|
}
|
|
}
|
|
|
|
|
|
// 开启智能扩量
|
|
// 开启智能扩量
|
|
- if (null!=strategy.getIsOpen()&&strategy.getIsOpen() == 1) {
|
|
|
|
|
|
+ if (null != strategy.getIsOpen() && strategy.getIsOpen() == 1) {
|
|
JSONObject intelli_extend = new JSONObject();
|
|
JSONObject intelli_extend = new JSONObject();
|
|
intelli_extend.put("is_open", strategy.getIsOpen());
|
|
intelli_extend.put("is_open", strategy.getIsOpen());
|
|
// 不可突破年龄
|
|
// 不可突破年龄
|
|
@@ -787,31 +838,31 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
// APP行为-按分类
|
|
// APP行为-按分类
|
|
String appInterestString = strategy.getAppInterest();
|
|
String appInterestString = strategy.getAppInterest();
|
|
- if (null != appInterestString&&!"".equals(appInterestString.trim())) {
|
|
|
|
|
|
+ if (null != appInterestString && !"".equals(appInterestString.trim())) {
|
|
target.put("app_interest", JSONArray.parseArray(appInterestString));
|
|
target.put("app_interest", JSONArray.parseArray(appInterestString));
|
|
}
|
|
}
|
|
// APP行为-按APP名称
|
|
// APP行为-按APP名称
|
|
String appIdsString = strategy.getAppIds();
|
|
String appIdsString = strategy.getAppIds();
|
|
- if (null != appIdsString&&!"".equals(appIdsString.trim())) {
|
|
|
|
|
|
+ if (null != appIdsString && !"".equals(appIdsString.trim())) {
|
|
target.put("app_ids", JSONArray.parseArray(appIdsString));
|
|
target.put("app_ids", JSONArray.parseArray(appIdsString));
|
|
}
|
|
}
|
|
|
|
|
|
// 人群包定向
|
|
// 人群包定向
|
|
String populationString = strategy.getPopulation();
|
|
String populationString = strategy.getPopulation();
|
|
- if (null != populationString&&!"".equals(populationString.trim())) {
|
|
|
|
|
|
+ if (null != populationString && !"".equals(populationString.trim())) {
|
|
target.put("population", JSONArray.parseArray(populationString));
|
|
target.put("population", JSONArray.parseArray(populationString));
|
|
}
|
|
}
|
|
// 人群包排除
|
|
// 人群包排除
|
|
String excludePopulationString = strategy.getExcludePopulation();
|
|
String excludePopulationString = strategy.getExcludePopulation();
|
|
- if (null != excludePopulationString&&!"".equals(excludePopulationString.trim())) {
|
|
|
|
|
|
+ if (null != excludePopulationString && !"".equals(excludePopulationString.trim())) {
|
|
target.put("exclude_population", JSONArray.parseArray(excludePopulationString));
|
|
target.put("exclude_population", JSONArray.parseArray(excludePopulationString));
|
|
}
|
|
}
|
|
// 付费人群包id
|
|
// 付费人群包id
|
|
String paidAudienceString = strategy.getPaidAudience();
|
|
String paidAudienceString = strategy.getPaidAudience();
|
|
- if (null != paidAudienceString&&!"".equals(paidAudienceString.trim())) {
|
|
|
|
|
|
+ if (null != paidAudienceString && !"".equals(paidAudienceString.trim())) {
|
|
target.put("paid_audience", JSONArray.parseArray(paidAudienceString));
|
|
target.put("paid_audience", JSONArray.parseArray(paidAudienceString));
|
|
}
|
|
}
|
|
- if (Check.isNull(strategy.getBehaviorInterest())){
|
|
|
|
|
|
+ if (Check.isNull(strategy.getBehaviorInterest())) {
|
|
// TODO 只是单独结构体 后续需要优化
|
|
// TODO 只是单独结构体 后续需要优化
|
|
target.put("behavior_interest", JSONObject.parseObject(strategy.getBehaviorInterest()));
|
|
target.put("behavior_interest", JSONObject.parseObject(strategy.getBehaviorInterest()));
|
|
}
|
|
}
|
|
@@ -821,17 +872,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
private void createCreativeByImage(List<MaterialCutFrame> cutFrameList, CtopOauthToken token, JSONObject creativeParams,
|
|
private void createCreativeByImage(List<MaterialCutFrame> cutFrameList, CtopOauthToken token, JSONObject creativeParams,
|
|
Long campaignId, Long unitId, KuaiShouVideoGet videoItem,
|
|
Long campaignId, Long unitId, KuaiShouVideoGet videoItem,
|
|
- int imageNumber){
|
|
|
|
- int creativeCnt = 1;
|
|
|
|
|
|
+ int imageNumber) {
|
|
|
|
+ int creativeCnt = 1;
|
|
|
|
|
|
- if ((null!=cutFrameList&&!cutFrameList.isEmpty())){
|
|
|
|
|
|
+ if ((null != cutFrameList && !cutFrameList.isEmpty())) {
|
|
for (int i = 0; i < cutFrameList.size(); i++) {
|
|
for (int i = 0; i < cutFrameList.size(); i++) {
|
|
String imageCode = cutFrameList.get(i).getSignature();
|
|
String imageCode = cutFrameList.get(i).getSignature();
|
|
String imageUrl = cutFrameList.get(i).getUrl();
|
|
String imageUrl = cutFrameList.get(i).getUrl();
|
|
- String imageToken = getImageToken(imageUrl,imageCode,token.getAccountId(),token.getAccessToken());
|
|
|
|
- creativeParams.put("image_token",imageToken);
|
|
|
|
- createCreative(token, creativeParams, campaignId, unitId, creativeCnt,videoItem);
|
|
|
|
- creativeCnt ++;
|
|
|
|
|
|
+ String imageToken = getImageToken(imageUrl, imageCode, token.getAccountId(), token.getAccessToken());
|
|
|
|
+ creativeParams.put("image_token", imageToken);
|
|
|
|
+ createCreative(token, creativeParams, campaignId, unitId, creativeCnt, videoItem);
|
|
|
|
+ creativeCnt++;
|
|
if (creativeCnt > imageNumber) {
|
|
if (creativeCnt > imageNumber) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -839,25 +890,25 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private String getImageToken(String imageUrl, String imageCode, Long accountId,String token){
|
|
|
|
|
|
+ private String getImageToken(String imageUrl, String imageCode, Long accountId, String token) {
|
|
// 根据imageUrl 和 imageCode,获取 imageToken (创建创意用)
|
|
// 根据imageUrl 和 imageCode,获取 imageToken (创建创意用)
|
|
- KuaiShouImageGet imageGet = imageGetService.getOneByParams(null,imageCode);
|
|
|
|
- if ((null == imageGet) || ("".equals(imageGet.getImageToken()))){
|
|
|
|
|
|
+ KuaiShouImageGet imageGet = imageGetService.getOneByParams(null, imageCode);
|
|
|
|
+ if ((null == imageGet) || ("".equals(imageGet.getImageToken()))) {
|
|
// 如果取不到image_token
|
|
// 如果取不到image_token
|
|
// 则调用上传url的方法 kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
|
|
// 则调用上传url的方法 kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
|
|
- return materialUploadService.kuauiShouImageUpload(imageUrl,imageCode,accountId,token);
|
|
|
|
|
|
+ return materialUploadService.kuauiShouImageUpload(imageUrl, imageCode, accountId, token);
|
|
}
|
|
}
|
|
return imageGet.getImageToken();
|
|
return imageGet.getImageToken();
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject creativeParams(CtopOauthToken token,Long unitId,KuaiShouVideoGet videoItem,AiKuaishouAdvertiserStrategy strategy){
|
|
|
|
|
|
+ private JSONObject creativeParams(CtopOauthToken token, Long unitId, KuaiShouVideoGet videoItem, AiKuaishouAdvertiserStrategy strategy) {
|
|
JSONObject creativeParams = new JSONObject();
|
|
JSONObject creativeParams = new JSONObject();
|
|
- creativeParams.put("advertiser_id",token.getAccountId());
|
|
|
|
- creativeParams.put("unit_id",unitId);
|
|
|
|
- creativeParams.put("photo_id",videoItem.getPhotoId());
|
|
|
|
- creativeParams.put("creative_material_type",videoItem.getMaterialType());
|
|
|
|
- creativeParams.put("action_bar_text",strategy.getActionBarText());
|
|
|
|
- creativeParams.put("description",strategy.getDescription());
|
|
|
|
|
|
+ creativeParams.put("advertiser_id", token.getAccountId());
|
|
|
|
+ creativeParams.put("unit_id", unitId);
|
|
|
|
+ creativeParams.put("photo_id", videoItem.getPhotoId());
|
|
|
|
+ creativeParams.put("creative_material_type", videoItem.getMaterialType());
|
|
|
|
+ creativeParams.put("action_bar_text", strategy.getActionBarText());
|
|
|
|
+ creativeParams.put("description", strategy.getDescription());
|
|
// 封面广告语标题
|
|
// 封面广告语标题
|
|
if (!Check.isNull(strategy.getStickerTitle())) {
|
|
if (!Check.isNull(strategy.getStickerTitle())) {
|
|
creativeParams.put("sticker_title", strategy.getStickerTitle());
|
|
creativeParams.put("sticker_title", strategy.getStickerTitle());
|
|
@@ -871,45 +922,45 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
creativeParams.put("expose_tag", strategy.getExposeTag());
|
|
creativeParams.put("expose_tag", strategy.getExposeTag());
|
|
}
|
|
}
|
|
// 广告标签2期
|
|
// 广告标签2期
|
|
- if (null!=strategy.getNewExposeTag()&&!"".equals(strategy.getNewExposeTag())) {
|
|
|
|
|
|
+ if (null != strategy.getNewExposeTag() && !"".equals(strategy.getNewExposeTag())) {
|
|
creativeParams.put("new_expose_tag", JSONArray.parseArray(strategy.getNewExposeTag()));
|
|
creativeParams.put("new_expose_tag", JSONArray.parseArray(strategy.getNewExposeTag()));
|
|
}
|
|
}
|
|
// 安卓下载中间页ID
|
|
// 安卓下载中间页ID
|
|
- if(null!=strategy.getSiteId()){
|
|
|
|
- creativeParams.put("site_id",strategy.getSiteId());
|
|
|
|
|
|
+ if (null != strategy.getSiteId()) {
|
|
|
|
+ creativeParams.put("site_id", strategy.getSiteId());
|
|
}
|
|
}
|
|
- if(null != strategy.getClickTrackUrl()&&!"".equals(strategy.getClickTrackUrl())){
|
|
|
|
- creativeParams.put("click_track_url",strategy.getClickTrackUrl());
|
|
|
|
|
|
+ if (null != strategy.getClickTrackUrl() && !"".equals(strategy.getClickTrackUrl())) {
|
|
|
|
+ creativeParams.put("click_track_url", strategy.getClickTrackUrl());
|
|
}
|
|
}
|
|
- if(null != strategy.getImpressionUrl()&&!"".equals(strategy.getImpressionUrl())){
|
|
|
|
- creativeParams.put("impression_url",strategy.getImpressionUrl());
|
|
|
|
|
|
+ if (null != strategy.getImpressionUrl() && !"".equals(strategy.getImpressionUrl())) {
|
|
|
|
+ creativeParams.put("impression_url", strategy.getImpressionUrl());
|
|
}
|
|
}
|
|
// 第三方有效播放监测链接
|
|
// 第三方有效播放监测链接
|
|
if (!Check.isNull(strategy.getAdPhotoPlayedT3sUrl())) {
|
|
if (!Check.isNull(strategy.getAdPhotoPlayedT3sUrl())) {
|
|
creativeParams.put("ad_photo_played_t3s_url", strategy.getAdPhotoPlayedT3sUrl());
|
|
creativeParams.put("ad_photo_played_t3s_url", strategy.getAdPhotoPlayedT3sUrl());
|
|
}
|
|
}
|
|
- if(null != strategy.getActionbarClickUrl()&&!"".equals(strategy.getActionbarClickUrl())){
|
|
|
|
- creativeParams.put("actionbar_click_url",strategy.getActionbarClickUrl());
|
|
|
|
|
|
+ if (null != strategy.getActionbarClickUrl() && !"".equals(strategy.getActionbarClickUrl())) {
|
|
|
|
+ creativeParams.put("actionbar_click_url", strategy.getActionbarClickUrl());
|
|
}
|
|
}
|
|
- if(null!=strategy.getCreativeCategory()){
|
|
|
|
- creativeParams.put("creative_category",strategy.getCreativeCategory());
|
|
|
|
|
|
+ if (null != strategy.getCreativeCategory()) {
|
|
|
|
+ creativeParams.put("creative_category", strategy.getCreativeCategory());
|
|
}
|
|
}
|
|
- if(null!=strategy.getCreativeTag()&&!"".equals(strategy.getCreativeTag())){
|
|
|
|
- creativeParams.put("creative_tag",JSONArray.parseArray(strategy.getCreativeTag()));
|
|
|
|
|
|
+ if (null != strategy.getCreativeTag() && !"".equals(strategy.getCreativeTag())) {
|
|
|
|
+ creativeParams.put("creative_tag", JSONArray.parseArray(strategy.getCreativeTag()));
|
|
}
|
|
}
|
|
return creativeParams;
|
|
return creativeParams;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private void createCreative(CtopOauthToken token,JSONObject creativeParams,Long campaignId,Long unitId,
|
|
|
|
- int creativeCnt,KuaiShouVideoGet videoGet){
|
|
|
|
- creativeParams.put("creative_name","自定义创意_"+creativeCnt);
|
|
|
|
|
|
+ private void createCreative(CtopOauthToken token, JSONObject creativeParams, Long campaignId, Long unitId,
|
|
|
|
+ int creativeCnt, KuaiShouVideoGet videoGet) {
|
|
|
|
+ creativeParams.put("creative_name", "自定义创意_" + creativeCnt);
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate
|
|
- (token.getAccessToken(), token.getAccountId(), creativeParams,1);
|
|
|
|
|
|
+ (token.getAccessToken(), token.getAccountId(), creativeParams, 1);
|
|
Integer creativeCode = (Integer) creativeCreateResult.get("code");
|
|
Integer creativeCode = (Integer) creativeCreateResult.get("code");
|
|
String creativeMessage = (String) creativeCreateResult.get("message");
|
|
String creativeMessage = (String) creativeCreateResult.get("message");
|
|
- if(creativeCode != 0 ){
|
|
|
|
- log.info("创意创建失败=>message:{}",creativeMessage);
|
|
|
|
|
|
+ if (creativeCode != 0) {
|
|
|
|
+ log.info("创意创建失败=>message:{}", creativeMessage);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
Long creativeId = (Long) creativeCreateResult.get("creativeId");
|
|
Long creativeId = (Long) creativeCreateResult.get("creativeId");
|