|
@@ -68,6 +68,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
*/
|
|
|
@Override
|
|
|
public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
|
|
|
+ String strategyUuid = UUID.randomUUID().toString();
|
|
|
strategy.setUnitType(4);
|
|
|
Long accountId = strategy.getAccountId();
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
@@ -108,7 +109,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
|
|
|
continue;
|
|
|
}
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo);
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo,strategyUuid);
|
|
|
int unitCnt = 0;
|
|
|
for (KuaiShouVideoGet videoItem : allVideos) {
|
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
@@ -136,6 +137,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
|
+ unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
|
|
|
if (unitCode != 0) {
|
|
|
log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
@@ -146,7 +148,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
videoCnt --;
|
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
|
- createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy);
|
|
|
+ createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy,strategyUuid);
|
|
|
if(videoCnt<=0){
|
|
|
return videoCnt;
|
|
|
}
|
|
@@ -161,7 +163,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
|
|
|
return videoCnt;
|
|
|
}
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null);
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null,strategyUuid);
|
|
|
if (null == newCampaignId) {
|
|
|
return videoCnt;
|
|
|
}
|
|
@@ -193,6 +195,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
|
+ unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
|
|
|
if (unitCode != 0) {
|
|
|
log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
@@ -203,7 +206,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
videoCnt -- ;
|
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
|
- createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy);
|
|
|
+ createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy,strategyUuid);
|
|
|
if(videoCnt<=0){
|
|
|
return 0L;
|
|
|
}
|
|
@@ -219,6 +222,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
*/
|
|
|
@Override
|
|
|
public void autoCreateProgramCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
|
|
|
+ String strategyUuid = UUID.randomUUID().toString();
|
|
|
strategy.setUnitType(7);
|
|
|
Long accountId = strategy.getAccountId();
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
@@ -265,7 +269,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
|
return;
|
|
|
}
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo);
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo,strategyUuid);
|
|
|
|
|
|
//创建组+创意
|
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos,5);
|
|
@@ -283,6 +287,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
|
+ unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
|
|
|
if (unitCode != 0) {
|
|
|
log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
@@ -304,7 +309,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null);
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null,strategyUuid);
|
|
|
if (null == newCampaignId) {
|
|
|
return;
|
|
|
}
|
|
@@ -330,6 +335,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
|
+ unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
|
|
|
if (unitCode != 0) {
|
|
|
log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
@@ -529,7 +535,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType,Integer createType,AiKuaiShouAppInfo appInfo) {
|
|
|
+ private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType,Integer createType,AiKuaiShouAppInfo appInfo,String uuid) {
|
|
|
JSONArray campaignList;
|
|
|
if ("ALL_CAMPAIGN".equals(checkType)) {
|
|
|
campaignList = kuaishouInterfaceService.getCampaignList(token, null, null, 1);
|
|
@@ -558,6 +564,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
Integer code = (Integer) campaignCreateResult.get("code");
|
|
|
String message = (String) campaignCreateResult.get("message");
|
|
|
AiKuaishouCampaignLevelOperationRecord record = new AiKuaishouCampaignLevelOperationRecord(strategy,null,code,message);
|
|
|
+ record.setCampaignUuid(uuid);
|
|
|
record.setCampaignName(campaignName);
|
|
|
if (code != 0) {
|
|
|
log.info("计划创建失败=>message:{}", message);
|
|
@@ -949,14 +956,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
private void createCreativeByImage(List<MaterialCutFrame> cutFrameList, CtopOauthToken token, JSONObject creativeParams,
|
|
|
Long campaignId, Long unitId, KuaiShouVideoGet videoItem,
|
|
|
- int imageNumber,AiKuaishouAdvertiserStrategy strategy) {
|
|
|
+ int imageNumber,AiKuaishouAdvertiserStrategy strategy,String uuid) {
|
|
|
if ((null != cutFrameList && !cutFrameList.isEmpty())) {
|
|
|
for (int i = 0; i < cutFrameList.size(); i++) {
|
|
|
String imageCode = cutFrameList.get(i).getSignature();
|
|
|
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, i+1, videoItem,strategy);
|
|
|
+ createCreative(token, creativeParams, campaignId, unitId, i+1, videoItem,strategy,uuid);
|
|
|
imageNumber --;
|
|
|
if (imageNumber<=0) {
|
|
|
break;
|
|
@@ -1030,7 +1037,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
|
|
|
private void createCreative(CtopOauthToken token, JSONObject creativeParams, Long campaignId, Long unitId,
|
|
|
- int creativeCnt, KuaiShouVideoGet videoGet,AiKuaishouAdvertiserStrategy strategy) {
|
|
|
+ int creativeCnt, KuaiShouVideoGet videoGet,AiKuaishouAdvertiserStrategy strategy,String uuid) {
|
|
|
String creativeName = "自定义创意_"+creativeCnt;
|
|
|
creativeParams.put("creative_name", creativeName);
|
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
|
|
@@ -1041,6 +1048,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
record.setCreativeName(creativeName);
|
|
|
record.setStatus(creativeCode);
|
|
|
record.setMessage(creativeMessage);
|
|
|
+ record.setAiStrategyUuid(uuid);
|
|
|
record.setCreateTime(new Date());
|
|
|
if (creativeCode != 0) {
|
|
|
creativeLevelOperationRecordService.saveOrUpdate(record);
|