|
@@ -263,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) {
|
|
//多应用
|
|
//多应用
|
|
@@ -298,6 +301,16 @@ 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 unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, null, "unit", newCampaignId);
|
|
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());
|
|
@@ -340,6 +353,14 @@ 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 unitName = getName(strategy.getGroupName(), strategy, createType, null, null, "unit", newCampaignId);
|
|
String unitName = getName(strategy.getGroupName(), strategy, createType, null, null, "unit", newCampaignId);
|
|
String appIdString = strategy.getAppIdArray();
|
|
String appIdString = strategy.getAppIdArray();
|
|
@@ -432,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<>();
|
|
@@ -446,12 +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;
|
|
|
|
|
|
+
|
|
|
|
+ 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");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
- log.info("创建程序化创意成功");
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
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) {
|