|
@@ -96,10 +96,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (null != singleAppid && singleAppid == 0) {
|
|
|
//多应用
|
|
|
JSONArray appIdArray = JSONArray.parseArray(strategy.getAppIdArray());
|
|
|
- String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
if (strategy.getMultipleBids() == 0) { // 非多应用多出价
|
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
|
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));
|
|
|
if (null == appInfo) {
|
|
|
log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
@@ -118,6 +119,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
|
|
|
for (KuaiShouVideoGet videoItem : allVideos) {
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+
|
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
if (null != overrunInfo) {
|
|
|
log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
@@ -132,6 +139,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//开始创建组+创意
|
|
|
String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appInfo.getAppId());
|
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -143,6 +151,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
|
unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
|
|
@@ -164,41 +173,54 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
}
|
|
|
} else if (strategy.getMultipleBids() == 1) { // 多应用多出价
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
|
|
|
if (Check.isNull(allVideos)) {
|
|
|
return videoCnt;
|
|
|
}
|
|
|
- for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
- Long appId = appIdArray.getLong(i);
|
|
|
- if (Check.isNull(appId)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
|
|
|
- if (Check.isNull(multipleBids)) {
|
|
|
+ for (KuaiShouVideoGet videoItem : allVideos) {
|
|
|
+ // 获取视频封面数据
|
|
|
+ List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
|
|
|
+ if ((null == cutFrameList || cutFrameList.isEmpty())) {
|
|
|
+ log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
|
|
|
continue;
|
|
|
}
|
|
|
- if (!Check.isNull(multipleBids.getTrackUrl())) {
|
|
|
- strategy.setClickTrackUrl(multipleBids.getTrackUrl());
|
|
|
- }
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
|
|
|
- for (KuaiShouVideoGet videoItem : allVideos) {
|
|
|
+ for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
+
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+
|
|
|
+ Long appId = appIdArray.getLong(i);
|
|
|
+ if (Check.isNull(appId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
|
|
|
+ if (Check.isNull(multipleBids)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!Check.isNull(multipleBids.getTrackUrl())) {
|
|
|
+ strategy.setClickTrackUrl(multipleBids.getTrackUrl());
|
|
|
+ }
|
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
if (null != overrunInfo) {
|
|
|
log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
|
return 0L;
|
|
|
}
|
|
|
- // 获取视频封面数据
|
|
|
- List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
|
|
|
- if ((null == cutFrameList || cutFrameList.isEmpty())) {
|
|
|
- log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
|
|
|
- continue;
|
|
|
- }
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
|
|
|
//开始创建组+创意
|
|
|
String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
|
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
|
unitParams.remove("cpa_bid");
|
|
|
unitParams.put("cpa_bid", multipleBids.getCpaBid());
|
|
|
+ if (!Check.isNull(multipleBids.getDeepConversionBid())) {
|
|
|
+ unitParams.remove("deep_conversion_bid");
|
|
|
+ unitParams.put("deep_conversion_bid", multipleBids.getDeepConversionBid());
|
|
|
+ }
|
|
|
strategy.setCpaBid(multipleBids.getCpaBid() + "");
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -206,6 +228,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
|
unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
@@ -229,9 +252,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
//单一应用
|
|
|
String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
@@ -253,6 +274,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
//3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
|
for (KuaiShouVideoGet videoItem : newVideos) {
|
|
|
+
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+
|
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
if (null != overrunInfo) {
|
|
|
return 0L;
|
|
@@ -265,6 +293,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
|
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -274,6 +303,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
@@ -298,7 +328,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
return videoCnt;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 创建程序化创意
|
|
|
*
|
|
@@ -344,7 +373,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
String key = token.getAccountId() + "_ProgramCreative" + "_" + nowDate;
|
|
|
JSONArray appIdArray = JSON.parseArray(strategy.getAppIdArray());
|
|
|
if (null != singleAppid && singleAppid == 0) {
|
|
|
- String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
if (strategy.getMultipleBids() == 0) { // 非多应用多出价
|
|
|
//多应用
|
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
@@ -354,6 +382,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
|
continue;
|
|
|
}
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
+
|
|
|
//判定是否通用监测链接
|
|
|
if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
|
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
@@ -365,6 +395,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (null == allVideos || allVideos.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
//判定创意创建是否超限
|
|
|
KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
if (null != overrunInfo) {
|
|
@@ -372,7 +408,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
return;
|
|
|
}
|
|
|
Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
|
|
|
-
|
|
|
//创建组+创意
|
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
@@ -387,12 +422,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//创建组
|
|
|
String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appInfo.getAppId());
|
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
|
BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
|
+ unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
+ unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
+ unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
@@ -416,54 +456,79 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (Check.isNull(allVideos)) {
|
|
|
return;
|
|
|
}
|
|
|
- for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
- Long appId = appIdArray.getLong(i);
|
|
|
- if (Check.isNull(appId)) {
|
|
|
+ String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
+ List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 1);
|
|
|
+ for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
|
+ List<KuaiShouVideoGet> kuaiShouVideoGets = splitVideos.get(j);
|
|
|
+ if (Check.isNull(kuaiShouVideoGets)) {
|
|
|
continue;
|
|
|
}
|
|
|
- KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
|
|
|
- if (Check.isNull(multipleBids)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!Check.isNull(multipleBids.getTrackUrl())) {
|
|
|
- strategy.setClickTrackUrl(multipleBids.getTrackUrl());
|
|
|
- }
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
|
|
|
- List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
|
- for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
|
- Object redisObj = redisUtil.get(key);
|
|
|
- if (!Check.isNull(redisObj)) {
|
|
|
- Integer value = (Integer) redisObj;
|
|
|
- if (value == 1) {
|
|
|
- log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
|
|
|
+ for (KuaiShouVideoGet videoGet : kuaiShouVideoGets) {
|
|
|
+ for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
- //创建组
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
|
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
|
- unitParams.put("cpa_bid", multipleBids.getCpaBid());
|
|
|
- Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
- Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
|
- String unitMessage = (String) unitCreateResult.get("message");
|
|
|
- AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
|
- BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
|
- unitLevelOperationRecord.setGroupName(unitName);
|
|
|
- unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
- unitLevelOperationRecord.setStatus(unitCode);
|
|
|
- unitLevelOperationRecord.setMessage(unitMessage);
|
|
|
- unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
- unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
|
|
|
- if (unitCode != 0) {
|
|
|
- log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
+
|
|
|
+ Object redisObj = redisUtil.get(key);
|
|
|
+ if (!Check.isNull(redisObj)) {
|
|
|
+ Integer value = (Integer) redisObj;
|
|
|
+ if (value == 1) {
|
|
|
+ log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long appId = appIdArray.getLong(i);
|
|
|
+ if (Check.isNull(appId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
|
|
|
+ if (Check.isNull(multipleBids)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!Check.isNull(multipleBids.getTrackUrl())) {
|
|
|
+ strategy.setClickTrackUrl(multipleBids.getTrackUrl());
|
|
|
+ }
|
|
|
+ Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
|
|
|
+ //创建组
|
|
|
+ String unitName = getName(strategy.getGroupName(), strategy, createType, videoGet.getPhotoName(), "unit", newCampaignId, appId);
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
|
+ unitParams.remove("cpa_bid");
|
|
|
+ unitParams.put("cpa_bid", multipleBids.getCpaBid());
|
|
|
+ if (!Check.isNull(multipleBids.getDeepConversionBid())) {
|
|
|
+ unitParams.remove("deep_conversion_bid");
|
|
|
+ unitParams.put("deep_conversion_bid", multipleBids.getDeepConversionBid());
|
|
|
+ }
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
+ Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
+ Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
|
+ String unitMessage = (String) unitCreateResult.get("message");
|
|
|
+ AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
|
+ BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
|
+ unitLevelOperationRecord.setGroupName(unitName);
|
|
|
+ unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
+ unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
+ unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
+ unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
+ unitLevelOperationRecord.setStatus(unitCode);
|
|
|
+ unitLevelOperationRecord.setMessage(unitMessage);
|
|
|
+ unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
+
|
|
|
+ unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
|
|
|
+ if (unitCode != 0) {
|
|
|
+ log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
+ unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long unitId = (Long) unitCreateResult.get("unitId");
|
|
|
+ unitLevelOperationRecord.setUnitId(unitId);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
- continue;
|
|
|
+ JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
|
|
|
+ createProgramCreative(token, creativeParams, strategy);
|
|
|
}
|
|
|
- Long unitId = (Long) unitCreateResult.get("unitId");
|
|
|
- unitLevelOperationRecord.setUnitId(unitId);
|
|
|
- unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
- JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
|
|
|
- createProgramCreative(token, creativeParams, strategy);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -474,7 +539,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (null == allVideos) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
Long appId = null;
|
|
|
String appIdString = strategy.getAppIdArray();
|
|
|
if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
|
|
@@ -492,6 +556,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//创意
|
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
Object redisObj = redisUtil.get(key);
|
|
|
if (!Check.isNull(redisObj)) {
|
|
|
Integer value = (Integer) redisObj;
|
|
@@ -503,12 +573,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//创建组
|
|
|
String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
|
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
|
BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
|
+ unitLevelOperationRecord.setCampaignId(newCampaignId);
|
|
|
+ unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
+ unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
@@ -526,6 +601,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
createProgramCreative(token, creativeParams, strategy);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -601,16 +677,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
return;
|
|
|
}
|
|
|
Integer code = resultJson.getInteger("code");
|
|
|
-
|
|
|
-
|
|
|
String message = resultJson.getString("message");
|
|
|
-
|
|
|
Long unitId = creativeParams.getLong("unit_id");
|
|
|
if (code == 0) {
|
|
|
createLandPageAndUnit(creativeParams, resultJson.getJSONObject("data"));
|
|
|
-
|
|
|
log.info("创建程序化创意成功,accountId:{},unit:{}", token.getAccountId(), unitId);
|
|
|
-
|
|
|
} else {
|
|
|
log.error("快手创建程序化创意失败,accountId:{},unitId:{},返回信息:{}", token.getAccountId(), unitId, message);
|
|
|
if (code == 400001 && "/rest/openapi/v2/creative/advanced/program/create调用已超日限,次日可恢复调用".equals(message)) {
|
|
@@ -619,10 +690,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
redisUtil.set(key, 1, 100000L);
|
|
|
updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//绑定落地页与广告组、创意的关系
|
|
@@ -1061,14 +1129,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
|
|
|
}
|
|
|
}
|
|
|
- JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
|
|
|
- if (!Check.isNull(appInterest)) {
|
|
|
- targetJsonObject.put("app_interest", appInterest);
|
|
|
- }
|
|
|
+
|
|
|
// APP行为-按APP名称
|
|
|
- JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
|
|
|
- if (!Check.isNull(appIds)) {
|
|
|
- targetJsonObject.put("app_ids", appIds);
|
|
|
+ if (sceneId != 5) {
|
|
|
+ JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
|
|
|
+ if (!Check.isNull(appIds)) {
|
|
|
+ targetJsonObject.put("app_ids", appIds);
|
|
|
+ }
|
|
|
+ JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
|
|
|
+ if (!Check.isNull(appInterest)) {
|
|
|
+ targetJsonObject.put("app_interest", appInterest);
|
|
|
+ }
|
|
|
}
|
|
|
// 人群包定向
|
|
|
JSONArray populationString = JSONArray.parseArray(strategy.getPopulation());
|
|
@@ -1104,7 +1175,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
}
|
|
|
unitParams.put("target", targetJsonObject);
|
|
|
- log.info("广告组创建参数:{}", unitParams.toJSONString());
|
|
|
return unitParams;
|
|
|
}
|
|
|
|
|
@@ -1392,12 +1462,16 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
} else if (creativeCode == -1 && creativeMessage.contains("超过可关联的有效创意的上限")) {
|
|
|
updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
+ } else if (creativeCode == -1 && creativeMessage.contains("视频不存在")) {
|
|
|
+ updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
}
|
|
|
|
|
|
AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord();
|
|
|
BeanUtils.copyProperties(strategy, record);
|
|
|
record.setCreativeName(creativeName);
|
|
|
record.setStatus(creativeCode);
|
|
|
+ record.setDescription(creativeParams.getString("description"));
|
|
|
+ record.setPhotoId(creativeParams.getString("photo_id"));
|
|
|
record.setMessage(creativeMessage);
|
|
|
record.setUnitId(unitId);
|
|
|
record.setAiStrategyUuid(uuid);
|
|
@@ -1422,9 +1496,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
@Autowired
|
|
|
private IKuaiShouAppListService appListService;
|
|
|
|
|
|
- private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, String materialName, String type, Long campaignId, Long appId) {
|
|
|
-
|
|
|
|
|
|
+ private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, String materialName, String type, Long campaignId, Long appId) {
|
|
|
if (wildcard.contains("{{应用名称}}") || wildcard.contains("{{应用标记}}")) {
|
|
|
KuaiShouAppList getAppInfo = appListService.getAppInfo(strategy.getAccountId(), appId);
|
|
|
if (!Check.isNull(getAppInfo)) {
|
|
@@ -1435,8 +1508,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
wildcard = wildcard.replace("{{应用标记}}", "");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
if (wildcard.contains("{{创意制作方式}}")) {
|
|
|
if (strategy.getUnitType() == 4) {
|
|
|
wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
|
|
@@ -1456,6 +1527,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
wildcard = wildcard.replace("{{素材名称}}", materialName);
|
|
|
}
|
|
|
}
|
|
|
+ if (wildcard.contains("{{渠道号}}")) {
|
|
|
+ KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(strategy.getAccountId(), appId);
|
|
|
+ if (!Check.isNull(multipleBids)) {
|
|
|
+ wildcard = wildcard.replace("{{渠道号}}", multipleBids.getChannelCode());
|
|
|
+ } else {
|
|
|
+ wildcard = wildcard.replace("{{渠道号}}", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!wildcard.contains("{{自定义}}")) {
|
|
|
wildcard = wildcard + "{{自定义}}";
|
|
|
}
|
|
@@ -1470,12 +1549,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
} else if ("unit".equals(type)) {
|
|
|
wildcard = wildcard.replace("{{日期}}", nowDate);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
wildcard = wildcard.replace("{{自定义}}", targetName);
|
|
|
-
|
|
|
-
|
|
|
if (!Check.isNull(campaignId)) {
|
|
|
Integer count = null;
|
|
|
if (null != strategy.getSingleAppid() && strategy.getSingleAppid() == 0 && strategy.getMultipleBids() == 0) {
|
|
@@ -1527,4 +1602,21 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean getUnitOverrun(Long accountId) {
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
+ String key = accountId + "_" + nowDate + "unit_create_overrun";
|
|
|
+ Object redisObj = redisUtil.get(key);
|
|
|
+ if (Check.isNull(redisObj)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Integer value = (Integer) redisObj;
|
|
|
+ if (value == 1) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|