|
@@ -246,6 +246,10 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
boolean urlNoNull = isNotNull(urlArr, null, 1);
|
|
|
boolean schUrlNoNull = isNotNull(schemaUriArr, null, 1);
|
|
|
|
|
|
+ //试玩分配方式 1 按账户,2按广告计划,3按广告组
|
|
|
+ Integer playableAllocation = appList.getInteger("playableAllocation");
|
|
|
+ JSONArray playableIds = appList.getJSONArray("playableIds");
|
|
|
+
|
|
|
//监测链接分配方式 1 按账户,2按广告计划,3按广告组
|
|
|
Integer linkAllocation = appList.getInteger("linkAllocation");
|
|
|
JSONArray clickTrackUrlList = appList.getJSONArray("clickUrlList");
|
|
@@ -276,6 +280,10 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (playableAllocation == 1 && !Check.isNull(playableIds)) {
|
|
|
+ groupPreview.setPlayableId(playableIds.getLong(0));
|
|
|
+ }
|
|
|
+
|
|
|
//素材数据
|
|
|
JSONObject materialArray = data.getJSONObject("materialArray");
|
|
|
//创意组
|
|
@@ -324,6 +332,9 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
actionbarClickUrl = actionbarClickUrlList.getString(i);
|
|
|
}
|
|
|
}
|
|
|
+ if (playableAllocation == 2 && !Check.isNull(playableIds)) {
|
|
|
+ groupPreview.setPlayableId(getPlayableId(playableIds, i + 1));
|
|
|
+ }
|
|
|
if (Check.isNull(campaignId)) {
|
|
|
campaignPreview.setId(null);
|
|
|
campaignPreview.setCampaignName(getName(campaignPreview.getCampaignNameFormat(), targetIds.getLong(i), null, appId, null) + i);
|
|
@@ -352,6 +363,9 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
actionbarClickUrl = actionbarClickUrlList.getString(count);
|
|
|
}
|
|
|
}
|
|
|
+ if (playableAllocation == 3 && !Check.isNull(playableIds)) {
|
|
|
+ groupPreview.setPlayableId(getPlayableId(playableIds, j + 1));
|
|
|
+ }
|
|
|
groupPreview.setId(null);
|
|
|
groupPreview.setAppId(appId);
|
|
|
groupPreview.setPlanId(campaignPreview.getId());
|
|
@@ -367,6 +381,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
groupPreview.setBid(bid);
|
|
|
}
|
|
|
}
|
|
|
+ groupPreview.setPlayButton(appList.getString("playButton"));
|
|
|
groupPreviewMapper.insert(groupPreview);
|
|
|
JSONObject material = materialList.getJSONObject(j);
|
|
|
JSONArray photoArr = material.getJSONArray("photoArr");
|
|
@@ -468,6 +483,10 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
actionbarClickUrl = actionbarClickUrlList.getString(i);
|
|
|
}
|
|
|
}
|
|
|
+ if (playableAllocation == 2 && !Check.isNull(playableIds)) {
|
|
|
+ groupPreview.setPlayableId(getPlayableId(playableIds, i + 1));
|
|
|
+ }
|
|
|
+
|
|
|
campaignPreview.setId(null);
|
|
|
campaignPreview.setCampaignName(getName(campaignPreview.getCampaignNameFormat(), null, null, appId, null) + i);
|
|
|
campaignPreviewMapper.insert(campaignPreview);
|
|
@@ -500,6 +519,9 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
actionbarClickUrl = actionbarClickUrlList.getString(count);
|
|
|
}
|
|
|
}
|
|
|
+ if (playableAllocation == 3 && !Check.isNull(playableIds)) {
|
|
|
+ groupPreview.setPlayableId(getPlayableId(playableIds, j + 1));
|
|
|
+ }
|
|
|
groupPreview.setId(null);
|
|
|
groupPreview.setAppId(appId);
|
|
|
groupPreview.setPlanId(campaignPreview.getId());
|
|
@@ -515,30 +537,74 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
groupPreview.setBid(bid);
|
|
|
}
|
|
|
}
|
|
|
+ groupPreview.setPlayButton(appList.getString("playButton"));
|
|
|
groupPreviewMapper.insert(groupPreview);
|
|
|
- for (int k = 0; k < photoArr.size(); k++) {
|
|
|
- creativePreview.setId(null);
|
|
|
- creativePreview.setSiteId(siteId);
|
|
|
- creativePreview.setClickTrackUrl(clickTrackUrl);
|
|
|
- creativePreview.setActionbarClickUrl(actionbarClickUrl);
|
|
|
- JSONObject photo = photoArr.getJSONObject(k);
|
|
|
- JSONObject image = photo.getJSONObject("image");
|
|
|
- creativePreview.setPlanId(campaignPreview.getId());
|
|
|
- creativePreview.setGroupId(groupPreview.getId());
|
|
|
- creativePreview.setPhotoId(photo.getString("photoId"));
|
|
|
- creativePreview.setImageTokens(photo.getString("imageToken"));
|
|
|
- creativePreview.setMaterialType(photo.getString("materialType"));
|
|
|
- creativePreview.setCreativeName(photo.getString("creativeName") + k);
|
|
|
- creativePreview.setImageUrl(image.getString("url"));
|
|
|
- creativePreview.setImageSignature(image.getString("signature"));
|
|
|
- if (matchingMethod == 1) {
|
|
|
- creativePreview.setDescription(photo.getString("description"));
|
|
|
- } else if (matchingMethod == 2) {
|
|
|
- creativePreview.setDescription(descriptionList.getString(k));
|
|
|
- } else if (matchingMethod == 3) {
|
|
|
- creativePreview.setDescription(descriptionList.getString(i));
|
|
|
+ if (groupPreview.getUnitType() == 4) {
|
|
|
+ for (int k = 0; k < photoArr.size(); k++) {
|
|
|
+ creativePreview.setId(null);
|
|
|
+ creativePreview.setSiteId(siteId);
|
|
|
+ creativePreview.setClickTrackUrl(clickTrackUrl);
|
|
|
+ creativePreview.setActionbarClickUrl(actionbarClickUrl);
|
|
|
+ JSONObject photo = photoArr.getJSONObject(k);
|
|
|
+ JSONObject image = photo.getJSONObject("image");
|
|
|
+ creativePreview.setPlanId(campaignPreview.getId());
|
|
|
+ creativePreview.setGroupId(groupPreview.getId());
|
|
|
+ creativePreview.setPhotoId(photo.getString("photoId"));
|
|
|
+ creativePreview.setImageTokens(photo.getString("imageToken"));
|
|
|
+ creativePreview.setMaterialType(photo.getString("materialType"));
|
|
|
+ creativePreview.setCreativeName(photo.getString("creativeName") + k);
|
|
|
+ creativePreview.setImageUrl(image.getString("url"));
|
|
|
+ creativePreview.setImageSignature(image.getString("signature"));
|
|
|
+ if (matchingMethod == 1) {
|
|
|
+ creativePreview.setDescription(photo.getString("description"));
|
|
|
+ } else if (matchingMethod == 2) {
|
|
|
+ creativePreview.setDescription(descriptionList.getString(k));
|
|
|
+ } else if (matchingMethod == 3) {
|
|
|
+ creativePreview.setDescription(descriptionList.getString(i));
|
|
|
+ }
|
|
|
+ creativePreviewMapper.insert(creativePreview);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (photoArr.size() >= 3) {
|
|
|
+ List<JSONObject> photoIds = JSONArray.parseArray(photoArr.toJSONString(), JSONObject.class);
|
|
|
+ List<List<JSONObject>> splitPhotoIds = Lists.newArrayList(Lists.partition(photoIds, 10));
|
|
|
+ for (int k = 0; k < splitPhotoIds.size(); k++) {
|
|
|
+ //广告语
|
|
|
+ JSONArray descriptions = materialArray.getJSONArray("descriptionList");
|
|
|
+ if (descriptions.size() > 3) {
|
|
|
+ creativePreview.setDescription(getRandomFromList(descriptions));
|
|
|
+ } else {
|
|
|
+ creativePreview.setDescription(JSONArray.toJSONString(descriptions));
|
|
|
+ }
|
|
|
+
|
|
|
+ //photoId集合
|
|
|
+ List<String> photos = new ArrayList<>();
|
|
|
+ // 图片集合
|
|
|
+ List<String> images = new ArrayList<>();
|
|
|
+ for (JSONObject object : splitPhotoIds.get(k)) {
|
|
|
+ if (!Check.isNull(object.getString("photoId"))) {
|
|
|
+ photos.add(object.getString("photoId"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(object.getString("imageToken"))) {
|
|
|
+ images.add(object.getString("imageToken"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ creativePreview.setId(null);
|
|
|
+ creativePreview.setSiteId(siteId);
|
|
|
+ creativePreview.setClickTrackUrl(clickTrackUrl);
|
|
|
+ creativePreview.setActionbarClickUrl(actionbarClickUrl);
|
|
|
+ creativePreview.setPlanId(campaignPreview.getId());
|
|
|
+ creativePreview.setGroupId(groupPreview.getId());
|
|
|
+ if (!photos.isEmpty()) {
|
|
|
+ creativePreview.setPhotoId(JSONArray.toJSONString(photos));
|
|
|
+ }
|
|
|
+ if (!images.isEmpty()) {
|
|
|
+ creativePreview.setImageTokens(JSONArray.toJSONString(images));
|
|
|
+ }
|
|
|
+ creativePreview.setCreativeName("程序化组-" + k);
|
|
|
+ creativePreviewMapper.insert(creativePreview);
|
|
|
+ }
|
|
|
}
|
|
|
- creativePreviewMapper.insert(creativePreview);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -546,6 +612,22 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private Long getPlayableId(JSONArray ids, Integer num) {
|
|
|
+ if (Check.isNull(ids)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ int size = ids.size();
|
|
|
+ if (size > 0) {
|
|
|
+ if (size >= num) {
|
|
|
+ return ids.getLong(num - 1);
|
|
|
+ } else {
|
|
|
+ return ids.getLong(num % size == 0 ? (size - 1) : ((num % size) - 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
//从集合里随机获取不重复的3个值
|
|
|
private String getRandomFromList(JSONArray arr) {
|
|
|
List<String> ids = JSONArray.parseArray(arr.toJSONString(), String.class);
|
|
@@ -562,11 +644,6 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
|
|
|
/**
|
|
|
* 判断非空
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return boolean
|
|
|
- * @throws
|
|
|
- * @author ZHAOXA
|
|
|
*/
|
|
|
private boolean isNotNull(JSONArray arr, JSONArray arr2, Integer num) {
|
|
|
if (num == 2) {
|
|
@@ -578,11 +655,6 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
|
|
|
/**
|
|
|
* 广告语整理
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return com.alibaba.fastjson.JSONArray
|
|
|
- * @throws
|
|
|
- * @author ZHAOXA
|
|
|
*/
|
|
|
private static JSONArray advertisingSlogan(JSONArray descriptionList, JSONArray materialList) {
|
|
|
if (materialList.size() <= descriptionList.size()) {
|
|
@@ -676,6 +748,9 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
groupPreview.setAppStore(groupJson.getString("appStore"));
|
|
|
groupPreview.setBatchId(batchId);
|
|
|
groupPreview.setUnitType(groupJson.getInteger("unitType"));
|
|
|
+ groupPreview.setMedia(groupJson.getString("media"));
|
|
|
+ groupPreview.setExcludeMedia(groupJson.getString("excludeMedia"));
|
|
|
+ groupPreview.setMediaSourceType(groupJson.getInteger("mediaSourceType"));
|
|
|
return groupPreview;
|
|
|
}
|
|
|
|