yumeng 5 éve
szülő
commit
489c1a2fb6

+ 4 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java

@@ -66,11 +66,14 @@ public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMappe
                     .append("&scope=%5B%22report_service%22%2C%22ad_query%22%2C%22account_service%22%2C%22ad_manage%22%5D")
                     .append("&redirect_uri=" + URLEncoder.encode(PropertiesUtils.getValue("kuaishou_config", "kuaishou_callback_url"), "UTF-8"));
         } else if (agentType == 0) {
+
+            // &scope=%5B%22ad_query%22%2C%22ad_manage%22%5D&
+            // &scope=%5B%22report_service%22%2C%22ad_query%22%2C%22account_service%22%2C%22ad_manage%22%5D
             sb.append(PropertiesUtils.getValue("kuaishou_config", "kuaishou_auth_url"))
                     .append(KuaishouInterfaceConstant.AUTH_PATH)
                     .append("?app_id=" + PropertiesUtils.getValue("kuaishou_config", "kuaishou_third_appid"))
                     .append("&state=" + URLEncoder.encode(URLEncoder.encode(state)))
-                    .append("&scope=%5B%22report_service%22%2C%22ad_query%22%2C%22account_service%22%2C%22ad_manage%22%5D")
+                    .append("&scope=%5B%22ad_query%22%2C%22ad_manage%22%5D&")
                     .append("&redirect_uri=" + URLEncoder.encode(PropertiesUtils.getValue("kuaishou_config", "kuaishou_callback_url"), "UTF-8"));
         }
 

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

@@ -1523,4 +1523,51 @@ public class BatchController {
         return result;
     }
 
