|
@@ -6,7 +6,6 @@ import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
|
|
@@ -34,6 +33,7 @@ import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Random;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -89,9 +89,11 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
throw new Exception("请选择需要创建的视频");
|
|
|
}
|
|
|
|
|
|
+ Integer imageCount = requestJson.getInteger("imageCount");
|
|
|
|
|
|
Integer createType = requestJson.getInteger("createType"); // 创建类型 0 单品 1 混搭
|
|
|
Integer unitType = requestJson.getInteger("unitType"); // 7程序化。4自定义
|
|
|
+ List<List<String>> photoIdsList = null;
|
|
|
if (unitType == 4) {
|
|
|
if (Check.isNull(createType)) {
|
|
|
throw new Exception("请选择创意创建方式混搭、单品");
|
|
@@ -104,6 +106,12 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
if (createType == 1 && createCount * 15 != photoArr.size()) {
|
|
|
throw new Exception("混搭视频数量必须和创建数量保持倍数关系");
|
|
|
}
|
|
|
+ } else {
|
|
|
+ List<String> photoIds = JSONArray.parseObject(photoArr.toJSONString(), List.class);
|
|
|
+ photoIdsList = Lists.newArrayList(Lists.partition(photoIds, imageCount));
|
|
|
+ if (createCount != photoIdsList.size()) {
|
|
|
+ throw new Exception("程序化视频数量必须和创建数量保持倍数关系");
|
|
|
+ }
|
|
|
}
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
String userId = requestJson.getString("userId");
|
|
@@ -144,7 +152,6 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
startNumber = requestJson.getInteger("startNumber");
|
|
|
}
|
|
|
}
|
|
|
- Integer imageCount = requestJson.getInteger("imageCount");
|
|
|
|
|
|
List<KuaiShouGroupTemplate> templates = new ArrayList<>();
|
|
|
for (int i = 0; i < createCount; i++) {
|
|
@@ -160,6 +167,8 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
continue;
|
|
|
}
|
|
|
template.setPhotoIds(photoIds.toJSONString());
|
|
|
+ } else {
|
|
|
+ template.setPhotoIds(photoIdsList.get(i).toString());
|
|
|
}
|
|
|
String name = "";
|
|
|
if (!unitName.contains("{{序号}}")) {
|
|
@@ -638,6 +647,14 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
createJson.put("creative_tag", JSONArray.parseArray(template.getCreativeTag()));
|
|
|
}
|
|
|
|
|
|
+ JSONArray descriptionList = JSONArray.parseArray(template.getDescription());
|
|
|
+ String description = null;
|
|
|
+ if (!Check.isNull(descriptionList)) {
|
|
|
+ int number = new Random().nextInt(descriptionList.size());
|
|
|
+ description = descriptionList.getString(number);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
JSONArray creatives = new JSONArray();
|
|
|
Integer createType = template.getCreateType();
|
|
|
if (createType == 0) { // 单品
|
|
@@ -659,7 +676,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
json.put("photo_id", template.getPhotoId());
|
|
|
json.put("creative_material_type", materialType);
|
|
|
json.put("action_bar_text", template.getActionBarText());
|
|
|
- json.put("description", template.getDescription());
|
|
|
+ json.put("description", description);
|
|
|
if (!Check.isNull(template.getSiteId())) {
|
|
|
json.put("site_id", template.getSiteId());
|
|
|
}
|
|
@@ -681,7 +698,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
json.put("photo_id", template.getPhotoId());
|
|
|
json.put("creative_material_type", materialType);
|
|
|
json.put("action_bar_text", template.getActionBarText());
|
|
|
- json.put("description", template.getDescription());
|
|
|
+ json.put("description", description);
|
|
|
if (!Check.isNull(template.getSiteId())) {
|
|
|
json.put("site_id", template.getSiteId());
|
|
|
}
|
|
@@ -720,7 +737,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
json.put("photo_id", photoId);
|
|
|
json.put("creative_material_type", materialType);
|
|
|
json.put("action_bar_text", template.getActionBarText());
|
|
|
- json.put("description", template.getDescription());
|
|
|
+ json.put("description", description);
|
|
|
if (!Check.isNull(template.getSiteId())) {
|
|
|
json.put("site_id", template.getSiteId());
|
|
|
}
|
|
@@ -801,28 +818,25 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
|
//作品广告语
|
|
|
createJson.put("captions", getCaptions(template.getDescription()));
|
|
|
|
|
|
- List<List<KuaiShouVideoGet>> splitVideos = Lists.newArrayList(Lists.partition(videos, imageCount));
|
|
|
- for (List<KuaiShouVideoGet> splitVideo : splitVideos) {
|
|
|
- JSONArray photoList = new JSONArray();
|
|
|
- for (KuaiShouVideoGet video : splitVideo) {
|
|
|
- JSONObject photo = new JSONObject();
|
|
|
- photo.put("photo_id", video.getPhotoId());//视频 ID
|
|
|
- photo.put("cover_image_token", null);//封面图片 token,通过上传图片接口获得,不传值则直接使用视频的首帧作为封面图片
|
|
|
- photo.put("creative_material_type", video.getMaterialType());//1:竖版视频 2:横版视频
|
|
|
- photoList.add(photo);
|
|
|
- }
|
|
|
- createJson.put("photo_list", photoList);
|
|
|
- Map<String, Object> creativeMap = this.createProgramCreatives(accountId, accessToken, createJson, 1);
|
|
|
- Integer code = (Integer) creativeMap.get("code");
|
|
|
- if (code == 0) {
|
|
|
- updateTemplate.setCreativeStatus(2);
|
|
|
- updateTemplate.setCreativeReviewDetail("创建程序化2.0创意成功");
|
|
|
- } else {
|
|
|
- updateTemplate.setCreativeStatus(3);
|
|
|
- updateTemplate.setCreativeReviewDetail((String) creativeMap.get("message"));
|
|
|
- }
|
|
|
- this.updateById(updateTemplate);
|
|
|
+ JSONArray photoList = new JSONArray();
|
|
|
+ for (KuaiShouVideoGet video : videos) {
|
|
|
+ JSONObject photo = new JSONObject();
|
|
|
+ photo.put("photo_id", video.getPhotoId());//视频 ID
|
|
|
+ photo.put("cover_image_token", null);//封面图片 token,通过上传图片接口获得,不传值则直接使用视频的首帧作为封面图片
|
|
|
+ photo.put("creative_material_type", video.getMaterialType());//1:竖版视频 2:横版视频
|
|
|
+ photoList.add(photo);
|
|
|
+ }
|
|
|
+ createJson.put("photo_list", photoList);
|
|
|
+ Map<String, Object> creativeMap = this.createProgramCreatives(accountId, accessToken, createJson, 1);
|
|
|
+ Integer code = (Integer) creativeMap.get("code");
|
|
|
+ if (code == 0) {
|
|
|
+ updateTemplate.setCreativeStatus(2);
|
|
|
+ updateTemplate.setCreativeReviewDetail("创建程序化2.0创意成功");
|
|
|
+ } else {
|
|
|
+ updateTemplate.setCreativeStatus(3);
|
|
|
+ updateTemplate.setCreativeReviewDetail((String) creativeMap.get("message"));
|
|
|
}
|
|
|
+ this.updateById(updateTemplate);
|
|
|
}
|
|
|
|
|
|
/**
|