Browse Source

调整批量工具

yumeng 5 years ago
parent
commit
edaa3be083

+ 7 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -165,6 +165,8 @@ public class MaterialInfoController {
                                                      HttpServletRequest req) {
 
         Result<IPage<MaterialInfo>> result = new Result<>();
+        String materialName = materialInfo.getMaterialName();
+        materialInfo.setMaterialName(null);
         QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
         Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
@@ -201,6 +203,10 @@ public class MaterialInfoController {
                 }
             }
         }
+        if (!Check.isNull(materialName)) {
+            queryWrapper.like("material_name", materialName);
+
+        }
         Page<MaterialInfo> page = new Page<>(pageNo, pageSize);
         IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
         List<MaterialInfo> materialInfoList = pageList.getRecords();
@@ -494,7 +500,7 @@ public class MaterialInfoController {
         Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
         Long projectId = materialInfo.getProjectId();
-        if(projectId != null){
+        if (projectId != null) {
             queryWrapper.eq("project_id", projectId);
         }
         queryWrapper.in("code", effiList);

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml

@@ -107,7 +107,7 @@
 
     <select id="queryProjectMemberByUserId" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
         select
-        distinct b.id as projectId,
+        distinct b.project_id as projectId,
         b.project_name as projectName,
         a.advertiser_id as advertiserId,
         a.advertiser_name as advertiserName,

+ 1 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -192,7 +192,6 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                             try {
                                 log.info("快手文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
                                 String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_UPLOAD;
-
                                 String result = exceptInfoForRestTemplate(url, requestJson, headerMap);
                                 JSONObject resultJson = JSONObject.parseObject(result);
                                 if (!Check.isNull(resultJson)) {
@@ -224,6 +223,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                             videoGet.setSignature(signature);
                                             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                                             videoGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
+                                            videoGet.setCoverUrl(materialInfo.getUrl() + "?x-oss-process=video/snapshot,t_10000,m_fast");
                                             kuaiShouVideoGetService.saveOrUpdate(videoGet);
                                             materialUploadImageService.uploadImage(videoGet.getSignature(), accountId, ctopOauthToken.getAccessToken());
 

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

@@ -665,8 +665,13 @@ public class BatchController {
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
 
-            JSONObject unitJson = batchService.createUnit(requestJson);
+            JSONObject unitJson = batchService.createUnit(requestJson, token);
             result.setSuccess(true);
             result.setResult(unitJson);
 
@@ -942,7 +947,7 @@ public class BatchController {
                         if (!Check.isNull(updateMap)) {
                             Integer code = (Integer) updateMap.get("code");
                             if (code == 0) {
-                                iKuaishouInterfaceService.getGroup(token.getAccessToken(), accountId, unitId);
+                                kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
                             } else {
                                 JSONObject failJson = new JSONObject();
                                 failJson.put("message", updateMap.get("message"));
@@ -1007,7 +1012,7 @@ public class BatchController {
                                 Map<String, Object> updateDeepMap = updateService.updateUnitDeepConversionBid(token.getAccessToken(), accountId, unitId, deepConversionBid, userId);
                             }
                         }
-                        iKuaishouInterfaceService.getGroup(token.getAccessToken(), accountId, unitId);
+                        kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
                         if (!Check.isNull(updateMap)) {
                             Integer code = (Integer) updateMap.get("code");
                             if (code != 0) {
@@ -1623,6 +1628,15 @@ public class BatchController {
     public Result<JSONObject> batchCopyUnit(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
         try {
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到token信息");
+            }
+
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
@@ -1630,10 +1644,8 @@ public class BatchController {
             if (Check.isNull(unitIds)) {
                 throw new Exception("请选择需要修改的广告组");
             }
-            Long accountId = requestJson.getLong("accountId");
-            Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
-
 
+            Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
             JSONObject returnJson = new JSONObject();
             JSONArray failArr = new JSONArray();
             for (int i = 0; i < unitIds.size(); i++) {
@@ -1641,7 +1653,7 @@ public class BatchController {
                 if (Check.isNull(unitId)) {
                     continue;
                 }
-
+                kuaiShouGroupService.getGroupByUnitId(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
                 QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("account_id", accountId);
                 queryWrapper.eq("unit_id", unitId);
@@ -1659,7 +1671,7 @@ public class BatchController {
                     unitName = unitNameStr;
                 }
                 group.setUnitName(unitName + RandomUtil.verifyCode());
-                JSONObject unitJson = batchService.copyUnit(group, copyToCampaignId);
+                JSONObject unitJson = batchService.copyUnit(group, copyToCampaignId, oauthToken);
                 if (!Check.isNull(unitJson)) {
                     Integer code = unitJson.getInteger("code");
                     if (code != 0) {
@@ -1695,10 +1707,15 @@ public class BatchController {
     public Result<JSONObject> copyUnit(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
         try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
             JSONObject returnJson = new JSONObject();
 
-            Long accountId = requestJson.getLong("accountId");
             Long unitId = requestJson.getLong("unitId");
+            kuaiShouGroupService.getGroupByUnitId(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
             Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
             JSONArray failArr = new JSONArray();
             Integer createCount = requestJson.getInteger("createCount");
@@ -1706,7 +1723,7 @@ public class BatchController {
                 throw new Exception("请选择迭代次数");
             }
             if (createCount == 1) {
-                JSONObject createJson = batchService.createUnit(requestJson);
+                JSONObject createJson = batchService.createUnit(requestJson, oauthToken);
                 if (!Check.isNull(createJson)) {
                     failArr = createJson.getJSONArray("fail");
                 }
@@ -1733,7 +1750,7 @@ public class BatchController {
                     for (int i = 0; i < createCount; i++) {
                         String randomName = unitName + RandomUtil.verifyCode();
                         group.setUnitName(randomName);
-                        JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId);
+                        JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId, oauthToken);
                         if (copyUnitJson.getInteger("code") != 0) {
                             JSONObject errJson = new JSONObject();
                             errJson.put("message", copyUnitJson.getString("message"));
@@ -1754,7 +1771,7 @@ public class BatchController {
                                 continue;
                             }
                             group.setUnitName(copyUnitName);
-                            JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId);
+                            JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId, oauthToken);
                             if (copyUnitJson.getInteger("code") != 0) {
                                 JSONObject errJson = new JSONObject();
                                 errJson.put("message", copyUnitJson.getString("message"));

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

@@ -58,7 +58,7 @@ public interface IBatchService {
      * @param requestJson
      * @return
      */
-    JSONObject createUnit(JSONObject requestJson) throws Exception;
+    JSONObject createUnit(JSONObject requestJson,CtopOauthToken oauthToken) throws Exception;
 
     /**
      * 批量复制广告组
@@ -66,7 +66,7 @@ public interface IBatchService {
      * @param copyToCampaignId
      * @return
      */
-    JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId);
+    JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId, CtopOauthToken oauthToken);
 
 
     /**
@@ -110,7 +110,7 @@ public interface IBatchService {
      * @param requestJson
      * @return
      */
-    JSONObject updateUnit(JSONObject requestJson,CtopOauthToken token) throws Exception;
+    JSONObject updateUnit(JSONObject requestJson, CtopOauthToken token) throws Exception;
 
     /**
      * 修改广告创意

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

@@ -12,4 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
 
     void getGroupList(String accessToken, Long accountId);
+
+    void getGroupByUnitId(String accessToken, Long accountId, Long unitId);
 }

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

@@ -139,16 +139,6 @@ public interface IKuaishouInterfaceService {
 
 
     /**
-     * 获取广告组信息 单条
-     *
-     * @param accessToken
-     * @param advertiserId
-     * @param
-     */
-    void getGroup(String accessToken, Long advertiserId, Long unitId);
-
-
-    /**
      * 获取创意列表
      *
      * @param token

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

@@ -169,12 +169,8 @@ public class BatchServiceImpl implements IBatchService {
      * @return
      */
     @Override
-    public JSONObject createUnit(JSONObject requestJson) throws Exception {
-        Long accountId = requestJson.getLong("accountId");
-        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-        if (Check.isNull(oauthToken)) {
-            throw new Exception("未获取到账户信息");
-        }
+    public JSONObject createUnit(JSONObject requestJson, CtopOauthToken oauthToken) throws Exception {
+
 
         JSONObject unitJson = new JSONObject();
 
@@ -408,7 +404,7 @@ public class BatchServiceImpl implements IBatchService {
                     unitJson.put("unit_name", unitName);
                 }
 
-                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
+                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson);
                 if (!Check.isNullMap(returnUnitMap)) {
                     Integer code = (Integer) returnUnitMap.get("code");
                     if (code == 0) {
@@ -428,7 +424,7 @@ public class BatchServiceImpl implements IBatchService {
                                     @Override
                                     public void run() {
                                         try {
-                                            copyCreative(accountId, unitId, copyUnitId);
+                                            copyCreative(oauthToken.getAccountId(), unitId, copyUnitId);
                                         } catch (Exception e) {
                                             e.printStackTrace();
                                         }
@@ -465,14 +461,9 @@ public class BatchServiceImpl implements IBatchService {
 
 
     @Override
-    public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId) {
+    public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId, CtopOauthToken oauthToken) {
         JSONObject returnJson = new JSONObject();
         try {
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(group.getAccountId());
-            if (Check.isNull(oauthToken)) {
-                throw new Exception("未获取到token信息");
-            }
-
             JSONObject unitJson = new JSONObject();
             unitJson.put("campaign_id", copyToCampaignId);
 
@@ -1002,186 +993,202 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONObject updateUnit(JSONObject requestJson, CtopOauthToken token) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        try {
 
-        JSONObject unitJson = new JSONObject();
-        unitJson.put("advertiser_id", token.getAccountId());
-
-        Long unitId = requestJson.getLong("unitId");
-        if (Check.isNull(unitId)) {
-            throw new Exception("请选择广告组");
-        }
+            JSONObject unitJson = new JSONObject();
+            unitJson.put("advertiser_id", token.getAccountId());
 
-        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"))) {
+            Long unitId = requestJson.getLong("unitId");
+            if (Check.isNull(unitId)) {
+                throw new Exception("请选择广告组");
+            }
 
-            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            boolean beginTimeBoolean = DateUtils.compare(requestJson.getString("beginTime"), nowDate);
-            if (beginTimeBoolean) {
-                unitJson.put("begin_time", nowDate);
-            } else {
-                unitJson.put("begin_time", requestJson.getString("beginTime"));
+            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"))) {
 
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                boolean beginTimeBoolean = DateUtils.compare(requestJson.getString("beginTime"), nowDate);
+                if (beginTimeBoolean) {
+                    unitJson.put("begin_time", nowDate);
+                } else {
+                    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"));
-        }
+            }
+            // 投放结束时间
+            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.getInteger("useAppMarket"))) {
+                unitJson.put("use_app_market", requestJson.getInteger("useAppMarket"));
+            }
+            // 转化目标
+            if (!Check.isNull(requestJson.getInteger("convertId"))) {
+                unitJson.put("convert_id", requestJson.getInteger("convertId"));
+            }
 
-        // 地域
-        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 targetJson = new JSONObject();
 
-        JSONObject intelliExtendJson = new JSONObject();
+            // 地域
+            if (!Check.isNull(requestJson.getJSONArray("region"))) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
 
-        // 开启智能扩量
-        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);
-        }
+            // 自定义年龄段
+            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"));
+            }
 
-        unitJson.put("target", targetJson);
+            JSONObject intelliExtendJson = new JSONObject();
 
-        JSONObject returnJson = updateService.updateUnit(token.getAccessToken(), unitJson);
+            // 开启智能扩量
+            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);
+
+            returnJson = updateService.updateUnit(token.getAccessToken(), unitJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
         return returnJson;
     }
 

+ 30 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -54,7 +54,6 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
      */
     @Override
     public void getGroupList(String accessToken, Long accountId) {
-
         QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
         campaignQueryWrapper.eq("account_id", accountId);
         campaignQueryWrapper.eq("status", 4);
@@ -109,6 +108,36 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     }
 
 
+    @Override
+    public void getGroupByUnitId(String accessToken, Long accountId, Long unitId) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("unit_id", unitId);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            log.error("获取广告组接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            log.error("获取广告组返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        addGroupV2(accountId, details);
+    }
+
+
     private void addGroupV2(Long advertiserId, JSONArray details) {
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();

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

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.mapper.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONObject;
@@ -113,6 +114,8 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
      * @param dayBudget
      * @return
      */
+    @Autowired
+    private IKuaiShouGroupService groupService;
     @Override
     public Map<String, Object> updateUnitDayBudget(String token, Long advertiserId, Long unitId, Long dayBudget, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -148,7 +151,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         log.info("修改广告组预算本地记录添加成功,unitId:{}", unitId);
                     }
                     // 重新请求数据
-                    interfaceService.getGroup(token, advertiserId, unitId);
+                    groupService.getGroupByUnitId(token, advertiserId, unitId);
                     returnMap.put("code", 0);
                     returnMap.put("success", true);
                     returnMap.put("message", "修改成功");
@@ -369,7 +372,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         deleteMap.put("unit_id", unitId);
                         groupMapper.deleteByMap(deleteMap);
                     } else {
-                        interfaceService.getGroup(token, advertiserId, unitId);
+                        groupService.getGroupByUnitId(token, advertiserId, unitId);
                     }
 
 
@@ -592,7 +595,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     if (!Check.isNull(data)) {
                         try {
                             Thread.sleep(500);
-                            interfaceService.getGroup(accessToken, unitJson.getLong("advertiser_id"), data.getLong("unit_id"));
+                            groupService.getGroupByUnitId(accessToken, unitJson.getLong("advertiser_id"), data.getLong("unit_id"));
                         } catch (InterruptedException e) {
                             e.printStackTrace();
                         }

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

@@ -64,10 +64,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private KuaiShouGroupMapper groupMapper;
     @Autowired
-    private KuaiShouAppInfoMapper appInfoMapper;
-    @Autowired
-    private KuaiShouScheduleMapper shouScheduleMapper;
-    @Autowired
     private IKuaiShouCreativeService creativeService;
     @Autowired
     private KuaiShouConversionInfosMapper conversionInfosMapper;
@@ -98,8 +94,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private MaterialInfoMapper materialInfoMapper;
     @Autowired
-    private KuaiShouGroupTargetMapper groupTargetMapper;
-    @Autowired
     private KuaiShouTargetingTagsMapper targetingTagsMapper;
     @Autowired
     private KuaishouReportDailyAccountMapper dailyAccountMapper;
@@ -135,6 +129,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouDailyFlowsService kuaiShouDailyFlowsService;
     @Autowired
     private IKuaishouPopulationService populationService;
+    @Autowired
+    private IKuaiShouGroupService getKuaiShouGroupService;
 
 
     @Override
@@ -986,6 +982,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param requestJson
      * @return
      */
+
+
     @Override
     public Map<String, Object> adUnitCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -1013,7 +1011,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             public void run() {
                                 try {
                                     Thread.sleep(500);
-                                    getGroup(accessToken, advertiserId, unitId);
+                                    getKuaiShouGroupService.getGroupByUnitId(accessToken, advertiserId, unitId);
                                 } catch (InterruptedException e) {
                                     e.printStackTrace();
                                 }
@@ -1198,60 +1196,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
-    /**
-     * 根据 id 获取组
-     *
-     * @param accessToken
-     * @param advertiserId
-     * @param unitId
-     */
-    @Override
-    public void getGroup(String accessToken, Long advertiserId, Long unitId) {
-
-        Map<String, Object> map = new HashMap<>();
-        map.put("unit_id", unitId);
-        map.put("account_id", advertiserId);
-        groupMapper.deleteByMap(map);
-        appInfoMapper.deleteByMap(map);
-        shouScheduleMapper.deleteByMap(map);
-
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Access-Token", accessToken);
-        headers.put("Content-Type", " application/json");
-
-        JSONObject param = new JSONObject();
-        param.put("advertiser_id", advertiserId);
-        param.put("unit_id", unitId);
-
-        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
-        try {
-            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
-            JSONObject resultJson = JSONObject.parseObject(result);
-            if (!Check.isNull(resultJson)) {
-                Integer code = resultJson.getInteger("code");
-                if (code == 0) {
-                    JSONObject dataJson = resultJson.getJSONObject("data");
-                    if (!Check.isNull(dataJson)) {
-                        JSONArray details = dataJson.getJSONArray("details");
-                        if (!Check.isNull(details)) {
-                            addGroup(advertiserId, details);
-                        }
-
-                    } else {
-                        log.error("获取广告组返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
-                    }
-                } else {
-                    log.error("获取广告组返回结果为空,advertiserId:{}", advertiserId);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-
-    }
-
-
     private void addGroup(Long advertiserId, JSONArray details) {
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();