+
+    @PostMapping(value = "/batchCopyUnit")
+    public Result<JSONObject> batchCopyUnit(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参为空");
+            }
+            JSONArray unitIds = requestJson.getJSONArray("unitIds");
+            if (Check.isNull(unitIds)) {
+                throw new Exception("请选择需要修改的广告组");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            Long campaignId = requestJson.getLong("campaignId");
+            Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
+            JSONObject returnJson = new JSONObject();
+            JSONArray failArr = new JSONArray();
+            for (int i = 0; i < unitIds.size(); i++) {
+                Long unitId = unitIds.getLong(i);
+                if (Check.isNull(unitId)) {
+                    continue;
+                }
+                JSONObject unitJson = batchService.copyUnit(accountId, campaignId, unitId, copyToCampaignId);
+                if (!Check.isNull(unitJson)) {
+                    Integer code = unitJson.getInteger("code");
+                    if (code != 0) {
+                        JSONObject failJson = new JSONObject();
+                        failJson.put("message", unitJson.get("message"));
+                        failJson.put("unitName", unitJson.get("unitName"));
+                        failArr.add(failJson);
+                    }
+                }
+                Thread.sleep(200);
+            }
+            returnJson.put("totalCount", unitIds.size());
+            returnJson.put("failCount", failArr.size());
+            returnJson.put("failInfo", failArr);
+            result.setSuccess(true);
+            result.setResult(returnJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
 }

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

@@ -59,6 +59,17 @@ public interface IBatchService {
      */
     JSONObject createUnit(JSONObject requestJson) throws Exception;
 
+    /**
+     * 批量复制广告组
+     *
+     * @param accountId
+     * @param campaignId
+     * @param unitId
+     * @param copyToCampaignId
+     * @return
+     */
+    JSONObject copyUnit(Long accountId, Long campaignId, Long unitId, Long copyToCampaignId);
+
 
     /**
      * 获取广告组信息

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

@@ -144,19 +144,27 @@ 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)) {
             throw new Exception("未获取到账户信息");
         }
 
+        JSONObject unitJson = new JSONObject();
+        String type = requestJson.getString("type");
+
         Long campaignId = requestJson.getLong("campaignId");
         if (Check.isNull(campaignId)) {
             throw new Exception("请选择广告计划");
         }
+        Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
+        if (!Check.isNull(type) && "copy".equals(type)) {
+            unitJson.put("campaign_id", copyToCampaignId);
+        } else {
+            unitJson.put("campaign_id", campaignId);
+        }
 
-        JSONObject unitJson = new JSONObject();
-        unitJson.put("campaign_id", campaignId);
 
         // 资源位置
         JSONArray scene_id = requestJson.getJSONArray("sceneId");
@@ -310,8 +318,6 @@ public class BatchServiceImpl implements IBatchService {
         }
 
         unitJson.put("target", targetJson);
-
-
         JSONArray groupArr = requestJson.getJSONArray("groupArr");
         if (Check.isNull(groupArr)) {
             throw new Exception("请输入需要创建的广告组");
@@ -324,9 +330,11 @@ public class BatchServiceImpl implements IBatchService {
         JSONArray successArr = new JSONArray();
         JSONArray failArr = new JSONArray();
 
+
         for (int i = 0; i < groupArr.size(); i++) {
             JSONObject groupJson = groupArr.getJSONObject(i);
             if (!Check.isNull(groupJson)) {
+
                 // 出价
                 if (!Check.isNull(groupJson.getLong("bid"))) {
                     unitJson.put("bid", groupJson.getLong("bid"));
@@ -355,10 +363,9 @@ public class BatchServiceImpl implements IBatchService {
                 }
                 String unitName = groupJson.getString("unitName");
                 if (!Check.isNull(unitName)) {
-                    unitJson.put("unit_name", unitName);
+                    unitJson.put("unit_name", unitName + RandomUtil.verifyCode());
                 }
 
-
                 Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
                 if (!Check.isNullMap(returnUnitMap)) {
                     Integer code = (Integer) returnUnitMap.get("code");
@@ -371,19 +378,22 @@ public class BatchServiceImpl implements IBatchService {
                         successJson.put("sceneId", scene_id);
                         successJson.put("ocpxActionType", ocpx_action_type);
                         successArr.add(successJson);
-
-
-                        String type = requestJson.getString("type");
                         if (!Check.isNull(type) && "copy".equals(type)) {
                             Long copyUnitId = requestJson.getLong("copyUnitId");
                             if (!Check.isNull(unitId) && !Check.isNull(copyUnitId)) {
-                                copyCreative(accountId, unitId, copyUnitId);
+                                Thread thread = new Thread() {
+                                    @Override
+                                    public void run() {
+                                        try {
+                                            copyCreative(accountId, unitId, copyUnitId);
+                                        } catch (Exception e) {
+                                            e.printStackTrace();
+                                        }
+                                    }
+                                };
+                                thread.start();
                             }
-
-
                         }
-
-
                     } else {
                         JSONObject failJson = new JSONObject();
                         failJson.put("unitName", unitName);
@@ -413,7 +423,9 @@ public class BatchServiceImpl implements IBatchService {
     @Autowired
     private KuaiShouGroupTargetMapper targetMapper;
 
-    private JSONObject copyUnit(Long accountId, Long campaignId, Long unitId) throws Exception {
+
+    @Override
+    public JSONObject copyUnit(Long accountId, Long campaignId, Long unitId, Long copyToCampaignId) {
         JSONObject returnJson = new JSONObject();
 
         try {
@@ -427,15 +439,14 @@ public class BatchServiceImpl implements IBatchService {
 
             }
 
-
             CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
             if (Check.isNull(oauthToken)) {
                 throw new Exception("未获取到token信息");
             }
 
-
             JSONObject unitJson = new JSONObject();
-            unitJson.put("campaign_id", campaignId);
+
+            unitJson.put("campaign_id", copyToCampaignId);
 
             // 资源位置
             JSONArray scene_id = JSONArray.parseArray(group.getSceneId());
@@ -445,243 +456,242 @@ public class BatchServiceImpl implements IBatchService {
 
             // 资源创作方式
             if (!Check.isNull(group.getUnitType())) {
-                unitJson.put("unit_type", group.getUnitType());
-            }
-
-            //投放开始时间
-            if (!Check.isNull(group.getBeginTime())) {
-                unitJson.put("begin_time", group.getBeginTime());
-            }
-            // 投放结束时间
-            if (!Check.isNull(group.getEndTime())) {
-                unitJson.put("end_time", group.getEndTime());
-            }
-            // 投放时间段
-            if (!Check.isNull(group.getScheduleTime())) {
-                unitJson.put("schedule_time", group.getScheduleTime());
-            }
-            // 广告组单日预算
-            if (!Check.isNull(group.getDayBudget())) {
-                unitJson.put("day_budget", group.getDayBudget());
-            }
-            // url类型
-            if (!Check.isNull(group.getUrlType())) {
-                unitJson.put("url_type", group.getUrlType());
-            }
-            // url
-            if (!Check.isNull(group.getUrl())) {
-                unitJson.put("url", group.getUrl());
-            }
-            // appId
-            if (!Check.isNull(group.getAppId())) {
-                unitJson.put("app_id", group.getAppId());
-            }
-            // 创意展现方式
-            if (!Check.isNull(group.getShowMode())) {
-                unitJson.put("show_mode", group.getShowMode());
-            }
-            if (!Check.isNull(group.getSpeed())) {
-                unitJson.put("speed", group.getSpeed());
-            }
-
-
-            QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
-            targetQueryWrapper.eq("account_id", accountId);
-            targetQueryWrapper.eq("unit_id", unitId);
-            targetQueryWrapper.last("limit 1");
-            KuaiShouGroupTarget groupTarget = targetMapper.selectOne(targetQueryWrapper);
-            if (!Check.isNull(groupTarget)) {
-                // -----------------用户定向-----------
-                JSONObject targetJson = new JSONObject();
-
-                // 地域
-                if (!Check.isNull(groupTarget.getRegion())) {
-                    targetJson.put("region", groupTarget.getRegion());
-                }
-
-                // 自定义年龄段
-                Integer ageMin = groupTarget.getAgeMin();
-                Integer ageMax = groupTarget.getAgeMax();
-
-
-                JSONObject ageJson = new JSONObject();
-                if (!Check.isNull(ageMin)) {
-                    ageJson.put("min", ageMin);
-
-                }
-                if (!Check.isNull(ageMax)) {
-                    ageJson.put("max", ageMax);
-
+                if (!Check.isNull(group.getUnitType())) {
+                    unitJson.put("unit_type", group.getUnitType());
                 }
 
-                targetJson.put("age", ageJson);
-
-                // 固定年龄段
-                if (!Check.isNull(groupTarget.getAgesRange())) {
-                    targetJson.put("ages_range", groupTarget.getAgesRange());
-                }
-                // 性别
-                if (!Check.isNull(groupTarget.getGender())) {
-                    targetJson.put("gender", groupTarget.getGender());
-                }
-                //操作系统
-                if (!Check.isNull(groupTarget.getPlatformOs())) {
-                    targetJson.put("platform_os", groupTarget.getPlatformOs());
-                }
-                //Android版本
-                if (!Check.isNull(groupTarget.getAndroidOsv())) {
-                    targetJson.put("android_osv", groupTarget.getAndroidOsv());
+                //投放开始时间
+                if (!Check.isNull(group.getBeginTime())) {
+                    unitJson.put("begin_time", group.getBeginTime());
                 }
-                // iOS版本
-                if (!Check.isNull(groupTarget.getIosOsv())) {
-                    targetJson.put("ios_osv", groupTarget.getIosOsv());
+                // 投放结束时间
+                if (!Check.isNull(group.getEndTime())) {
+                    unitJson.put("end_time", group.getEndTime());
                 }
-                //网络环境
-                if (!Check.isNull(groupTarget.getNetwork())) {
-                    targetJson.put("network", groupTarget.getNetwork());
+                // 投放时间段
+                if (!Check.isNull(group.getScheduleTime())) {
+                    unitJson.put("schedule_time", group.getScheduleTime());
                 }
-                //设备品牌
-                if (!Check.isNull(groupTarget.getDeviceBrand())) {
-                    targetJson.put("device_brand", groupTarget.getDeviceBrand());
+                // 广告组单日预算
+                if (!Check.isNull(group.getDayBudget())) {
+                    unitJson.put("day_budget", group.getDayBudget());
                 }
-                //设备价格
-                if (!Check.isNull(groupTarget.getDevicePrice())) {
-                    targetJson.put("device_price", groupTarget.getDevicePrice());
+                // url类型
+                if (!Check.isNull(group.getUrlType())) {
+                    unitJson.put("url_type", group.getUrlType());
                 }
-                //商业兴趣类型
-                if (!Check.isNull(groupTarget.getBusinessInterestType())) {
-                    targetJson.put("business_interest_type", groupTarget.getBusinessInterestType());
+                // url
+                if (!Check.isNull(group.getUrl())) {
+                    unitJson.put("url", group.getUrl());
                 }
-                // 商业兴趣
-                if (!Check.isNull(groupTarget.getBusinessInterest())) {
-                    targetJson.put("business_interest", groupTarget.getBusinessInterest());
+                // appId
+                if (!Check.isNull(group.getAppId())) {
+                    unitJson.put("app_id", group.getAppId());
                 }
-                //网红粉丝
-                if (!Check.isNull(groupTarget.getFansStar())) {
-                    targetJson.put("fans_star", groupTarget.getFansStar());
+                // 创意展现方式
+                if (!Check.isNull(group.getShowMode())) {
+                    unitJson.put("show_mode", group.getShowMode());
                 }
-                //兴趣视频用户
-                if (!Check.isNull(groupTarget.getInterestVideo())) {
-                    targetJson.put("interest_video", groupTarget.getInterestVideo());
-                }
-                // APP行为-按分类
-                if (!Check.isNull(groupTarget.getAppInterest())) {
-                    targetJson.put("app_interest", groupTarget.getAppInterest());
-                }
-                // APP行为-按APP名称
-                if (!Check.isNull(groupTarget.getAppIds())) {
-                    targetJson.put("app_ids", groupTarget.getAppIds());
-                }
-                // 人群包定向
-                if (!Check.isNull(groupTarget.getPopulation())) {
-                    targetJson.put("population", groupTarget.getPopulation());
-                }
-                // 人群包排除
-                if (!Check.isNull(groupTarget.getExcludePopulation())) {
-                    targetJson.put("exclude_population", groupTarget.getExcludePopulation());
+                if (!Check.isNull(group.getSpeed())) {
+                    unitJson.put("speed", group.getSpeed());
                 }
 
-                JSONObject intelliExtendJson = new JSONObject();
 
-                // 开启智能扩量
-                if (!Check.isNull(groupTarget.getIsOpen())) {
-                    intelliExtendJson.put("is_open", groupTarget.getIsOpen());
-                }
-                //不可突破年龄
-                if (!Check.isNull(groupTarget.getNoAgeBreak())) {
-                    intelliExtendJson.put("no_age_break", groupTarget.getNoAgeBreak());
-                }
-                //不可突破性别
-                if (!Check.isNull(groupTarget.getNoGenderBreak())) {
-                    intelliExtendJson.put("no_gender_break", groupTarget.getNoGenderBreak());
-                }
-                // 不可突破地域
-                if (!Check.isNull(groupTarget.getNoAreaBreak())) {
-                    intelliExtendJson.put("no_area_break", groupTarget.getNoAreaBreak());
-                }
-                if (!Check.isNull(intelliExtendJson)) {
-                    targetJson.put("intelli_extend", intelliExtendJson);
-                }
+                QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
+                targetQueryWrapper.eq("account_id", accountId);
+                targetQueryWrapper.eq("unit_id", unitId);
+                targetQueryWrapper.last("limit 1");
+                KuaiShouGroupTarget groupTarget = targetMapper.selectOne(targetQueryWrapper);
+                if (!Check.isNull(groupTarget)) {
+                    // -----------------用户定向-----------
+                    JSONObject targetJson = new JSONObject();
 
-                unitJson.put("target", targetJson);
+                    // 地域
+                    if (!Check.isNull(groupTarget.getRegion())) {
+                        targetJson.put("region", JSONArray.parseArray(groupTarget.getRegion()));
+                    }
 
+                    // 自定义年龄段
+                    Integer ageMin = groupTarget.getAgeMin();
+                    Integer ageMax = groupTarget.getAgeMax();
 
-            }
 
+                    JSONObject ageJson = new JSONObject();
+                    if (!Check.isNull(ageMin)) {
+                        ageJson.put("min", ageMin);
+                    }
+                    if (!Check.isNull(ageMax)) {
+                        ageJson.put("max", ageMax);
+                    }
 
-            // 出价
-            if (!Check.isNull(group.getBid())) {
-                unitJson.put("bid", group.getBid());
-            }
-            // 出价类型
-            Integer bidType = group.getBidType();
-            if (!Check.isNull(bidType)) {
-                unitJson.put("bid_type", bidType);
-            }
-            // 深度转化出价
-            if (!Check.isNull(group.getCpaBid())) {
-                unitJson.put("cpa_bid", group.getCpaBid());
-            }
-            // 深度转化目标出价
-            if (!Check.isNull(group.getDeepConversionBid())) {
-                unitJson.put("deep_conversion_bid", group.getDeepConversionBid());
-            }
-            // 深度转化目标
-            if (!Check.isNull(group.getDeepConversionType())) {
-                unitJson.put("deep_conversion_type", group.getDeepConversionType());
-            }
-            // 优化目标
-            Integer ocpx_action_type = group.getOcpxActionType();
-            if (!Check.isNull(ocpx_action_type)) {
-                unitJson.put("ocpx_action_type", ocpx_action_type);
-            }
-            String unitName = group.getUnitName();
-            if (!Check.isNull(unitName)) {
-                unitJson.put("unit_name", unitName);
-            }
+                    targetJson.put("age", ageJson);
 
+                    // 固定年龄段
+                    if (!Check.isNull(groupTarget.getAgesRange())) {
+                        targetJson.put("ages_range", JSONArray.parseArray(groupTarget.getAgesRange()));
+                    }
+                    // 性别
+                    if (!Check.isNull(groupTarget.getGender())) {
+                        targetJson.put("gender", groupTarget.getGender());
+                    }
+                    //操作系统
+                    if (!Check.isNull(groupTarget.getPlatformOs())) {
+                        targetJson.put("platform_os", groupTarget.getPlatformOs());
+                    }
+                    //Android版本
+                    if (!Check.isNull(groupTarget.getAndroidOsv())) {
+                        targetJson.put("android_osv", groupTarget.getAndroidOsv());
+                    }
+                    // iOS版本
+                    if (!Check.isNull(groupTarget.getIosOsv())) {
+                        targetJson.put("ios_osv", groupTarget.getIosOsv());
+                    }
+                    //网络环境
+                    if (!Check.isNull(groupTarget.getNetwork())) {
+                        targetJson.put("network", groupTarget.getNetwork());
+                    }
+                    //设备品牌
+                    if (!Check.isNull(groupTarget.getDeviceBrand())) {
+                        targetJson.put("device_brand", JSONArray.parseArray(groupTarget.getDeviceBrand()));
+                    }
+                    //设备价格
+                    if (!Check.isNull(groupTarget.getDevicePrice())) {
+                        targetJson.put("device_price", JSONArray.parseArray(groupTarget.getDevicePrice()));
+                    }
+                    //商业兴趣类型
+                    if (!Check.isNull(groupTarget.getBusinessInterestType())) {
+                        targetJson.put("business_interest_type", groupTarget.getBusinessInterestType());
+                    }
+                    // 商业兴趣
+                    if (!Check.isNull(groupTarget.getBusinessInterest())) {
+                        targetJson.put("business_interest", JSONArray.parseArray(groupTarget.getBusinessInterest()));
+                    }
+                    //网红粉丝
+                    if (!Check.isNull(groupTarget.getFansStar())) {
+                        targetJson.put("fans_star", JSONArray.parseArray(groupTarget.getFansStar()));
+                    }
+                    //兴趣视频用户
+                    if (!Check.isNull(groupTarget.getInterestVideo())) {
+                        targetJson.put("interest_video", JSONArray.parseArray(groupTarget.getInterestVideo()));
+                    }
+                    // APP行为-按分类
+                    if (!Check.isNull(groupTarget.getAppInterest())) {
+                        targetJson.put("app_interest", JSONArray.parseArray(groupTarget.getAppInterest()));
+                    }
+                    // APP行为-按APP名称
+                    if (!Check.isNull(groupTarget.getAppIds())) {
+                        targetJson.put("app_ids", groupTarget.getAppIds());
+                    }
+                    // 人群包定向
+                    if (!Check.isNull(groupTarget.getPopulation())) {
+                        targetJson.put("population", JSONArray.parseArray(groupTarget.getPopulation()));
+                    }
+                    // 人群包排除
+                    if (!Check.isNull(groupTarget.getExcludePopulation())) {
+                        targetJson.put("exclude_population", JSONArray.parseArray(groupTarget.getExcludePopulation()));
+                    }
 
-            Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
-            if (!Check.isNullMap(returnUnitMap)) {
-                Integer code = (Integer) returnUnitMap.get("code");
-                if (code == 0) {
-                    JSONObject successJson = new JSONObject();
-                    successJson.put("unitId", returnUnitMap.get("unitId"));
-                    successJson.put("unitName", unitName);
-                    successJson.put("sceneId", scene_id);
-                    successJson.put("ocpxActionType", ocpx_action_type);
-                    //  successArr.add(successJson);
+                    JSONObject intelliExtendJson = new JSONObject();
 
+                    // 开启智能扩量
+                    if (!Check.isNull(groupTarget.getIsOpen())) {
+                        intelliExtendJson.put("is_open", groupTarget.getIsOpen());
+                    }
+                    //不可突破年龄
+                    if (!Check.isNull(groupTarget.getNoAgeBreak())) {
+                        intelliExtendJson.put("no_age_break", groupTarget.getNoAgeBreak());
+                    }
+                    //不可突破性别
+                    if (!Check.isNull(groupTarget.getNoGenderBreak())) {
+                        intelliExtendJson.put("no_gender_break", groupTarget.getNoGenderBreak());
+                    }
+                    // 不可突破地域
+                    if (!Check.isNull(groupTarget.getNoAreaBreak())) {
+                        intelliExtendJson.put("no_area_break", groupTarget.getNoAreaBreak());
+                    }
+                    if (!Check.isNull(intelliExtendJson)) {
+                        targetJson.put("intelli_extend", intelliExtendJson);
+                    }
 
-                    // String type = requestJson.getString("type");
-                    //   if (Check.isNull(type) && "copy".equals(type)) {
-                    // Long copyUnitId = requestJson.getLong("copyUnitId");
-                    //   copyCreative(accountId, copyUnitId);
+                    unitJson.put("target", targetJson);
+                }
 
-                    // }
 
+                // 出价
+                if (!Check.isNull(group.getBid())) {
+                    unitJson.put("bid", group.getBid());
+                }
+                // 出价类型
+                Integer bidType = group.getBidType();
+                if (!Check.isNull(bidType)) {
+                    unitJson.put("bid_type", bidType);
+                }
+                // 深度转化出价
+                if (!Check.isNull(group.getCpaBid())) {
+                    unitJson.put("cpa_bid", group.getCpaBid());
+                }
+                // 深度转化目标出价
+                if (!Check.isNull(group.getDeepConversionBid())) {
+                    unitJson.put("deep_conversion_bid", group.getDeepConversionBid());
+                }
+                // 深度转化目标
+                if (!Check.isNull(group.getDeepConversionType())) {
+                    unitJson.put("deep_conversion_type", group.getDeepConversionType());
+                }
+                // 优化目标
+                Integer ocpx_action_type = group.getOcpxActionType();
+                if (!Check.isNull(ocpx_action_type)) {
+                    unitJson.put("ocpx_action_type", ocpx_action_type);
+                }
+                String unitName = group.getUnitName();
+                if (!Check.isNull(unitName)) {
+                    if (campaignId == copyToCampaignId) {
+                        unitJson.put("unit_name", unitName + RandomUtil.verifyCode());
+                    } else {
+                        unitJson.put("unit_name", unitName);
+                    }
+                }
+
+                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
+                if (!Check.isNullMap(returnUnitMap)) {
+                    Integer code = (Integer) returnUnitMap.get("code");
+                    if (code == 0) {
+                        Long copyUnitId = (Long) returnUnitMap.get("unitId");
+                        returnJson.put("unitId", copyUnitId);
+
+                        returnJson.put("unitName", unitName);
+                        returnJson.put("code", 0);
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    copyCreative(accountId, unitId, copyUnitId);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        };
+                        thread.start();
+                    } else {
+                        returnJson.put("code", -1);
+                        returnJson.put("unitName", unitJson.getString("unitName"));
+                        returnJson.put("message", returnUnitMap.get("message"));
+                    }
 
                 } else {
-                    JSONObject failJson = new JSONObject();
-                    failJson.put("unitName", unitName);
-                    failJson.put("failMessage", returnUnitMap.get("message"));
-                    // failArr.add(failJson);
+                    returnJson.put("code", -1);
+                    returnJson.put("message", "快手接口返回数据为空");
                 }
-
             }
-
-
         } catch (Exception e) {
             e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
-
         }
 
         return returnJson;
-    }
-
 
+    }
 
 
     /**

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

@@ -871,11 +871,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             //1: 获取广告主信息数据
             getAdvertiserReportHourly(token, getStartDate, getStartDate);
             //2:获取广告计划信息数据
-            getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
+            // getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
             //3:获取广告组信息数据
-            getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
+            // getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
             //4: 获取广告创意信息数据
-            getAdvertiserCreativeReportHourly(token, getStartDate, getStartDate);
+            // getAdvertiserCreativeReportHourly(token, getStartDate, getStartDate);
         }
         //获取全量广告计划数据
         getCampaignList(token, null, null);