|
@@ -64,7 +64,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
*
|
|
*
|
|
* @param strategy 账户配置信息
|
|
* @param strategy 账户配置信息
|
|
* @param createType 创意创建类型 1:素材上新 2:历史高质量 3:历史遗漏素材 4:历史打捞
|
|
* @param createType 创意创建类型 1:素材上新 2:历史高质量 3:历史遗漏素材 4:历史打捞
|
|
- * @param videoCnt 视频数量
|
|
|
|
|
|
+ * @param videoCnt 视频数量
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
|
|
public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
|
|
@@ -78,8 +78,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
//1:获取视频信息
|
|
//1:获取视频信息
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
- Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
- Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
|
|
+ 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);
|
|
@@ -92,7 +92,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
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());
|
|
|
|
|
|
+ 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));
|
|
@@ -104,12 +104,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
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);
|
|
if (null == allVideos || allVideos.isEmpty()) {
|
|
if (null == allVideos || allVideos.isEmpty()) {
|
|
- log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
|
|
|
|
|
|
+ log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo,strategyUuid);
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
|
|
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()));
|
|
@@ -126,13 +126,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitCnt++;
|
|
unitCnt++;
|
|
//开始创建组+创意
|
|
//开始创建组+创意
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
- String unitName = getName(strategy.getGroupName(),strategy,createType,appInfo,timestamp,unitCnt);
|
|
|
|
|
|
+ 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");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
- BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
|
|
|
|
|
|
+ BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
@@ -147,10 +147,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
- videoCnt --;
|
|
|
|
|
|
+ videoCnt--;
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
- createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy,strategyUuid);
|
|
|
|
- if(videoCnt<=0){
|
|
|
|
|
|
+ createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid);
|
|
|
|
+ if (videoCnt <= 0) {
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -158,13 +158,13 @@ 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);
|
|
|
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
|
+ 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",createType,null,strategyUuid);
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
|
|
if (null == newCampaignId) {
|
|
if (null == newCampaignId) {
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
@@ -184,14 +184,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
unitCnt++;
|
|
unitCnt++;
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
- String unitName = getName(strategy.getGroupName(),strategy,createType,null,timestamp,unitCnt);
|
|
|
|
|
|
+ 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);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
- BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
|
|
|
|
|
|
+ BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
@@ -206,10 +206,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
- videoCnt -- ;
|
|
|
|
|
|
+ videoCnt--;
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
- createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy,strategyUuid);
|
|
|
|
- if(videoCnt<=0){
|
|
|
|
|
|
+ createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid);
|
|
|
|
+ if (videoCnt <= 0) {
|
|
return 0L;
|
|
return 0L;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -234,8 +234,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
//1:获取视频信息
|
|
//1:获取视频信息
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
|
|
- Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
- Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
|
|
+ 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);
|
|
@@ -258,11 +258,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
}
|
|
}
|
|
- String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
|
|
+ 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);
|
|
|
|
- if (null == allVideos||allVideos.isEmpty()) {
|
|
|
|
|
|
+ List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
|
|
|
|
+ if (null == allVideos || allVideos.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//判定创意创建是否超限
|
|
//判定创意创建是否超限
|
|
@@ -271,20 +271,20 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo,strategyUuid);
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
|
|
|
|
|
|
//创建组+创意
|
|
//创建组+创意
|
|
- 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 unitName = getName(strategy.getGroupName(),strategy,createType,appInfo,timestamp,null);
|
|
|
|
|
|
+ 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");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
- BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
|
|
|
|
|
|
+ BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
@@ -300,32 +300,32 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
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,strategy);
|
|
|
|
|
|
+ createProgramCreative(token, creativeParams, strategy);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
|
|
+ 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",createType,null,strategyUuid);
|
|
|
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
|
|
if (null == newCampaignId) {
|
|
if (null == newCampaignId) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//创意
|
|
//创意
|
|
- 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 unitName = getName(strategy.getGroupName(),strategy,createType,null,timestamp,null);
|
|
|
|
|
|
+ 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))) {
|
|
appId = JSON.parseArray(appIdString).getLong(0);
|
|
appId = JSON.parseArray(appIdString).getLong(0);
|
|
}
|
|
}
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
@@ -333,7 +333,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
- BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
|
|
|
|
|
|
+ BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
@@ -349,51 +349,72 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
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,strategy);
|
|
|
|
|
|
+ createProgramCreative(token, creativeParams, strategy);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy,Integer hour) throws ParseException {
|
|
|
|
- Long unitNum = strategy.getCustomUnitCnt()*hour/20;
|
|
|
|
- log.info("{}当前时间内需要创建组总数:{}",strategy.getAccountId(),unitNum);
|
|
|
|
|
|
+ public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy, Integer hour) throws ParseException {
|
|
|
|
+
|
|
|
|
+ Long customUnitCnt = strategy.getCustomUnitCnt();
|
|
|
|
+ if (Check.isNull(customUnitCnt)) {
|
|
|
|
+ Integer imageCnt = strategy.getImageCnt();
|
|
|
|
+ if (imageCnt <= 1) {
|
|
|
|
+ customUnitCnt = 600L;
|
|
|
|
+ } else {
|
|
|
|
+ customUnitCnt = 2000L / imageCnt;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long unitNum = customUnitCnt * hour / 20;
|
|
|
|
+ log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
|
|
//查询当前账户创建自定义类型组数量
|
|
//查询当前账户创建自定义类型组数量
|
|
int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
|
|
int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
|
|
- log.info("{}截止目前创建组总数:{}",strategy.getAccountId(),unitCreateCnt);
|
|
|
|
- long remindCnt = unitNum-unitCreateCnt;
|
|
|
|
- if(remindCnt>=1){
|
|
|
|
- log.info("{}组创建不足,剩余需要创建个数{},使用历史遗漏素材创建",strategy.getAccountId(),remindCnt);
|
|
|
|
|
|
+ log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
|
|
|
|
+ long remindCnt = unitNum - unitCreateCnt;
|
|
|
|
+ if (remindCnt >= 1) {
|
|
|
|
+ log.info("{}组创建不足,剩余需要创建个数{},使用历史遗漏素材创建", strategy.getAccountId(), remindCnt);
|
|
//优先创建历史遗漏素材
|
|
//优先创建历史遗漏素材
|
|
- remindCnt = this.autoCreateCreative(strategy,3,remindCnt);
|
|
|
|
|
|
+ remindCnt = this.autoCreateCreative(strategy, 3, remindCnt);
|
|
}
|
|
}
|
|
- if(remindCnt>=1){
|
|
|
|
- log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建",strategy.getAccountId(),remindCnt);
|
|
|
|
|
|
+ if (remindCnt >= 1) {
|
|
|
|
+ log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
|
|
//高质量素材
|
|
//高质量素材
|
|
- remindCnt = this.autoCreateCreative(strategy,2,remindCnt);
|
|
|
|
|
|
+ remindCnt = this.autoCreateCreative(strategy, 2, remindCnt);
|
|
}
|
|
}
|
|
- if(remindCnt>=1){
|
|
|
|
|
|
+ if (remindCnt >= 1) {
|
|
//历史打捞素材
|
|
//历史打捞素材
|
|
- log.info("{}组创建不足,剩余需要创建个数{},使用历史打捞素材创建",strategy.getAccountId(),remindCnt);
|
|
|
|
- this.autoCreateCreative(strategy,4,remindCnt);
|
|
|
|
|
|
+ log.info("{}组创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), remindCnt);
|
|
|
|
+ this.autoCreateCreative(strategy, 4, remindCnt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void customCreativeLimit(AiKuaishouAdvertiserStrategy strategy) {
|
|
public void customCreativeLimit(AiKuaishouAdvertiserStrategy strategy) {
|
|
Long unitNum = strategy.getCustomUnitCnt();
|
|
Long unitNum = strategy.getCustomUnitCnt();
|
|
- log.info("{}当天可创建组总数:{}",strategy.getAccountId(),unitNum);
|
|
|
|
|
|
+ if (Check.isNull(unitNum)) {
|
|
|
|
+ Integer imageCnt = strategy.getImageCnt();
|
|
|
|
+ if (imageCnt <= 1) {
|
|
|
|
+ unitNum = 600L;
|
|
|
|
+ } else {
|
|
|
|
+ unitNum = 2000L / imageCnt;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ log.info("{}当天可创建组总数:{}", strategy.getAccountId(), unitNum);
|
|
//查询当前账户创建自定义类型组数量
|
|
//查询当前账户创建自定义类型组数量
|
|
int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
|
|
int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
|
|
- log.info("{}截止目前创建组总数:{}",strategy.getAccountId(),unitCreateCnt);
|
|
|
|
- long remindCnt = unitNum-unitCreateCnt;
|
|
|
|
- if(remindCnt>=1){
|
|
|
|
- log.info("{}组创建不足,剩余需要创建个数{},开始上新素材创建",strategy.getAccountId(),remindCnt);
|
|
|
|
- this.autoCreateCreative(strategy,1,remindCnt);
|
|
|
|
|
|
+ log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
|
|
|
|
+ long remindCnt = unitNum - unitCreateCnt;
|
|
|
|
+ if (remindCnt >= 1) {
|
|
|
|
+ log.info("{}组创建不足,剩余需要创建个数{},开始上新素材创建", strategy.getAccountId(), remindCnt);
|
|
|
|
+ this.autoCreateCreative(strategy, 1, remindCnt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams,AiKuaishouAdvertiserStrategy strategy) {
|
|
|
|
|
|
+
|
|
|
|
+ private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAdvertiserStrategy strategy) {
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
@@ -463,7 +484,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
JSONArray captions = new JSONArray();
|
|
JSONArray captions = new JSONArray();
|
|
captions.add(strategy.getDescription());
|
|
captions.add(strategy.getDescription());
|
|
- programJson.put("captions",captions);
|
|
|
|
|
|
+ programJson.put("captions", captions);
|
|
if (!Check.isNull(strategy.getCreativeCategory())) {
|
|
if (!Check.isNull(strategy.getCreativeCategory())) {
|
|
programJson.put("creative_category", strategy.getCreativeCategory());
|
|
programJson.put("creative_category", strategy.getCreativeCategory());
|
|
programJson.put("creative_tag", JSON.parseArray(strategy.getCreativeTag()));
|
|
programJson.put("creative_tag", JSON.parseArray(strategy.getCreativeTag()));
|
|
@@ -472,21 +493,33 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
|
|
|
|
private List<KuaiShouVideoGet> getNewVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
|
|
private List<KuaiShouVideoGet> getNewVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
|
|
- if(null == appInfo){
|
|
|
|
- return videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), null, null);
|
|
|
|
- }else{
|
|
|
|
|
|
+ if (null == appInfo) {
|
|
|
|
+ if (Check.isNull(strategy.getMaterialKeyword())) { // 素材名称为空 不需要标注特殊素材
|
|
|
|
+ return videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), null, null);
|
|
|
|
+ } else {// tt语音特殊素材查询
|
|
|
|
+ return videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), strategy.getMaterialKeyword(), null);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
//查询通用素材
|
|
//查询通用素材
|
|
- List<KuaiShouVideoGet> generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), "all", null);
|
|
|
|
- //2:查询特定素材
|
|
|
|
- List<KuaiShouVideoGet> customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
|
|
|
|
|
|
+ List<KuaiShouVideoGet> generalVideos = new ArrayList<>();
|
|
|
|
+ List<KuaiShouVideoGet> customVideos = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ if (Check.isNull(strategy.getMaterialKeyword())) {
|
|
|
|
+ generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), "all", null);
|
|
|
|
+ //2:查询特定素材
|
|
|
|
+ customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
|
|
|
|
+ } else { // tt语音特殊素材查询
|
|
|
|
+ generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), strategy.getMaterialKeyword(), null);
|
|
|
|
+
|
|
|
|
+ }
|
|
if (Check.isNull(generalVideos) && Check.isNull(customVideos)) {
|
|
if (Check.isNull(generalVideos) && Check.isNull(customVideos)) {
|
|
- log.info("账户:{},appId({}){}到{}这段时间没有上新素材", strategy.getAccountId(), appInfo.getAppId(), startTime, endTime);
|
|
|
|
|
|
+ log.info("账户:{},appId({}){}到{}这段时间没有上新素材", strategy.getAccountId(), appInfo.getAppId(), startTime, endTime);
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
}
|
|
}
|
|
//合并
|
|
//合并
|
|
- 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);
|
|
@@ -495,27 +528,37 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private List<KuaiShouVideoGet> getRelateZeroVideoList(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo,Integer relativeCnt,Long videoCnt) {
|
|
|
|
|
|
+ private List<KuaiShouVideoGet> getRelateZeroVideoList(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer relativeCnt, Long videoCnt) {
|
|
Integer channelType = null;
|
|
Integer channelType = null;
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
channelType = strategy.getChannelType();
|
|
channelType = strategy.getChannelType();
|
|
}
|
|
}
|
|
- String appVersion = null;
|
|
|
|
- if(null!=appInfo&&null!=appInfo.getAppVersion()){
|
|
|
|
- appVersion = appInfo.getAppVersion();
|
|
|
|
|
|
+ String appVersion = null;
|
|
|
|
+ if (Check.isNull(strategy.getMaterialKeyword())) {
|
|
|
|
+ if (null != appInfo && null != appInfo.getAppVersion()) {
|
|
|
|
+ appVersion = appInfo.getAppVersion();
|
|
|
|
+ }
|
|
|
|
+ } else { // tt语音特殊素材查询
|
|
|
|
+ appVersion = strategy.getMaterialKeyword();
|
|
}
|
|
}
|
|
- return videoGetService.getZeroVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType,relativeCnt);
|
|
|
|
|
|
+
|
|
|
|
+ return videoGetService.getZeroVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType, relativeCnt);
|
|
}
|
|
}
|
|
|
|
|
|
- private List<KuaiShouVideoGet> getHistoryTopVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo,Long videoCnt) {
|
|
|
|
|
|
+ private List<KuaiShouVideoGet> getHistoryTopVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Long videoCnt) {
|
|
Integer channelType = null;
|
|
Integer channelType = null;
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
channelType = strategy.getChannelType();
|
|
channelType = strategy.getChannelType();
|
|
}
|
|
}
|
|
- String appVersion = null;
|
|
|
|
- if(null!=appInfo&&null!=appInfo.getAppVersion()){
|
|
|
|
- appVersion = appInfo.getAppVersion();
|
|
|
|
|
|
+ String appVersion = null;
|
|
|
|
+ if (Check.isNull(strategy.getMaterialKeyword())) {
|
|
|
|
+ if (null != appInfo && null != appInfo.getAppVersion()) {
|
|
|
|
+ appVersion = appInfo.getAppVersion();
|
|
|
|
+ }
|
|
|
|
+ } else { // tt语音 特殊素材查询
|
|
|
|
+ appVersion = strategy.getMaterialKeyword();
|
|
}
|
|
}
|
|
|
|
+
|
|
return videoGetService.getHistoryTopVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType);
|
|
return videoGetService.getHistoryTopVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -527,19 +570,19 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
* @param startTime 开始时间
|
|
* @param startTime 开始时间
|
|
* @param endTime 结束时间
|
|
* @param endTime 结束时间
|
|
*/
|
|
*/
|
|
- private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer createType,Long videoCnt) {
|
|
|
|
|
|
+ private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer createType, Long videoCnt) {
|
|
if (createType == 1) {
|
|
if (createType == 1) {
|
|
return getNewVideoListByParams(strategy, startTime, endTime, appInfo);
|
|
return getNewVideoListByParams(strategy, startTime, endTime, appInfo);
|
|
} else if (createType == 2) {
|
|
} else if (createType == 2) {
|
|
- return getHistoryTopVideoListByParams(strategy, startTime, endTime, appInfo,videoCnt);
|
|
|
|
- } else if(createType==3){
|
|
|
|
- return getRelateZeroVideoList(strategy, startTime, endTime, appInfo,0,videoCnt);
|
|
|
|
- }else{
|
|
|
|
- return getRelateZeroVideoList(strategy, startTime, endTime, appInfo,20,videoCnt);
|
|
|
|
|
|
+ return getHistoryTopVideoListByParams(strategy, startTime, endTime, appInfo, videoCnt);
|
|
|
|
+ } else if (createType == 3) {
|
|
|
|
+ return getRelateZeroVideoList(strategy, startTime, endTime, appInfo, 0, videoCnt);
|
|
|
|
+ } else { // type == 4 历史素材打捞
|
|
|
|
+ return getRelateZeroVideoList(strategy, startTime, endTime, appInfo, 20, videoCnt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType,Integer createType,AiKuaiShouAppInfo appInfo,String uuid) {
|
|
|
|
|
|
+ private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
|
|
JSONArray campaignList;
|
|
JSONArray campaignList;
|
|
String timestamp = null;
|
|
String timestamp = null;
|
|
if ("ALL_CAMPAIGN".equals(checkType)) {
|
|
if ("ALL_CAMPAIGN".equals(checkType)) {
|
|
@@ -560,16 +603,16 @@ 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 = getName(strategy.getCampaignName(),strategy,createType,appInfo,timestamp,null);
|
|
|
|
|
|
+ String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, timestamp, null);
|
|
campaignParams.put("campaign_name", campaignName);
|
|
campaignParams.put("campaign_name", campaignName);
|
|
campaignParams.put("type", strategy.getCampaignType());
|
|
campaignParams.put("type", strategy.getCampaignType());
|
|
- 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());
|
|
}
|
|
}
|
|
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");
|
|
- AiKuaishouCampaignLevelOperationRecord record = new AiKuaishouCampaignLevelOperationRecord(strategy,null,code,message);
|
|
|
|
|
|
+ AiKuaishouCampaignLevelOperationRecord record = new AiKuaishouCampaignLevelOperationRecord(strategy, null, code, message);
|
|
record.setAiStrategyUuid(uuid);
|
|
record.setAiStrategyUuid(uuid);
|
|
record.setCampaignName(campaignName);
|
|
record.setCampaignName(campaignName);
|
|
if (code != 0) {
|
|
if (code != 0) {
|
|
@@ -601,10 +644,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitParams.put("use_app_market", strategy.getUseAppMarket());
|
|
unitParams.put("use_app_market", strategy.getUseAppMarket());
|
|
}
|
|
}
|
|
//组单日预算
|
|
//组单日预算
|
|
- if(null!=strategy.getUnitDayBudget()&&strategy.getUnitDayBudget()!=0){
|
|
|
|
- unitParams.put("day_budget",strategy.getUnitDayBudget());
|
|
|
|
- }else{
|
|
|
|
- unitParams.put("day_budget",0);
|
|
|
|
|
|
+ if (null != strategy.getUnitDayBudget() && strategy.getUnitDayBudget() != 0) {
|
|
|
|
+ unitParams.put("day_budget", strategy.getUnitDayBudget());
|
|
|
|
+ } else {
|
|
|
|
+ unitParams.put("day_budget", 0);
|
|
}
|
|
}
|
|
//应用商店列表
|
|
//应用商店列表
|
|
if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
|
|
if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
|
|
@@ -643,10 +686,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
Integer sceneId = null;
|
|
Integer sceneId = null;
|
|
String scenceIdString = strategy.getSceneId();
|
|
String scenceIdString = strategy.getSceneId();
|
|
if (!Check.isNull(scenceIdString) && !Check.isNull(JSON.parseArray(scenceIdString))) {
|
|
if (!Check.isNull(scenceIdString) && !Check.isNull(JSON.parseArray(scenceIdString))) {
|
|
- JSONArray scenceArray = JSON.parseArray(scenceIdString);
|
|
|
|
|
|
+ JSONArray scenceArray = JSON.parseArray(scenceIdString);
|
|
sceneId = scenceArray.getInteger(0);
|
|
sceneId = scenceArray.getInteger(0);
|
|
//资源位置
|
|
//资源位置
|
|
- if(unitType == 7){
|
|
|
|
|
|
+ if (unitType == 7) {
|
|
//程序化
|
|
//程序化
|
|
scenceArray = cleanPramgramErrorScence(scenceArray);
|
|
scenceArray = cleanPramgramErrorScence(scenceArray);
|
|
}
|
|
}
|
|
@@ -656,8 +699,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
//投放开始时间
|
|
//投放开始时间
|
|
if (!Check.isNull(strategy.getBeginTime())) {
|
|
if (!Check.isNull(strategy.getBeginTime())) {
|
|
unitParams.put("begin_time", strategy.getBeginTime());
|
|
unitParams.put("begin_time", strategy.getBeginTime());
|
|
- }else {
|
|
|
|
- unitParams.put("begin_time",DateUtils.formatDate());
|
|
|
|
|
|
+ } else {
|
|
|
|
+ unitParams.put("begin_time", DateUtils.formatDate());
|
|
}
|
|
}
|
|
//投放结束时间
|
|
//投放结束时间
|
|
if (!Check.isNull(strategy.getEndTime())) {
|
|
if (!Check.isNull(strategy.getEndTime())) {
|
|
@@ -750,7 +793,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
if (null != strategy.getAgesRange() && !"".equals(strategy.getAgesRange())) {
|
|
if (null != strategy.getAgesRange() && !"".equals(strategy.getAgesRange())) {
|
|
JSONArray agesRange = JSON.parseArray(strategy.getAgesRange());
|
|
JSONArray agesRange = JSON.parseArray(strategy.getAgesRange());
|
|
- if(null!=agesRange&&!agesRange.isEmpty()){
|
|
|
|
|
|
+ if (null != agesRange && !agesRange.isEmpty()) {
|
|
targetJsonObject.put("ages_range", JSON.parseArray(strategy.getAgesRange()));
|
|
targetJsonObject.put("ages_range", JSON.parseArray(strategy.getAgesRange()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -799,18 +842,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
targetJsonObject.put("intelli_extend", intelliExtend);
|
|
targetJsonObject.put("intelli_extend", intelliExtend);
|
|
}
|
|
}
|
|
unitParams.put("target", targetJsonObject);
|
|
unitParams.put("target", targetJsonObject);
|
|
- log.info("广告组创建参数:{}",unitParams.toJSONString());
|
|
|
|
|
|
+ log.info("广告组创建参数:{}", unitParams.toJSONString());
|
|
return unitParams;
|
|
return unitParams;
|
|
}
|
|
}
|
|
|
|
|
|
private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
|
|
private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
|
|
JSONArray result = new JSONArray();
|
|
JSONArray result = new JSONArray();
|
|
- if(null==scenceArray||scenceArray.isEmpty()){
|
|
|
|
|
|
+ if (null == scenceArray || scenceArray.isEmpty()) {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
- for (int i=0;i<scenceArray.size();i++){
|
|
|
|
- Integer senceId =scenceArray.getInteger(i);
|
|
|
|
- if(senceId!=5&&senceId!=3){
|
|
|
|
|
|
+ for (int i = 0; i < scenceArray.size(); i++) {
|
|
|
|
+ Integer senceId = scenceArray.getInteger(i);
|
|
|
|
+ if (senceId != 5 && senceId != 3) {
|
|
result.add(senceId);
|
|
result.add(senceId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -963,16 +1006,16 @@ 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,AiKuaishouAdvertiserStrategy strategy,String uuid) {
|
|
|
|
|
|
+ int imageNumber, AiKuaishouAdvertiserStrategy strategy, String uuid) {
|
|
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, i+1, videoItem,strategy,uuid);
|
|
|
|
- imageNumber --;
|
|
|
|
- if (imageNumber<=0) {
|
|
|
|
|
|
+ createCreative(token, creativeParams, campaignId, unitId, i + 1, videoItem, strategy, uuid);
|
|
|
|
+ imageNumber--;
|
|
|
|
+ if (imageNumber <= 0) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1044,14 +1087,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
|
|
|
|
private void createCreative(CtopOauthToken token, JSONObject creativeParams, Long campaignId, Long unitId,
|
|
private void createCreative(CtopOauthToken token, JSONObject creativeParams, Long campaignId, Long unitId,
|
|
- int creativeCnt, KuaiShouVideoGet videoGet,AiKuaishouAdvertiserStrategy strategy,String uuid) {
|
|
|
|
- String creativeName = "自定义创意_"+creativeCnt;
|
|
|
|
|
|
+ int creativeCnt, KuaiShouVideoGet videoGet, AiKuaishouAdvertiserStrategy strategy, String uuid) {
|
|
|
|
+ String creativeName = "自定义创意_" + creativeCnt;
|
|
creativeParams.put("creative_name", creativeName);
|
|
creativeParams.put("creative_name", creativeName);
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(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");
|
|
- AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord();
|
|
|
|
- BeanUtils.copyProperties(strategy,record);
|
|
|
|
|
|
+ AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord();
|
|
|
|
+ BeanUtils.copyProperties(strategy, record);
|
|
record.setCreativeName(creativeName);
|
|
record.setCreativeName(creativeName);
|
|
record.setStatus(creativeCode);
|
|
record.setStatus(creativeCode);
|
|
record.setMessage(creativeMessage);
|
|
record.setMessage(creativeMessage);
|
|
@@ -1068,68 +1111,68 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @param wildcard 计划名称/组名称
|
|
|
|
- * @param strategy 账户id
|
|
|
|
|
|
+ * @param wildcard 计划名称/组名称
|
|
|
|
+ * @param strategy 账户id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer createType,AiKuaiShouAppInfo appInfo,String timestamp,Integer cnt) {
|
|
|
|
- if(wildcard.contains("{{应用包名}}")){
|
|
|
|
|
|
+ private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String timestamp, Integer cnt) {
|
|
|
|
+ if (wildcard.contains("{{应用包名}}")) {
|
|
String appName = "";
|
|
String appName = "";
|
|
- if(null!=appInfo){
|
|
|
|
|
|
+ if (null != appInfo) {
|
|
appName = appInfo.getAppName();
|
|
appName = appInfo.getAppName();
|
|
}
|
|
}
|
|
- wildcard = 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 = wildcard.replace("{{创意制作方式}}",creatype);
|
|
// wildcard = wildcard.replace("{{创意制作方式}}",creatype);
|
|
- if(strategy.getUnitType() == 4){
|
|
|
|
- wildcard = wildcard.replace("{{创意制作方式}}","自定义");
|
|
|
|
- }else if(strategy.getUnitType() == 7){
|
|
|
|
- wildcard = wildcard.replace("{{创意制作方式}}","程序化");
|
|
|
|
|
|
+ if (strategy.getUnitType() == 4) {
|
|
|
|
+ wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
|
|
|
|
+ } else if (strategy.getUnitType() == 7) {
|
|
|
|
+ wildcard = wildcard.replace("{{创意制作方式}}", "程序化");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(wildcard.contains("{{广告位置}}")){
|
|
|
|
|
|
+ if (wildcard.contains("{{广告位置}}")) {
|
|
String adsence = getAdSenceByParams(strategy.getSceneId());
|
|
String adsence = getAdSenceByParams(strategy.getSceneId());
|
|
- wildcard = wildcard.replace("{{广告位置}}",adsence);
|
|
|
|
|
|
+ wildcard = wildcard.replace("{{广告位置}}", adsence);
|
|
}
|
|
}
|
|
- if(!wildcard.contains("{{自定义}}")){
|
|
|
|
- wildcard = wildcard+"{{自定义}}";
|
|
|
|
|
|
+ if (!wildcard.contains("{{自定义}}")) {
|
|
|
|
+ wildcard = wildcard + "{{自定义}}";
|
|
}
|
|
}
|
|
- String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
|
|
|
|
- if(null!=appInfo){
|
|
|
|
- targetName = appInfo.getAppVersion()+"-"+targetName;
|
|
|
|
|
|
+ String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
|
+ if (null != appInfo) {
|
|
|
|
+ targetName = appInfo.getAppVersion() + "-" + targetName;
|
|
}
|
|
}
|
|
- wildcard = wildcard.replace("{{自定义}}",targetName);
|
|
|
|
|
|
+ wildcard = wildcard.replace("{{自定义}}", targetName);
|
|
|
|
|
|
- if(null!=timestamp&&!"".equals(timestamp.trim())){
|
|
|
|
- wildcard = wildcard+"-"+timestamp;
|
|
|
|
|
|
+ if (null != timestamp && !"".equals(timestamp.trim())) {
|
|
|
|
+ wildcard = wildcard + "-" + timestamp;
|
|
}
|
|
}
|
|
- if(null!=cnt){
|
|
|
|
- wildcard = wildcard+"-"+cnt.toString();
|
|
|
|
|
|
+ if (null != cnt) {
|
|
|
|
+ wildcard = wildcard + "-" + cnt.toString();
|
|
}
|
|
}
|
|
- wildcard = wildcard.replace("--","-");
|
|
|
|
- if(wildcard.startsWith("-")){
|
|
|
|
- wildcard = wildcard.substring(1,wildcard.length());
|
|
|
|
|
|
+ wildcard = wildcard.replace("--", "-");
|
|
|
|
+ if (wildcard.startsWith("-")) {
|
|
|
|
+ wildcard = wildcard.substring(1, wildcard.length());
|
|
}
|
|
}
|
|
- if(wildcard.endsWith("-")){
|
|
|
|
- wildcard = wildcard.substring(0,wildcard.length()-1);
|
|
|
|
|
|
+ if (wildcard.endsWith("-")) {
|
|
|
|
+ wildcard = wildcard.substring(0, wildcard.length() - 1);
|
|
}
|
|
}
|
|
return wildcard;
|
|
return wildcard;
|
|
}
|
|
}
|
|
|
|
|
|
private String getAdSenceByParams(String sceneIdString) {
|
|
private String getAdSenceByParams(String sceneIdString) {
|
|
String adsence = "";
|
|
String adsence = "";
|
|
- if(null==sceneIdString||"".equals(sceneIdString)){
|
|
|
|
|
|
+ if (null == sceneIdString || "".equals(sceneIdString)) {
|
|
return adsence;
|
|
return adsence;
|
|
}
|
|
}
|
|
JSONArray sceneIdArray = JSON.parseArray(sceneIdString);
|
|
JSONArray sceneIdArray = JSON.parseArray(sceneIdString);
|
|
- if(null == sceneIdArray||sceneIdArray.isEmpty()){
|
|
|
|
|
|
+ if (null == sceneIdArray || sceneIdArray.isEmpty()) {
|
|
return adsence;
|
|
return adsence;
|
|
}
|
|
}
|
|
- for (int i=0;i < sceneIdArray.size();i++){
|
|
|
|
- adsence += KuaishouCreativeAdsenceTypeEnum.getNameByType(sceneIdArray.getInteger(i))+",";
|
|
|
|
|
|
+ for (int i = 0; i < sceneIdArray.size(); i++) {
|
|
|
|
+ adsence += KuaishouCreativeAdsenceTypeEnum.getNameByType(sceneIdArray.getInteger(i)) + ",";
|
|
}
|
|
}
|
|
- return adsence.substring(0,adsence.length()-1);
|
|
|
|
|
|
+ return adsence.substring(0, adsence.length() - 1);
|
|
}
|
|
}
|
|
}
|
|
}
|