|
@@ -8,47 +8,26 @@ import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
|
|
|
|
-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.AiKuaishouUnitLevelOperationRecord;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
|
|
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
|
|
import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
|
|
import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
|
|
import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreativeLevelOperationRecordService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouUnitLevelOperationRecordService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
|
|
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
|
|
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.entity.KuaiShouVideoGet;
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
|
+import org.jeecg.common.util.RedisUtil;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
@@ -79,8 +58,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
private IAiKuaishouUnitLevelOperationRecordService unitLevelOperationRecordService;
|
|
private IAiKuaishouUnitLevelOperationRecordService unitLevelOperationRecordService;
|
|
@Autowired
|
|
@Autowired
|
|
private IAiKuaishouCreativeLevelOperationRecordService creativeLevelOperationRecordService;
|
|
private IAiKuaishouCreativeLevelOperationRecordService creativeLevelOperationRecordService;
|
|
- @Autowired
|
|
|
|
- private IKuaishouLandpagePackageService landpagePackageService;
|
|
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建自定义创意
|
|
* 创建自定义创意
|
|
@@ -121,6 +99,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
|
|
if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setClickTrackUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
strategy.setImpressionUrl(appInfo.getTrackUrl());
|
|
@@ -148,8 +127,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
unitCnt++;
|
|
unitCnt++;
|
|
//开始创建组+创意
|
|
//开始创建组+创意
|
|
- String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, unitCnt);
|
|
|
|
|
|
+ String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, videoItem.getPhotoName(), "unit", newCampaignId);
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
@@ -206,9 +184,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
unitCnt++;
|
|
unitCnt++;
|
|
- String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, unitCnt);
|
|
|
|
- Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
|
|
|
|
+ String unitName = getName(strategy.getGroupName(), strategy, createType, null, videoItem.getPhotoName(), "unit", newCampaignId);
|
|
|
|
+
|
|
|
|
+ Long appId = null;
|
|
|
|
+ if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
|
|
|
|
+ appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
@@ -216,6 +198,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
|
|
BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
unitLevelOperationRecord.setGroupName(unitName);
|
|
|
|
+ if (!Check.isNull(strategy.getCpaBid())) {
|
|
|
|
+ unitLevelOperationRecord.setCpaBid(Integer.valueOf(strategy.getCpaBid() + ""));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(strategy.getBid())) {
|
|
|
|
+ unitLevelOperationRecord.setBid(Integer.valueOf(strategy.getBid() + ""));
|
|
|
|
+ }
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setCreateTime(new Date());
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
unitLevelOperationRecord.setMessage(unitMessage);
|
|
@@ -275,6 +263,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
|
|
String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
|
|
String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
|
|
String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
|
|
|
|
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ String key = token.getAccountId() + "_ProgramCreative" + "_" + nowDate;
|
|
|
|
+
|
|
|
|
|
|
if (null != singleAppid && singleAppid == 0) {
|
|
if (null != singleAppid && singleAppid == 0) {
|
|
//多应用
|
|
//多应用
|
|
@@ -310,9 +301,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
//创建组+创意
|
|
//创建组+创意
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
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());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//创建组
|
|
//创建组
|
|
- String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, null);
|
|
|
|
|
|
+ String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, null, "unit", newCampaignId);
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
@@ -350,17 +350,25 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if (null == newCampaignId) {
|
|
if (null == newCampaignId) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
//创意
|
|
//创意
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
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());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//创建组
|
|
//创建组
|
|
- String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, null);
|
|
|
|
|
|
+ String unitName = getName(strategy.getGroupName(), strategy, createType, null, null, "unit", newCampaignId);
|
|
String appIdString = strategy.getAppIdArray();
|
|
String appIdString = strategy.getAppIdArray();
|
|
Long appId = null;
|
|
Long appId = null;
|
|
- if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
|
|
|
|
- appId = JSON.parseArray(appIdString).getLong(0);
|
|
|
|
|
|
+ if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
|
|
|
|
+ if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
|
|
|
|
+ appId = JSON.parseArray(appIdString).getLong(0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
|
|
@@ -390,7 +398,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy, Integer hour) throws ParseException {
|
|
public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy, Integer hour) throws ParseException {
|
|
-
|
|
|
|
Long customUnitCnt = strategy.getCustomUnitCnt();
|
|
Long customUnitCnt = strategy.getCustomUnitCnt();
|
|
if (Check.isNull(customUnitCnt)) {
|
|
if (Check.isNull(customUnitCnt)) {
|
|
Integer imageCnt = strategy.getImageCnt();
|
|
Integer imageCnt = strategy.getImageCnt();
|
|
@@ -399,7 +406,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
} else {
|
|
} else {
|
|
customUnitCnt = 2000L / imageCnt;
|
|
customUnitCnt = 2000L / imageCnt;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
Long unitNum = customUnitCnt * hour / 20;
|
|
Long unitNum = customUnitCnt * hour / 20;
|
|
@@ -447,6 +453,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouUpdateService updateService;
|
|
|
|
|
|
private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAdvertiserStrategy strategy) {
|
|
private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAdvertiserStrategy strategy) {
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
@@ -461,26 +469,26 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
|
|
+
|
|
|
|
+
|
|
String message = resultJson.getString("message");
|
|
String message = resultJson.getString("message");
|
|
- if (null == code || code != 0) {
|
|
|
|
- log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", token.getAccountId(), message, creativeParams);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- log.info("创建程序化创意成功");
|
|
|
|
- createLandPageAndUnit(creativeParams, resultJson.getJSONObject("data"));
|
|
|
|
- }
|
|
|
|
|
|
|
|
- //绑定落地页与广告组、创意的关系
|
|
|
|
- private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
|
|
|
|
- if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
|
|
|
|
- Thread thread = new Thread() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- thread.start();
|
|
|
|
|
|
+ Long unitId = creativeParams.getLong("unit_id");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ 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)) {
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ String key = token.getAccountId() + "_ProgramCreative" + "_" + nowDate;
|
|
|
|
+ redisUtil.set(key, 1, 100000L);
|
|
|
|
+ updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt, String appVersion) {
|
|
private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt, String appVersion) {
|
|
@@ -643,24 +651,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
|
|
private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
|
|
- // JSONArray campaignList;
|
|
|
|
- String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- /*if ("ALL_CAMPAIGN".equals(checkType)) {
|
|
|
|
- campaignList = kuaishouInterfaceService.getCampaignList(token, null, null, 1);
|
|
|
|
- } else {
|
|
|
|
- timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
|
|
|
|
- campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(), 1);
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
- /* if (!Check.isNull(campaignList)){
|
|
|
|
- for (int i = 0; i < campaignList.size(); i++) {
|
|
|
|
- JSONObject jsonObject = campaignList.getJSONObject(i);
|
|
|
|
- if (jsonObject.getString("campaign_name").contains(replaceString)) {
|
|
|
|
- return jsonObject.getLong("campaign_id");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
Long campaignId = null;
|
|
Long campaignId = null;
|
|
if ("ALL_CAMPAIGN".equals(checkType)) {
|
|
if ("ALL_CAMPAIGN".equals(checkType)) {
|
|
campaignId = campaignService.getCampaignIdByAccountAndName(strategy.getAccountId(), replaceString);
|
|
campaignId = campaignService.getCampaignIdByAccountAndName(strategy.getAccountId(), replaceString);
|
|
@@ -675,7 +667,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
// 不存在“上新”计划,则创建一个计划
|
|
// 不存在“上新”计划,则创建一个计划
|
|
JSONObject campaignParams = new JSONObject();
|
|
JSONObject campaignParams = new JSONObject();
|
|
campaignParams.put("advertiser_id", token.getAccountId());
|
|
campaignParams.put("advertiser_id", token.getAccountId());
|
|
- String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, timestamp, null);
|
|
|
|
|
|
+ String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, null, "plan", null);
|
|
campaignParams.put("campaign_name", campaignName);
|
|
campaignParams.put("campaign_name", campaignName);
|
|
campaignParams.put("type", strategy.getCampaignType());
|
|
campaignParams.put("type", strategy.getCampaignType());
|
|
if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {
|
|
if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {
|
|
@@ -711,10 +703,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitParams.put("unit_name", unitName);
|
|
unitParams.put("unit_name", unitName);
|
|
//出价类型
|
|
//出价类型
|
|
unitParams.put("bid_type", strategy.getBidType());
|
|
unitParams.put("bid_type", strategy.getBidType());
|
|
- // 优先从系统应用商店下载
|
|
|
|
- if (null != strategy.getUseAppMarket()) {
|
|
|
|
- unitParams.put("use_app_market", strategy.getUseAppMarket());
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
//组单日预算
|
|
//组单日预算
|
|
if (null != strategy.getUnitDayBudget() && strategy.getUnitDayBudget() != 0) {
|
|
if (null != strategy.getUnitDayBudget() && strategy.getUnitDayBudget() != 0) {
|
|
unitParams.put("day_budget", strategy.getUnitDayBudget());
|
|
unitParams.put("day_budget", strategy.getUnitDayBudget());
|
|
@@ -722,11 +711,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
unitParams.put("day_budget", 0);
|
|
unitParams.put("day_budget", 0);
|
|
}
|
|
}
|
|
//应用商店列表
|
|
//应用商店列表
|
|
- if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
|
|
|
|
- unitParams.put("app_store", JSON.parseArray(strategy.getAppStore()));
|
|
|
|
- }
|
|
|
|
unitParams.put("ocpx_action_type", strategy.getOcpxActionType());
|
|
unitParams.put("ocpx_action_type", strategy.getOcpxActionType());
|
|
-
|
|
|
|
//出价
|
|
//出价
|
|
if (null != strategy.getBid() && strategy.getBid() != 0) {
|
|
if (null != strategy.getBid() && strategy.getBid() != 0) {
|
|
unitParams.put("bid", strategy.getBid());
|
|
unitParams.put("bid", strategy.getBid());
|
|
@@ -754,21 +739,63 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if (!Check.isNull(strategy.getDeepConversionBid())) {
|
|
if (!Check.isNull(strategy.getDeepConversionBid())) {
|
|
unitParams.put("deep_conversion_bid", strategy.getDeepConversionBid());
|
|
unitParams.put("deep_conversion_bid", strategy.getDeepConversionBid());
|
|
}
|
|
}
|
|
-
|
|
|
|
Integer sceneId = null;
|
|
Integer sceneId = null;
|
|
String scenceIdString = strategy.getSceneId();
|
|
String scenceIdString = strategy.getSceneId();
|
|
|
|
|
|
if (!Check.isNull(scenceIdString) && !Check.isNull(JSON.parseArray(scenceIdString))) {
|
|
if (!Check.isNull(scenceIdString) && !Check.isNull(JSON.parseArray(scenceIdString))) {
|
|
JSONArray scenceArray = JSON.parseArray(scenceIdString);
|
|
JSONArray scenceArray = JSON.parseArray(scenceIdString);
|
|
sceneId = scenceArray.getInteger(0);
|
|
sceneId = scenceArray.getInteger(0);
|
|
- //资源位置
|
|
|
|
- /* if (unitType == 7) {
|
|
|
|
- //程序化
|
|
|
|
- scenceArray = cleanPramgramErrorScence(scenceArray);
|
|
|
|
- }*/
|
|
|
|
unitParams.put("scene_id", scenceArray);
|
|
unitParams.put("scene_id", scenceArray);
|
|
}
|
|
}
|
|
|
|
+ Integer campaignType = strategy.getCampaignType();
|
|
|
|
+ if (campaignType == 2) { // 提升应用安装
|
|
|
|
+ //应用ID
|
|
|
|
+ if (!Check.isNull(appId)) {
|
|
|
|
+ unitParams.put("app_id", appId);
|
|
|
|
+ }
|
|
|
|
+ // 直达链接
|
|
|
|
+ if (!Check.isNull(strategy.getSchemaUri())) {
|
|
|
|
+ unitParams.put("schema_uri", strategy.getSchemaUri());
|
|
|
|
+ }
|
|
|
|
+ // 优先从系统应用商店下载
|
|
|
|
+ if (null != strategy.getUseAppMarket()) {
|
|
|
|
+ unitParams.put("use_app_market", strategy.getUseAppMarket());
|
|
|
|
+ }
|
|
|
|
+ if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
|
|
|
|
+ unitParams.put("app_store", JSON.parseArray(strategy.getAppStore()));
|
|
|
|
+ }
|
|
|
|
+ } else if (campaignType == 3) { // 获取电商下单
|
|
|
|
+ //url类型
|
|
|
|
+ if (!Check.isNull(strategy.getUrlType())) {
|
|
|
|
+ unitParams.put("url_type", strategy.getUrlType());
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(strategy.getUrl())) {
|
|
|
|
+ unitParams.put("url", strategy.getUrl());
|
|
|
|
+ }
|
|
|
|
+ } else if (campaignType == 5) { //收集销售线索
|
|
|
|
+ //url类型
|
|
|
|
+ if (!Check.isNull(strategy.getWebUriType())) {
|
|
|
|
+ unitParams.put("web_uri_type", strategy.getWebUriType());
|
|
|
|
+ }
|
|
|
|
+ //url
|
|
|
|
+ if (!Check.isNull(strategy.getUrl())) {
|
|
|
|
+ unitParams.put("url", strategy.getUrl());
|
|
|
|
+ }
|
|
|
|
+ } else if (campaignType == 7) { // 提高应用活跃
|
|
|
|
+ // appId
|
|
|
|
+ if (!Check.isNull(appId)) {
|
|
|
|
+ unitParams.put("app_id", appId);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // url
|
|
|
|
+ if (!Check.isNull(strategy.getUrl())) {
|
|
|
|
+ unitParams.put("url", strategy.getUrl());
|
|
|
|
+ }
|
|
|
|
+ //调起链接
|
|
|
|
+ if (!Check.isNull(strategy.getSchemaUri())) {
|
|
|
|
+ unitParams.put("schema_uri", strategy.getSchemaUri());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//投放开始时间
|
|
//投放开始时间
|
|
if (!Check.isNull(strategy.getBeginTime())) {
|
|
if (!Check.isNull(strategy.getBeginTime())) {
|
|
unitParams.put("begin_time", strategy.getBeginTime());
|
|
unitParams.put("begin_time", strategy.getBeginTime());
|
|
@@ -787,26 +814,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if (!Check.isNull(strategy.getConvertId())) {
|
|
if (!Check.isNull(strategy.getConvertId())) {
|
|
unitParams.put("convert_id", strategy.getConvertId());
|
|
unitParams.put("convert_id", strategy.getConvertId());
|
|
}
|
|
}
|
|
- //url类型
|
|
|
|
- if (!Check.isNull(strategy.getUrlType())) {
|
|
|
|
- unitParams.put("url_type", strategy.getUrlType());
|
|
|
|
- }
|
|
|
|
- //url类型
|
|
|
|
- if (!Check.isNull(strategy.getWebUriType())) {
|
|
|
|
- unitParams.put("web_uri_type", strategy.getWebUriType());
|
|
|
|
- }
|
|
|
|
- //url
|
|
|
|
- if (!Check.isNull(strategy.getUrl())) {
|
|
|
|
- unitParams.put("url", strategy.getUrl());
|
|
|
|
- }
|
|
|
|
- //调起链接
|
|
|
|
- if (!Check.isNull(strategy.getSchemaUri())) {
|
|
|
|
- unitParams.put("schema_uri", strategy.getSchemaUri());
|
|
|
|
- }
|
|
|
|
- //应用ID
|
|
|
|
- if (!Check.isNull(appId)) {
|
|
|
|
- unitParams.put("app_id", appId);
|
|
|
|
- }
|
|
|
|
//创意展现方式
|
|
//创意展现方式
|
|
if (!Check.isNull(strategy.getShowMode())) {
|
|
if (!Check.isNull(strategy.getShowMode())) {
|
|
unitParams.put("show_mode", strategy.getShowMode());
|
|
unitParams.put("show_mode", strategy.getShowMode());
|
|
@@ -827,7 +834,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if (!Check.isNull(strategy.getAutoCreatePhoto())) {
|
|
if (!Check.isNull(strategy.getAutoCreatePhoto())) {
|
|
unitParams.put("auto_create_photo", strategy.getAutoCreatePhoto());
|
|
unitParams.put("auto_create_photo", strategy.getAutoCreatePhoto());
|
|
}
|
|
}
|
|
-
|
|
|
|
if (unitType == 7) {
|
|
if (unitType == 7) {
|
|
//是否开启智能抽帧
|
|
//是否开启智能抽帧
|
|
if (!Check.isNull(strategy.getSmartCover())) {
|
|
if (!Check.isNull(strategy.getSmartCover())) {
|
|
@@ -857,8 +863,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
// 定向数据
|
|
// 定向数据
|
|
unitParams.put("target", target);
|
|
unitParams.put("target", target);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
// 设置定向内容
|
|
// 设置定向内容
|
|
JSONObject targetJsonObject = new JSONObject();
|
|
JSONObject targetJsonObject = new JSONObject();
|
|
if (null != strategy.getRegion() && !"".equals(strategy.getRegion())) {
|
|
if (null != strategy.getRegion() && !"".equals(strategy.getRegion())) {
|
|
@@ -888,31 +892,53 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if (null != strategy.getDevicePrice() && !"".equals(strategy.getDevicePrice()) && !"[]".equals(strategy.getDevicePrice())) {
|
|
if (null != strategy.getDevicePrice() && !"".equals(strategy.getDevicePrice()) && !"[]".equals(strategy.getDevicePrice())) {
|
|
targetJsonObject.put("device_price", JSON.parseArray(strategy.getDevicePrice()));
|
|
targetJsonObject.put("device_price", JSON.parseArray(strategy.getDevicePrice()));
|
|
}
|
|
}
|
|
- if (null != strategy.getPopulation() && !"".equals(strategy.getPopulation())) {
|
|
|
|
- JSONArray population = JSON.parseArray(strategy.getPopulation());
|
|
|
|
- targetJsonObject.put("population", population);
|
|
|
|
|
|
+ if (sceneId != 5) {
|
|
|
|
+ if (null != strategy.getFilterConvertedLevel() && strategy.getFilterConvertedLevel() != 0) {
|
|
|
|
+ targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (null != strategy.getFilterConvertedLevel() && strategy.getFilterConvertedLevel() != 0) {
|
|
|
|
- targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
|
|
|
|
|
|
+
|
|
|
|
+ JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
|
|
|
|
+ if (!Check.isNull(appInterest)) {
|
|
|
|
+ targetJsonObject.put("app_interest", appInterest);
|
|
}
|
|
}
|
|
- if (null != strategy.getExcludePopulation() && !"".equals(strategy.getExcludePopulation())) {
|
|
|
|
- JSONArray excludePopulation = JSON.parseArray(strategy.getExcludePopulation());
|
|
|
|
- targetJsonObject.put("exclude_population", excludePopulation);
|
|
|
|
|
|
+ // APP行为-按APP名称
|
|
|
|
+ JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
|
|
|
|
+ if (!Check.isNull(appIds)) {
|
|
|
|
+ targetJsonObject.put("app_ids", appIds);
|
|
}
|
|
}
|
|
|
|
+ // 人群包定向
|
|
|
|
+ JSONArray populationString = JSONArray.parseArray(strategy.getPopulation());
|
|
|
|
+ if (!Check.isNull(populationString)) {
|
|
|
|
+ targetJsonObject.put("population", populationString);
|
|
|
|
+ }
|
|
|
|
+ // 人群包排除
|
|
|
|
+ JSONArray excludePopulationString = JSONArray.parseArray(strategy.getExcludePopulation());
|
|
|
|
+ if (!Check.isNull(excludePopulationString)) {
|
|
|
|
+ targetJsonObject.put("exclude_population", excludePopulationString);
|
|
|
|
+ }
|
|
|
|
+ // 付费人群包id
|
|
|
|
+ JSONArray paidAudienceString = JSONArray.parseArray(strategy.getPaidAudience());
|
|
|
|
+ if (!Check.isNull(paidAudienceString)) {
|
|
|
|
+ targetJsonObject.put("paid_audience", paidAudienceString);
|
|
|
|
+ }
|
|
|
|
+
|
|
//是否开启智能扩量
|
|
//是否开启智能扩量
|
|
- if (null != strategy.getIsOpen() && strategy.getIsOpen().equals(1)) {
|
|
|
|
- JSONObject intelliExtend = new JSONObject();
|
|
|
|
- intelliExtend.put("is_open", 1);
|
|
|
|
- if (null != strategy.getNoAgeBreak() && strategy.getNoAgeBreak().equals(1)) {
|
|
|
|
- intelliExtend.put("no_age_break", 1);
|
|
|
|
- }
|
|
|
|
- if (null != strategy.getNoGenderBreak() && strategy.getNoGenderBreak().equals(1)) {
|
|
|
|
- intelliExtend.put("no_gender_break", 1);
|
|
|
|
- }
|
|
|
|
- if (null != strategy.getNoAreaBreak() && strategy.getNoAreaBreak().equals(1)) {
|
|
|
|
- intelliExtend.put("no_area_break", 1);
|
|
|
|
|
|
+ if (sceneId != 5) {
|
|
|
|
+ if (null != strategy.getIsOpen() && strategy.getIsOpen().equals(1)) {
|
|
|
|
+ JSONObject intelliExtend = new JSONObject();
|
|
|
|
+ intelliExtend.put("is_open", 1);
|
|
|
|
+ if (null != strategy.getNoAgeBreak() && strategy.getNoAgeBreak().equals(1)) {
|
|
|
|
+ intelliExtend.put("no_age_break", 1);
|
|
|
|
+ }
|
|
|
|
+ if (null != strategy.getNoGenderBreak() && strategy.getNoGenderBreak().equals(1)) {
|
|
|
|
+ intelliExtend.put("no_gender_break", 1);
|
|
|
|
+ }
|
|
|
|
+ if (null != strategy.getNoAreaBreak() && strategy.getNoAreaBreak().equals(1)) {
|
|
|
|
+ intelliExtend.put("no_area_break", 1);
|
|
|
|
+ }
|
|
|
|
+ targetJsonObject.put("intelli_extend", intelliExtend);
|
|
}
|
|
}
|
|
- targetJsonObject.put("intelli_extend", intelliExtend);
|
|
|
|
}
|
|
}
|
|
unitParams.put("target", targetJsonObject);
|
|
unitParams.put("target", targetJsonObject);
|
|
log.info("广告组创建参数:{}", unitParams.toJSONString());
|
|
log.info("广告组创建参数:{}", unitParams.toJSONString());
|
|
@@ -1045,30 +1071,30 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
|
|
|
}
|
|
}
|
|
// APP行为-按分类
|
|
// APP行为-按分类
|
|
- String appInterestString = strategy.getAppInterest();
|
|
|
|
- if (null != appInterestString && !"".equals(appInterestString.trim())) {
|
|
|
|
- target.put("app_interest", JSON.parseArray(appInterestString));
|
|
|
|
|
|
+ JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
|
|
|
|
+ if (!Check.isNull(appInterest)) {
|
|
|
|
+ target.put("app_interest", appInterest);
|
|
}
|
|
}
|
|
// APP行为-按APP名称
|
|
// APP行为-按APP名称
|
|
- String appIdsString = strategy.getAppIds();
|
|
|
|
- if (null != appIdsString && !"".equals(appIdsString.trim())) {
|
|
|
|
- target.put("app_ids", JSON.parseArray(appIdsString));
|
|
|
|
|
|
+ JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
|
|
|
|
+ if (!Check.isNull(appIds)) {
|
|
|
|
+ target.put("app_ids", appIds);
|
|
}
|
|
}
|
|
|
|
|
|
// 人群包定向
|
|
// 人群包定向
|
|
- String populationString = strategy.getPopulation();
|
|
|
|
- if (null != populationString && !"".equals(populationString.trim())) {
|
|
|
|
- target.put("population", JSON.parseArray(populationString));
|
|
|
|
|
|
+ JSONArray populationString = JSONArray.parseArray(strategy.getPopulation());
|
|
|
|
+ if (!Check.isNull(populationString)) {
|
|
|
|
+ target.put("population", populationString);
|
|
}
|
|
}
|
|
// 人群包排除
|
|
// 人群包排除
|
|
- String excludePopulationString = strategy.getExcludePopulation();
|
|
|
|
- if (null != excludePopulationString && !"".equals(excludePopulationString.trim())) {
|
|
|
|
- target.put("exclude_population", JSON.parseArray(excludePopulationString));
|
|
|
|
|
|
+ JSONArray excludePopulationString = JSONArray.parseArray(strategy.getExcludePopulation());
|
|
|
|
+ if (!Check.isNull(excludePopulationString)) {
|
|
|
|
+ target.put("exclude_population", excludePopulationString);
|
|
}
|
|
}
|
|
// 付费人群包id
|
|
// 付费人群包id
|
|
- String paidAudienceString = strategy.getPaidAudience();
|
|
|
|
- if (null != paidAudienceString && !"".equals(paidAudienceString.trim())) {
|
|
|
|
- target.put("paid_audience", JSON.parseArray(paidAudienceString));
|
|
|
|
|
|
+ JSONArray paidAudienceString = JSONArray.parseArray(strategy.getPaidAudience());
|
|
|
|
+ if (!Check.isNull(paidAudienceString)) {
|
|
|
|
+ target.put("paid_audience", paidAudienceString);
|
|
}
|
|
}
|
|
if (Check.isNull(strategy.getBehaviorInterest())) {
|
|
if (Check.isNull(strategy.getBehaviorInterest())) {
|
|
target.put("behavior_interest", JSON.parseObject(strategy.getBehaviorInterest()));
|
|
target.put("behavior_interest", JSON.parseObject(strategy.getBehaviorInterest()));
|
|
@@ -1171,11 +1197,19 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
|
|
Integer creativeCode = (Integer) creativeCreateResult.get("code");
|
|
Integer creativeCode = (Integer) creativeCreateResult.get("code");
|
|
String creativeMessage = (String) creativeCreateResult.get("message");
|
|
String creativeMessage = (String) creativeCreateResult.get("message");
|
|
|
|
+
|
|
|
|
+ if (creativeCode == -1 && "/rest/openapi/v2/creative/create调用已超日限,次日可恢复调用".equals(creativeMessage)) {
|
|
|
|
+ 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();
|
|
AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord();
|
|
BeanUtils.copyProperties(strategy, record);
|
|
BeanUtils.copyProperties(strategy, record);
|
|
record.setCreativeName(creativeName);
|
|
record.setCreativeName(creativeName);
|
|
record.setStatus(creativeCode);
|
|
record.setStatus(creativeCode);
|
|
record.setMessage(creativeMessage);
|
|
record.setMessage(creativeMessage);
|
|
|
|
+ record.setUnitId(unitId);
|
|
record.setAiStrategyUuid(uuid);
|
|
record.setAiStrategyUuid(uuid);
|
|
record.setCreateTime(new Date());
|
|
record.setCreateTime(new Date());
|
|
if (creativeCode != 0) {
|
|
if (creativeCode != 0) {
|
|
@@ -1193,7 +1227,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
* @param strategy 账户id
|
|
* @param strategy 账户id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String timestamp, Integer cnt) {
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisUtil redisUtil;
|
|
|
|
+
|
|
|
|
+ private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String materialName, String type, Long campaignId) {
|
|
if (wildcard.contains("{{应用包名}}")) {
|
|
if (wildcard.contains("{{应用包名}}")) {
|
|
String appName = "";
|
|
String appName = "";
|
|
if (null != appInfo) {
|
|
if (null != appInfo) {
|
|
@@ -1202,8 +1239,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
wildcard = wildcard.replace("{{应用包名}}", appName);
|
|
wildcard = wildcard.replace("{{应用包名}}", appName);
|
|
}
|
|
}
|
|
if (wildcard.contains("{{创意制作方式}}")) {
|
|
if (wildcard.contains("{{创意制作方式}}")) {
|
|
-// String creatype = KuaishouCreativeCreateTypeEnum.getNameByType(strategy.getOpenProgramCreate());
|
|
|
|
-// wildcard = wildcard.replace("{{创意制作方式}}",creatype);
|
|
|
|
if (strategy.getUnitType() == 4) {
|
|
if (strategy.getUnitType() == 4) {
|
|
wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
|
|
wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
|
|
} else if (strategy.getUnitType() == 7) {
|
|
} else if (strategy.getUnitType() == 7) {
|
|
@@ -1214,20 +1249,59 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
String adsence = getAdSenceByParams(strategy.getSceneId());
|
|
String adsence = getAdSenceByParams(strategy.getSceneId());
|
|
wildcard = wildcard.replace("{{广告位置}}", adsence);
|
|
wildcard = wildcard.replace("{{广告位置}}", adsence);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (wildcard.contains("{{素材名称}}")) {
|
|
|
|
+ if (Check.isNull(materialName)) {
|
|
|
|
+ wildcard = wildcard.replace("{{素材名称}}", "");
|
|
|
|
+ } else {
|
|
|
|
+ wildcard = wildcard.replace("{{素材名称}}", materialName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (!wildcard.contains("{{自定义}}")) {
|
|
if (!wildcard.contains("{{自定义}}")) {
|
|
wildcard = wildcard + "{{自定义}}";
|
|
wildcard = wildcard + "{{自定义}}";
|
|
}
|
|
}
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ String nowDate = DateUtils.formatDate(date, "yy-MMdd");
|
|
|
|
+ if (type.equals("plan")) {
|
|
|
|
+ if (wildcard.contains("{{日期}}")) {
|
|
|
|
+ wildcard = wildcard.replace("{{日期}}", nowDate);
|
|
|
|
+ } else {
|
|
|
|
+ wildcard = wildcard + "-" + nowDate;
|
|
|
|
+ }
|
|
|
|
+ } else if ("unit".equals(type)) {
|
|
|
|
+ wildcard = wildcard.replace("{{日期}}", nowDate);
|
|
|
|
+ }
|
|
|
|
+
|
|
String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
if (null != appInfo) {
|
|
if (null != appInfo) {
|
|
targetName = appInfo.getAppVersion() + "-" + targetName;
|
|
targetName = appInfo.getAppVersion() + "-" + targetName;
|
|
}
|
|
}
|
|
wildcard = wildcard.replace("{{自定义}}", targetName);
|
|
wildcard = wildcard.replace("{{自定义}}", targetName);
|
|
|
|
|
|
- if (null != timestamp && !"".equals(timestamp.trim())) {
|
|
|
|
- wildcard = wildcard + "-" + timestamp;
|
|
|
|
- }
|
|
|
|
- if (null != cnt) {
|
|
|
|
- wildcard = wildcard + "-" + cnt.toString();
|
|
|
|
|
|
+ if (!Check.isNull(campaignId)) {
|
|
|
|
+ Integer count = null;
|
|
|
|
+ if (null != strategy.getSingleAppid() && strategy.getSingleAppid() == 0) {
|
|
|
|
+ String redisKey = strategy.getAccountId() + "_" + campaignId;
|
|
|
|
+ Object redisValue = redisUtil.get(redisKey);
|
|
|
|
+ if (Check.isNull(redisValue)) {
|
|
|
|
+ count = 1;
|
|
|
|
+ redisUtil.set(redisKey, count);
|
|
|
|
+ } else {
|
|
|
|
+ count = (Integer) redisValue + 1;
|
|
|
|
+ redisUtil.set(redisKey, count);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String redisKey = strategy.getAccountId() + "_" + campaignId + nowDate;
|
|
|
|
+ Object redisValue = redisUtil.get(redisKey);
|
|
|
|
+ if (Check.isNull(redisValue)) {
|
|
|
|
+ count = 1;
|
|
|
|
+ redisUtil.set(redisKey, count, 100000L);
|
|
|
|
+ } else {
|
|
|
|
+ count = (Integer) redisValue + 1;
|
|
|
|
+ redisUtil.set(redisKey, count, 100000L);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wildcard = wildcard + "-" + count;
|
|
}
|
|
}
|
|
wildcard = wildcard.replace("--", "-");
|
|
wildcard = wildcard.replace("--", "-");
|
|
if (wildcard.startsWith("-")) {
|
|
if (wildcard.startsWith("-")) {
|
|
@@ -1253,4 +1327,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
return adsence.substring(0, adsence.length() - 1);
|
|
return adsence.substring(0, adsence.length() - 1);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ String s = DateUtils.formatDate(date, "yy-MMdd");
|
|
|
|
+ String timestamp = DateUtils.formatDate(new Date(), "HHmmss");
|
|
|
|
+ System.err.println(timestamp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|