Просмотр исходного кода

策略功能,创建广告组、计划、创意

zhaoxian 4 лет назад
Родитель
Сommit
42ada511da

+ 12 - 15
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouStrategyController.java

@@ -5,6 +5,8 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -90,13 +92,14 @@ public class KuaishouStrategyController {
     @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-添加")
     @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-添加", notes = "kuaishou.modules.batch-优化评估策略表-添加")
     @PostMapping(value = "/add")
-    public Result<Object> add(@RequestBody KuaishouStrategy kuaishouStrategy) {
+    public Result<Object> add(@RequestBody JSONObject data) {
         Result<Object> result = new Result<>();
         try {
-            if (Check.isNull(kuaishouStrategy.getAccountId())) {
+            if (Check.isNull(data.getLong("accountId"))) {
                 return Result.error(-1, "请选择账户");
             }
-            kuaishouStrategyService.save(kuaishouStrategy);
+            KuaishouStrategy strategy = JSONObject.toJavaObject(data, KuaishouStrategy.class);
+            kuaishouStrategyService.save(strategy);
             result.success("添加成功!");
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -114,19 +117,13 @@ public class KuaishouStrategyController {
     @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-编辑")
     @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-编辑", notes = "kuaishou.modules.batch-优化评估策略表-编辑")
     @PostMapping(value = "/edit")
-    public Result<KuaishouStrategy> edit(@RequestBody KuaishouStrategy kuaishouStrategy) {
-        Result<KuaishouStrategy> result = new Result<KuaishouStrategy>();
-        KuaishouStrategy kuaishouStrategyEntity = kuaishouStrategyService.getById(kuaishouStrategy.getId());
-        if (kuaishouStrategyEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = kuaishouStrategyService.updateById(kuaishouStrategy);
-            if (ok) {
-                result.success("修改成功!");
-            }
+    public Result<Object> edit(@RequestBody JSONArray ids) {
+        try {
+            return kuaishouStrategyService.shutDownPlan(ids);
+        } catch (Exception e) {
+            log.error("关停策略下的计划异常", e);
         }
-
-        return result;
+        return Result.error("关停失败");
     }
 
     /**

+ 18 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouStrategy.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
-import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -30,9 +29,9 @@ public class KuaishouStrategy {
     /**
      * id
      */
-    @TableId(type = IdType.ID_WORKER_STR)
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "id")
-    private String id;
+    private Long id;
     /**
      * 账户ID
      */
@@ -80,7 +79,7 @@ public class KuaishouStrategy {
      */
     @Excel(name = "模板id", width = 15)
     @ApiModelProperty(value = "模板id")
-    private Long templateId;
+    private String templateId;
     /**
      * 地域
      */
@@ -187,19 +186,30 @@ public class KuaishouStrategy {
     /**
      * 广告位 1:优选广告位
      */
-    private JSONArray sceneId;
+    private String sceneId;
     /**
      * 下载详情页ID,建站id
      */
-    private Integer siteId;
+    private String siteId;
     /**
      * 第三方开始播放监测链接
      */
     private String impressionUrl;
     /**
-     * 第三方有效播放监测链接
+     * 第三方开始播放监测链接
+     */
+    private String url;
+    /**
+     * 当计划类型为3(获取电商下单)时必填:
+     * 1 - 淘宝商品短链
+     * 2 - 淘宝商品itemID
+     * 4 - 金牛电商
+     */
+    private String urlType;
+    /**
+     * 第三方点击检测链接
      */
-    private String adPhotoPlayedT3sUrl;
+    private String clickTrackUrl;
     /**
      * 第三方点击按钮监测链接
      */

+ 26 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouStrategyService.java

@@ -1,14 +1,39 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.Map;
 
 /**
  * @Description: kuaishou.modules.batch-优化评估策略表
  * @Author: jeecg-boot
- * @Date:   2020-12-10
+ * @Date: 2020-12-10
  * @Version: V1.0
  */
 public interface IKuaishouStrategyService extends IService<KuaishouStrategy> {
+    /**
+     * 页面关停操作
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    Result<Object> shutDownPlan(JSONArray ids);
 
+    /**
+     * 创建快手广告计划
+     *
+     * @param oauthToken token签名
+     * @param groupJson  广告计划
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data);
 }

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

@@ -4,18 +4,69 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.*;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.JsonUtil;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouConversionInfos;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouConversionTypes;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListChildren;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAdvertiserBaseInfoMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouConversionInfosMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouConversionTypesMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListChildrenMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAdvertiserBaseInfoService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouOverRunSendMessageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.entity.*;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyGroup;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyGroupMapper;
-import cn.com.ctop.kuaishou.modules.report.service.*;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeStatisticService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyAccountService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -49,7 +100,11 @@ import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -1981,6 +2036,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         };
                         thread.start();
                         returnMap.put("code", 0);
+                        returnMap.put("creativeId", creativeId);
                         returnMap.put("message", "success");
                         returnMap.put("success", true);
                     }
@@ -2009,7 +2065,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 returnMap.put("desc", "result is null");
                 returnMap.put("success", false);
             }
-
         } catch (Exception e) {
             log.error("创建广告创意失败,advertiser_id:{}", advertiserId);
             returnMap.put("code", -1);

+ 177 - 41
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouStrategyServiceImpl.java

@@ -1,23 +1,32 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouStrategyMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -27,6 +36,7 @@ import java.util.Map;
  * @version V1.0
  * @date 2020-12-10
  */
+@Slf4j
 @Service
 public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMapper, KuaishouStrategy> implements IKuaishouStrategyService {
     @Autowired
@@ -35,28 +45,127 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
     private IKuaiShouImageGetService imageGetService;
     @Autowired
     private IKuaiShouMaterialUploadService uploadService;
+    @Autowired
+    private IKuaiShouUpdateService kuaiShouUpdateService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    //TODO
+    @Override
+    public Result<Object> shutDownPlan(JSONArray ids) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        for (Object id : ids) {
+            List<JSONObject> list = new ArrayList<>();
+            CtopOauthToken token = tokenService.getTokenByAccountId(list.get(0).getLong("accountId"));
+            for (JSONObject object : list) {
+                kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), NoEn.NO2.valueInt(), userId);
+            }
+        }
+        return null;
+    }
 
     /**
      * @param oauthToken token签名
-     * @param strategy   策略对象
      * @param groupJson  广告计划
      * @return void
      * @throws
      * @author ZHAOXA
      */
-    private void createGroupLevelStrategy(CtopOauthToken oauthToken, KuaishouStrategy strategy, JSONObject groupJson) throws Exception {
+    public Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
+        JSONObject planJson = new JSONObject();
+        /**计划类型
+         * 2: 提升应用安装
+         * 3:获取电商下单
+         * 4:推广品牌活动
+         * 5:收集销售线索
+         * 7:提高应用活跃
+         */
+        if (Check.isNull(data.getInteger("type"))) {
+            return getNullValueResult("广告组必填参数:type,计划类型为空");
+        } else {
+            planJson.put("type", data.getInteger("type"));
+        }
+        //单日预算金额
+        if (!Check.isNull(data.getLong("dayBudget"))) {
+            planJson.put("day_budget", data.getLong("dayBudget"));
+        }
+        //分日预算
+        if (!Check.isNull(data.getJSONArray("dayBudgetSchedule"))) {
+            planJson.put("day_budget_schedule", data.getJSONArray("dayBudgetSchedule"));
+        }
+        return kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), planJson);
+    }
+
+    public JSONArray createGroupLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
+        JSONArray resultArr = new JSONArray();
+        JSONArray groupInfo = data.getJSONArray("groupInfo");
+        for (int i = 0; i < groupInfo.size(); i++) {
+            Map<String, Object> resutlGroupMap = new HashMap<>();
+            JSONObject groupJson = groupInfo.getJSONObject(i);
+            try {
+                resutlGroupMap = createGroupLevelAd(oauthToken, groupJson);
+            } catch (Exception e) {
+                log.error("unitName:{},根据策略创建广告组异常", groupJson.get("unitName"), e);
+            }
+            if (!Check.isNull(resutlGroupMap)) {
+                resutlGroupMap.put("unitName", groupJson.getString("unitName"));
+                if ((boolean) resutlGroupMap.get("success")) {
+                    JSONArray creativeInfo = groupJson.getJSONArray("creativeInfo");
+                    if (Check.isNull(creativeInfo)) {
+                        resutlGroupMap.put("desc", "入参数据缺失创意级信息,仅创建计划成功");
+                    } else {
+                        JSONArray resultCretiveList = new JSONArray();
+                        for (int j = 0; j < creativeInfo.size(); j++) {
+                            Map<String, Object> creativeMap = new HashMap<>();
+                            JSONObject creativeJson = creativeInfo.getJSONObject(i);
+                            creativeMap.put("creativeName", creativeJson.getString("creativeName"));
+                            creativeJson.put("unitId", resutlGroupMap.get("unitId"));
+                            try {
+                                creativeMap = createCreativeLevelStrategy(oauthToken, creativeJson);
+                            } catch (Exception e) {
+                                log.error("unitId:{},根据策略创建广告创意异常", resutlGroupMap.get("unitId"), e);
+                            }
+                            resultCretiveList.add(creativeMap);
+                        }
+                        resutlGroupMap.put("resultCretiveList", resultCretiveList);
+                    }
+                }
+            }
+            resultArr.add(resutlGroupMap);
+        }
+        return resultArr;
+    }
+
+
+    /**
+     * 根据策略创建广告组
+     *
+     * @param oauthToken token签名
+     * @param groupJson  广告计划
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private Map<String, Object> createGroupLevelAd(CtopOauthToken oauthToken, JSONObject groupJson) throws Exception {
         JSONObject unitJson = new JSONObject();
         //广告计划ID
-        if (!Check.isNull(groupJson.getString("campaignId"))) {
-            unitJson.put("campaign_id", groupJson.getString("campaignId"));
+        if (!Check.isNull(groupJson.getLong("campaignId"))) {
+            unitJson.put("campaign_id", groupJson.getLong("campaignId"));
+        } else {
+            return getNullValueResult("广告组必填参数:campaign_id,广告计划ID为空");
         }
         //广告组名称
         if (!Check.isNull(groupJson.getString("unitName"))) {
             unitJson.put("unit_name", groupJson.getString("unitName"));
+        } else {
+            return getNullValueResult("广告组必填参数:unit_name,广告组名称为空");
         }
         // 优化目标出价类型
         if (!Check.isNull(groupJson.getInteger("bidType"))) {
             unitJson.put("bid_type", groupJson.getInteger("bidType"));
+        } else {
+            return getNullValueResult("广告组必填参数:bid_type,优化目标出价类型为空");
         }
         /* 资源位置
         1:优选广告位
@@ -68,14 +177,20 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
         Integer sceneId = groupJson.getJSONArray("sceneId").getInteger(0);
         if (!Check.isNull(groupJson.getJSONArray("sceneId"))) {
             unitJson.put("scene_id", groupJson.getJSONArray("sceneId"));
+        } else {
+            return getNullValueResult("广告组必填参数:scene_id,资源位置为空");
         }
         // 资源创作方式  4: 自定义;5:程序化创意  7:程序化创意2.0
         if (!Check.isNull(groupJson.getInteger("unitType"))) {
             unitJson.put("unit_type", groupJson.getInteger("unitType"));
+        } else {
+            return getNullValueResult("广告组必填参数:unit_type,资源创作方式为空");
         }
-        // 创意展现方式1 - 轮播 2 - 优选
+        // 创意展现方式 1-轮播 2-优选
         if (!Check.isNull(groupJson.getInteger("showMode"))) {
             unitJson.put("show_mode", groupJson.getInteger("showMode"));
+        } else {
+            return getNullValueResult("广告组必填参数:show_mode,创意展现方式为空");
         }
         /**
          投放方式
@@ -85,51 +200,52 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
          */
         if (!Check.isNull(groupJson.getInteger("speed"))) {
             unitJson.put("speed", groupJson.getInteger("speed"));
+        } else {
+            return getNullValueResult("广告组必填参数:speed,投放方式为空");
         }
-
         // 封面点击出价
-        if (!Check.isNull(strategy.getBid())) {
-            unitJson.put("bid", strategy.getBid());
+        if (!Check.isNull(groupJson.getLong("bid"))) {
+            unitJson.put("bid", groupJson.getLong("bid"));
         }
-
         // 深度转化出价
-        if (!Check.isNull(strategy.getCpaBid())) {
-            unitJson.put("cpa_bid", strategy.getCpaBid());
+        if (!Check.isNull(groupJson.getLong("cpaBid"))) {
+            unitJson.put("cpa_bid", groupJson.getLong("cpaBid"));
         }
         // 深度转化目标出价
-        if (!Check.isNull(strategy.getDeepConversionBid())) {
-            unitJson.put("deep_conversion_bid", strategy.getDeepConversionBid());
+        if (!Check.isNull(groupJson.getLong("deepConversionBid"))) {
+            unitJson.put("deep_conversion_bid", groupJson.getLong("deepConversionBid"));
         }
         // 深度转化目标
-        if (!Check.isNull(strategy.getDeepConversionType())) {
-            unitJson.put("deep_conversion_type", strategy.getDeepConversionType());
+        if (!Check.isNull(groupJson.getInteger("deepConversionType"))) {
+            unitJson.put("deep_conversion_type", groupJson.getInteger("deepConversionType"));
         }
         // 优化目标
-        if (!Check.isNull(strategy.getOcpxActionType())) {
-            unitJson.put("ocpx_action_type", strategy.getOcpxActionType());
+        if (!Check.isNull(groupJson.getInteger("ocpxActionType"))) {
+            unitJson.put("ocpx_action_type", groupJson.getInteger("ocpxActionType"));
         }
         //投放开始时间
-        if (!Check.isNull(strategy.getBeginTime())) {
+        if (!Check.isNull(groupJson.getString("beginTime"))) {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            boolean beginTimeBoolean = DateUtils.compare(strategy.getBeginTime(), nowDate);
+            boolean beginTimeBoolean = DateUtils.compare(groupJson.getString("beginTime"), nowDate);
             if (beginTimeBoolean) {
                 unitJson.put("begin_time", nowDate);
             } else {
-                unitJson.put("begin_time", strategy.getBeginTime());
+                unitJson.put("begin_time", groupJson.getString("beginTime"));
             }
+        } else {
+            return getNullValueResult("广告组必填参数:begin_time,投放开始时间为空");
         }
         // 投放结束时间
-        if (!Check.isNull(strategy.getEndTime())) {
-            unitJson.put("end_time", strategy.getEndTime());
+        if (!Check.isNull(groupJson.getString("endTime"))) {
+            unitJson.put("end_time", groupJson.getString("beginTime"));
         }
         // 投放时间段
-        if (!Check.isNull(strategy.getScheduleTime())) {
-            unitJson.put("schedule_time", strategy.getScheduleTime());
+        if (!Check.isNull(groupJson.getString("scheduleTime"))) {
+            unitJson.put("schedule_time", groupJson.getString("scheduleTime"));
         }
         //定向模板id(选)
-        Long templateId = strategy.getTemplateId();
-        if (!Check.isNull(templateId)) {
-            unitJson.put("template_id", templateId);
+        if (!Check.isNull(groupJson.getLong("templateId"))) {
+            unitJson.put("template_id", groupJson.getLong("templateId"));
         }
         // 优先从系统应用商店下载 1:优先从系统应用商店下载使用,默认0
         if (!Check.isNull(groupJson.getInteger("useAppMarket"))) {
@@ -180,8 +296,8 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
         // -----------------用户定向-----------
         JSONObject targetJson = new JSONObject();
         // 地域
-        if (!Check.isNull(strategy.getRegion())) {
-            targetJson.put("region", strategy.getRegion());
+        if (!Check.isNull(groupJson.getJSONArray("region"))) {
+            targetJson.put("region", groupJson.getJSONArray("region"));
         }
         // 自定义年龄段
         JSONArray ageArr = groupJson.getJSONArray("age");
@@ -192,16 +308,16 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
             targetJson.put("age", ageJson);
         }
         // 固定年龄段
-        if (!Check.isNull(strategy.getAgesRange())) {
-            targetJson.put("ages_range", strategy.getAgesRange());
+        if (!Check.isNull(groupJson.getJSONArray("agesRange"))) {
+            targetJson.put("ages_range", groupJson.getJSONArray("agesRange"));
         }
         // 性别
-        if (!Check.isNull(strategy.getGender())) {
-            targetJson.put("gender", strategy.getGender());
+        if (!Check.isNull(groupJson.getInteger("gender"))) {
+            targetJson.put("gender", groupJson.getInteger("gender"));
         }
         //操作系统
-        if (!Check.isNull(strategy.getPlatformOs())) {
-            targetJson.put("platform_os", strategy.getPlatformOs());
+        if (!Check.isNull(groupJson.getInteger("platformOs"))) {
+            targetJson.put("platform_os", groupJson.getInteger("platformOs"));
         }
         //Android版本
         if (!Check.isNull(groupJson.getInteger("androidOsv"))) {
@@ -276,19 +392,19 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
             targetJson.put("app_ids", groupJson.getJSONArray("appIds"));
         }
         // 人群包定向
-        if (!Check.isNull(strategy.getPopulation())) {
-            targetJson.put("population", strategy.getPopulation());
+        if (!Check.isNull(groupJson.getJSONArray("population"))) {
+            targetJson.put("population", groupJson.getJSONArray("population"));
         }
         // 人群包排除
-        if (!Check.isNull(strategy.getExcludePopulation())) {
-            targetJson.put("exclude_population", strategy.getExcludePopulation());
+        if (!Check.isNull(groupJson.getJSONArray("excludePopulation"))) {
+            targetJson.put("exclude_population", groupJson.getJSONArray("excludePopulation"));
         }
 
         if (!Check.isNull(groupJson.getJSONArray("thirdPlatformCode"))) {
             targetJson.put("third_platform_code", groupJson.getJSONArray("thirdPlatformCode"));
         }
         unitJson.put("target", targetJson);
-        Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
+        return kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
     }
 
     /**
@@ -299,16 +415,20 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
      * @throws
      * @author ZHAOXA
      */
-    private Map<String, Object> createCreativeLevelStrategy(CtopOauthToken oauthToken, KuaishouStrategy strategy, JSONObject data) {
+    private Map<String, Object> createCreativeLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
         Map<String, Object> resultMap = new HashMap<>();
         JSONObject creativeJson = new JSONObject();
         //广告组ID
         if (!Check.isNull(data.get("unitId"))) {
             creativeJson.put("unit_id", data.get("unitId"));
+        } else {
+            return getNullValueResult("广告创意必填参数:unit_id,广告组ID为空");
         }
         //创意名称
         if (!Check.isNull(data.get("creativeName"))) {
             creativeJson.put("creative_name", data.get("creativeName"));
+        } else {
+            return getNullValueResult("广告创意必填参数:creative_name,创意名称为空");
         }
         //视频ID
         if (!Check.isNull(data.get("photoId"))) {
@@ -325,14 +445,20 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
         String creativeMaterialType = data.getString("creativeMaterialType");
         if (!Check.isNull(creativeMaterialType)) {
             creativeJson.put("creative_material_type", creativeMaterialType);
+        } else {
+            return getNullValueResult("广告创意必填参数:creative_material_type,素材类型为空");
         }
         //行动号召按钮文案
         if (!Check.isNull(data.getString("actionBarText"))) {
             creativeJson.put("action_bar_text", data.getString("actionBarText"));
+        } else {
+            return getNullValueResult("广告创意必填参数:action_bar_text,行动号召按钮文案为空");
         }
         //广告语
         if (!Check.isNull(data.getString("description"))) {
             creativeJson.put("description", data.getString("description"));
+        } else {
+            return getNullValueResult("广告创意必填参数:description,广告语为空");
         }
         //便利贴创意短广告语
         if (!Check.isNull(data.getString("shortSlogan"))) {
@@ -409,4 +535,14 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
         }
         return kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), creativeJson, 1);
     }
+
+    private Map<String, Object> getNullValueResult(String msg) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", -1);
+        map.put("message", "error");
+        map.put("desc", msg);
+        map.put("success", false);
+        return map;
+    }
+
 }