yumeng 5 سال پیش
والد
کامیت
759c431712

+ 50 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyPlanReportLoadJob.java

@@ -0,0 +1,50 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+/**
+ * 头条计划层级数据
+ */
+@Slf4j
+public class BytedanceDailyPlanReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
+
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+        tokens.forEach(token -> {
+
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    //获取广告计划信息数据
+                    reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                }
+            });
+        });
+    }
+}

+ 34 - 5
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,7 +1,10 @@
 package org.jeecg;
 
+import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
@@ -27,7 +30,6 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
@@ -175,6 +177,10 @@ public class SampleTest {
 
     }
 
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
 
     @Test
     public void testMa2() throws Exception {
@@ -196,7 +202,7 @@ public class SampleTest {
         }*/
 
 
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+       /* SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date parse = dateFormat.parse("2020-01-05");
 
 
@@ -211,7 +217,7 @@ public class SampleTest {
             kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, parse, parse);
 
         }
-
+*/
 
 
      /*   Date deleteDate = DateUtils.addDay(new Date(), -2);
@@ -220,12 +226,35 @@ public class SampleTest {
         //1:查询当日数据
 
 
-        log.info("快手物料数据同步完成");
-
 
         //1: 获取广告主信息数据
 
 
+        // Date getDate = DateUtils.addDay(new Date(), -1);
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse = simpleDateFormat.parse("2020-01-09");
+
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+        for (CtopOauthToken token : tokens) {
+
+          /*  executorService.submit(new Runnable() {
+                @Override
+                public void run() {*/
+                    //获取广告计划信息数据
+                    //reportService.getAdvertiserPlanReport(token, parse, parse, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token, parse, parse, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+
+                }
+           // });
+       // }
+
+
     }
 
 }

