|
@@ -60,32 +60,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
@Autowired
|
|
@Autowired
|
|
private IAiKuaiShouAppInfoService appInfoService;
|
|
private IAiKuaiShouAppInfoService appInfoService;
|
|
|
|
|
|
- String getReplaceStringByCreateType(AiKuaishouAdvertiserStrategy strategy, Integer createType) {
|
|
|
|
- String replaceString ;
|
|
|
|
- if(strategy.getUnitType() == 7){
|
|
|
|
- if (createType == 2) {
|
|
|
|
- replaceString = "程序化高质量";
|
|
|
|
- } else if (createType == 3) {
|
|
|
|
- replaceString = "程序化上新";
|
|
|
|
- } else if(createType == 4){
|
|
|
|
- replaceString = "程序化历史";
|
|
|
|
- }else {
|
|
|
|
- replaceString= "程序化上新";
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- if (createType == 2) {
|
|
|
|
- replaceString = "自定义高质量";
|
|
|
|
- } else if (createType == 3) {
|
|
|
|
- replaceString = "自定义上新";
|
|
|
|
- } else if(createType == 4){
|
|
|
|
- replaceString = "自定义历史";
|
|
|
|
- }else{
|
|
|
|
- replaceString = "自定义上新";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return replaceString;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 创建自定义创意
|
|
* 创建自定义创意
|
|
*
|
|
*
|
|
@@ -96,7 +70,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
@Override
|
|
@Override
|
|
public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
|
|
public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
|
|
strategy.setUnitType(4);
|
|
strategy.setUnitType(4);
|
|
- 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) {
|
|
if (null == token) {
|
|
@@ -105,36 +78,21 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
//1:获取视频信息
|
|
//1:获取视频信息
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
- Integer timeStart;
|
|
|
|
- Integer timeEnd;
|
|
|
|
- if(createType == 1){
|
|
|
|
- timeStart = -10;
|
|
|
|
- timeEnd = -5;
|
|
|
|
- }else if(createType == 2){
|
|
|
|
- //历史高质量
|
|
|
|
- timeStart = -14*60*24;
|
|
|
|
- timeEnd = -1*60*24;
|
|
|
|
- }else if(createType == 3){
|
|
|
|
- //历史遗漏
|
|
|
|
- timeStart = -60*60*24;
|
|
|
|
- timeEnd = -1*60*24;
|
|
|
|
- }else{
|
|
|
|
- //历史打捞
|
|
|
|
- timeStart = -60*60*24;
|
|
|
|
- timeEnd = -1*60*24;
|
|
|
|
- }
|
|
|
|
|
|
+ Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
+ Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
Long now = System.currentTimeMillis();
|
|
Long now = System.currentTimeMillis();
|
|
- String startTime = DateUtils.formatDateTime(now+timeStart*60*1000L);
|
|
|
|
|
|
+ String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
|
|
String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
|
|
String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
|
|
|
|
|
|
//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 = JSON.parseArray(appidString);
|
|
JSONArray appIdArray = JSON.parseArray(appidString);
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
for (int i = 0; i < appIdArray.size(); i++) {
|
|
for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
|
|
AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
|
|
if (null == appInfo) {
|
|
if (null == appInfo) {
|
|
log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
@@ -151,11 +109,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
|
|
log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN");
|
|
|
|
-
|
|
|
|
- //开始创建组+创意
|
|
|
|
- String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- String unitNamePrefix = getUnitNamePrefix(strategy,replaceString,timestamp);
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo);
|
|
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()));
|
|
@@ -170,7 +124,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
unitCnt++;
|
|
unitCnt++;
|
|
- String unitName = unitNamePrefix + "-" + unitCnt;
|
|
|
|
|
|
+ //开始创建组+创意
|
|
|
|
+ String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
+ String unitName = getName(strategy.getGroupName(),strategy,createType,appInfo,timestamp,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");
|
|
@@ -191,19 +147,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//单一应用
|
|
//单一应用
|
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType,videoCnt);
|
|
List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType,videoCnt);
|
|
if (null == newVideos || newVideos.isEmpty()) {
|
|
if (null == newVideos || newVideos.isEmpty()) {
|
|
log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
|
|
log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY");
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null);
|
|
if (null == newCampaignId) {
|
|
if (null == newCampaignId) {
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
|
|
|
|
//3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
//3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
- String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- String unitNamePrefix = getUnitNamePrefix(strategy,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()));
|
|
@@ -217,7 +172,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
unitCnt++;
|
|
unitCnt++;
|
|
- String unitName = unitNamePrefix + "-" + unitCnt;
|
|
|
|
|
|
+ String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
+ String unitName = getName(strategy.getGroupName(),strategy,createType,null,timestamp,unitCnt);
|
|
Long appId = JSON.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
Long appId = JSON.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);
|
|
@@ -238,13 +194,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
- private String getUnitNamePrefix(AiKuaishouAdvertiserStrategy strategy,String replaceString,String timestamp){
|
|
|
|
- String unitNamePrefix = strategy.getGroupName();
|
|
|
|
- if(!unitNamePrefix.contains("自定义")){
|
|
|
|
- unitNamePrefix += "-自定义-";
|
|
|
|
- }
|
|
|
|
- return unitNamePrefix.replace("自定义", replaceString) + timestamp;
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建程序化创意
|
|
* 创建程序化创意
|
|
@@ -262,32 +211,16 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
//1:获取视频信息
|
|
//1:获取视频信息
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
- Integer timeStart;
|
|
|
|
- Integer timeEnd;
|
|
|
|
- if(createType == 1){
|
|
|
|
- timeStart = -10;
|
|
|
|
- timeEnd = -5;
|
|
|
|
- }else if(createType == 2){
|
|
|
|
- //历史高质量
|
|
|
|
- timeStart = -14*60*24;
|
|
|
|
- timeEnd = -1*60*24;
|
|
|
|
- }else if(createType == 3){
|
|
|
|
- //历史遗漏
|
|
|
|
- timeStart = -60*60*24;
|
|
|
|
- timeEnd = -1*60*24;
|
|
|
|
- }else{
|
|
|
|
- //历史打捞
|
|
|
|
- timeStart = -60*60*24;
|
|
|
|
- timeEnd = -1*60*24;
|
|
|
|
- }
|
|
|
|
|
|
+ Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
+ Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
Long now = System.currentTimeMillis();
|
|
Long now = System.currentTimeMillis();
|
|
- String startTime = DateUtils.formatDateTime(now+timeStart*60*1000L);
|
|
|
|
|
|
+ String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
|
|
String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
|
|
String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
|
|
|
|
|
|
//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 = JSON.parseArray(appidString);
|
|
JSONArray appIdArray = JSON.parseArray(appidString);
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
@@ -302,7 +235,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
}
|
|
}
|
|
- String replaceString = getReplaceStringByCreateType(strategy, createType);
|
|
|
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
replaceString = appInfo.getAppVersion() + replaceString;
|
|
replaceString = appInfo.getAppVersion() + replaceString;
|
|
//1:查询可用素材
|
|
//1:查询可用素材
|
|
List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType,videoCnt);
|
|
List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType,videoCnt);
|
|
@@ -315,15 +248,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN");
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo);
|
|
|
|
|
|
- //创意
|
|
|
|
|
|
+ //创建组+创意
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos,5);
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos,5);
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
//创建组
|
|
//创建组
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
- String unitNamePrefix = getUnitNamePrefix(strategy,replaceString,timestamp);
|
|
|
|
- String unitName = unitNamePrefix + "-" + timestamp;
|
|
|
|
|
|
+ String unitName = getName(strategy.getGroupName(),strategy,createType,appInfo,timestamp,null);
|
|
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");
|
|
@@ -339,14 +271,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- String replaceString = getReplaceStringByCreateType(strategy, createType);
|
|
|
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
//单一应用
|
|
//单一应用
|
|
List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType,videoCnt);
|
|
List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType,videoCnt);
|
|
if (null == allVideos) {
|
|
if (null == allVideos) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY");
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null);
|
|
if (null == newCampaignId) {
|
|
if (null == newCampaignId) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -356,8 +288,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
//创建组
|
|
//创建组
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
- String unitNamePrefix = getUnitNamePrefix(strategy,replaceString,timestamp);
|
|
|
|
- String unitName = unitNamePrefix + "-" + timestamp;
|
|
|
|
|
|
+ String unitName = getName(strategy.getGroupName(),strategy,createType,null,timestamp,null);
|
|
String appIdString = strategy.getAppIdArray();
|
|
String appIdString = strategy.getAppIdArray();
|
|
Long appId = null;
|
|
Long appId = null;
|
|
if(!Check.isNull(appIdString)&&!Check.isNull(JSON.parseArray(appIdString))){
|
|
if(!Check.isNull(appIdString)&&!Check.isNull(JSON.parseArray(appIdString))){
|
|
@@ -399,7 +330,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if(remindCnt>=1){
|
|
if(remindCnt>=1){
|
|
//历史打捞素材
|
|
//历史打捞素材
|
|
log.info("组创建不足,剩余需要创建个数{},使用历史打捞素材创建",remindCnt);
|
|
log.info("组创建不足,剩余需要创建个数{},使用历史打捞素材创建",remindCnt);
|
|
- remindCnt = this.autoCreateCreative(strategy,4,remindCnt);
|
|
|
|
|
|
+ this.autoCreateCreative(strategy,4,remindCnt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -549,14 +480,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType) {
|
|
|
|
- JSONArray campaignList = null;
|
|
|
|
- Date campaignDate = new Date();
|
|
|
|
- String timestamp = "";
|
|
|
|
- if (null != checkType && checkType.equals("ALL_CAMPAIGN")) {
|
|
|
|
|
|
+ private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType,Integer createType,AiKuaiShouAppInfo appInfo) {
|
|
|
|
+ JSONArray campaignList;
|
|
|
|
+ if (null != checkType && "ALL_CAMPAIGN".equals(checkType)) {
|
|
campaignList = kuaishouInterfaceService.getCampaignList(token, null, null, 1);
|
|
campaignList = kuaishouInterfaceService.getCampaignList(token, null, null, 1);
|
|
} else {
|
|
} else {
|
|
- timestamp = DateUtils.formatDate(campaignDate, "yyyyMMddHHmmss");
|
|
|
|
campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(), 1);
|
|
campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(), 1);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -571,14 +499,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
// 不存在“上新”计划,则创建一个计划
|
|
// 不存在“上新”计划,则创建一个计划
|
|
JSONObject campaignParams = new JSONObject();
|
|
JSONObject campaignParams = new JSONObject();
|
|
campaignParams.put("advertiser_id", token.getAccountId());
|
|
campaignParams.put("advertiser_id", token.getAccountId());
|
|
- String campaignName = strategy.getCampaignName();
|
|
|
|
- if(!campaignName.contains("自定义")){
|
|
|
|
- campaignName+= "-自定义-";
|
|
|
|
- }
|
|
|
|
- campaignName =campaignName.replace("自定义", replaceString) + timestamp;
|
|
|
|
|
|
+ String campaignName = getName(strategy.getCampaignName(),strategy,createType,appInfo,null,null);
|
|
campaignParams.put("campaign_name", campaignName);
|
|
campaignParams.put("campaign_name", campaignName);
|
|
campaignParams.put("type", strategy.getCampaignType());
|
|
campaignParams.put("type", strategy.getCampaignType());
|
|
- //TODO 目前设定为不限
|
|
|
|
if(null!=strategy.getCampaignDayBudget()&&strategy.getCampaignDayBudget()!=0){
|
|
if(null!=strategy.getCampaignDayBudget()&&strategy.getCampaignDayBudget()!=0){
|
|
campaignParams.put("day_budget", strategy.getCampaignDayBudget());
|
|
campaignParams.put("day_budget", strategy.getCampaignDayBudget());
|
|
}
|
|
}
|
|
@@ -965,7 +888,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
target.put("paid_audience", JSON.parseArray(paidAudienceString));
|
|
target.put("paid_audience", JSON.parseArray(paidAudienceString));
|
|
}
|
|
}
|
|
if (Check.isNull(strategy.getBehaviorInterest())) {
|
|
if (Check.isNull(strategy.getBehaviorInterest())) {
|
|
- // TODO 只是单独结构体 后续需要优化
|
|
|
|
target.put("behavior_interest", JSON.parseObject(strategy.getBehaviorInterest()));
|
|
target.put("behavior_interest", JSON.parseObject(strategy.getBehaviorInterest()));
|
|
}
|
|
}
|
|
return target;
|
|
return target;
|
|
@@ -975,17 +897,15 @@ 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 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());
|
|
String imageToken = getImageToken(imageUrl, imageCode, token.getAccountId(), token.getAccessToken());
|
|
creativeParams.put("image_token", imageToken);
|
|
creativeParams.put("image_token", imageToken);
|
|
- createCreative(token, creativeParams, campaignId, unitId, creativeCnt, videoItem);
|
|
|
|
- creativeCnt++;
|
|
|
|
- if (creativeCnt > imageNumber) {
|
|
|
|
|
|
+ createCreative(token, creativeParams, campaignId, unitId, i+1, videoItem);
|
|
|
|
+ imageNumber --;
|
|
|
|
+ if (imageNumber<=0) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1077,40 +997,38 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @param wildcard 计划名称
|
|
|
|
|
|
+ * @param wildcard 计划名称/组名称
|
|
* @param strategy 账户id
|
|
* @param strategy 账户id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer num,Integer createType,AiKuaiShouAppInfo appInfo) {
|
|
|
|
-// if(wildcard.contains("{{定向包}}")){
|
|
|
|
-// String targetName = "";
|
|
|
|
-// }
|
|
|
|
- if(wildcard.contains("{{日期}}")){
|
|
|
|
- String date = DateUtils.getNowDate("yyyyMMddHHmmss");
|
|
|
|
- wildcard.replace("{{日期}}","-"+date+"-");
|
|
|
|
- }
|
|
|
|
- if(wildcard.contains("{{下标号}}")){
|
|
|
|
- String numString = num.toString();
|
|
|
|
- wildcard.replace("{{下标号}}","-"+numString+"-");
|
|
|
|
- }
|
|
|
|
|
|
+ private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer createType,AiKuaiShouAppInfo appInfo,String timestamp,Integer cnt) {
|
|
if(wildcard.contains("{{应用包名}}")){
|
|
if(wildcard.contains("{{应用包名}}")){
|
|
String appName = "";
|
|
String appName = "";
|
|
if(null!=appInfo){
|
|
if(null!=appInfo){
|
|
appName = appInfo.getAppName();
|
|
appName = appInfo.getAppName();
|
|
}
|
|
}
|
|
- wildcard.replace("{{应用包名}}","-"+appName+"-");
|
|
|
|
|
|
+ wildcard = wildcard.replace("{{应用包名}}","-"+appName+"-");
|
|
}
|
|
}
|
|
if(wildcard.contains("{{创意制作方式}}")){
|
|
if(wildcard.contains("{{创意制作方式}}")){
|
|
String creatype = KuaishouCreativeCreateTypeEnum.getNameByType(strategy.getOpenProgramCreate());
|
|
String creatype = KuaishouCreativeCreateTypeEnum.getNameByType(strategy.getOpenProgramCreate());
|
|
- wildcard.replace("{{创意制作方式}}","-"+creatype+"-");
|
|
|
|
|
|
+ wildcard = wildcard.replace("{{创意制作方式}}","-"+creatype+"-");
|
|
}
|
|
}
|
|
if(wildcard.contains("{{广告位置}}")){
|
|
if(wildcard.contains("{{广告位置}}")){
|
|
String adsence = getAdSenceByParams(strategy.getSceneId());
|
|
String adsence = getAdSenceByParams(strategy.getSceneId());
|
|
- wildcard.replace("{{广告位置}}","-"+adsence+"-");
|
|
|
|
|
|
+ wildcard = wildcard.replace("{{广告位置}}","-"+adsence+"-");
|
|
}
|
|
}
|
|
if(wildcard.contains("{{自定义}}")){
|
|
if(wildcard.contains("{{自定义}}")){
|
|
String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
- wildcard.replace("{{自定义}}","-"+targetName+"-");
|
|
|
|
|
|
+ if(null!=appInfo){
|
|
|
|
+ targetName = appInfo.getAppVersion()+"-"+targetName;
|
|
|
|
+ }
|
|
|
|
+ wildcard = wildcard.replace("{{自定义}}","-"+targetName+"-");
|
|
|
|
+ }
|
|
|
|
+ if(null!=timestamp&&!"".equals(timestamp.trim())){
|
|
|
|
+ wildcard = wildcard+"-"+timestamp;
|
|
|
|
+ }
|
|
|
|
+ if(null!=cnt){
|
|
|
|
+ wildcard = wildcard+"-"+cnt.toString();
|
|
}
|
|
}
|
|
wildcard = wildcard.replace("--","-");
|
|
wildcard = wildcard.replace("--","-");
|
|
if(wildcard.startsWith("-")){
|
|
if(wildcard.startsWith("-")){
|