|
@@ -370,6 +370,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
}
|
|
|
AiKuaishouUnitLevelOperationRecord unitRecord = new AiKuaishouUnitLevelOperationRecord(strategy, unitParams, unitCode, unitMessage, strategyUuid, videoItem.getAutoTargetId(), channelId);
|
|
|
if (unitCode != 0) {
|
|
|
+ rollbackPlayId(unitParams, strategy);
|
|
|
log.error("****** 账户({})组创建失败,入参:{},message:{}", accountId, unitParams, unitMessage);
|
|
|
String redisKey = strategy.getAccountId() + "_" + newCampaignId + DateUtils.formatDate(new Date(), "yyMMdd");
|
|
|
Integer redisCnt = (Integer) redisUtil.get(redisKey);
|
|
@@ -1615,15 +1616,15 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
photo.put("cover_image_token", null);// 封面图片 token,通过上传图片接口获得,不传值则直接使用视频的首帧作为封面图片
|
|
|
photo.put("creative_material_type", type);//1:竖版视频 2:横版视频
|
|
|
photoList.add(photo);
|
|
|
- if(!Check.isNull(type)&&type==1){
|
|
|
+ if (!Check.isNull(type) && type == 1) {
|
|
|
vids.add(photoId);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
hids.add(photoId);
|
|
|
}
|
|
|
}
|
|
|
programJson.put("photo_list", photoList);
|
|
|
- programJson.put("vids",vids);
|
|
|
- programJson.put("hids",hids);
|
|
|
+ programJson.put("vids", vids);
|
|
|
+ programJson.put("hids", hids);
|
|
|
//落地页 ID
|
|
|
if (!Check.isNull(strategy.getSiteId()) && !"-1".equals(strategy.getSiteId())) {
|
|
|
programJson.put("site_id", strategy.getSiteId());
|
|
@@ -2049,7 +2050,11 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (!Check.isNull(strategy.getIntentionTarget()) && strategy.getIntentionTarget() != 0) {
|
|
|
unitParams.put("intention_target", true);
|
|
|
}
|
|
|
-
|
|
|
+ //试玩 ID
|
|
|
+ if (!Check.isNull(strategy.getPlayableIds())) {
|
|
|
+ unitParams.put("playable_id", getPlayId(strategy.getPlayableIds(), strategy.getId(), campaignId));
|
|
|
+ unitParams.put("play_button", strategy.getPlayButton());
|
|
|
+ }
|
|
|
//是否开启自动生成视频
|
|
|
if (!Check.isNull(strategy.getAutoCreatePhoto())) {
|
|
|
unitParams.put("auto_create_photo", strategy.getAutoCreatePhoto());
|
|
@@ -2778,4 +2783,86 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
int num = (int) (Math.random() * (end - start + 1) + start);
|
|
|
return num;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 轮询使用 playableIds 值,playableIds string格式:123,456,789,122
|
|
|
+ */
|
|
|
+ public Long getPlayId(String playableIds, Long strategyId, Long campaignId) {
|
|
|
+ JSONObject obj = JSONObject.parseObject(playableIds);
|
|
|
+ String playIds = obj.getString("ids");
|
|
|
+ String playId = null;
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ String redisKey = strategyId + "-play-" + campaignId + "-" + DateUtils.formatDate(new Date(), "yyMMdd");
|
|
|
+ Map<Object, Object> mget = redisUtil.hmget(redisKey);
|
|
|
+ if (Check.isNullMap(mget)) {
|
|
|
+ String[] ids = playIds.split(",");
|
|
|
+ playId = ids[0];
|
|
|
+ if (ids.length > 1) {
|
|
|
+ String newValues = playIds.replace(playId + ",", "");
|
|
|
+ map.put(String.valueOf(0), newValues);
|
|
|
+ }
|
|
|
+ map.put(String.valueOf(1), playId);
|
|
|
+ redisUtil.hmset(redisKey, map, 100000L);
|
|
|
+ } else {
|
|
|
+ for (Object key : mget.keySet()) {
|
|
|
+ String keyIndex = String.valueOf(key);
|
|
|
+ String values = String.valueOf(mget.get(keyIndex));
|
|
|
+ String[] ids = values.split(",");
|
|
|
+ playId = ids[0];
|
|
|
+ if (ids.length > 1) {
|
|
|
+ String newValues = values.replace(playId + ",", "");
|
|
|
+ map.put(keyIndex, newValues);
|
|
|
+ } else {
|
|
|
+ redisUtil.hdel(redisKey, keyIndex);
|
|
|
+ }
|
|
|
+ int upIndex = Integer.valueOf(keyIndex) + 1;
|
|
|
+ String upValues = String.valueOf(mget.get(String.valueOf(upIndex)));
|
|
|
+ if ("null".equals(upValues)) {
|
|
|
+ map.put(String.valueOf(upIndex), playId);
|
|
|
+ } else {
|
|
|
+ map.put(String.valueOf(upIndex), upValues + "," + playId);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ redisUtil.hmset(redisKey, map, 100000L);
|
|
|
+ }
|
|
|
+ return Long.valueOf(playId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回滚 playableIds 值
|
|
|
+ */
|
|
|
+ public void rollbackPlayId(JSONObject unitParams, AiKuaishouAccountAutoStrategy strategy) {
|
|
|
+ Long playableId = unitParams.getLong("playable_id");
|
|
|
+ if (Check.isNull(playableId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ String redisKey = strategy.getId() + "-play-" + unitParams.getLong("campaign_id") + "-" + DateUtils.formatDate(new Date(), "yyMMdd");
|
|
|
+ Map<Object, Object> mget = redisUtil.hmget(redisKey);
|
|
|
+ if (!Check.isNullMap(mget)) {
|
|
|
+ for (Object key : mget.keySet()) {
|
|
|
+ String keyIndex = String.valueOf(key);
|
|
|
+ String values = String.valueOf(mget.get(keyIndex));
|
|
|
+ if (values.contains(playableId + "")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ values = playableId + "," + values;
|
|
|
+ map.put(keyIndex, values);
|
|
|
+
|
|
|
+ String upIndex = Integer.valueOf(keyIndex) + 1 + "";
|
|
|
+ String upValues = String.valueOf(mget.get(upIndex));
|
|
|
+ if (!"null".equals(upValues)) {
|
|
|
+ if (String.valueOf(playableId).equals(upValues)) {
|
|
|
+ redisUtil.hdel(redisKey, upIndex);
|
|
|
+ } else {
|
|
|
+ String newValues = upValues.replace("," + playableId, "");
|
|
|
+ map.put(upIndex, newValues);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ redisUtil.hmset(redisKey, map, 100000L);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|