+ 13 - 2
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -114,12 +114,12 @@ public class KuaishouInterfaceConstant {
     /**
      * 修改广告计划预算
      */
-    public static final String UPDATE_CAMPAIGN = "/rest/openapi/v1/campaign/update/";
+    public static final String UPDATE_CAMPAIGN_BUDGET = "/rest/openapi/v1/campaign/update/";
 
     /**
      * 修改广告组预算
      */
-    public static final String UPDATE_UNIT = "/rest/openapi/v1/ad_unit/update/day_budget";
+    public static final String UPDATE_UNIT_BUDGET = "/rest/openapi/v1/ad_unit/update/day_budget";
 
 
     /**
@@ -134,6 +134,17 @@ public class KuaishouInterfaceConstant {
     public static final String UPDATE_CAMPAIGN_STATUS = "/rest/openapi/v1/campaign/update/status";
 
     /**
+     * 修改广告计划
+     */
+    public static final String UPDATE_CAMPAIGN = "/rest/openapi/v2/campaign/update";
+
+
+    /**
+     * 修改广告组
+     */
+    public static final String UPDATE_UNIT = "/rest/openapi/v2/ad_unit/update";
+
+    /**
      * 修改广告组状态
      */
     public static final String UPDATE_UNIT_STATUS = "/rest/openapi/v1/ad_unit/update/status";

+ 139 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -17,10 +17,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -67,6 +65,10 @@ public class BatchController {
     private IKuaiShouDirectionalTemplateService kuaiShouDirectionalTemplateService;
     @Autowired
     private IKuaiShouCreativeService kuaiShouCreativeService;
+    @Autowired
+    private IKuaiShouAppInfoService appInfoService;
+    @Autowired
+    private IKuaiShouGroupTargetService targetService;
 
 
     /**
@@ -357,7 +359,7 @@ public class BatchController {
             JSONObject campaignJson = new JSONObject();
             campaignJson.put("campaign_name", requestJson.getString("campaignName"));
             campaignJson.put("type", requestJson.getInteger("type"));
-            campaignJson.put("day_budget", requestJson.getLong("day_budget"));
+            campaignJson.put("day_budget", requestJson.getLong("dayBudget"));
             Map<String, Object> campaignMap = iKuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
             Integer code = (Integer) campaignMap.get("code");
             if (code != 0) {
@@ -600,9 +602,6 @@ public class BatchController {
     }
 
 
-
-
-
     /**
      * 获取 创意列表
      *
@@ -1038,7 +1037,6 @@ public class BatchController {
     }
 
 
-
     /**
      * 编辑 定向模板
      *
@@ -1080,5 +1078,139 @@ public class BatchController {
     }
 
 
+    /**
+     * 获取 广告组详情
+     *
+     * @param accountId
+     * @param unitId
+     * @return
+     */
+
+
+    @GetMapping(value = "/getUnitDetail")
+    public Result<JSONObject> getUnitDetail(Long accountId, Long unitId) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(accountId) || Check.isNull(unitId)) {
+                throw new Exception("参数错误");
+            }
+            JSONObject returnJson = new JSONObject();
+            QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
+            groupQueryWrapper.eq("account_id", accountId);
+            groupQueryWrapper.eq("unit_id", unitId);
+            groupQueryWrapper.orderByDesc("create_time").last("limit 1");
+            KuaiShouGroup group = kuaiShouGroupService.getOne(groupQueryWrapper);
+            if (!Check.isNull(group)) {
+                returnJson.put("baseInfo", group);
+                QueryWrapper<KuaiShouAppInfo> appInfoQueryWrapper = new QueryWrapper<>();
+                appInfoQueryWrapper.eq("account_id", accountId);
+                appInfoQueryWrapper.eq("unit_id", unitId);
+                appInfoQueryWrapper.orderByDesc("create_time").last("limit 1");
+                KuaiShouAppInfo appInfo = appInfoService.getOne(appInfoQueryWrapper);
+                if (!Check.isNull(appInfo)) {
+                    returnJson.put("appInfo", appInfo);
+                }
+                QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
+                targetQueryWrapper.eq("account_id", accountId);
+                targetQueryWrapper.eq("unit_id", unitId);
+                targetQueryWrapper.orderByDesc("create_time").last("limit 1");
+                KuaiShouGroupTarget target = targetService.getOne(targetQueryWrapper);
+                if (!Check.isNull(target)) {
+                    returnJson.put("target", target);
+                }
+            }
+            result.setSuccess(true);
+            result.setResult(returnJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+
+    /**
+     * 修改广告计划
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/updateCampaign")
+    public Result<JSONObject> updateCampaign(@RequestBody JSONObject requestJson) {
+
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参为空");
+            }
+
+            JSONObject campaignJson = batchService.updateCampaign(requestJson);
+            result.setSuccess(true);
+            result.setResult(campaignJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+
+        return result;
+
+    }
+
+
+    /**
+     * 修改广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/updateUnit")
+    public Result<JSONObject> updateUnit(@RequestBody JSONObject requestJson) {
+
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参为空");
+            }
+
+            JSONObject unitJson = batchService.updateUnit(requestJson);
+            result.setSuccess(true);
+            result.setResult(unitJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 修改广告创意
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/updateCreative")
+    public Result<JSONObject> updateCreative(@RequestBody JSONObject requestJson) {
+
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参为空");
+            }
+
+            JSONObject creativeJson = batchService.updateCreative(requestJson);
+            result.setSuccess(true);
+            result.setResult(creativeJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
 
 }

+ 25 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java

@@ -85,4 +85,29 @@ public interface IBatchService {
      * @return
      */
     KuaiShouCreative getCreativeInfo(Long accountId, Long creativeId);
+
+    /**
+     * 修改计划信息
+     *
+     * @param requestJson
+     * @return
+     */
+    JSONObject updateCampaign(JSONObject requestJson) throws Exception;
+
+
+    /**
+     * 修改广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    JSONObject updateUnit(JSONObject requestJson) throws Exception;
+
+    /**
+     * 修改广告创意
+     *
+     * @param requestJson
+     * @return
+     */
+    JSONObject updateCreative(JSONObject requestJson) throws Exception;
 }

+ 28 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouUpdateService.java

@@ -86,4 +86,32 @@ public interface IKuaiShouUpdateService {
      */
     Map<String, Object> updateCreative(String token, Long advertiserId, JSONObject requestJson);
 
+
+    /**
+     * 修改广告计划
+     *
+     * @param accessToken
+     * @param requestJson
+     * @return
+     */
+
+    JSONObject updateCampaign(String accessToken, JSONObject requestJson);
+
+    /**
+     * 修改广告组
+     *
+     * @param accessToken
+     * @param unitJson
+     * @return
+     */
+    JSONObject updateUnit(String accessToken, JSONObject unitJson);
+
+    /**
+     * 修改广告创意
+     *
+     * @param accessToken
+     * @param creativeJson
+     * @return
+     */
+    JSONObject updateCreative(String accessToken, JSONObject creativeJson);
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -350,4 +350,9 @@ public interface IKuaishouInterfaceService {
     void getCreativeList2(CtopOauthToken token, Date startDate, Date endDate, Integer page);
 
     void getCreative(String token, Long advertiserId, Long creativeId);
+
+
 }
+
+
+

+ 377 - 79
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -13,6 +13,7 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -35,6 +36,8 @@ public class BatchServiceImpl implements IBatchService {
     private KuaiShouCampaignMapper campaignMapper;
     @Autowired
     private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
 
 
     /**
@@ -141,7 +144,6 @@ public class BatchServiceImpl implements IBatchService {
 
     @Override
     public JSONObject createUnit(JSONObject requestJson) throws Exception {
-        System.err.println(requestJson);
         Long accountId = requestJson.getLong("accountId");
         CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
         if (Check.isNull(oauthToken)) {
@@ -157,35 +159,35 @@ public class BatchServiceImpl implements IBatchService {
         unitJson.put("campaign_id", campaignId);
 
         // 资源位置
-        JSONArray scene_id = requestJson.getJSONArray("scene_id");
+        JSONArray scene_id = requestJson.getJSONArray("sceneId");
         if (!Check.isNull(scene_id)) {
             unitJson.put("scene_id", scene_id);
         }
 
         // 资源创作方式
-        if (!Check.isNull(requestJson.getInteger("unit_type"))) {
-            unitJson.put("unit_type", requestJson.getInteger("unit_type"));
+        if (!Check.isNull(requestJson.getInteger("unitType"))) {
+            unitJson.put("unit_type", requestJson.getInteger("unitType"));
         }
 
         //投放开始时间
-        if (!Check.isNull(requestJson.getString("begin_time"))) {
-            unitJson.put("begin_time", requestJson.getString("begin_time"));
+        if (!Check.isNull(requestJson.getString("beginTime"))) {
+            unitJson.put("begin_time", requestJson.getString("beginTime"));
         }
         // 投放结束时间
-        if (!Check.isNull(requestJson.getString("end_time"))) {
-            unitJson.put("end_time", requestJson.getString("end_time"));
+        if (!Check.isNull(requestJson.getString("endTime"))) {
+            unitJson.put("end_time", requestJson.getString("endTime"));
         }
         // 投放时间段
-        if (!Check.isNull(requestJson.getString("schedule_time"))) {
-            unitJson.put("schedule_time", requestJson.getString("schedule_time"));
+        if (!Check.isNull(requestJson.getString("scheduleTime"))) {
+            unitJson.put("schedule_time", requestJson.getString("scheduleTime"));
         }
         // 广告组单日预算
-        if (!Check.isNull(requestJson.getLong("day_budget"))) {
-            unitJson.put("day_budget", requestJson.getLong("day_budget"));
+        if (!Check.isNull(requestJson.getLong("dayBudget"))) {
+            unitJson.put("day_budget", requestJson.getLong("dayBudget"));
         }
         // url类型
-        if (!Check.isNull(requestJson.getInteger("url_type"))) {
-            unitJson.put("url_type", requestJson.getInteger("url_type"));
+        if (!Check.isNull(requestJson.getInteger("urlType"))) {
+            unitJson.put("url_type", requestJson.getInteger("urlType"));
         }
         // url
         if (!Check.isNull(requestJson.getString("url"))) {
@@ -196,8 +198,8 @@ public class BatchServiceImpl implements IBatchService {
             unitJson.put("app_id", requestJson.getLong("appId"));
         }
         // 创意展现方式
-        if (!Check.isNull(requestJson.getInteger("show_mode"))) {
-            unitJson.put("show_mode", requestJson.getInteger("show_mode"));
+        if (!Check.isNull(requestJson.getInteger("showMode"))) {
+            unitJson.put("show_mode", requestJson.getInteger("showMode"));
         }
         if (!Check.isNull(requestJson.getInteger("speed"))) {
             unitJson.put("speed", requestJson.getInteger("speed"));
@@ -221,87 +223,87 @@ public class BatchServiceImpl implements IBatchService {
             targetJson.put("age", ageJson);
         }
         // 固定年龄段
-        if (!Check.isNull(requestJson.getJSONArray("ages_range"))) {
-            targetJson.put("ages_range", requestJson.getJSONArray("ages_range"));
+        if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
+            targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
         }
         // 性别
         if (!Check.isNull(requestJson.getInteger("gender"))) {
             targetJson.put("gender", requestJson.getInteger("gender"));
         }
         //操作系统
-        if (!Check.isNull(requestJson.getInteger("platform_os"))) {
-            targetJson.put("platform_os", requestJson.getInteger("platform_os"));
+        if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+            targetJson.put("platform_os", requestJson.getInteger("platformOs"));
         }
         //Android版本
-        if (!Check.isNull(requestJson.getInteger("android_osv"))) {
-            targetJson.put("android_osv", requestJson.getInteger("android_osv"));
+        if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+            targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
         }
         // iOS版本
-        if (!Check.isNull(requestJson.getInteger("ios_osv"))) {
-            targetJson.put("ios_osv", requestJson.getInteger("ios_osv"));
+        if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+            targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
         }
         //网络环境
         if (!Check.isNull(requestJson.getInteger("network"))) {
             targetJson.put("network", requestJson.getInteger("network"));
         }
         //设备品牌
-        if (!Check.isNull(requestJson.getJSONArray("device_brand"))) {
-            targetJson.put("device_brand", requestJson.getJSONArray("device_brand"));
+        if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
+            targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
         }
         //设备价格
-        if (!Check.isNull(requestJson.getJSONArray("device_price"))) {
-            targetJson.put("device_price", requestJson.getJSONArray("device_price"));
+        if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+            targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
         }
         //商业兴趣类型
-        if (!Check.isNull(requestJson.getInteger("business_interest_type"))) {
-            targetJson.put("business_interest_type", requestJson.getInteger("business_interest_type"));
+        if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+            targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
         }
         // 商业兴趣
-        if (!Check.isNull(requestJson.getJSONArray("business_interest"))) {
-            targetJson.put("business_interest", requestJson.getJSONArray("business_interest"));
+        if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+            targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
         }
         //网红粉丝
-        if (!Check.isNull(requestJson.getJSONArray("fans_star"))) {
-            targetJson.put("fans_star", requestJson.getJSONArray("fans_star"));
+        if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+            targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
         }
         //兴趣视频用户
-        if (!Check.isNull(requestJson.getJSONArray("interest_video"))) {
-            targetJson.put("interest_video", requestJson.getJSONArray("interest_video"));
+        if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+            targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
         }
         // APP行为-按分类
-        if (!Check.isNull(requestJson.getJSONArray("app_interest"))) {
-            targetJson.put("app_interest", requestJson.getJSONArray("app_interest"));
+        if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+            targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
         }
         // APP行为-按APP名称
-        if (!Check.isNull(requestJson.getJSONArray("app_ids"))) {
-            targetJson.put("app_ids", requestJson.getJSONArray("app_ids"));
+        if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+            targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
         }
         // 人群包定向
         if (!Check.isNull(requestJson.getJSONArray("population"))) {
             targetJson.put("population", requestJson.getJSONArray("population"));
         }
         // 人群包排除
-        if (!Check.isNull(requestJson.getJSONArray("exclude_population"))) {
-            targetJson.put("exclude_population", requestJson.getJSONArray("exclude_population"));
+        if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+            targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
         }
 
         JSONObject intelliExtendJson = new JSONObject();
 
         // 开启智能扩量
-        if (!Check.isNull(requestJson.getInteger("is_open"))) {
-            intelliExtendJson.put("is_open", requestJson.getInteger("is_open"));
+        if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+            intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
         }
         //不可突破年龄
-        if (!Check.isNull(requestJson.getInteger("no_age_break"))) {
-            intelliExtendJson.put("no_age_break", requestJson.getInteger("no_age_break"));
+        if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+            intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
         }
         //不可突破性别
-        if (!Check.isNull(requestJson.getInteger("no_gender_break"))) {
-            intelliExtendJson.put("no_gender_break", requestJson.getInteger("no_gender_break"));
+        if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+            intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
         }
         // 不可突破地域
-        if (!Check.isNull(requestJson.getInteger("no_area_break"))) {
-            intelliExtendJson.put("no_area_break", requestJson.getInteger("no_area_break"));
+        if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+            intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
         }
         if (!Check.isNull(intelliExtendJson)) {
             targetJson.put("intelli_extend", intelliExtendJson);
@@ -330,24 +332,24 @@ public class BatchServiceImpl implements IBatchService {
                     unitJson.put("bid", groupJson.getLong("bid"));
                 }
                 // 出价类型
-                Integer bidType = groupJson.getInteger("bid_type");
+                Integer bidType = groupJson.getInteger("bidType");
                 if (!Check.isNull(bidType)) {
                     unitJson.put("bid_type", bidType);
                 }
                 // 深度转化出价
-                if (!Check.isNull(groupJson.getLong("cpa_bid"))) {
-                    unitJson.put("cpa_bid", groupJson.getLong("cpa_bid"));
+                if (!Check.isNull(groupJson.getLong("cpaBid"))) {
+                    unitJson.put("cpa_bid", groupJson.getLong("cpaBid"));
                 }
                 // 深度转化目标出价
-                if (!Check.isNull(groupJson.getLong("deep_conversion_bid"))) {
-                    unitJson.put("deep_conversion_bid", groupJson.getLong("deep_conversion_bid"));
+                if (!Check.isNull(groupJson.getLong("deepConversionBid"))) {
+                    unitJson.put("deep_conversion_bid", groupJson.getLong("deepConversionBid"));
                 }
                 // 深度转化目标
-                if (!Check.isNull(groupJson.getInteger("deep_conversion_type"))) {
-                    unitJson.put("deep_conversion_type", groupJson.getInteger("deep_conversion_type"));
+                if (!Check.isNull(groupJson.getInteger("deepConversionType"))) {
+                    unitJson.put("deep_conversion_type", groupJson.getInteger("deepConversionType"));
                 }
                 // 优化目标
-                Integer ocpx_action_type = groupJson.getInteger("ocpx_action_type");
+                Integer ocpx_action_type = groupJson.getInteger("ocpxActionType");
                 if (!Check.isNull(ocpx_action_type)) {
                     unitJson.put("ocpx_action_type", ocpx_action_type);
                 }
@@ -361,14 +363,14 @@ public class BatchServiceImpl implements IBatchService {
                     Integer code = (Integer) returnUnitMap.get("code");
                     if (code == 0) {
                         JSONObject successJson = new JSONObject();
-                        successJson.put("unit_id", returnUnitMap.get("unitId"));
-                        successJson.put("unit_name", unitName);
-                        successJson.put("scene_id", scene_id);
-                        successJson.put("ocpx_action_type", ocpx_action_type);
+                        successJson.put("unitId", returnUnitMap.get("unitId"));
+                        successJson.put("unitName", unitName);
+                        successJson.put("sceneId", scene_id);
+                        successJson.put("ocpxActionType", ocpx_action_type);
                         successArr.add(successJson);
                     } else {
                         JSONObject failJson = new JSONObject();
-                        failJson.put("unit_name", unitName);
+                        failJson.put("unitName", unitName);
                         failJson.put("failMessage", returnUnitMap.get("message"));
                         failArr.add(failJson);
                     }
@@ -414,8 +416,6 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONObject createCreative(JSONObject requestJson) throws Exception {
-        System.err.println(requestJson);
-
         if (Check.isNull(requestJson)) {
             throw new Exception("入参为空");
         }
@@ -438,21 +438,18 @@ public class BatchServiceImpl implements IBatchService {
 
 
         JSONObject creativeJson = new JSONObject();
-
-
         creativeJson.put("advertiser_id", accountId);
-
         creativeJson.put("unit_id", unitId);
 
         // 素材类型
-        if (!Check.isNull(requestJson.get("creative_material_type"))) {
-            creativeJson.put("creative_material_type", requestJson.get("creative_material_type"));
+        if (!Check.isNull(requestJson.get("creativeMaterialType"))) {
+            creativeJson.put("creative_material_type", requestJson.get("creativeMaterialType"));
         }
 
-        String action_bar_text = requestJson.getString("action_bar_text");
+        String action_bar_text = requestJson.getString("actionBarText");
         // 视频id
 
-        String click_track_url = requestJson.getString("click_track_url");
+        String click_track_url = requestJson.getString("clickTrackUrl");
         JSONObject returnJson = new JSONObject();
         JSONArray successArr = new JSONArray();
         JSONArray failArr = new JSONArray();
@@ -462,8 +459,8 @@ public class BatchServiceImpl implements IBatchService {
                 JSONObject dataJson = dataJsons.getJSONObject(i);
                 if (!Check.isNull(dataJsons)) {
                     String description = dataJson.getString("description");
-                    String photo_id = dataJson.getString("photo_id");
-                    JSONArray imageTokens = dataJson.getJSONArray("image_tokens");
+                    String photo_id = dataJson.getString("photoId");
+                    JSONArray imageTokens = dataJson.getJSONArray("imageTokens");
                     if (!Check.isNull(imageTokens)) {
                         for (int j = 0; j < imageTokens.size(); j++) {
                             JSONObject imageJson = imageTokens.getJSONObject(j);
@@ -482,12 +479,11 @@ public class BatchServiceImpl implements IBatchService {
                                     Integer code = (Integer) returnUnitMap.get("code");
                                     if (code == 0) {
                                         JSONObject successJson = new JSONObject();
-                                        successJson.put("creative_name", name);
-
+                                        successJson.put("creativeName", name);
                                         successArr.add(successJson);
                                     } else {
                                         JSONObject failJson = new JSONObject();
-                                        failJson.put("creative_name", name);
+                                        failJson.put("creativeName", name);
                                         failJson.put("failMessage", returnUnitMap.get("message"));
                                         failArr.add(failJson);
                                     }
@@ -496,9 +492,7 @@ public class BatchServiceImpl implements IBatchService {
                         }
                     }
                 }
-
             }
-
         }
 
         returnJson.put("success", successArr);
@@ -529,6 +523,310 @@ public class BatchServiceImpl implements IBatchService {
     }
 
 
+    /**
+     * 修改计划信息
+     *
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject updateCampaign(JSONObject requestJson) throws Exception {
+        Long accountId = requestJson.getLong("accountId");
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        if (Check.isNull(oauthToken)) {
+            throw new Exception("未获取到账户信息");
+        }
+
+        JSONObject campaignJson = new JSONObject();
+        campaignJson.put("advertiser_id", accountId);
+        Long campaignId = requestJson.getLong("campaignId");
+        if (Check.isNull(campaignId)) {
+            throw new Exception("请选择广告计划");
+        }
+        campaignJson.put("campaign_id", campaignId);
+        if (!Check.isNull(requestJson.getString("campaignName"))) {
+            campaignJson.put("campaign_name", requestJson.getString("campaignName"));
+        }
+        if (!Check.isNull(requestJson.getString("dayBudget"))) {
+            campaignJson.put("day_budget", requestJson.getString("dayBudget"));
+        }
+        JSONObject returnJson = updateService.updateCampaign(oauthToken.getAccessToken(), campaignJson);
+        return returnJson;
+    }
+
+
+    /**
+     * 修改广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject updateUnit(JSONObject requestJson) throws Exception {
+
+        Long accountId = requestJson.getLong("accountId");
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        if (Check.isNull(oauthToken)) {
+            throw new Exception("未获取到账户信息");
+        }
+        JSONObject unitJson = new JSONObject();
+        unitJson.put("advertiser_id", accountId);
+
+        Long unitId = requestJson.getLong("unitId");
+        if (Check.isNull(unitId)) {
+            throw new Exception("请选择广告组");
+        }
+
+        unitJson.put("unit_id", unitId);
+        // 广告组名称
+        if (!Check.isNull(requestJson.getString("unitName"))) {
+            unitJson.put("unit_name", requestJson.getString("unitName"));
+        }
+        // 出价
+        if (!Check.isNull(requestJson.getLong("bid"))) {
+            unitJson.put("bid", requestJson.getLong("bid"));
+        }
+        // 深度转化出价
+        if (!Check.isNull(requestJson.getLong("cpaBid"))) {
+            unitJson.put("cpa_bid", requestJson.getLong("cpaBid"));
+        }
+        // 深度转化目标出价
+        if (!Check.isNull(requestJson.getLong("deepConversionBid"))) {
+            unitJson.put("deep_conversion_bid", requestJson.getLong("deepConversionBid"));
+        }
+        //投放开始时间
+        if (!Check.isNull(requestJson.getString("beginTime"))) {
+            unitJson.put("begin_time", requestJson.getString("beginTime"));
+        }
+        // 投放结束时间
+        if (!Check.isNull(requestJson.getString("endTime"))) {
+            unitJson.put("end_time", requestJson.getString("endTime"));
+        }
+        // 投放时间段
+        if (!Check.isNull(requestJson.getString("scheduleTime"))) {
+            unitJson.put("schedule_time", requestJson.getString("scheduleTime"));
+        }
+        // 广告组单日预算
+        if (!Check.isNull(requestJson.getLong("dayBudget"))) {
+            unitJson.put("day_budget", requestJson.getLong("dayBudget"));
+        }
+        // url类型
+        if (!Check.isNull(requestJson.getInteger("urlType"))) {
+            unitJson.put("url_type", requestJson.getInteger("urlType"));
+        }
+        // url
+        if (!Check.isNull(requestJson.getString("url"))) {
+            unitJson.put("url", requestJson.getString("url"));
+        }
+        // appId
+        if (!Check.isNull(requestJson.getLong("appId"))) {
+            unitJson.put("app_id", requestJson.getLong("appId"));
+        }
+
+        // 创意展现方式
+        if (!Check.isNull(requestJson.getInteger("showMode"))) {
+            unitJson.put("show_mode", requestJson.getInteger("showMode"));
+        }
+        //投放方式
+        if (!Check.isNull(requestJson.getInteger("speed"))) {
+            unitJson.put("speed", requestJson.getInteger("speed"));
+        }
+
+
+        // -----------------用户定向-----------
+        JSONObject targetJson = new JSONObject();
+
+        // 地域
+        if (!Check.isNull(requestJson.getJSONArray("region"))) {
+            targetJson.put("region", requestJson.getJSONArray("region"));
+        }
+
+        // 自定义年龄段
+        JSONArray ageArr = requestJson.getJSONArray("age");
+        if (!Check.isNull(ageArr)) {
+            JSONObject ageJson = new JSONObject();
+            ageJson.put("min", ageArr.get(0));
+            ageJson.put("max", ageArr.get(1));
+            targetJson.put("age", ageJson);
+        }
+        // 固定年龄段
+        if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
+            targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
+        }
+        // 性别
+        if (!Check.isNull(requestJson.getInteger("gender"))) {
+            targetJson.put("gender", requestJson.getInteger("gender"));
+        }
+        //操作系统
+        if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+            targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+        }
+        //Android版本
+        if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+            targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+        }
+        // iOS版本
+        if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+            targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+        }
+        //网络环境
+        if (!Check.isNull(requestJson.getInteger("network"))) {
+            targetJson.put("network", requestJson.getInteger("network"));
+        }
+        //设备品牌
+        if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
+            targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+        }
+        //设备价格
+        if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+            targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+        }
+        //商业兴趣类型
+        if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+            targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+        }
+        // 商业兴趣
+        if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+            targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+        }
+        //网红粉丝
+        if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+            targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+        }
+        //兴趣视频用户
+        if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+            targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+        }
+        // APP行为-按分类
+        if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+            targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+        }
+        // APP行为-按APP名称
+        if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+            targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+        }
+        // 人群包定向
+        if (!Check.isNull(requestJson.getJSONArray("population"))) {
+            targetJson.put("population", requestJson.getJSONArray("population"));
+        }
+        // 人群包排除
+        if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+            targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+        }
+
+        JSONObject intelliExtendJson = new JSONObject();
+
+        // 开启智能扩量
+        if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+            intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+        }
+        //不可突破年龄
+        if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+            intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+        }
+        //不可突破性别
+        if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+            intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+        }
+        // 不可突破地域
+        if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+            intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+        }
+        if (!Check.isNull(intelliExtendJson)) {
+            targetJson.put("intelli_extend", intelliExtendJson);
+        }
+
+        unitJson.put("target", targetJson);
+
+        JSONObject returnJson = updateService.updateUnit(oauthToken.getAccessToken(), unitJson);
+        return returnJson;
+    }
+
+    /**
+     * 修改广告创意
+     *
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject updateCreative(JSONObject requestJson) throws Exception {
+        if (Check.isNull(requestJson)) {
+            throw new Exception("入参为空");
+        }
+
+        Long accountId = requestJson.getLong("accountId");
+        if (Check.isNull(accountId)) {
+            throw new Exception("请输入需创建账号");
+        }
+        JSONObject creativeJson = new JSONObject();
+        creativeJson.put("advertiser_id", accountId);
+
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        if (Check.isNull(oauthToken)) {
+            throw new Exception("未获取到账户信息");
+        }
+
+        Long creativeId = requestJson.getLong("creativeId");
+        if (Check.isNull(creativeId)) {
+            throw new Exception("请选择广告创意");
+        }
+        creativeJson.put("creative_id", creativeId);
+
+
+        // 创意名称
+        if (!Check.isNull(requestJson.get("creativeName"))) {
+            creativeJson.put("creative_name", requestJson.get("creativeName"));
+        }
+
+        //封面
+        if (!Check.isNull(requestJson.get("photoId"))) {
+            creativeJson.put("photo_id", requestJson.get("photoId"));
+        }
+
+        // 视频id
+        if (!Check.isNull(requestJson.get("imageToken"))) {
+            creativeJson.put("image_token", requestJson.get("imageToken"));
+        }
+
+        // 行动号召按钮
+        if (!Check.isNull(requestJson.get("actionBarText"))) {
+            creativeJson.put("action_bar_text", requestJson.get("actionBarText"));
+        }
+
+
+        // 广告语
+        if (!Check.isNull(requestJson.get("description"))) {
+            creativeJson.put("description", requestJson.get("description"));
+        }
+        // 封面标题
+        if (!Check.isNull(requestJson.get("stickerTitle"))) {
+            creativeJson.put("sticker_title", requestJson.get("stickerTitle"));
+        }
+
+        // 贴纸样式
+        if (!Check.isNull(requestJson.get("overlayType"))) {
+            creativeJson.put("overlay_type", requestJson.get("overlayType"));
+        }
+        // 第三方检测链接
+        if (!Check.isNull(requestJson.get("clickTrackUrl"))) {
+            creativeJson.put("click_track_url", requestJson.get("clickTrackUrl"));
+        }
+
+        // 后贴片 第三方检测链接
+        if (!Check.isNull(requestJson.get("adPhotoPlayedT3sUrl"))) {
+            creativeJson.put("ad_photo_played_t3s_url", requestJson.get("adPhotoPlayedT3sUrl"));
+        }
+
+        // 后贴片 第三方检测链接
+        if (!Check.isNull(requestJson.get("impressionUrl"))) {
+            creativeJson.put("impression_url", requestJson.get("impressionUrl"));
+        }
+        JSONObject returnJson = updateService.updateCreative(oauthToken.getAccessToken(), creativeJson);
+
+        return returnJson;
+    }
+
+
 }
 
 

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

@@ -43,7 +43,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
     public Map<String, Object> updateCampaign(String token, Long advertiserId, Long campaignId, Long dayBudget, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
         try {
-            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_CAMPAIGN;
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_CAMPAIGN_BUDGET;
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Content-Type", "application/json");
             headers.put("Access-Token", token);
@@ -117,7 +117,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
     public Map<String, Object> updateUnitDayBudget(String token, Long advertiserId, Long unitId, Long dayBudget, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
         try {
-            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_UNIT;
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_UNIT_BUDGET;
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Content-Type", "application/json");
             headers.put("Access-Token", token);
@@ -525,4 +525,155 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
 
         return returnMap;
     }
+
+
+    @Override
+    public JSONObject updateCampaign(String accessToken, JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_CAMPAIGN;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", "application/json");
+
+
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        try {
+                            Thread.sleep(500);
+                            interfaceService.getCampaign(accessToken, requestJson.getLong("advertiser_id"), data.getLong("campaign_id"));
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+                        returnJson.put("code", 0);
+                    } else {
+                        returnJson.put("code", -1);
+                        returnJson.put("message", "返回信息为空");
+                    }
+
+                } else {
+                    returnJson.put("code", -1);
+                    returnJson.put("message", resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+
+
+        return returnJson;
+    }
+
+
+    /**
+     * 修改广告组
+     *
+     * @param accessToken
+     * @param unitJson
+     * @return
+     */
+
+    @Override
+    public JSONObject updateUnit(String accessToken, JSONObject unitJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_UNIT;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", "application/json");
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, unitJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        try {
+                            Thread.sleep(500);
+                            interfaceService.getGroup(accessToken, unitJson.getLong("advertiser_id"), data.getLong("unit_id"));
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+
+                        returnJson.put("code", 0);
+                    } else {
+                        returnJson.put("code", -1);
+                        returnJson.put("message", "返回信息为空");
+                    }
+
+                } else {
+                    returnJson.put("code", -1);
+                    returnJson.put("message", resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+
+
+        return returnJson;
+    }
+
+
+    /**
+     * 修改 广告创意
+     *
+     * @param accessToken
+     * @param creativeJson
+     * @return
+     */
+    @Override
+    public JSONObject updateCreative(String accessToken, JSONObject creativeJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_CREATIVE;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", "application/json");
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, creativeJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+
+                        try {
+                            Thread.sleep(500);
+                            interfaceService.getCreative(accessToken, creativeJson.getLong("advertiser_id"), data.getLong("creative_id"));
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+
+
+                        returnJson.put("code", 0);
+                    } else {
+                        returnJson.put("code", -1);
+                        returnJson.put("message", "返回信息为空");
+                    }
+
+                } else {
+                    returnJson.put("code", -1);
+                    returnJson.put("message", resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+
+
+        return returnJson;
+    }
+
 }

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

@@ -1153,7 +1153,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         Thread thread = new Thread() {
                             @Override
                             public void run() {
-                                getGroup(accessToken, advertiserId, unitId);
+                                try {
+                                    Thread.sleep(1 * 1000);
+                                    getGroup(accessToken, advertiserId, unitId);
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+
                             }
 
                         };
@@ -2318,8 +2324,24 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                     JSONObject dataJson = resultJson.getJSONObject("data");
+
                     if (!Check.isNullMap(dataJson)) {
-                        return dataJson;
+                        JSONObject returnJson = new JSONObject();
+                        returnJson.put("isActivate", dataJson.getInteger("is_activate"));
+                        returnJson.put("isFormSubmit", dataJson.getInteger("is_form_submit"));
+                        JSONArray deep_conversion_types = dataJson.getJSONArray("deep_conversion_types");
+                        if (!Check.isNull(deep_conversion_types)) {
+                            JSONArray deepConversionTypes = new JSONArray();
+                            for (int i = 0; i < deep_conversion_types.size(); i++) {
+                                JSONObject json = new JSONObject();
+                                JSONObject deepConversion = deep_conversion_types.getJSONObject(i);
+                                json.put("desc", deepConversion.getString("desc"));
+                                json.put("deepConversionType", deepConversion.getInteger("deep_conversion_type"));
+                                deepConversionTypes.add(json);
+                            }
+                            returnJson.put("deepConversionTypes", deepConversionTypes);
+                        }
+                        return returnJson;
                     }
                 } else {
                     log.error("获取可选的深度转化类型返回异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
@@ -2375,8 +2397,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("code", 0);
                         returnMap.put("message", "success");
                         returnMap.put("success", true);
-
-
                     }
                 } else {
                     log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
@@ -3547,8 +3567,28 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
-                    JSONArray data = resultJson.getJSONArray("data");
-                    return data;
+                    JSONArray dataArr = resultJson.getJSONArray("data");
+                    if (!Check.isNull(dataArr)) {
+                        JSONArray returnArr = new JSONArray();
+                        for (int i = 0; i < dataArr.size(); i++) {
+                            JSONObject dataJson = dataArr.getJSONObject(i);
+                            if (!Check.isNull(dataJson)) {
+                                JSONObject returnJson = new JSONObject();
+                                returnJson.put("orientationId", dataJson.getLong("orientation_id"));
+                                returnJson.put("orientationName", dataJson.getString("orientation_name"));
+                                returnJson.put("type", dataJson.getInteger("type"));
+                                returnJson.put("populationType", dataJson.getLong("population_type"));
+                                returnJson.put("recordSize", dataJson.getLong("record_size"));
+                                returnJson.put("matchSize", dataJson.getLong("match_size"));
+                                returnJson.put("coverNum", dataJson.getLong("cover_num"));
+                                returnJson.put("status", dataJson.getInteger("status"));
+                                returnJson.put("createTime", dataJson.getInteger("create_time"));
+                                returnArr.add(returnJson);
+                            }
+                        }
+                        return returnArr;
+                    }
+
                 } else {
                     log.error("获取人群包管理返回数据为空,accountId:{}", accountId);
                     return null;
@@ -3645,8 +3685,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
+                    JSONArray returnArr = new JSONArray();
                     JSONArray data = resultJson.getJSONArray("data");
-                    return data;
+                    for (int i = 0; i < data.size(); i++) {
+                        JSONObject jsonObject = data.getJSONObject(i);
+                        if (!Check.isNull(jsonObject)) {
+                            JSONObject returnJson = new JSONObject();
+                            returnJson.put("appId", jsonObject.getString("app_id"));
+                            returnJson.put("appName", jsonObject.getString("app_name"));
+                            returnArr.add(returnJson);
+                        }
+                    }
+                    return returnArr;
                 }
             }
         } catch (Exception e) {
@@ -3657,4 +3707,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+
+
 }

+ 1 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java

@@ -222,6 +222,7 @@ public class ReportServiceImpl implements IReportService {
     }
 
     private void getPlanReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
+        log.info("获取头条计划报表,accountId:{}", token.getAccountId());
         conditions.setPage(page);
         var config = new SerializeConfig();
         config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;