|
@@ -1,23 +1,34 @@
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
|
|
+import cn.com.ctop.common.module.enums.SceneIdEnum;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCampaignPreviewMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCampaignPreviewMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCreativePreviewMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCreativePreviewMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCampaignPreviewService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCampaignPreviewService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
|
|
import com.alibaba.excel.util.CollectionUtils;
|
|
import com.alibaba.excel.util.CollectionUtils;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.xxl.job.core.enums.NoEn;
|
|
import com.xxl.job.core.enums.NoEn;
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
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.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 快手-广告计划预览信息
|
|
* 快手-广告计划预览信息
|
|
@@ -36,6 +47,10 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
KuaishouBatchGroupPreviewMapper groupPreviewMapper;
|
|
KuaishouBatchGroupPreviewMapper groupPreviewMapper;
|
|
@Autowired
|
|
@Autowired
|
|
KuaishouBatchCreativePreviewMapper creativePreviewMapper;
|
|
KuaishouBatchCreativePreviewMapper creativePreviewMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouTemplateService kuaishouTemplateService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouAppListService kuaiShouAppListService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public JSONObject queryByBatchId(String batchId, String accountId) {
|
|
public JSONObject queryByBatchId(String batchId, String accountId) {
|
|
@@ -43,18 +58,58 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
QueryWrapper<KuaishouBatchCampaignPreview> campaignWrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaishouBatchCampaignPreview> campaignWrapper = new QueryWrapper<>();
|
|
campaignWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
|
|
campaignWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
|
|
List<KuaishouBatchCampaignPreview> campaignPreviewList = campaignPreviewMapper.selectList(campaignWrapper);
|
|
List<KuaishouBatchCampaignPreview> campaignPreviewList = campaignPreviewMapper.selectList(campaignWrapper);
|
|
- obj.put("campaignList", campaignPreviewList);
|
|
|
|
QueryWrapper<KuaishouBatchGroupPreview> groupWrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaishouBatchGroupPreview> groupWrapper = new QueryWrapper<>();
|
|
groupWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
|
|
groupWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
|
|
List<KuaishouBatchGroupPreview> groupPreviewList = groupPreviewMapper.selectList(groupWrapper);
|
|
List<KuaishouBatchGroupPreview> groupPreviewList = groupPreviewMapper.selectList(groupWrapper);
|
|
- obj.put("groupList", groupPreviewList);
|
|
|
|
QueryWrapper<KuaishouBatchCreativePreview> creativeWrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaishouBatchCreativePreview> creativeWrapper = new QueryWrapper<>();
|
|
creativeWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
|
|
creativeWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
|
|
List<KuaishouBatchCreativePreview> creativePreviewList = creativePreviewMapper.selectList(creativeWrapper);
|
|
List<KuaishouBatchCreativePreview> creativePreviewList = creativePreviewMapper.selectList(creativeWrapper);
|
|
- obj.put("creativeList", creativePreviewList);
|
|
|
|
|
|
+ obj.put("campaignList", getCampaignList(campaignPreviewList, groupPreviewList, creativePreviewList));
|
|
return obj;
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private List<KuaishouBatchCampaignPreview> getCampaignList(List<KuaishouBatchCampaignPreview> campaignPreviewList, List<KuaishouBatchGroupPreview> kuaishouBatchGroupPreviews, List<KuaishouBatchCreativePreview> kuaishouBatchCreativePreviews) {
|
|
|
|
+ List<KuaishouBatchGroupPreview> groups = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (KuaishouBatchGroupPreview groupPreview : kuaishouBatchGroupPreviews) {
|
|
|
|
+ JSONArray materialArr = new JSONArray();
|
|
|
|
+ JSONArray descriptionArr = new JSONArray();
|
|
|
|
+ for (KuaishouBatchCreativePreview creativePreview : kuaishouBatchCreativePreviews) {
|
|
|
|
+ if (groupPreview.getPlanId().equals(creativePreview.getPlanId()) && creativePreview.getGroupId().equals(groupPreview.getId())) {
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
+ obj.put("photoId", creativePreview.getPhotoId());
|
|
|
|
+ obj.put("imageUrl", creativePreview.getImageUrl());
|
|
|
|
+ materialArr.add(obj);
|
|
|
|
+ descriptionArr.add(creativePreview.getDescription());
|
|
|
|
+ groupPreview.setSiteId(creativePreview.getSiteId());
|
|
|
|
+ groupPreview.setClickTrackUrl(creativePreview.getClickTrackUrl());
|
|
|
|
+ groupPreview.setActionbarClickUrl(creativePreview.getActionbarClickUrl());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<KuaishouTemplate> queryWrapper = new QueryWrapper();
|
|
|
|
+ queryWrapper.eq("template_id", groupPreview.getTemplateId());
|
|
|
|
+ KuaishouTemplate template = kuaishouTemplateService.getOne(queryWrapper);
|
|
|
|
+ if (!Check.isNull(template)) {
|
|
|
|
+ groupPreview.setTemplateName(template.getTemplateName());
|
|
|
|
+ }
|
|
|
|
+ groupPreview.setMaterialArr(materialArr);
|
|
|
|
+ groupPreview.setDescriptionArr(descriptionArr);
|
|
|
|
+ groups.add(groupPreview);
|
|
|
|
+ }
|
|
|
|
+ List<KuaishouBatchCampaignPreview> campaigns = new ArrayList<>();
|
|
|
|
+ for (KuaishouBatchCampaignPreview campaignPreview : campaignPreviewList) {
|
|
|
|
+ List<KuaishouBatchGroupPreview> groupList = new ArrayList<>();
|
|
|
|
+ for (KuaishouBatchGroupPreview group : groups) {
|
|
|
|
+ if (campaignPreview.getId().equals(group.getPlanId())) {
|
|
|
|
+ groupList.add(group);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ campaignPreview.setKuaishouBatchGroupPreviews(groupList);
|
|
|
|
+ campaigns.add(campaignPreview);
|
|
|
|
+ }
|
|
|
|
+ return campaigns;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void addPreviewData(JSONObject data) throws Exception {
|
|
public void addPreviewData(JSONObject data) throws Exception {
|
|
String batchId = data.getString("batchId");
|
|
String batchId = data.getString("batchId");
|
|
@@ -121,7 +176,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
//应用分配方式 1 按账户,2按广告计划,3按广告组
|
|
//应用分配方式 1 按账户,2按广告计划,3按广告组
|
|
Integer appAllocation = appList.getInteger("appAllocation");
|
|
Integer appAllocation = appList.getInteger("appAllocation");
|
|
Integer appId = null;
|
|
Integer appId = null;
|
|
- Integer siteId = null;
|
|
|
|
|
|
+ Long siteId = null;
|
|
String url = null;
|
|
String url = null;
|
|
JSONArray appArr = appList.getJSONArray("appArr");
|
|
JSONArray appArr = appList.getJSONArray("appArr");
|
|
JSONArray urlArr = appList.getJSONArray("urlArr");
|
|
JSONArray urlArr = appList.getJSONArray("urlArr");
|
|
@@ -140,7 +195,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
if (appAllocation == 1) {
|
|
if (appAllocation == 1) {
|
|
if (appNoNull) {
|
|
if (appNoNull) {
|
|
appId = appArr.getJSONObject(0).getInteger("appId");
|
|
appId = appArr.getJSONObject(0).getInteger("appId");
|
|
- siteId = appArr.getJSONObject(0).getInteger("siteId");
|
|
|
|
|
|
+ siteId = appArr.getJSONObject(0).getLong("siteId");
|
|
}
|
|
}
|
|
if (urlNoNull) {
|
|
if (urlNoNull) {
|
|
url = urlArr.getString(0);
|
|
url = urlArr.getString(0);
|
|
@@ -182,7 +237,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
if (appAllocation == 2) {
|
|
if (appAllocation == 2) {
|
|
if (appNoNull) {
|
|
if (appNoNull) {
|
|
appId = appArr.getJSONObject(i).getInteger("appId");
|
|
appId = appArr.getJSONObject(i).getInteger("appId");
|
|
- siteId = appArr.getJSONObject(i).getInteger("siteId");
|
|
|
|
|
|
+ siteId = appArr.getJSONObject(i).getLong("siteId");
|
|
}
|
|
}
|
|
if (urlNoNull) {
|
|
if (urlNoNull) {
|
|
url = urlArr.getString(i);
|
|
url = urlArr.getString(i);
|
|
@@ -197,14 +252,14 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
}
|
|
}
|
|
}
|
|
}
|
|
campaignPreview.setId(null);
|
|
campaignPreview.setId(null);
|
|
- campaignPreview.setCampaignName(campaignPreview.getCampaignName() + i);
|
|
|
|
|
|
+ campaignPreview.setCampaignName(getName(campaignPreview.getCampaignName(), null, null, appId, null) + i);
|
|
campaignPreviewMapper.insert(campaignPreview);
|
|
campaignPreviewMapper.insert(campaignPreview);
|
|
for (int j = 0; j < materialList.size(); j++) {
|
|
for (int j = 0; j < materialList.size(); j++) {
|
|
if (appAllocation == 3) {
|
|
if (appAllocation == 3) {
|
|
appCount--;
|
|
appCount--;
|
|
if (appNoNull) {
|
|
if (appNoNull) {
|
|
appId = appArr.getJSONObject(appCount).getInteger("appId");
|
|
appId = appArr.getJSONObject(appCount).getInteger("appId");
|
|
- siteId = appArr.getJSONObject(appCount).getInteger("siteId");
|
|
|
|
|
|
+ siteId = appArr.getJSONObject(appCount).getLong("siteId");
|
|
}
|
|
}
|
|
if (urlNoNull) {
|
|
if (urlNoNull) {
|
|
url = urlArr.getString(appCount);
|
|
url = urlArr.getString(appCount);
|
|
@@ -223,7 +278,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
groupPreview.setAppId(appId);
|
|
groupPreview.setAppId(appId);
|
|
groupPreview.setPlanId(campaignPreview.getId());
|
|
groupPreview.setPlanId(campaignPreview.getId());
|
|
groupPreview.setTemplateId(targetIds.getLong(i));
|
|
groupPreview.setTemplateId(targetIds.getLong(i));
|
|
- groupPreview.setUnitName(groupPreview.getUnitName() + j);
|
|
|
|
|
|
+ groupPreview.setUnitName(getName(groupPreview.getUnitName(), targetIds.getLong(i), groupPreview.getSceneId(), appId, groupPreview.getUnitType()) + j);
|
|
groupPreview.setUrl(url);
|
|
groupPreview.setUrl(url);
|
|
groupPreviewMapper.insert(groupPreview);
|
|
groupPreviewMapper.insert(groupPreview);
|
|
JSONObject material = materialList.getJSONObject(j);
|
|
JSONObject material = materialList.getJSONObject(j);
|
|
@@ -266,7 +321,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
if (appAllocation == 2) {
|
|
if (appAllocation == 2) {
|
|
if (appNoNull) {
|
|
if (appNoNull) {
|
|
appId = appArr.getJSONObject(i).getInteger("appId");
|
|
appId = appArr.getJSONObject(i).getInteger("appId");
|
|
- siteId = appArr.getJSONObject(i).getInteger("siteId");
|
|
|
|
|
|
+ siteId = appArr.getJSONObject(i).getLong("siteId");
|
|
}
|
|
}
|
|
if (urlNoNull) {
|
|
if (urlNoNull) {
|
|
url = urlArr.getString(i);
|
|
url = urlArr.getString(i);
|
|
@@ -281,7 +336,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
}
|
|
}
|
|
}
|
|
}
|
|
campaignPreview.setId(null);
|
|
campaignPreview.setId(null);
|
|
- campaignPreview.setCampaignName(campaignPreview.getCampaignName() + i);
|
|
|
|
|
|
+ campaignPreview.setCampaignName(getName(campaignPreview.getCampaignName(), null, null, appId, null) + i);
|
|
campaignPreviewMapper.insert(campaignPreview);
|
|
campaignPreviewMapper.insert(campaignPreview);
|
|
JSONObject material = materialList.getJSONObject(i);
|
|
JSONObject material = materialList.getJSONObject(i);
|
|
JSONArray photoArr = material.getJSONArray("photoArr");
|
|
JSONArray photoArr = material.getJSONArray("photoArr");
|
|
@@ -294,7 +349,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
appCount--;
|
|
appCount--;
|
|
if (appNoNull) {
|
|
if (appNoNull) {
|
|
appId = appArr.getJSONObject(appCount).getInteger("appId");
|
|
appId = appArr.getJSONObject(appCount).getInteger("appId");
|
|
- siteId = appArr.getJSONObject(appCount).getInteger("siteId");
|
|
|
|
|
|
+ siteId = appArr.getJSONObject(appCount).getLong("siteId");
|
|
}
|
|
}
|
|
if (urlNoNull) {
|
|
if (urlNoNull) {
|
|
url = urlArr.getString(appCount);
|
|
url = urlArr.getString(appCount);
|
|
@@ -313,7 +368,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
groupPreview.setAppId(appId);
|
|
groupPreview.setAppId(appId);
|
|
groupPreview.setPlanId(campaignPreview.getId());
|
|
groupPreview.setPlanId(campaignPreview.getId());
|
|
groupPreview.setTemplateId(targetIds.getLong(j));
|
|
groupPreview.setTemplateId(targetIds.getLong(j));
|
|
- groupPreview.setUnitName(groupPreview.getUnitName() + j);
|
|
|
|
|
|
+ groupPreview.setUnitName(getName(groupPreview.getUnitName(), targetIds.getLong(i), groupPreview.getSceneId(), appId, groupPreview.getUnitType()) + j);
|
|
groupPreview.setUrl(url);
|
|
groupPreview.setUrl(url);
|
|
groupPreviewMapper.insert(groupPreview);
|
|
groupPreviewMapper.insert(groupPreview);
|
|
for (int k = 0; k < photoArr.size(); k++) {
|
|
for (int k = 0; k < photoArr.size(); k++) {
|
|
@@ -386,6 +441,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
KuaishouBatchCampaignPreview campaignPreview = new KuaishouBatchCampaignPreview();
|
|
KuaishouBatchCampaignPreview campaignPreview = new KuaishouBatchCampaignPreview();
|
|
campaignPreview.setAccountId(campaignJson.getLong("accountId"));
|
|
campaignPreview.setAccountId(campaignJson.getLong("accountId"));
|
|
campaignPreview.setCampaignName(campaignJson.getString("campaignName"));
|
|
campaignPreview.setCampaignName(campaignJson.getString("campaignName"));
|
|
|
|
+ campaignPreview.setCampaignNameFormat(campaignJson.getString("campaignName"));
|
|
campaignPreview.setCampaignType(campaignJson.getInteger("campaignType"));
|
|
campaignPreview.setCampaignType(campaignJson.getInteger("campaignType"));
|
|
campaignPreview.setPutStatus(campaignJson.getInteger("campaignStatus"));
|
|
campaignPreview.setPutStatus(campaignJson.getInteger("campaignStatus"));
|
|
campaignPreview.setDayBudget(campaignJson.getInteger("dayBudget"));
|
|
campaignPreview.setDayBudget(campaignJson.getInteger("dayBudget"));
|
|
@@ -408,6 +464,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
KuaishouBatchGroupPreview groupPreview = new KuaishouBatchGroupPreview();
|
|
KuaishouBatchGroupPreview groupPreview = new KuaishouBatchGroupPreview();
|
|
groupPreview.setAccountId(groupJson.getLong("accountId"));
|
|
groupPreview.setAccountId(groupJson.getLong("accountId"));
|
|
groupPreview.setUnitName(groupJson.getString("unitName"));
|
|
groupPreview.setUnitName(groupJson.getString("unitName"));
|
|
|
|
+ groupPreview.setUnitNameFormat(groupJson.getString("unitName"));
|
|
groupPreview.setPutStatus(campaignJson.getInteger("unitStatus") == 2 ? 2 : null);
|
|
groupPreview.setPutStatus(campaignJson.getInteger("unitStatus") == 2 ? 2 : null);
|
|
groupPreview.setBidType(groupJson.getInteger("bidType"));
|
|
groupPreview.setBidType(groupJson.getInteger("bidType"));
|
|
if (groupJson.getInteger("bidType") == 2) {
|
|
if (groupJson.getInteger("bidType") == 2) {
|
|
@@ -472,4 +529,97 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
return creativePreview;
|
|
return creativePreview;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @param content 通配符String
|
|
|
|
+ * @param templateId 定向模板ID
|
|
|
|
+ * @param sceneId 广告位置ID
|
|
|
|
+ * @param appId 应用包id、渠道号
|
|
|
|
+ * @param unitType 创意制作方式
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String getName(String content, Long templateId, String sceneId, Integer appId, Integer unitType) {
|
|
|
|
+ String reg = "\\{\\{(.+?)\\}\\}";
|
|
|
|
+ List<String> params = getParams(reg, content);
|
|
|
|
+ if (Check.isNull(params)) {
|
|
|
|
+ return content;
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> data = new HashMap<>();
|
|
|
|
+ for (int i = 0; i < params.size(); i++) {
|
|
|
|
+ String regName = params.get(i);
|
|
|
|
+ if ("日期".equals(regName)) {
|
|
|
|
+ data.put(regName, DateUtils.getNowDate("yyyy-MM-dd"));
|
|
|
|
+ } else if ("定向包".equals(regName)) {
|
|
|
|
+ if (!Check.isNull(templateId)) {
|
|
|
|
+ QueryWrapper<KuaishouTemplate> queryWrapper = new QueryWrapper();
|
|
|
|
+ queryWrapper.eq("template_id", templateId);
|
|
|
|
+ KuaishouTemplate template = kuaishouTemplateService.getOne(queryWrapper);
|
|
|
|
+ data.put(regName, template.getTemplateName());
|
|
|
|
+ }
|
|
|
|
+ } else if ("广告位置".equals(regName)) {
|
|
|
|
+ if (!Check.isNull(sceneId)) {
|
|
|
|
+ Integer sceneid = JSONObject.parseArray(sceneId).getInteger(0);
|
|
|
|
+ if (sceneid == 1 || sceneid == 5) {
|
|
|
|
+ data.put(regName, SceneIdEnum.getEnumById(sceneid).getName());
|
|
|
|
+ } else {
|
|
|
|
+ data.put(regName, "场景广告位");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if ("应用名称".equals(regName)) {
|
|
|
|
+ if (!Check.isNull(appId)) {
|
|
|
|
+ QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper();
|
|
|
|
+ queryWrapper.eq("app_id", appId);
|
|
|
|
+ KuaiShouAppList one = kuaiShouAppListService.getOne(queryWrapper);
|
|
|
|
+ data.put(regName, one.getAppName());
|
|
|
|
+ }
|
|
|
|
+ } else if ("渠道号".equals(regName)) {
|
|
|
|
+ if (!Check.isNull(appId)) {
|
|
|
|
+ QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper();
|
|
|
|
+ queryWrapper.eq("app_id", appId);
|
|
|
|
+ KuaiShouAppList one = kuaiShouAppListService.getOne(queryWrapper);
|
|
|
|
+ data.put(regName, one.getAppVersion());
|
|
|
|
+ }
|
|
|
|
+ } else if ("创意制作方式".equals(regName)) {
|
|
|
|
+ if (!Check.isNull(unitType)) {
|
|
|
|
+ data.put(regName, unitType == 4 ? "自定义" : "程序化创意2.0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String text = parse(reg, content, data);
|
|
|
|
+ return text;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static String parse(String pattern, String content, Map<String, String> data) {
|
|
|
|
+ Pattern p = Pattern.compile(pattern);
|
|
|
|
+ Matcher m = p.matcher(content);
|
|
|
|
+
|
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
|
+ while (m.find()) {
|
|
|
|
+ String key = m.group(1);
|
|
|
|
+ String value = data.get(key);
|
|
|
|
+ m.appendReplacement(sb, value == null ? "" : value);
|
|
|
|
+ }
|
|
|
|
+ m.appendTail(sb);
|
|
|
|
+ return sb.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据正则表达式获取文本中的变量名列表
|
|
|
|
+ *
|
|
|
|
+ * @param pattern
|
|
|
|
+ * @param content
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static List<String> getParams(String pattern, String content) {
|
|
|
|
+ Pattern p = Pattern.compile(pattern);
|
|
|
|
+ Matcher m = p.matcher(content);
|
|
|
|
+
|
|
|
|
+ List<String> result = new ArrayList<String>();
|
|
|
|
+ while (m.find()) {
|
|
|
|
+ result.add(m.group(1));
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|