|
@@ -13,6 +13,7 @@ import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoTarget;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCampaignLevelOperationRecord;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCreativeLevelOperationRecord;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouProgramCreativeLevelOperationRecord;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouAutoTypeEnum;
|
|
@@ -23,6 +24,7 @@ import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountAutoTargetServi
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountAutoVideoService;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreativeLevelOperationRecordService;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouProgramCreativeLevelOperationRecordService;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouUnitLevelOperationRecordService;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
|
|
@@ -92,6 +94,10 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
private IKuaishouAccountCreativeOverrunInfoService overrunInfoService;
|
|
|
@Autowired
|
|
|
private IAiKuaishouCampaignLevelOperationRecordService aiKuaishouCampaignLevelOperationRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAiKuaishouProgramCreativeLevelOperationRecordService kuaishouProgramCreativeLevelOperationRecordService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IAiKuaiShouAppInfoService appInfoService;
|
|
|
@Autowired
|
|
@@ -772,9 +778,9 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject unitParams = (JSONObject) result.getResult();
|
|
|
- log.info("--------------执行创建程序化广告组,参数:{}", unitParams);
|
|
|
+// log.info("--------------执行创建程序化广告组,参数:{}", unitParams);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
- log.info("--------------创建程序化广告组结果,返回数据:{}", unitCreateResult.toString());
|
|
|
+// log.info("--------------创建程序化广告组结果,返回数据:{}", unitCreateResult.toString());
|
|
|
unitCode = (Integer) unitCreateResult.get("code");
|
|
|
unitMessage = (String) unitCreateResult.get("message");
|
|
|
|
|
@@ -802,7 +808,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//获取创意参数
|
|
|
JSONObject creativeParams = getProgramCreativeParams(token, unitId, videos, strategy, videoCnt, null, usedchannel);
|
|
|
//执行创建创意
|
|
|
- boolean flag = createProgramCreatives(token, creativeParams, strategy, 1);
|
|
|
+ boolean flag = createProgramCreatives(token, creativeParams, strategy, newCampaignId, uuid, 1);
|
|
|
if (flag) {
|
|
|
//创意成功,则素材置为不可用,添加素材使用记录
|
|
|
updateVideoUsed(videoType, videos, "program", null);
|
|
@@ -967,7 +973,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//获取创意参数
|
|
|
JSONObject creativeParams = getProgramCreativeParams(token, unitId, videos, strategy, videoCnt, videos.get(0).getAppVersion(), null);
|
|
|
//执行创建创意
|
|
|
- createProgramCreatives(token, creativeParams, strategy, 1);
|
|
|
+// createProgramCreatives(token, creativeParams, strategy, 1);
|
|
|
if (videoCnt <= 0) {
|
|
|
removeProRedisVideos(successVideoList, videoKey);
|
|
|
return 0;
|
|
@@ -1216,7 +1222,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//获取创意参数
|
|
|
JSONObject creativeParams = getProgramCreativeParams(token, unitId, videos, strategy, videoCnt, null, channel);
|
|
|
//执行创建创意
|
|
|
- boolean flag = createProgramCreatives(token, creativeParams, strategy, 1);
|
|
|
+ boolean flag = createProgramCreatives(token, creativeParams, strategy, newCampaignId, uuid, 1);
|
|
|
if (flag) {
|
|
|
successVideoList.add(videos);
|
|
|
//创意成功,则素材置为不可用,添加素材使用记录
|
|
@@ -1595,15 +1601,25 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
|
|
|
//素材列表
|
|
|
JSONArray photoList = new JSONArray();
|
|
|
+ List<String> vids = new ArrayList<>();//竖版视频ID
|
|
|
+ List<String> hids = new ArrayList<>();//横版视频ID
|
|
|
for (AiKuaishouAccountAutoVideo video : videos) {
|
|
|
+ Integer type = video.getMaterialType();
|
|
|
+ String photoId = video.getPhotoId();
|
|
|
JSONObject photo = new JSONObject();
|
|
|
- photo.put("photo_id", video.getPhotoId());//视频 ID
|
|
|
+ photo.put("photo_id", photoId);//视频 ID
|
|
|
photo.put("cover_image_token", null);// 封面图片 token,通过上传图片接口获得,不传值则直接使用视频的首帧作为封面图片
|
|
|
- photo.put("creative_material_type", video.getMaterialType());//1:竖版视频 2:横版视频
|
|
|
+ photo.put("creative_material_type", type);//1:竖版视频 2:横版视频
|
|
|
photoList.add(photo);
|
|
|
+ if(!Check.isNull(type)&&type==1){
|
|
|
+ vids.add(photoId);
|
|
|
+ }else{
|
|
|
+ hids.add(photoId);
|
|
|
+ }
|
|
|
}
|
|
|
programJson.put("photo_list", photoList);
|
|
|
-
|
|
|
+ programJson.put("vids",vids);
|
|
|
+ programJson.put("hids",hids);
|
|
|
//落地页 ID
|
|
|
if (!Check.isNull(strategy.getSiteId()) && !"-1".equals(strategy.getSiteId())) {
|
|
|
programJson.put("site_id", strategy.getSiteId());
|
|
@@ -1673,7 +1689,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
/**
|
|
|
* 执行创建程序化创意
|
|
|
*/
|
|
|
- private boolean createProgramCreatives(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAccountAutoStrategy strategy, int count) {
|
|
|
+ private boolean createProgramCreatives(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAccountAutoStrategy strategy, Long campaignId, String uuid, int count) {
|
|
|
try {
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
@@ -1689,21 +1705,25 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
Integer code = resultJson.getInteger("code");
|
|
|
String message = resultJson.getString("message");
|
|
|
Long unitId = creativeParams.getLong("unit_id");
|
|
|
+ AiKuaishouProgramCreativeLevelOperationRecord record = new AiKuaishouProgramCreativeLevelOperationRecord(creativeParams, campaignId, unitId, uuid, message);
|
|
|
if (code == 0) {
|
|
|
createLandPageAndUnit(creativeParams, resultJson.getJSONObject("data"));
|
|
|
+ record.setStatus(0);
|
|
|
+ kuaishouProgramCreativeLevelOperationRecordService.saveOrUpdate(record);
|
|
|
} else {
|
|
|
log.error("快手创建程序化创意失败,accountId:{},unitId:{},返回信息:{},入参:{}", token.getAccountId(), unitId, message, creativeParams.toJSONString());
|
|
|
if ("系统错误".equals(message) && count <= 3) {
|
|
|
log.info("第{}次重新创建程序化创意", count);
|
|
|
//系统错误,则重新执行
|
|
|
- return createProgramCreatives(token, creativeParams, strategy, count + 1);
|
|
|
+ return createProgramCreatives(token, creativeParams, strategy, campaignId, uuid, count + 1);
|
|
|
} else if (code == 400001 && "/rest/openapi/v2/creative/advanced/program/create调用已超日限,次日可恢复调用".equals(message)) {
|
|
|
String statDate = DateUtils.formatDate(new Date());
|
|
|
String programKey = token.getAccountId() + "_pcreativecount_" + statDate;
|
|
|
redisUtil.set(programKey, 1, 100000L);
|
|
|
updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
}
|
|
|
-
|
|
|
+ record.setStatus(-1);
|
|
|
+ kuaishouProgramCreativeLevelOperationRecordService.saveOrUpdate(record);
|
|
|
return false;
|
|
|
}
|
|
|
} catch (Exception e) {
|