|
@@ -16,6 +16,7 @@ import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunIn
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -23,10 +24,7 @@ import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -89,15 +87,15 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
int timeStart = -10;
|
|
|
int timeEnd = -5;
|
|
|
Long now = System.currentTimeMillis();
|
|
|
- String startTime = DateUtils.formatDate(new Date(now + timeStart * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
- String endTime = DateUtils.formatDate(new Date(now + timeEnd * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String startTime = DateUtils.formatDate(new Date(now + timeStart * 60 * 1000), DateUtils.NEW_FORMAT);
|
|
|
+ String endTime = DateUtils.formatDate(new Date(now + timeEnd * 60 * 1000), DateUtils.NEW_FORMAT);
|
|
|
|
|
|
//2:判定账户是否单一应用
|
|
|
Integer singleAppid = strategy.getSingleAppid();
|
|
|
if (null != singleAppid && singleAppid == 0) {
|
|
|
//非单一应用
|
|
|
String appidString = strategy.getAppIdArray();
|
|
|
- JSONArray appIdArray = JSONArray.parseArray(appidString);
|
|
|
+ JSONArray appIdArray = JSON.parseArray(appidString);
|
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
|
for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
|
|
@@ -173,7 +171,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
unitCnt++;
|
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
|
- Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
|
+ Long appId = JSON.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
@@ -205,7 +203,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
public void autoCreateProgramCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, JSONObject params) {
|
|
|
strategy.setUnitType(7);
|
|
|
String replaceString = getReplaceStringByCreateType(strategy, createType);
|
|
|
- ;
|
|
|
Long accountId = strategy.getAccountId();
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
|
if (null == token) {
|
|
@@ -217,15 +214,15 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
int timeStart = -10;
|
|
|
int timeEnd = -5;
|
|
|
Long now = System.currentTimeMillis();
|
|
|
- String startTime = DateUtils.formatDate(new Date(now + timeStart * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
- String endTime = DateUtils.formatDate(new Date(now + timeEnd * 60 * 1000), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String startTime = DateUtils.formatDate(new Date(now + timeStart * 60 * 1000), DateUtils.NEW_FORMAT);
|
|
|
+ String endTime = DateUtils.formatDate(new Date(now + timeEnd * 60 * 1000), DateUtils.NEW_FORMAT);
|
|
|
|
|
|
//2:判定账户是否单一应用
|
|
|
Integer singleAppid = strategy.getSingleAppid();
|
|
|
if (null != singleAppid && singleAppid == 0) {
|
|
|
//非单一应用
|
|
|
String appidString = strategy.getAppIdArray();
|
|
|
- JSONArray appIdArray = JSONArray.parseArray(appidString);
|
|
|
+ JSONArray appIdArray = JSON.parseArray(appidString);
|
|
|
if (null != appIdArray && !appIdArray.isEmpty()) {
|
|
|
for (int i = 0; i < appIdArray.size(); i++) {
|
|
|
AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
|
|
@@ -244,6 +241,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (null == allVideos) {
|
|
|
return;
|
|
|
}
|
|
|
+ //判定创意创建是否超限
|
|
|
+ KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
+ if (null != overrunInfo) {
|
|
|
+ log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN");
|
|
|
//创建组
|
|
|
String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
@@ -261,12 +264,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//创意
|
|
|
List<List<KuaiShouVideoGet>> splitVideos = new ListUtils<KuaiShouVideoGet>().split(allVideos, allVideos.size() / 5);
|
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
|
- KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
- if (null != overrunInfo) {
|
|
|
- log.info("该账户创意创建已超限=>accountId:{}", accountId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j);
|
|
|
createProgramCreative(token, creativeParams);
|
|
|
}
|
|
@@ -296,7 +293,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
unitCnt++;
|
|
|
String unitName = unitNamePrefix + "-" + unitCnt;
|
|
|
- Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
|
+ Long appId = JSON.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
|
+ // 每个组,搭配n个创意
|
|
|
+ List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
|
|
|
+ if ((null == cutFrameList || cutFrameList.isEmpty())) {
|
|
|
+ log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
@@ -306,13 +309,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
continue;
|
|
|
}
|
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
|
-
|
|
|
- // 每个组,搭配5个创意
|
|
|
- List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
|
|
|
- if ((null == cutFrameList || cutFrameList.isEmpty())) {
|
|
|
- log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
|
|
|
- continue;
|
|
|
- }
|
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
|
createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt());
|
|
|
}
|
|
@@ -325,7 +321,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, creativeParams.toJSONString(), headers);
|
|
|
- JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ JSONObject resultJson = JSON.parseObject(result);
|
|
|
log.info("创建程序化创意返回结果:{}", resultJson);
|
|
|
if (Check.isNull(resultJson)) {
|
|
|
log.error("程序化创意创意异常:api接口返回为空");
|
|
@@ -338,7 +334,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
return;
|
|
|
}
|
|
|
log.info("创建程序化创意成功");
|
|
|
- return;
|
|
|
}
|
|
|
|
|
|
private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt) {
|
|
@@ -351,7 +346,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
JSONArray coverImageTokens = new JSONArray();
|
|
|
for (KuaiShouVideoGet videoGet : list) {
|
|
|
List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoGet.getSignature());
|
|
|
- if (null != cutFrameList && !cutFrameList.isEmpty()) {
|
|
|
+ if (Check.isNull(cutFrameList)) {
|
|
|
MaterialCutFrame cutFrame = cutFrameList.get(0);
|
|
|
String imageToken = getImageToken(cutFrame.getUrl(), cutFrame.getSignature(), token.getAccountId(), token.getAccessToken());
|
|
|
if (!Check.isNull(imageToken)) {
|
|
@@ -365,12 +360,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
verticalPhotoIds.add(videoGet.getPhotoId());
|
|
|
}
|
|
|
}
|
|
|
- if (!horizontalPhotoIds.isEmpty()) {
|
|
|
- programJson.put("horizontal_photo_ids", horizontalPhotoIds);
|
|
|
- }
|
|
|
- if (!verticalPhotoIds.isEmpty()) {
|
|
|
- programJson.put("vertical_photo_ids", verticalPhotoIds);
|
|
|
- }
|
|
|
+ programJson.put("horizontal_photo_ids", horizontalPhotoIds);
|
|
|
+ programJson.put("vertical_photo_ids", verticalPhotoIds);
|
|
|
if (coverImageTokens.size() >= 5) {
|
|
|
coverImageTokens.remove(0);
|
|
|
}
|
|
@@ -380,15 +371,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (!Check.isNull(strategy.getStickerTitle())) {
|
|
|
programJson.put("sticker_styles", strategy.getStickerTitle());
|
|
|
}
|
|
|
-// if (!Check.isNull(programCreativeJson.getJSONArray("cover_slogans"))) {
|
|
|
-// programJson.put("cover_slogans", programCreativeJson.getJSONArray("cover_slogans"));
|
|
|
-// }
|
|
|
+
|
|
|
if (!Check.isNull(strategy.getActionBarText())) {
|
|
|
programJson.put("action_bar", strategy.getActionBarText());
|
|
|
}
|
|
|
-// if (!Check.isNull(programCreativeJson.getJSONArray("captions"))) {
|
|
|
-// programJson.put("captions", programCreativeJson.getJSONArray("captions"));
|
|
|
-// }
|
|
|
if (!Check.isNull(strategy.getClickTrackUrl())) {
|
|
|
programJson.put("click_url", strategy.getClickTrackUrl());
|
|
|
}
|
|
@@ -397,9 +383,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
if (!Check.isNull(strategy.getCreativeCategory())) {
|
|
|
programJson.put("creative_category", strategy.getCreativeCategory());
|
|
|
- }
|
|
|
- if (!Check.isNull(strategy.getCreativeTag())) {
|
|
|
- programJson.put("creative_tag", JSONArray.parseArray(strategy.getCreativeTag()));
|
|
|
+ programJson.put("creative_tag", JSON.parseArray(strategy.getCreativeTag()));
|
|
|
}
|
|
|
return programJson;
|
|
|
}
|
|
@@ -408,14 +392,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
List<KuaiShouVideoGet> generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), null, null);
|
|
|
//2:查询特定素材
|
|
|
List<KuaiShouVideoGet> customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
|
|
|
- if (null == generalVideos || generalVideos.isEmpty() || null == customVideos || customVideos.isEmpty()) {
|
|
|
+ if ((null == generalVideos || generalVideos.isEmpty()) &&(null == customVideos || customVideos.isEmpty())) {
|
|
|
log.info("账户:{},appId({}){}到{}这段时间没有上新素材", strategy.getAccountId(), appInfo.getAppId(), startTime, endTime);
|
|
|
- return null;
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
//合并
|
|
|
- if (null == generalVideos || generalVideos.isEmpty()) {
|
|
|
+ if (null == generalVideos||generalVideos.isEmpty()) {
|
|
|
return customVideos;
|
|
|
- } else if (null == customVideos || customVideos.isEmpty()) {
|
|
|
+ } else if (null == customVideos||customVideos.isEmpty()) {
|
|
|
return generalVideos;
|
|
|
} else {
|
|
|
generalVideos.addAll(customVideos);
|
|
@@ -467,13 +451,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
timestamp = DateUtils.formatDate(campaignDate, "yyyyMMddHHmmss");
|
|
|
campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(), 1);
|
|
|
}
|
|
|
- Long newCampaignId = 0L;
|
|
|
- if (null != campaignList && campaignList.size() > 0) {
|
|
|
+
|
|
|
+ if (null != campaignList && !campaignList.isEmpty()) {
|
|
|
for (int i = 0; i < campaignList.size(); i++) {
|
|
|
JSONObject jsonObject = campaignList.getJSONObject(i);
|
|
|
if (jsonObject.getString("campaign_name").contains(replaceString)) {
|
|
|
- newCampaignId = jsonObject.getLong("campaign_id");
|
|
|
- return newCampaignId;
|
|
|
+ return jsonObject.getLong("campaign_id");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -493,8 +476,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
log.info("计划创建失败=>message:{}", message);
|
|
|
return null;
|
|
|
}
|
|
|
- newCampaignId = (Long) campaignCreateResult.get("campaignId");
|
|
|
- return newCampaignId;
|
|
|
+ return (Long) campaignCreateResult.get("campaignId");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -516,12 +498,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
//应用商店列表
|
|
|
if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
|
|
|
- unitParams.put("app_store", JSONArray.parseArray(strategy.getAppStore()));
|
|
|
+ unitParams.put("app_store", JSON.parseArray(strategy.getAppStore()));
|
|
|
}
|
|
|
unitParams.put("ocpx_action_type", strategy.getOcpxActionType());
|
|
|
|
|
|
-
|
|
|
- // 在本策略中,都是 OCPM 的出价方式
|
|
|
//出价
|
|
|
if (null != strategy.getBid() && strategy.getBid() != 0) {
|
|
|
unitParams.put("bid", strategy.getBid());
|
|
@@ -552,9 +532,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//资源位置
|
|
|
Integer sceneId = null;
|
|
|
String scenceIdString = strategy.getSceneId();
|
|
|
- if (null != scenceIdString && !scenceIdString.trim().equals(scenceIdString) && Check.isNull(JSONArray.parseArray(scenceIdString))) {
|
|
|
- sceneId = JSONArray.parseArray(strategy.getSceneId()).getInteger(0);
|
|
|
- unitParams.put("scene_id", JSONArray.parseArray(strategy.getSceneId()));
|
|
|
+ if (!Check.isNull(scenceIdString) && Check.isNull(JSON.parseArray(scenceIdString))) {
|
|
|
+ sceneId = JSON.parseArray(strategy.getSceneId()).getInteger(0);
|
|
|
+ unitParams.put("scene_id", JSON.parseArray(strategy.getSceneId()));
|
|
|
}
|
|
|
|
|
|
//投放开始时间
|
|
@@ -569,9 +549,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (!Check.isNull(strategy.getScheduleTime())) {
|
|
|
unitParams.put("schedule_time", strategy.getScheduleTime());
|
|
|
}
|
|
|
-// if (!Check.isNull(strategy.getLong("day_budget"))) {
|
|
|
-// unitParams.put("day_budget", groupCreateJson.getLong("day_budget")); //投放时间段
|
|
|
-// }
|
|
|
//转化id
|
|
|
if (!Check.isNull(strategy.getConvertId())) {
|
|
|
unitParams.put("convert_id", strategy.getConvertId());
|
|
@@ -608,19 +585,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (!Check.isNull(strategy.getSiteType())) {
|
|
|
unitParams.put("site_type", strategy.getSiteType());
|
|
|
}
|
|
|
-// if (!Check.isNull(strategy.getInteger("target_action_type")) || !Check.isNull(strategy.getString("code"))) {
|
|
|
-// JSONObject gift_data = new JSONObject();
|
|
|
-// if (!Check.isNull(groupCreateJson.getInteger("target_action_type"))) {
|
|
|
-// gift_data.put("target_action_type", groupCreateJson.getInteger("target_action_type"));
|
|
|
-// }
|
|
|
-// if (!Check.isNull(groupCreateJson.getString("code"))) {
|
|
|
-// gift_data.put("code", groupCreateJson.getString("code"));
|
|
|
-// }
|
|
|
-// unitParams.put("gift_data", gift_data); //游戏礼包码
|
|
|
-// }
|
|
|
-// if (!Check.isNull(groupCreateJson.getBoolean("video_landing_page"))) {
|
|
|
-// unitParams.put("video_landing_page", groupCreateJson.getBoolean("video_landing_page")); //是否使用落地页前置功能
|
|
|
-// }
|
|
|
//智能定向
|
|
|
if (!Check.isNull(strategy.getAutoTarget())) {
|
|
|
unitParams.put("auto_target", strategy.getAutoTarget());
|
|
@@ -629,15 +593,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (!Check.isNull(strategy.getAutoCreatePhoto())) {
|
|
|
unitParams.put("auto_create_photo", strategy.getAutoCreatePhoto());
|
|
|
}
|
|
|
-// if (!Check.isNull(strategy.getItemId())) {
|
|
|
-// unitParams.put("item_id", groupCreateJson.getLong("item_id")); //电商关联Id (小店通)
|
|
|
-// }
|
|
|
-// if (!Check.isNull(groupCreateJson.getLong("merchant_item_put_type"))) {
|
|
|
-// unitParams.put("merchant_item_put_type", groupCreateJson.getLong("merchant_item_put_type")); //电商广告投放类型(小店通)
|
|
|
-// }
|
|
|
-// if (!Check.isNull(groupCreateJson.getLong("fiction_id"))) {
|
|
|
-// unitParams.put("fiction_id", groupCreateJson.getLong("fiction_id")); //小说ID
|
|
|
-// }
|
|
|
|
|
|
if (unitType == 7) {
|
|
|
//是否开启智能抽帧
|
|
@@ -673,10 +628,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
// 设置定向内容
|
|
|
JSONObject targetJsonObject = new JSONObject();
|
|
|
if (null != strategy.getRegion() && !"".equals(strategy.getRegion())) {
|
|
|
- targetJsonObject.put("region", JSONArray.parseArray(strategy.getRegion()));
|
|
|
+ targetJsonObject.put("region", JSON.parseArray(strategy.getRegion()));
|
|
|
}
|
|
|
if (null != strategy.getAgesRange() && !"".equals(strategy.getAgesRange())) {
|
|
|
- targetJsonObject.put("ages_range", JSONArray.parseArray(strategy.getAgesRange()));
|
|
|
+ targetJsonObject.put("ages_range", JSON.parseArray(strategy.getAgesRange()));
|
|
|
}
|
|
|
if (null != strategy.getGender()) {
|
|
|
targetJsonObject.put("gender", strategy.getGender());
|
|
@@ -691,20 +646,20 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
targetJsonObject.put("ios_osv", strategy.getIosOsv());
|
|
|
}
|
|
|
if (null != strategy.getDeviceBrand() && !"".equals(strategy.getDeviceBrand()) && !"[]".equals(strategy.getDeviceBrand())) {
|
|
|
- targetJsonObject.put("device_brand", JSONArray.parseArray(strategy.getDeviceBrand()));
|
|
|
+ targetJsonObject.put("device_brand", JSON.parseArray(strategy.getDeviceBrand()));
|
|
|
}
|
|
|
if (null != strategy.getDevicePrice() && !"".equals(strategy.getDevicePrice()) && !"[]".equals(strategy.getDevicePrice())) {
|
|
|
- targetJsonObject.put("device_price", JSONArray.parseArray(strategy.getDevicePrice()));
|
|
|
+ targetJsonObject.put("device_price", JSON.parseArray(strategy.getDevicePrice()));
|
|
|
}
|
|
|
if (null != strategy.getPopulation() && !"".equals(strategy.getPopulation())) {
|
|
|
- JSONArray population = JSONArray.parseArray(strategy.getPopulation());
|
|
|
+ JSONArray population = JSON.parseArray(strategy.getPopulation());
|
|
|
targetJsonObject.put("population", population);
|
|
|
}
|
|
|
if (null != strategy.getFilterConvertedLevel() && strategy.getFilterConvertedLevel() != 0) {
|
|
|
targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
|
|
|
}
|
|
|
if (null != strategy.getExcludePopulation() && !"".equals(strategy.getExcludePopulation())) {
|
|
|
- JSONArray excludePopulation = JSONArray.parseArray(strategy.getExcludePopulation());
|
|
|
+ JSONArray excludePopulation = JSON.parseArray(strategy.getExcludePopulation());
|
|
|
targetJsonObject.put("exclude_population", excludePopulation);
|
|
|
}
|
|
|
//是否开启智能扩量
|
|
@@ -738,12 +693,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
// 地域
|
|
|
String regionString = strategy.getRegion();
|
|
|
if (null != regionString && !"".equals(regionString.trim())) {
|
|
|
- target.put("region", JSONArray.parseArray(regionString));
|
|
|
+ target.put("region", JSON.parseArray(regionString));
|
|
|
}
|
|
|
String districtIdString = strategy.getDistrictIds();
|
|
|
// 商圈定向
|
|
|
if (null != districtIdString && !"".equals(districtIdString.trim())) {
|
|
|
- target.put("district_ids", JSONArray.parseArray(districtIdString));
|
|
|
+ target.put("district_ids", JSON.parseArray(districtIdString));
|
|
|
}
|
|
|
// 用户类型
|
|
|
if (null != strategy.getUserType()) {
|
|
@@ -759,7 +714,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
// 固定年龄段
|
|
|
String ageRangeString = strategy.getAgesRange();
|
|
|
if (null != ageRangeString && !"".equals(ageRangeString.trim())) {
|
|
|
- target.put("ages_range", JSONArray.parseArray(ageRangeString));
|
|
|
+ target.put("ages_range", JSON.parseArray(ageRangeString));
|
|
|
}
|
|
|
// 性别
|
|
|
if (null != strategy.getGender()) {
|
|
@@ -784,12 +739,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
// 设备品牌
|
|
|
String deviceBrandString = strategy.getDeviceBrand();
|
|
|
if (null != deviceBrandString && !"".equals(deviceBrandString.trim())) {
|
|
|
- target.put("device_brand", JSONArray.parseArray(deviceBrandString));
|
|
|
+ target.put("device_brand", JSON.parseArray(deviceBrandString));
|
|
|
}
|
|
|
// 设备价格
|
|
|
String devicePriceString = strategy.getDevicePrice();
|
|
|
if (null != devicePriceString && !"".equals(devicePriceString.trim())) {
|
|
|
- target.put("device_price", JSONArray.parseArray(devicePriceString));
|
|
|
+ target.put("device_price", JSON.parseArray(devicePriceString));
|
|
|
}
|
|
|
if (sceneId != 5) {
|
|
|
// 商业兴趣类型
|
|
@@ -799,17 +754,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
// 商业兴趣
|
|
|
String businessInterestString = strategy.getBusinessInterest();
|
|
|
if (null != businessInterestString && !"".equals(businessInterestString.trim())) {
|
|
|
- target.put("business_interest", JSONArray.parseArray(businessInterestString));
|
|
|
+ target.put("business_interest", JSON.parseArray(businessInterestString));
|
|
|
}
|
|
|
// 网红粉丝
|
|
|
String fansStarString = strategy.getFansStar();
|
|
|
if (null != fansStarString && !"".equals(fansStarString.trim())) {
|
|
|
- target.put("fans_star", JSONArray.parseArray(fansStarString));
|
|
|
+ target.put("fans_star", JSON.parseArray(fansStarString));
|
|
|
}
|
|
|
// 兴趣视频用户
|
|
|
String interestVideoString = strategy.getInterestVideo();
|
|
|
if (null != interestVideoString && !"".equals(interestVideoString.trim())) {
|
|
|
- target.put("interest_video", JSONArray.parseArray(interestVideoString));
|
|
|
+ target.put("interest_video", JSON.parseArray(interestVideoString));
|
|
|
}
|
|
|
// 过滤已转化人群
|
|
|
if (null != strategy.getFilterConvertedLevel()) {
|
|
@@ -818,53 +773,54 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
// 开启智能扩量
|
|
|
if (null != strategy.getIsOpen() && strategy.getIsOpen() == 1) {
|
|
|
- JSONObject intelli_extend = new JSONObject();
|
|
|
- intelli_extend.put("is_open", strategy.getIsOpen());
|
|
|
+ JSONObject intelliExtend = new JSONObject();
|
|
|
+ intelliExtend.put("is_open", strategy.getIsOpen());
|
|
|
// 不可突破年龄
|
|
|
if (!Check.isNull(strategy.getNoAgeBreak())) {
|
|
|
- intelli_extend.put("no_age_break", strategy.getNoAgeBreak());
|
|
|
+ intelliExtend.put("no_age_break", strategy.getNoAgeBreak());
|
|
|
}
|
|
|
// 不可突破性别
|
|
|
if (!Check.isNull(strategy.getNoGenderBreak())) {
|
|
|
- intelli_extend.put("no_gender_break", strategy.getNoGenderBreak());
|
|
|
+ intelliExtend.put("no_gender_break", strategy.getNoGenderBreak());
|
|
|
}
|
|
|
// 不可突破地域
|
|
|
if (!Check.isNull(strategy.getNoAreaBreak())) {
|
|
|
- intelli_extend.put("no_area_break", strategy.getNoAreaBreak());
|
|
|
+ intelliExtend.put("no_area_break", strategy.getNoAreaBreak());
|
|
|
}
|
|
|
- target.put("intelli_extend", intelli_extend); // 智能扩量
|
|
|
+ // 智能扩量
|
|
|
+ target.put("intelli_extend", intelliExtend);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
// APP行为-按分类
|
|
|
String appInterestString = strategy.getAppInterest();
|
|
|
if (null != appInterestString && !"".equals(appInterestString.trim())) {
|
|
|
- target.put("app_interest", JSONArray.parseArray(appInterestString));
|
|
|
+ target.put("app_interest", JSON.parseArray(appInterestString));
|
|
|
}
|
|
|
// APP行为-按APP名称
|
|
|
String appIdsString = strategy.getAppIds();
|
|
|
if (null != appIdsString && !"".equals(appIdsString.trim())) {
|
|
|
- target.put("app_ids", JSONArray.parseArray(appIdsString));
|
|
|
+ target.put("app_ids", JSON.parseArray(appIdsString));
|
|
|
}
|
|
|
|
|
|
// 人群包定向
|
|
|
String populationString = strategy.getPopulation();
|
|
|
if (null != populationString && !"".equals(populationString.trim())) {
|
|
|
- target.put("population", JSONArray.parseArray(populationString));
|
|
|
+ target.put("population", JSON.parseArray(populationString));
|
|
|
}
|
|
|
// 人群包排除
|
|
|
String excludePopulationString = strategy.getExcludePopulation();
|
|
|
if (null != excludePopulationString && !"".equals(excludePopulationString.trim())) {
|
|
|
- target.put("exclude_population", JSONArray.parseArray(excludePopulationString));
|
|
|
+ target.put("exclude_population", JSON.parseArray(excludePopulationString));
|
|
|
}
|
|
|
// 付费人群包id
|
|
|
String paidAudienceString = strategy.getPaidAudience();
|
|
|
if (null != paidAudienceString && !"".equals(paidAudienceString.trim())) {
|
|
|
- target.put("paid_audience", JSONArray.parseArray(paidAudienceString));
|
|
|
+ target.put("paid_audience", JSON.parseArray(paidAudienceString));
|
|
|
}
|
|
|
if (Check.isNull(strategy.getBehaviorInterest())) {
|
|
|
// TODO 只是单独结构体 后续需要优化
|
|
|
- target.put("behavior_interest", JSONObject.parseObject(strategy.getBehaviorInterest()));
|
|
|
+ target.put("behavior_interest", JSON.parseObject(strategy.getBehaviorInterest()));
|
|
|
}
|
|
|
return target;
|
|
|
}
|
|
@@ -894,8 +850,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
// 根据imageUrl 和 imageCode,获取 imageToken (创建创意用)
|
|
|
KuaiShouImageGet imageGet = imageGetService.getOneByParams(null, imageCode);
|
|
|
if ((null == imageGet) || ("".equals(imageGet.getImageToken()))) {
|
|
|
- // 如果取不到image_token
|
|
|
- // 则调用上传url的方法 kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
|
|
|
+ /**
|
|
|
+ * 如果取不到image_token
|
|
|
+ * 则调用上传url的方法 kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
|
|
|
+ */
|
|
|
return materialUploadService.kuauiShouImageUpload(imageUrl, imageCode, accountId, token);
|
|
|
}
|
|
|
return imageGet.getImageToken();
|
|
@@ -922,11 +880,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
creativeParams.put("expose_tag", strategy.getExposeTag());
|
|
|
}
|
|
|
// 广告标签2期
|
|
|
- if (null != strategy.getNewExposeTag() && !"".equals(strategy.getNewExposeTag())) {
|
|
|
- creativeParams.put("new_expose_tag", JSONArray.parseArray(strategy.getNewExposeTag()));
|
|
|
+ if (Check.isNull(strategy.getNewExposeTag())) {
|
|
|
+ creativeParams.put("new_expose_tag", JSON.parseArray(strategy.getNewExposeTag()));
|
|
|
}
|
|
|
// 安卓下载中间页ID
|
|
|
- if (null != strategy.getSiteId()) {
|
|
|
+ if (Check.isNull(strategy.getSiteId())) {
|
|
|
creativeParams.put("site_id", strategy.getSiteId());
|
|
|
}
|
|
|
if (null != strategy.getClickTrackUrl() && !"".equals(strategy.getClickTrackUrl())) {
|
|
@@ -946,7 +904,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
creativeParams.put("creative_category", strategy.getCreativeCategory());
|
|
|
}
|
|
|
if (null != strategy.getCreativeTag() && !"".equals(strategy.getCreativeTag())) {
|
|
|
- creativeParams.put("creative_tag", JSONArray.parseArray(strategy.getCreativeTag()));
|
|
|
+ creativeParams.put("creative_tag", JSON.parseArray(strategy.getCreativeTag()));
|
|
|
}
|
|
|
return creativeParams;
|
|
|
}
|