Quellcode durchsuchen

修改添加广告组和定向模板、人群包绑定关系

zhaoxian vor 4 Jahren
Ursprung
Commit
c79ea757d4

+ 19 - 15
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java

@@ -612,22 +612,26 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
 
     @Override
     public void createUnitAndTemplate(JSONObject request) throws Exception {
-        JSONObject target = templateMapper.queryByTemplateId(request.getLong("templateId"));
-        if (Check.isNull(target)) {
-            throw new Exception("添加广告组和定向模板绑定关系失败");
+        try {
+            JSONObject target = templateMapper.queryByTemplateId(request.getLong("templateId"));
+            if (Check.isNull(target)) {
+                throw new Exception("添加广告组和定向模板绑定关系失败");
+            }
+            KuaishouDirectionalaPckageRel relEntity = new KuaishouDirectionalaPckageRel();
+            relEntity.setDirId(target.getString("dir_id"));
+            relEntity.setProjectId(target.getLong("project_id"));
+            relEntity.setTemplateId(request.getLong("templateId"));
+            relEntity.setTemplateName(target.getString("template_name"));
+            relEntity.setDataStatus(1);
+            relEntity.setRelId(request.getLong("unitId"));
+            relEntity.setRelType("unit");
+            relEntity.setExcludePopulation(request.getString("excludePopulation"));
+            relEntity.setPopulation(request.getString("population"));
+            relEntity.setPaidAudience(request.getString("paidAudience"));
+            relService.save(relEntity);
+        } catch (Exception e) {
+            log.error("添加广告组和定向模板绑定关系异常", e);
         }
-        KuaishouDirectionalaPckageRel relEntity = new KuaishouDirectionalaPckageRel();
-        relEntity.setDirId(target.getString("dir_id"));
-        relEntity.setProjectId(target.getLong("project_id"));
-        relEntity.setTemplateId(request.getLong("templateId"));
-        relEntity.setTemplateName(target.getString("template_name"));
-        relEntity.setDataStatus(1);
-        relEntity.setRelId(request.getLong("unitId"));
-        relEntity.setRelType("unit");
-        relEntity.setExcludePopulation(request.getString("excludePopulation"));
-        relEntity.setPopulation(request.getString("population"));
-        relEntity.setPaidAudience(request.getString("paidAudience"));
-        relService.save(relEntity);
     }
 
 }

+ 10 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java

@@ -480,16 +480,19 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                                     JSONObject request = new JSONObject();
                                     request.put("accountId", requestJson.getLong("advertiser_id"));
                                     request.put("unitId", unitId);
-                                    request.put("excludePopulation", requestJson.getJSONObject("target").getJSONArray("exclude_population"));
-                                    request.put("population", requestJson.getJSONObject("target").getJSONArray("population"));
-                                    request.put("paidAudience", requestJson.getJSONObject("target").getJSONArray("paid_audience"));
-                                    if (!Check.isNull(requestJson.getLong("templateId"))) {
-                                        request.put("templateId", requestJson.getLong("templateId"));
+                                    JSONObject target = requestJson.getJSONObject("target");
+                                    if (!Check.isNull(target)) {
+                                        request.put("excludePopulation", target.getJSONArray("exclude_population"));
+                                        request.put("population", target.getJSONArray("population"));
+                                        request.put("paidAudience", target.getJSONArray("paid_audience"));
+                                        populationGroupService.createPopulationAndGroupRel(request);
+                                    }
+                                    if (!Check.isNull(requestJson.getLong("template_id"))) {
+                                        request.put("templateId", requestJson.getLong("template_id"));
                                         directionalPackageService.createUnitAndTemplate(request);
                                     }
-                                    populationGroupService.createPopulationAndGroupRel(request);
                                 } catch (Exception e) {
-                                    log.error("添加广告组和定向模板、人群包绑定关系异常," + e);
+                                    log.error("添加广告组和定向模板、人群包绑定关系异常,", e);
                                 }
                             }
                         };

+ 23 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -6,8 +6,19 @@ import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignDayBudget;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignStatus;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupBid;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupDayBudget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignDayBudgetMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignStatusMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupBidMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupDayBudgetMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
@@ -617,16 +628,19 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                                     JSONObject request = new JSONObject();
                                     request.put("accountId", unitJson.getLong("advertiser_id"));
                                     request.put("unitId", data.getLong("unit_id"));
-                                    request.put("excludePopulation", unitJson.getJSONObject("target").getJSONArray("exclude_population"));
-                                    request.put("population", unitJson.getJSONObject("target").getJSONArray("population"));
-                                    request.put("paidAudience", unitJson.getJSONObject("target").getJSONArray("paid_audience"));
-                                    if (!Check.isNull(unitJson.getLong("templateId"))) {
-                                        request.put("templateId", unitJson.getLong("templateId"));
+                                    JSONObject target = unitJson.getJSONObject("target");
+                                    if (!Check.isNull(target)) {
+                                        request.put("excludePopulation", target.getJSONArray("exclude_population"));
+                                        request.put("population", target.getJSONArray("population"));
+                                        request.put("paidAudience", target.getJSONArray("paid_audience"));
+                                        populationGroupService.createPopulationAndGroupRel(request);
+                                    }
+                                    if (!Check.isNull(unitJson.getLong("template_id"))) {
+                                        request.put("templateId", unitJson.getLong("template_id"));
                                         directionalPackageService.createUnitAndTemplate(request);
                                     }
-                                    populationGroupService.createPopulationAndGroupRel(request);
                                 } catch (Exception e) {
-                                    log.error("添加广告组和定向模板、人群包绑定关系异常," + e);
+                                    log.error("添加广告组和定向模板、人群包绑定关系异常,", e);
                                 }
                             }
                         };

+ 10 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -1033,16 +1033,19 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     JSONObject request = new JSONObject();
                                     request.put("accountId", requestJson.getLong("advertiser_id"));
                                     request.put("unitId", unitId);
-                                    request.put("excludePopulation", requestJson.getJSONObject("target").getJSONArray("exclude_population"));
-                                    request.put("population", requestJson.getJSONObject("target").getJSONArray("population"));
-                                    request.put("paidAudience", requestJson.getJSONObject("target").getJSONArray("paid_audience"));
-                                    if (!Check.isNull(requestJson.getLong("templateId"))) {
-                                        request.put("templateId", requestJson.getLong("templateId"));
+                                    JSONObject target = requestJson.getJSONObject("target");
+                                    if (!Check.isNull(target)) {
+                                        request.put("excludePopulation", target.getJSONArray("exclude_population"));
+                                        request.put("population", target.getJSONArray("population"));
+                                        request.put("paidAudience", target.getJSONArray("paid_audience"));
+                                        populationGroupService.createPopulationAndGroupRel(request);
+                                    }
+                                    if (!Check.isNull(requestJson.getLong("template_id"))) {
+                                        request.put("templateId", requestJson.getLong("template_id"));
                                         directionalPackageService.createUnitAndTemplate(request);
                                     }
-                                    populationGroupService.createPopulationAndGroupRel(request);
                                 } catch (Exception e) {
-                                    log.error("添加广告组和定向模板、人群包绑定关系异常," + e);
+                                    log.error("添加广告组和定向模板、人群包绑定关系异常,", e);
                                 }
                             }
                         };