|
@@ -222,7 +222,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
|
|
|
Map<String, Object> groupMap = kuaishouInterfaceService.adUnitCreate(accessToken, accountId, groupJson);
|
|
|
if ((Integer) groupMap.get("code") != 0) {
|
|
|
logger.error("创建广告组失败,accountId:{},unitName:{}", accountId, unitName);
|
|
|
- throw new Exception("创建广告组失败");
|
|
|
+ return groupMap;
|
|
|
}
|
|
|
groupCreateTemplate.setUnitId((Long) groupMap.get("unitId"));
|
|
|
groupCreateTemplate.setUnitName(name);
|
|
@@ -284,7 +284,6 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
|
|
|
throw new Exception("未获取到token信息");
|
|
|
}
|
|
|
String accessToken = cTopOauthToken.getAccessToken();
|
|
|
-
|
|
|
Long unitId = requestJson.getLong("unitId");
|
|
|
if (Check.isNull(unitId)) {
|
|
|
logger.error("创建创意广告组为空,accountId:{}", accountId);
|
|
@@ -295,70 +294,75 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
|
|
|
}
|
|
|
createJson.put("unit_id", unitId);
|
|
|
|
|
|
- String videoUrl;
|
|
|
- String videoUploadType = requestJson.getString("videoUploadType");
|
|
|
- if ("2".equals(videoUploadType)) { // 本地上传视频
|
|
|
- videoUrl = videoService.localInsert(requestJson);
|
|
|
- } else {
|
|
|
- videoUrl = requestJson.getString("videoUrl");
|
|
|
- }
|
|
|
-
|
|
|
- if (Check.isNull(videoUrl)) {
|
|
|
- logger.error("创建创意视频为空,accountId:{}", accountId);
|
|
|
+ if (Check.isNull(requestJson.getString("description"))) {
|
|
|
+ logger.error("请填写广告语,accountId:{}", accountId);
|
|
|
returnMap.put("code", -1);
|
|
|
returnMap.put("success", false);
|
|
|
- returnMap.put("message", "请选择上传的视频");
|
|
|
+ returnMap.put("message", "请填写广告语");
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> videoMap = kuaishouInterfaceService.videoUpload(accountId, accessToken, videoUrl); // 上传视频到快手后台
|
|
|
- if ((Integer) videoMap.get("code") != 0) {
|
|
|
- logger.error("上传视频失败,accountId:{}", accountId);
|
|
|
- returnMap.put("code", -1);
|
|
|
- returnMap.put("success", false);
|
|
|
- returnMap.put("message", "上传视频失败");
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
- createJson.put("photo_id", videoMap.get("photoId"));
|
|
|
if (!Check.isNull(requestJson.getString("actionBarText"))) {
|
|
|
createJson.put("action_bar_text", requestJson.getString("actionBarText"));
|
|
|
}
|
|
|
|
|
|
- if (Check.isNull(requestJson.getString("description"))) {
|
|
|
- logger.error("请填写广告语,accountId:{}", accountId);
|
|
|
- returnMap.put("code", -1);
|
|
|
- returnMap.put("success", false);
|
|
|
- returnMap.put("message", "请填写广告语");
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
+ Integer creativeMaterialType = requestJson.getInteger("creativeMaterialType"); // 1 竖版视频 2 横版视频 3 贴片图片
|
|
|
+ createJson.put("creative_material_type", creativeMaterialType);
|
|
|
createJson.put("description", requestJson.getString("description"));
|
|
|
- if (!Check.isNull(requestJson.getString("clickTrackUrl"))) {
|
|
|
- createJson.put("click_track_url", requestJson.getString("clickTrackUrl"));
|
|
|
- }
|
|
|
+ String creativeName = requestJson.getString("creativeName");
|
|
|
+ Integer sceneId = requestJson.getInteger("sceneId");
|
|
|
+ if (sceneId == 2) { // 普通 广告
|
|
|
+ JSONObject localVideoJson = new JSONObject();
|
|
|
+ localVideoJson.put("videoType", requestJson.getString("videoType"));
|
|
|
+ localVideoJson.put("login_id", requestJson.getString("loginId"));
|
|
|
+ localVideoJson.put("videoUrl", requestJson.getString("videoUrl"));
|
|
|
+ localVideoJson.put("description", requestJson.getString("description"));
|
|
|
+ localVideoJson.put("positionType", requestJson.getString("positionType"));
|
|
|
+ String videoUrl = videoService.localInsert(localVideoJson); // 校验文件是否在本地有留存记录
|
|
|
+ if (Check.isNull(videoUrl)) {
|
|
|
+ logger.error("创建创意视频为空,accountId:{}", accountId);
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("message", "请选择上传的视频");
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
|
|
|
- if (!Check.isNull(requestJson.getString("showImpressionUrl"))) {
|
|
|
- createJson.put("impression_url", requestJson.getString("showImpressionUrl"));
|
|
|
- }
|
|
|
+ Map<String, Object> videoMap = kuaishouInterfaceService.videoUpload(accountId, accessToken, videoUrl); // 上传视频到快手后台
|
|
|
+ if ((Integer) videoMap.get("code") != 0) {
|
|
|
+ logger.error("上传视频失败,accountId:{}", accountId);
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("message", "上传视频失败");
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+ createJson.put("photo_id", videoMap.get("photoId"));
|
|
|
|
|
|
- JSONArray imageUrlArr = requestJson.getJSONArray("imageUrl");
|
|
|
- if (Check.isNull(imageUrlArr)) {
|
|
|
- logger.error("请选择封面图,accountId:{}", accountId);
|
|
|
- returnMap.put("code", -1);
|
|
|
- returnMap.put("success", false);
|
|
|
- returnMap.put("message", "请选择广告创意封面图");
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
|
|
|
- String creativeName = requestJson.getString("creativeName");
|
|
|
- for (int i = 0; i < imageUrlArr.size(); i++) {
|
|
|
- String imagePath;
|
|
|
- String imageUrl = imageUrlArr.get(i).toString();
|
|
|
- if (!Check.isNull(imageUrl)) {
|
|
|
- if ("2".equals(requestJson.getString("imageType"))) {
|
|
|
- imagePath = imageService.localInsert(imageUrl, requestJson);
|
|
|
- } else {
|
|
|
- imagePath = imageUrl;
|
|
|
+ if (!Check.isNull(requestJson.getString("clickTrackUrl"))) {
|
|
|
+ createJson.put("click_track_url", requestJson.getString("clickTrackUrl"));
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray imageUrlArr = requestJson.getJSONArray("imageUrl");
|
|
|
+ if (Check.isNull(imageUrlArr)) {
|
|
|
+ logger.error("请选择封面图,accountId:{}", accountId);
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("message", "请选择广告创意封面图");
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < imageUrlArr.size(); i++) {
|
|
|
+ String imageUrl = imageUrlArr.get(i).toString();
|
|
|
+ if (Check.isNull(imageUrl)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
+ JSONObject imageJson = new JSONObject();
|
|
|
+ imageJson.put("loginId", requestJson.getString("loginId"));
|
|
|
+ imageJson.put("videoUploadType", requestJson.getString("videoUploadType"));
|
|
|
+ imageJson.put("url", imageUrl);
|
|
|
+ imageJson.put(" positionType", requestJson.getString(" positionType"));
|
|
|
+ String imagePath = imageService.localInsert(imageJson);
|
|
|
|
|
|
Map<String, Object> imageMap = kuaishouInterfaceService.imageUpload(accountId, accessToken, imagePath, 0);
|
|
|
if ((Integer) imageMap.get("code") != 0) {
|
|
@@ -371,17 +375,112 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
|
|
|
createJson.put("creative_name", creativeName + "_" + i);
|
|
|
Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson);
|
|
|
if ((Integer) creativeMap.get("code") != 0) {
|
|
|
- throw new Exception("批量创建创意失败");
|
|
|
+ return creativeMap;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ } else if (sceneId == 3) { // 后贴片 广告
|
|
|
+ if (!Check.isNull(requestJson.getString("impressionUrl"))) {
|
|
|
+ createJson.put("impression_url", requestJson.getString("impressionUrl"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Check.isNull(requestJson.getString("adPhotoPlayedT3sUrl"))) {
|
|
|
+ createJson.put("ad_photo_played_t3s_url", requestJson.getString("adPhotoPlayedT3sUrl"));
|
|
|
+ }
|
|
|
+ if (creativeMaterialType != 3) { // 后贴片 视频集合
|
|
|
+ JSONArray haveSinglePicVideoUrlArr = requestJson.getJSONArray("haveSinglePicVideoUrl");
|
|
|
+ if (Check.isNull(haveSinglePicVideoUrlArr)) {
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("message", "请选择视频素材进行上传素材");
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < haveSinglePicVideoUrlArr.size(); i++) {
|
|
|
+ String haveSinglePicVideoUrl = haveSinglePicVideoUrlArr.get(i).toString();
|
|
|
+ if (Check.isNull(haveSinglePicVideoUrl)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JSONObject haveLocalVideoJson = new JSONObject();
|
|
|
+ haveLocalVideoJson.put("positionType", requestJson.getString("positionType"));
|
|
|
+ haveLocalVideoJson.put("videoUrl", haveSinglePicVideoUrl);
|
|
|
+ haveLocalVideoJson.put("description", requestJson.getString("description"));
|
|
|
+ haveLocalVideoJson.put("login_id", requestJson.getString("loginId"));
|
|
|
+ haveLocalVideoJson.put("videoType", requestJson.getString("videoType"));
|
|
|
+ String havaVideoUrl = videoService.localInsert(haveLocalVideoJson); // 校验文件是否在本地有留存记录
|
|
|
+ if (Check.isNull(havaVideoUrl)) {
|
|
|
+ logger.error("创建创意视频为空,accountId:{}", accountId);
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ returnMap.put("message", "请选择上传的视频");
|
|
|
+ returnMap.put("success", false);
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> videoMap = kuaishouInterfaceService.videoUpload(accountId, accessToken, havaVideoUrl); // 上传视频到快手后台
|
|
|
+ if ((Integer) videoMap.get("code") != 0) {
|
|
|
+ logger.error("上传视频失败,accountId:{}", accountId);
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("message", "上传视频失败");
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+ createJson.put("photo_id", videoMap.get("photoId"));
|
|
|
+ createJson.put("creative_name", creativeName + "_" + i);
|
|
|
+ Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson);
|
|
|
+ if ((Integer) creativeMap.get("code") != 0) {
|
|
|
+ throw new Exception("批量创建创意失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else { // 后贴片图片素材
|
|
|
+ JSONArray haveSinglePicimagesListArr = requestJson.getJSONArray("haveSinglePicimagesList");
|
|
|
+ if (Check.isNull(haveSinglePicimagesListArr)) {
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("message", "请选择后贴片图片素材进行上传");
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < haveSinglePicimagesListArr.size(); i++) {
|
|
|
+ String imageUrl = haveSinglePicimagesListArr.get(i).toString();
|
|
|
+ if (Check.isNull(imageUrl)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JSONObject imageJson = new JSONObject();
|
|
|
+ imageJson.put("url", imageUrl);
|
|
|
+ imageJson.put(" positionType", requestJson.getString(" positionType"));
|
|
|
+ imageJson.put("loginId", requestJson.getString("loginId"));
|
|
|
+ imageJson.put("videoUploadType", requestJson.getString("videoUploadType"));
|
|
|
+
|
|
|
+ String imagePath = imageService.localInsert(imageJson);
|
|
|
+
|
|
|
+ Map<String, Object> imageMap = kuaishouInterfaceService.imageUpload(accountId, accessToken, imagePath, 0);
|
|
|
+ if ((Integer) imageMap.get("code") != 0) {
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("message", "上传图片失败");
|
|
|
+ returnMap.put("code", -1);
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+ createJson.put("creative_name", creativeName + "_" + i);
|
|
|
+ JSONArray image_tokens = new JSONArray();
|
|
|
+ image_tokens.add(imageMap.get("imageToken"));
|
|
|
+
|
|
|
+
|
|
|
+ createJson.put("image_tokens", image_tokens);
|
|
|
+ Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson);
|
|
|
+ if ((Integer) creativeMap.get("code") != 0) {
|
|
|
+ return creativeMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
returnMap.put("code", 0);
|
|
|
returnMap.put("success", true);
|
|
|
returnMap.put("message", "创建创意成功");
|
|
|
- return returnMap;
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (
|
|
|
+ Exception e) {
|
|
|
returnMap.put("code", -1);
|
|
|
returnMap.put("success", false);
|
|
|
returnMap.put("message", "批量创建广告创意失败");
|
|
@@ -414,7 +513,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
|
|
|
queryWrapper.eq("account_id", accountId).eq("campaign_id", campaignId).orderByDesc("create_time");
|
|
|
queryWrapper.last("limit 1");
|
|
|
KuaiShouCampaignCreate campaignCreate = campaignCreateMapper.selectOne(queryWrapper);
|
|
|
- if(Check.isNull(campaignCreate)){
|
|
|
+ if (Check.isNull(campaignCreate)) {
|
|
|
continue;
|
|
|
}
|
|
|
optionsJson.put("label", campaignCreate.getCampaignName());
|