Browse Source

Merge remote-tracking branch 'origin/test' into test

xuzuoyun 5 năm trước cách đây
mục cha
commit
cb5fdfb888
45 tập tin đã thay đổi với 3304 bổ sung325 xóa
  1. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 12 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  3. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  4. 48 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  5. 58 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAppListJob.java
  6. 1 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java
  7. 16 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  8. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountWarningLoadJob.java
  9. 42 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/TargetingTagsJob.java
  10. 2 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/shiro/authc/aop/JwtFilter.java
  11. 72 2
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  12. 67 0
      module-common/src/main/java/cn/com/ctop/common/module/enums/MaterialEnum.java
  13. 0 7
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java
  14. 3 2
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java
  15. 17 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  16. 59 3
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java
  17. 791 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  18. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouTargetingTagsController.java
  19. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaignDayBudget.java
  20. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaignStatus.java
  21. 77 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java
  22. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupBid.java
  23. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupDayBudget.java
  24. 7 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java
  25. 71 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouTargetingTags.java
  26. 4 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  27. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/BatchMapper.java
  28. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouTargetingTagsMapper.java
  29. 9 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/BatchMapper.xml
  30. 27 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  31. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouImageGetMapper.xml
  32. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouTargetingTagsMapper.xml
  33. 11 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  34. 67 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  35. 0 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouImageGetService.java
  36. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouTargetingTagsService.java
  37. 46 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  38. 12 16
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java
  39. 486 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  40. 19 17
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreateAppTemplateServiceImpl.java
  41. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouTargetingTagsServiceImpl.java
  42. 44 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  43. 869 206
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  44. 30 2
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml
  45. 2 2
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -133,6 +133,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/system/userCompany/**", "anon");
         filterChainDefinitionMap.put("/qywexin", "anon");
         filterChainDefinitionMap.put("/test/getGroupData/**", "anon");
+        filterChainDefinitionMap.put("/test/getVideoAndImage/**", "anon");
+        filterChainDefinitionMap.put("/test/gerCreative/**", "anon");
 
 		filterChainDefinitionMap.put("/report/kuaishouReportDailyAgent/get","anon");
 

+ 12 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java

@@ -85,7 +85,7 @@ public class AdvertiserController {
         Result<IPage<Advertiser>> result = new Result<IPage<Advertiser>>();
         String roleCode = materialReportMapper.getRoleCodeByUserId(advertiser.getUserId());
         String userId = advertiser.getUserId();
-        if ("admin".equals(roleCode) || "kuaishouOperationManager".equals(roleCode)|| "touTiaoOperationManager".equals(roleCode)) {
+        if ("admin".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode)) {
             advertiser.setUserId(null);
         }
         QueryWrapper<Advertiser> queryWrapper = QueryGenerator.initQueryWrapper(advertiser, req.getParameterMap());
@@ -130,26 +130,26 @@ public class AdvertiserController {
     public Result<Advertiser> add(@RequestBody Advertiser advertiser) {
         Result<Advertiser> result = new Result<Advertiser>();
         try {
+            String userId = advertiser.getUserId();
             String name = advertiser.getName().trim();
+            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
+            userCompanyQueryWrapper.eq("user_id", userId);
+            userCompanyQueryWrapper.orderByDesc("create_time");
+            userCompanyQueryWrapper.last("limit 1");
+            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
             QueryWrapper<Advertiser> advertiserQueryWrapper = new QueryWrapper<>();
             advertiserQueryWrapper.eq("name", name);
+            if (!Check.isNull(userCompany)) {
+                advertiserQueryWrapper.eq("company_id", userCompany.getCompanyId());
+            }
             advertiserQueryWrapper.last("limit 1");
             advertiserQueryWrapper.orderByDesc("create_time");
             Advertiser checkAdvertiser = advertiserService.getOne(advertiserQueryWrapper);
             if (!Check.isNull(checkAdvertiser)) {
                 throw new Exception("广告主已存在");
             }
-
-            String userId = advertiser.getUserId();
-            if (!Check.isNull(userId)) {
-                QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
-                userCompanyQueryWrapper.eq("user_id", userId);
-                userCompanyQueryWrapper.orderByDesc("create_time");
-                userCompanyQueryWrapper.last("limit 1");
-                UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
-                if (!Check.isNull(userCompany)) {
-                    advertiser.setCompanyId(userCompany.getCompanyId());
-                }
+            if (!Check.isNull(userCompany)) {
+                advertiser.setCompanyId(userCompany.getCompanyId());
             }
             advertiserService.save(advertiser);
             result.success("添加成功!");

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

@@ -2,7 +2,10 @@ package org.jeecg.modules.ctop.controller;
 
 
 import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.service.IMaterialAscriptionService;
 import cn.com.ctop.common.module.service.IMaterialInfoService;
+import cn.com.ctop.common.module.service.IMaterialParameterService;
+import cn.com.ctop.common.module.service.IMaterialTagService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import com.alibaba.fastjson.JSON;
@@ -40,8 +43,11 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.text.ParseException;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * 素材信息
@@ -57,6 +63,12 @@ import java.util.Map;
 public class MaterialInfoController {
     @Autowired
     private IMaterialInfoService materialInfoService;
+    @Autowired
+    private IMaterialAscriptionService materialAscriptionService;
+    @Autowired
+    private IMaterialParameterService materialParameterService;
+    @Autowired
+    private IMaterialTagService materialTagService;
 
     @GetMapping(value = "/report")
     public JSONObject report(String userId) {
@@ -82,6 +94,7 @@ public class MaterialInfoController {
         return result;
     }
 
+
     /**
      * 分页列表查询
      *
@@ -246,6 +259,12 @@ public class MaterialInfoController {
     public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
         try {
             materialInfoService.removeById(id);
+            Map<String, Object> deleteMap = new HashMap<>();
+            deleteMap.put("material_id", id);
+
+            materialAscriptionService.removeByMap(deleteMap);
+            materialParameterService.removeByMap(deleteMap);
+            materialTagService.removeByMap(deleteMap);
         } catch (Exception e) {
             log.error("删除失败", e.getMessage());
             return Result.error("删除失败!");
@@ -326,6 +345,7 @@ public class MaterialInfoController {
         return mv;
     }
 
+
     /**
      * 通过excel导入数据
      *

+ 48 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -16,6 +16,8 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * @author jeecg-boot
@@ -96,4 +98,50 @@ public class TestController {
         }
         return "Success";
     }
+
+
+    @GetMapping(value = "/getVideoAndImage")
+    public String getVideoAndImage() {
+        QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+        tokenQueryWrapper.eq("media_id", 2);
+        List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
+        for (CtopOauthToken token : ctopOauthTokens) {
+
+            kuaishouInterfaceService.getVideoList2(token, null, null, 1);
+            kuaishouInterfaceService.getImageList2(token, null, null, 1);
+            kuaishouInterfaceService.getCreativeList2(token, null, null, 1);
+
+
+        }
+        return "Success";
+    }
+
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
+    @GetMapping(value = "/gerCreative")
+    public void gerCreative() {
+        QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+        oauthTokenQueryWrapper.eq("media_id", 2);
+        List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+        for (CtopOauthToken token : ctopOauthTokens) {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                    /*    //  kuaishouInterfaceService.getCreativeList(token, null, null);
+                        kuaishouInterfaceService.getVideoList2(token, null, null,1);
+                        //3: 获取图片信息数据
+                        kuaishouInterfaceService.getImageList2(token, null, null,1);
+                        Thread.sleep(1 * 1000);*/
+                        kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+        }
+
+    }
 }

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

@@ -0,0 +1,58 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 获取广告计划分时报表
+ */
+@Slf4j
+public class KuaishouAppListJob implements Job {
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+                oauthTokenQueryWrapper.eq("media_id", 2);
+                List<CtopOauthToken> tokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+                for (CtopOauthToken token : tokens) {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    });
+                }
+
+            }
+
+        };
+        thread.start();
+
+
+    }
+}

+ 1 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java

@@ -46,9 +46,7 @@ public class KuaishouCommentAutoDelete implements Job {
                             } else {
                                 log.info("error,删除评论调用shell脚本执行失败");
                             }
-
-
-                            Thread.sleep(10000);
+                            Thread.sleep(5 * 1000);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }

+ 16 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java

@@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * 获取创意分天报表
@@ -26,6 +28,8 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
+    static ExecutorService executorService = null;
+
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         Thread thread = new Thread() {
@@ -35,6 +39,7 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
                 kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
+                executorService = Executors.newFixedThreadPool(4);
                 List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取头条数据异常:为获取到可用的token");
@@ -43,11 +48,18 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
 
                 log.info("快手物料数据同步完成");
 
-                tokens.forEach(token -> {
 
-                    // 获取广告创意信息数据
-                    kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate);
-                });
+                for (CtopOauthToken token : tokens) {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            log.info("获取创意分天报表开始,accountId:{}", token.getAccountId());
+                            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate);
+                        }
+                    });
+
+
+                }
             }
         };
         thread.start();

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountWarningLoadJob.java

@@ -46,7 +46,7 @@ public class KuaishouHourlyAccountWarningLoadJob implements Job {
                     for (CtopOauthToken token : tokens) {
                         accountWarningService.accountWarning(token.getAccountId(), statDate, anotherDay);
                     }
-                    log.info("开始时段消耗预警定时任务执行完毕,耗时:{} ms", System.currentTimeMillis() - l);
+                    log.info("时段消耗预警定时任务执行完毕,耗时:{} ms", System.currentTimeMillis() - l);
 
                 } catch (Exception e) {
                     e.printStackTrace();

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

@@ -0,0 +1,42 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+public class TargetingTagsJob implements Job {
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
+
+    /**
+     * 定时更新 快手 标签
+     *
+     * @param jobExecutionContext
+     * @throws JobExecutionException
+     */
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+                tokenQueryWrapper.eq("media_id", 2);
+                tokenQueryWrapper.orderByDesc("create_time");
+                tokenQueryWrapper.last("limit 1");
+                CtopOauthToken token = oauthTokenMapper.selectOne(tokenQueryWrapper);
+                iKuaishouInterfaceService.getTargetingTags(token.getAccountId(), token.getAccessToken());
+                iKuaishouInterfaceService.areaList(token.getAccessToken());
+            }
+        };
+        thread.start();
+
+    }
+}

+ 2 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/shiro/authc/aop/JwtFilter.java

@@ -56,10 +56,9 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
             // 如果没有抛出异常则代表登入成功,返回true
             return true;
         } catch (Exception e) {
-            log.error("登录失败");
-
+            return false;
         }
-        return false;
+
 
     }
 

+ 72 - 2
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,10 +1,13 @@
 package org.jeecg;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.jeecg.modules.ctop.service.IBidWarningService;
@@ -23,7 +26,12 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
@@ -141,7 +149,7 @@ public class SampleTest {
     @Test
     public void testMail() throws Exception {
         // String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page
-        kuaishouInterfaceService.getGroupList("adf659b9b43e8952f9a3f0c5269505ca", 35675L, null, null, 1);
+        kuaishouInterfaceService.getTargetingTags(23212L, "101a5c994d0a87322f305a306a30e38e");
     }
 
 
@@ -150,14 +158,76 @@ public class SampleTest {
 
     @Autowired
     private IAccountWarningService accountWarningService;
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
 
     @Test
     public void testMa() throws Exception {
-       // accountWarningService.accountWarning(23212L);
+        // accountWarningService.accountWarning(23212L);
+        QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+        oauthTokenQueryWrapper.eq("media_id", 2);
+        List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+        for (CtopOauthToken token : ctopOauthTokens) {
+            kuaishouInterfaceService.getCreativeList(token, null, null);
+        }
+
 
     }
 
 
+    @Test
+    public void testMa2() throws Exception {
+
+       /* QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+        oauthTokenQueryWrapper.eq("media_id", 2);
+        List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+        for (CtopOauthToken token : ctopOauthTokens) {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        kuaishouInterfaceService.getCreativeList(token, null, null);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+        }*/
+
+
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse = dateFormat.parse("2020-01-05");
+
+
+        QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+        oauthTokenQueryWrapper.eq("media_id", 2);
+        List<Long> list = new ArrayList<>();
+        list.add(3162138L);
+        list.add(3418818L);
+        oauthTokenQueryWrapper.in("account_id", list);
+        List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+        for (CtopOauthToken token : ctopOauthTokens) {
+            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, parse, parse);
+
+        }
+
+
+
+     /*   Date deleteDate = DateUtils.addDay(new Date(), -2);
+        kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+        Date getDate = DateUtils.addDay(new Date(), -1);*/
+        //1:查询当日数据
+
+
+        log.info("快手物料数据同步完成");
+
+
+        //1: 获取广告主信息数据
+
+
+    }
+
 }
 
 

+ 67 - 0
module-common/src/main/java/cn/com/ctop/common/module/enums/MaterialEnum.java

@@ -0,0 +1,67 @@
+package cn.com.ctop.common.module.enums;
+
+public enum MaterialEnum {
+
+
+    VerticalVideoSmall(1, 720, 1280),
+    VerticalVideoBig(1, 1080, 1920),
+    HorizontalVideoSmall(2, 1280, 720),
+    HorizontalVideoBig(2, 1920, 1080);
+
+    private Integer type;
+    private Integer width;
+    private Integer height;
+
+
+    private MaterialEnum(Integer type, Integer width, Integer height) {
+        this.type = type;
+        this.width = width;
+        this.height = height;
+    }
+
+    public static Integer getTypeBySize(Integer widthStr, Integer heightStr) {
+        for (MaterialEnum material : MaterialEnum.values()) {
+            Integer width = material.getWidth();
+            Integer height = material.getHeight();
+            if (widthStr.equals(width) && heightStr.equals(height)) {
+                return material.getType();
+            }
+        }
+
+        return 0;
+    }
+
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public Integer getWidth() {
+        return width;
+    }
+
+    public void setWidth(Integer width) {
+        this.width = width;
+    }
+
+    public Integer getHeight() {
+        return height;
+    }
+
+    public void setHeight(Integer height) {
+        this.height = height;
+    }
+
+    @Override
+    public String toString() {
+        return "MaterialEnum{" +
+                "type=" + type +
+                ", width=" + width +
+                ", height=" + height +
+                '}';
+    }
+}

+ 0 - 7
module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java

@@ -71,17 +71,10 @@ public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMappe
     @Override
     public String getByteDanceCodeUrl(String state) throws UnsupportedEncodingException {
         StringBuffer sb = new StringBuffer();
-        JSONArray jsonArray = new JSONArray();
-        jsonArray.add("100");
-        jsonArray.add("2");
-        jsonArray.add("3");
-        jsonArray.add("4");
-        jsonArray.add("5");
         sb.append(PropertiesUtils.getValue("bytedance_config", "bytedance_auth_url"))
                 .append(BytedanceInterfaceConstant.AUTH_PATH)
                 .append("?app_id=" + PropertiesUtils.getValue("bytedance_config", "bytedance_appid"))
                 .append("&state=" + URLEncoder.encode(state))
-              //  .append("&scope=" + jsonArray)
                 .append("&redirect_uri=" + URLEncoder.encode(PropertiesUtils.getValue("bytedance_config", "bytedance_callback_url"), "UTF-8"));
         return sb.toString();
     }

+ 3 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -308,7 +308,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         String savePath = this.imageUploadPath + fileName;
         try {
             /*将网络资源地址传给,即赋值给url*/
-            URL url = new URL("https:" + fileUrl);
+            URL url = new URL(fileUrl);
             /*此为联系获得网络资源的固定格式用法,以便后面的in变量获得url截取网络资源的输入流*/
             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
             DataInputStream in = new DataInputStream(connection.getInputStream());
@@ -367,8 +367,9 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
             result.put("message", "今日头条视频上传失败");
             return result;
         }
+        log.info("头条素材上传成功,accountId:{}", advertiserId);
         JSONObject data = bytedanceObject.getJSONObject("data");
-        FileInfo fileInfo = new FileInfo(md5Hex, data, advertiserId, token, "https:" + videoUrl, videoPath, "VIDEO", "1");
+        FileInfo fileInfo = new FileInfo(md5Hex, data, advertiserId, token, videoUrl, videoPath, "VIDEO", "1");
         fileInfoMapper.insert(fileInfo);
         result.put("code", 0);
         result.put("file", fileInfo);

+ 17 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -4,7 +4,7 @@ package cn.com.ctop.common.module.utils;
  * 2019年9月9日13:21:39
  */
 public class KuaishouInterfaceConstant {
-    public static final String AUTH_PATH = "/#/openapi/oauth";
+    public static final String AUTH_PATH = "/openapi/oauth";
     public static final String AUTH_TOKEN = "/rest/openapi/oauth2/authorize/access_token";
     public static final String REFRESH_TOKEN = "/rest/openapi/oauth2/authorize/refresh_token";
     /**
@@ -94,6 +94,22 @@ public class KuaishouInterfaceConstant {
      */
     public static final String DAILY_FLOWS = "/rest/openapi/v1/advertiser/fund/daily_flows";
 
+    /**
+     * 获取人群包接口
+     */
+    public static final String POPULATION_LIST = "/rest/openapi/v1/dmp/population/list";
+
+    /**
+     * 获取可选的应用定向
+     */
+    public static final String APP_SEARCH = "/rest/openapi/v1/tool/app/search";
+
+
+    /**
+     * 获取定向标签
+     */
+    public static final String TARGETING_TAGS = "/rest/openapi/v1/tool/targeting_tags/list";
+
 
     /**
      * 修改广告计划预算

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

@@ -2,13 +2,20 @@ package cn.com.ctop.manage.modules.material.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.entity.MaterialParameter;
+import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
+import cn.com.ctop.common.module.mapper.MaterialParameterMapper;
 import cn.com.ctop.common.module.service.IFileInfoService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadService;
 import com.alibaba.fastjson.JSONArray;
@@ -48,6 +55,8 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
     private IKuaishouInterfaceService kuaishouInterfaceService;
     @Autowired
     private IFileInfoService fileInfoService;
+    @Autowired
+    private IKuaiShouImageGetService iKuaiShouImageGetService;
 
 
     /**
@@ -123,6 +132,10 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
 
     }
 
+    @Autowired
+    private MaterialParameterMapper parameterMapper;
+    @Autowired
+    private IKuaiShouVideoGetService kuaiShouVideoGetService;
 
     private void kuaiShouUpload(String mediaId, JSONArray materialArray, JSONArray accountArray) {
         for (int j = 0; j < materialArray.size(); j++) {
@@ -174,12 +187,55 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                         JSONObject dataJson = resultJson.getJSONObject("data");
                                         if (!Check.isNull(dataJson)) {
                                             if ("IMAGE".equals(materialInfo.getType())) {
-                                                kuaishouInterfaceService.imageGet(accountId, ctopOauthToken.getAccessToken(), dataJson.getString("image_token"));
+                                                //   kuaishouInterfaceService.imageGet(accountId, ctopOauthToken.getAccessToken(), dataJson.getString("image_token"));
+                                                if (!Check.isNull(dataJson)) {
+                                                    String signature = dataJson.getString("signature");
+                                                    KuaiShouImageGet imageGet = new KuaiShouImageGet();
+                                                    imageGet.setId(accountId + signature);
+                                                    imageGet.setAccountId(accountId);
+                                                    imageGet.setUrl(dataJson.getString("url"));
+                                                    imageGet.setWidth(dataJson.getInteger("width"));
+                                                    imageGet.setHeight(dataJson.getInteger("height"));
+                                                    imageGet.setSize(dataJson.getInteger("size"));
+                                                    imageGet.setFormat(dataJson.getString("format"));
+                                                    Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
+                                                    if (!Check.isNull(type)) {
+                                                        imageGet.setMaterialType(type);
+                                                    }
+                                                    imageGet.setSignature(signature);
+                                                    imageGet.setImageToken(dataJson.getString("image_token"));
+                                                    iKuaiShouImageGetService.saveOrUpdate(imageGet);
+                                                }
+
                                             } else if ("VIDEO".equals(materialInfo.getType())) {
-                                                kuaishouInterfaceService.videoGet(accountId, ctopOauthToken.getAccessToken(), dataJson.getString("photo_id"), dataJson.getString("signature"));
+                                                // kuaishouInterfaceService.videoGet(accountId, ctopOauthToken.getAccessToken(), dataJson.getString("photo_id"), dataJson.getString("signature"));
+                                                String photoId = dataJson.getString("photo_id");
+                                                String signature = dataJson.getString("signature");
+                                                KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+                                                videoGet.setAccountId(accountId);
+                                                videoGet.setId(accountId + signature);
+                                                videoGet.setUrl(materialInfo.getUrl());
+                                                QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
+                                                parameterQueryWrapper.eq("material_id", materialId);
+                                                parameterQueryWrapper.last("limit 1");
+
+                                                MaterialParameter materialParameter = parameterMapper.selectOne(parameterQueryWrapper);
+                                                if (!Check.isNull(materialParameter)) {
+                                                    String width = materialParameter.getWidth();
+                                                    String height = materialParameter.getHeight();
+                                                    videoGet.setWidth(Integer.valueOf(width));
+                                                    videoGet.setHeight(Integer.valueOf(height));
+                                                    Integer type = MaterialEnum.getTypeBySize(Integer.valueOf(width), Integer.valueOf(height));
+                                                    if (!Check.isNull(type)) {
+                                                        videoGet.setMaterialType(type);
+                                                    }
+                                                }
+                                                videoGet.setPhotoId(photoId);
+                                                //    videoGet.setCoverUrl(dataJson.getString("cover_url"));
+                                                videoGet.setSignature(signature);
+                                                kuaiShouVideoGetService.saveOrUpdate(videoGet);
                                             }
                                         }
-
                                         log.info("素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);
                                     } else {
                                         log.error("同步素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);

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

@@ -2,13 +2,15 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
+import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.SpendVo;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 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.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @Api(tags = "快手-批量工具")
@@ -43,11 +46,24 @@ public class BatchController {
     private IKuaiShouUpdateService updateService;
     @Autowired
     private ICtopOauthTokenService tokenService;
-
     @Autowired
     private IKuaiShouGroupService kuaiShouGroupService;
     @Autowired
     private KuaiShouRegionListParentMapper regionListParentMapper;
+    @Autowired
+    private IKuaiShouAppListService kuaiShouAppListService;
+    @Autowired
+    private KuaiShouTargetingTagsMapper targetingTagsMapper;
+    @Autowired
+    private IKuaiShouImageGetService kuaiShouImageGetService;
+    @Autowired
+    private IKuaiShouVideoGetService kuaiShouVideoGetService;
+    @Autowired
+    private MaterialInfoMapper materialInfoMapper;
+    @Autowired
+    private KuaiShouCampaignMapper campaignMapper;
+    @Autowired
+    private IKuaiShouActionBarTextService actionBarTextService;
 
 
     /**
@@ -114,6 +130,64 @@ public class BatchController {
 
 
     /**
+     * 批量修改广告计划状态
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateStatus")
+    public Result<JSONObject> batchUpdateStatus(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+
+
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            Integer putStatus = requestJson.getInteger("putStatus");
+            if (putStatus == null) {
+                throw new Exception("请选择状态");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray campaignIds = requestJson.getJSONArray("campaignIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(campaignIds)) {
+                for (int i = 0; i < campaignIds.size(); i++) {
+                    Long campaignId = campaignIds.getLong(i);
+                    if (!Check.isNull(campaignId)) {
+                        Map<String, Object> updateMap = updateService.updateCampaignStatus(token.getAccessToken(), accountId, campaignId, putStatus, userId);
+                        if (!Check.isNull(updateMap)) {
+                            Integer code = (Integer) updateMap.get("code");
+                            if (code != 0) {
+                                JSONObject failJson = new JSONObject();
+                                failJson.put("message", updateMap.get("message"));
+                                KuaiShouCampaign campaign = batchService.getCampaignInfo(accountId, campaignId);
+                                if (!Check.isNull(campaign)) {
+                                    failJson.put("campaignName", campaign.getCampaignName());
+                                }
+                                failArr.add(failJson);
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", campaignIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+    /**
      * 批量修改广告计划预算
      *
      * @param requestJson
@@ -122,7 +196,6 @@ public class BatchController {
     @PostMapping(value = "/batchUpdateDayBudget")
     public Result<JSONObject> batchUpdateDayBudget(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
-
         try {
             Long accountId = requestJson.getLong("accountId");
             CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
@@ -135,14 +208,32 @@ public class BatchController {
             }
             String userId = requestJson.getString("userId");
             JSONArray campaignIds = requestJson.getJSONArray("campaignIds");
+            JSONArray failArr = new JSONArray();
             if (!Check.isNull(campaignIds)) {
                 for (int i = 0; i < campaignIds.size(); i++) {
                     Long campaignId = campaignIds.getLong(i);
                     if (!Check.isNull(campaignId)) {
-                        updateService.updateCampaign(token.getAccessToken(), accountId, campaignId, dayBudget, userId);
+                        Map<String, Object> updateMap = updateService.updateCampaign(token.getAccessToken(), accountId, campaignId, dayBudget, userId);
+                        if (!Check.isNull(updateMap)) {
+                            Integer code = (Integer) updateMap.get("code");
+                            if (code != 0) {
+                                JSONObject failJson = new JSONObject();
+                                failJson.put("message", updateMap.get("message"));
+                                KuaiShouCampaign campaign = batchService.getCampaignInfo(accountId, campaignId);
+                                if (!Check.isNull(campaign)) {
+                                    failJson.put("campaignName", campaign.getCampaignName());
+                                }
+                                failArr.add(failJson);
+                            }
+                        }
                     }
                 }
             }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", campaignIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
             result.setSuccess(true);
         } catch (Exception e) {
             e.printStackTrace();
@@ -169,6 +260,7 @@ public class BatchController {
                                                     HttpServletRequest req) {
         Result<IPage<KuaiShouGroup>> result = new Result<IPage<KuaiShouGroup>>();
         QueryWrapper<KuaiShouGroup> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouGroup, req.getParameterMap());
+        queryWrapper.orderByDesc("unit_id");
         Page<KuaiShouGroup> page = new Page<KuaiShouGroup>(pageNo, pageSize);
         IPage<KuaiShouGroup> pageList = kuaiShouGroupService.page(page, queryWrapper);
         result.setSuccess(true);
@@ -180,23 +272,713 @@ public class BatchController {
     /**
      * 获取区域列表
      *
-     * @param kuaiShouRegionListParent
+     * @param
      * @return
      */
+    @Autowired
+    private IKuaiShouRegionListParentService kuaiShouRegionListParentService;
+
     @GetMapping(value = "/getRegion")
     public Result<List<KuaiShouRegionListParent>> getRegion(KuaiShouRegionListParent kuaiShouRegionListParent, HttpServletRequest req) {
         Result<List<KuaiShouRegionListParent>> result = new Result<>();
 
+
         try {
+            /*JSONArray regionArr = new JSONArray();
+            QueryWrapper<KuaiShouRegionListParent> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("level", 1);
+            List<KuaiShouRegionListParent> regionListParents = regionListParentMapper.selectList(queryWrapper);
+            if (!Check.isNull(regionListParents)) {
+
+                for (KuaiShouRegionListParent regionListParent : regionListParents) {
+                    if (Check.isNull(regionListParent)) {
+                        continue;
+                    }
+                    JSONObject parentJson = new JSONObject();
+                    Long regionId = regionListParent.getRegionId();
+                    parentJson.put("regionId", regionId);
+                    parentJson.put("name", regionListParent.getName());
+                    QueryWrapper<KuaiShouRegionListParent> childrenQueryWrapper = new QueryWrapper<>();
+                    childrenQueryWrapper.eq("parent", regionId);
+                    List<KuaiShouRegionListParent> childrenRegions = regionListParentMapper.selectList(childrenQueryWrapper);
+
+                    JSONArray childrenArr = new JSONArray();
+                    if (!Check.isNull(childrenRegions)) {
+                        for (KuaiShouRegionListParent childrenRegion : childrenRegions) {
+                            if (!Check.isNull(childrenRegion)) {
+                                JSONObject childrenJson = new JSONObject();
+                                childrenJson.put("regionId", childrenRegion.getRegionId());
+                                childrenJson.put("name", childrenRegion.getName());
+                                childrenArr.add(childrenJson);
+                            }
+                        }
+                        parentJson.put("children", childrenArr);
+
+                    }
+
+                    regionArr.add(parentJson);
+                }
+            }*/
+
+
             QueryWrapper<KuaiShouRegionListParent> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouRegionListParent, req.getParameterMap());
 
-            List<KuaiShouRegionListParent> regionListParents = regionListParentMapper.selectList(queryWrapper);
+            List<KuaiShouRegionListParent> pageList = kuaiShouRegionListParentService.list(queryWrapper);
+
+            result.setSuccess(true);
+            result.setResult(pageList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+
+        }
+        return result;
+    }
+
+
+    /**
+     * 创建广告计划
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/campaignCreate")
+    public Result<Object> campaignCreate(@RequestBody JSONObject requestJson) {
+        Result<Object> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject campaignJson = new JSONObject();
+            campaignJson.put("campaign_name", requestJson.getString("campaignName"));
+            campaignJson.put("type", requestJson.getInteger("type"));
+            campaignJson.put("day_budget", requestJson.getLong("day_budget"));
+            Map<String, Object> campaignMap = iKuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
+            Integer code = (Integer) campaignMap.get("code");
+            if (code != 0) {
+                throw new Exception((String) campaignMap.get("message"));
+            }
             result.setSuccess(true);
-            result.setResult(regionListParents);
+            result.setResult(campaignMap.get("campaignId"));
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
+            result.setMessage(e.getMessage());
+
+        }
+        return result;
 
+    }
+
+
+    /**
+     * 获取应用列表
+     */
+
+    @GetMapping(value = "/getAppList")
+    public Result<List<KuaiShouAppList>> getAppList(KuaiShouAppList kuaiShouAppList, HttpServletRequest req) {
+        Result<List<KuaiShouAppList>> result = new Result<>();
+        try {
+            QueryWrapper<KuaiShouAppList> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouAppList, req.getParameterMap());
+            queryWrapper.orderByDesc("return_time");
+
+            List<KuaiShouAppList> appList = kuaiShouAppListService.list(queryWrapper);
+            result.setSuccess(true);
+            result.setResult(appList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 获取人群包接口
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getPopulationList")
+    public Result<JSONArray> getAppList(Long accountId) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONArray jsonArray = iKuaishouInterfaceService.getPopulationList(accountId, oauthToken.getAccessToken());
+            result.setSuccess(true);
+            result.setResult(jsonArray);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+
+    /**
+     * 获取商业兴趣
+     *
+     * @param kuaiShouTargetingTags BUSINESS_INTEREST:商业兴趣
+     *                              APP_INTEREST:APP行为
+     *                              FANS_STAR:网红类别
+     *                              INTEREST_VIDEO:兴趣视频
+     * @param req
+     * @return
+     */
+    @GetMapping(value = "/getTargetList")
+    public Result<List<KuaiShouTargetingTags>> getTargetList(KuaiShouTargetingTags kuaiShouTargetingTags, HttpServletRequest req) {
+        Result<List<KuaiShouTargetingTags>> result = new Result<>();
+        try {
+            QueryWrapper<KuaiShouTargetingTags> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouTargetingTags, req.getParameterMap());
+            queryWrapper.orderByAsc("tag_id");
+            List<KuaiShouTargetingTags> targetingTagList = targetingTagsMapper.selectList(queryWrapper);
+            result.setSuccess(true);
+            result.setResult(targetingTagList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+
+    /**
+     * 获取可选的深度类型
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getIsActivate")
+    public Result<JSONObject> getIsActivate(Long accountId) {
+        Result result = new Result<JSONObject>();
+        try {
+            CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("未获取授权信息");
+            }
+            JSONObject deepConversionJson = iKuaishouInterfaceService.getDeepConversionInfosV2(accountId, token.getAccessToken());
+            if (Check.isNull(deepConversionJson)) {
+                throw new Exception("深度类型数据返回为空");
+            }
+
+            result.setSuccess(true);
+            result.setResult(deepConversionJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+
+    }
+
+
+    /**
+     * 获取app列表
+     *
+     * @param accountId
+     * @param appName
+     * @return
+     */
+    @GetMapping(value = "/getAppSearch")
+    public Result<JSONObject> getAppSearch(Long accountId, String appName) {
+        Result result = new Result<JSONObject>();
+        try {
+            CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("未获取授权信息");
+            }
+            JSONArray appArray = iKuaishouInterfaceService.getAppSearch(accountId, token.getAccessToken(), appName);
+            result.setSuccess(true);
+            result.setResult(appArray);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+
+    }
+
+    /**
+     * 获取项目最高出价
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getProjectMaxBid")
+    public Result<BigDecimal> getProjectMaxBid(Long accountId) {
+        Result<BigDecimal> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入accountId");
+            }
+            BigDecimal maxBid = batchService.getProjectMaxBid(accountId);
+            result.setSuccess(true);
+            result.setResult(maxBid);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+
+    }
+
+
+    /**
+     * 获取项目最高出价
+     *
+     * @param campaignId
+     * @return
+     */
+    @GetMapping(value = "/checkUnitName")
+    public Result<Boolean> checkUnitName(Long campaignId, String unitName) {
+        Result<Boolean> result = new Result<>();
+        try {
+            if (Check.isNull(campaignId)) {
+                throw new Exception("请传入广告计划id");
+            }
+            if (Check.isNull(unitName)) {
+                throw new Exception("请传入广告组名称");
+            }
+            Boolean checkUnitName = batchService.checkUnitName(campaignId, unitName);
+            result.setSuccess(true);
+            result.setResult(checkUnitName);
+            if (!checkUnitName) {
+                result.setMessage("广告组名称该计划下已存在");
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 批量创建广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/createUnit")
+    public Result<JSONObject> createUnit(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参为空");
+            }
+
+            JSONObject unitJson = batchService.createUnit(requestJson);
+            result.setSuccess(true);
+            result.setResult(unitJson);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    @Autowired
+    private IKuaiShouCreativeService kuaiShouCreativeService;
+
+
+    @GetMapping(value = "/getCreativeList")
+    public Result<IPage<KuaiShouCreative>> getCreativeList(KuaiShouCreative kuaiShouCreative, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
+        Result<IPage<KuaiShouCreative>> result = new Result<>();
+
+        QueryWrapper<KuaiShouCreative> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouCreative, req.getParameterMap());
+        queryWrapper.orderByDesc("creative_id");
+        Page<KuaiShouCreative> page = new Page<>(pageNo, pageSize);
+        IPage<KuaiShouCreative> creativeList = kuaiShouCreativeService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(creativeList);
+        return result;
+    }
+
+
+    /**
+     * 批量修改广告组预算
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateUnitBudget")
+    public Result<JSONObject> batchUpdateUnitBudget(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+
+
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            Long dayBudget = requestJson.getLong("dayBudget");
+            if (Check.isNull(dayBudget)) {
+                throw new Exception("预算信息为空");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray unitIds = requestJson.getJSONArray("unitIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(unitIds)) {
+                for (int i = 0; i < unitIds.size(); i++) {
+                    Long unitId = unitIds.getLong(i);
+                    if (!Check.isNull(unitId)) {
+                        Map<String, Object> updateMap = updateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, dayBudget, userId);
+                        if (!Check.isNull(updateMap)) {
+                            Integer code = (Integer) updateMap.get("code");
+                            if (code != 0) {
+                                JSONObject failJson = new JSONObject();
+                                failJson.put("message", updateMap.get("message"));
+                                KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
+                                if (!Check.isNull(group)) {
+                                    failJson.put("unitName", group.getUnitName());
+                                }
+                                failArr.add(failJson);
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", unitIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 批量修改广告组状态
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateUnitStatus")
+    public Result<JSONObject> batchUpdateUnitStatus(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+
+
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            Integer putStatus = requestJson.getInteger("putStatus");
+            if (putStatus == null) {
+                throw new Exception("请选择状态");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray unitIds = requestJson.getJSONArray("unitIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(unitIds)) {
+                for (int i = 0; i < unitIds.size(); i++) {
+                    Long unitId = unitIds.getLong(i);
+                    if (!Check.isNull(unitId)) {
+                        Map<String, Object> updateMap = updateService.updateUnitStatus(token.getAccessToken(), accountId, unitId, putStatus, userId);
+                        if (!Check.isNull(updateMap)) {
+                            Integer code = (Integer) updateMap.get("code");
+                            if (code != 0) {
+                                JSONObject failJson = new JSONObject();
+                                failJson.put("message", updateMap.get("message"));
+                                KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
+                                if (!Check.isNull(group)) {
+                                    failJson.put("campaignName", group.getUnitName());
+                                }
+                                failArr.add(failJson);
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", unitIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 批量修改广告组状态
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateUnitBid")
+    public Result<JSONObject> batchUpdateUnitBid(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            Long bid = requestJson.getLong("bid");
+            if (bid == null) {
+                throw new Exception("请输入出价");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray unitIds = requestJson.getJSONArray("unitIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(unitIds)) {
+                for (int i = 0; i < unitIds.size(); i++) {
+                    Long unitId = unitIds.getLong(i);
+                    if (!Check.isNull(unitId)) {
+                        Map<String, Object> updateMap = updateService.updateUnitBid(token.getAccessToken(), accountId, unitId, bid, userId);
+                        if (!Check.isNull(updateMap)) {
+                            Integer code = (Integer) updateMap.get("code");
+                            if (code != 0) {
+                                JSONObject failJson = new JSONObject();
+                                failJson.put("message", updateMap.get("message"));
+                                KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
+                                if (!Check.isNull(group)) {
+                                    failJson.put("campaignName", group.getUnitName());
+                                }
+                                failArr.add(failJson);
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", unitIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 获取封面列表
+     *
+     * @param kuaiShouImageGet
+     * @param req
+     * @return
+     */
+    @GetMapping(value = "/getImageList")
+    public Result<IPage<KuaiShouImageGet>> getImageList(KuaiShouImageGet kuaiShouImageGet, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
+        Result<IPage<KuaiShouImageGet>> result = new Result<>();
+        try {
+            QueryWrapper<KuaiShouImageGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouImageGet, req.getParameterMap());
+            queryWrapper.orderByDesc("create_time");
+            Page<KuaiShouImageGet> page = new Page<>(pageNo, pageSize);
+            IPage<KuaiShouImageGet> pageList = kuaiShouImageGetService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+
+        }
+
+        return result;
+
+
+    }
+
+    /**
+     * 获取视频列表
+     *
+     * @param kuaiShouVideoGet
+     * @param req
+     * @return
+     */
+    @GetMapping(value = "/getVideoList")
+    public Result<IPage<KuaiShouVideoGet>> getVideoList(KuaiShouVideoGet kuaiShouVideoGet, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
+        Result<IPage<KuaiShouVideoGet>> result = new Result<IPage<KuaiShouVideoGet>>();
+        try {
+
+            QueryWrapper<KuaiShouVideoGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouVideoGet, req.getParameterMap());
+            queryWrapper.orderByDesc("create_time");
+            Page<KuaiShouVideoGet> page = new Page<KuaiShouVideoGet>(pageNo, pageSize);
+            IPage<KuaiShouVideoGet> pageList = kuaiShouVideoGetService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 获取素材信息
+     *
+     * @param code
+     * @return
+     */
+    @GetMapping(value = "/getCreativeCopywriter")
+    public Result<MaterialInfo> getVideoList(String code) {
+        Result<MaterialInfo> result = new Result<>();
+        try {
+
+            QueryWrapper<MaterialInfo> materialInfoQueryWrapper = new QueryWrapper<>();
+            materialInfoQueryWrapper.eq("code", code);
+            materialInfoQueryWrapper.last("limit 1");
+            MaterialInfo materialInfo = materialInfoMapper.selectOne(materialInfoQueryWrapper);
+            result.setSuccess(true);
+            result.setResult(materialInfo);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 获取行动号召按钮
+     *
+     * @param campaignId
+     * @return
+     */
+    @GetMapping(value = "/getActionBarText")
+    public Result<List<KuaiShouActionBarText>> queryPageList(String campaignId) {
+        Result<List<KuaiShouActionBarText>> result = new Result<>();
+        QueryWrapper<KuaiShouCampaign> wrapper = new QueryWrapper<>();
+        wrapper.eq("campaign_id", campaignId);
+        wrapper.orderByDesc("create_time");
+        wrapper.last("limit 1");
+        KuaiShouCampaign campaign = campaignMapper.selectOne(wrapper);
+        if (!Check.isNull(campaignId)) {
+            QueryWrapper<KuaiShouActionBarText> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("type", campaign.getCampaignType());
+            List<KuaiShouActionBarText> list = actionBarTextService.list(queryWrapper);
+            result.setSuccess(true);
+            result.setResult(list);
+        } else {
+            result.setSuccess(false);
+            result.setMessage("未获取到广告计划信息");
+        }
+
+        return result;
+    }
+
+    /**
+     * 创建创意
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/createCreative")
+    public Result<JSONObject> createCreative(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            JSONObject creativeJson = batchService.createCreative(requestJson);
+            result.setResult(creativeJson);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+
+        return result;
+    }
+
+
+    /**
+     * 批量修改广告组状态
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateCreativeStatus")
+    public Result<JSONObject> batchUpdateCreativeStatus(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            Integer putStatus = requestJson.getInteger("putStatus");
+            if (putStatus == null) {
+                throw new Exception("请选择状态");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray creativeIds = requestJson.getJSONArray("creativeIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(creativeIds)) {
+                for (int i = 0; i < creativeIds.size(); i++) {
+                    Long creativeId = creativeIds.getLong(i);
+                    if (!Check.isNull(creativeId)) {
+                        Map<String, Object> updateMap = updateService.updateCreativeStatus(token.getAccessToken(), accountId, creativeId, putStatus, userId);
+                        if (!Check.isNull(updateMap)) {
+                            Integer code = (Integer) updateMap.get("code");
+                            if (code != 0) {
+                                JSONObject failJson = new JSONObject();
+                                failJson.put("message", updateMap.get("message"));
+                                KuaiShouCreative creative = batchService.getCreativeInfo(accountId, creativeId);
+                                if (!Check.isNull(creative)) {
+                                    failJson.put("campaignName", creative.getCreativeName());
+                                }
+                                failArr.add(failJson);
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", creativeIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
         }
         return result;
     }

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

@@ -0,0 +1,248 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouTargetingTagsService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手-定向标签
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-19
+ */
+@Slf4j
+@Api(tags = "快手-定向标签")
+@RestController
+@RequestMapping("/kuaishou/kuaiShouTargetingTags")
+public class KuaiShouTargetingTagsController {
+    @Autowired
+    private IKuaiShouTargetingTagsService kuaiShouTargetingTagsService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaiShouTargetingTags
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-定向标签-分页列表查询")
+    @ApiOperation(value = "快手-定向标签-分页列表查询", notes = "快手-定向标签-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaiShouTargetingTags>> queryPageList(KuaiShouTargetingTags kuaiShouTargetingTags,
+                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                              HttpServletRequest req) {
+        Result<IPage<KuaiShouTargetingTags>> result = new Result<IPage<KuaiShouTargetingTags>>();
+        QueryWrapper<KuaiShouTargetingTags> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouTargetingTags, req.getParameterMap());
+        Page<KuaiShouTargetingTags> page = new Page<KuaiShouTargetingTags>(pageNo, pageSize);
+        IPage<KuaiShouTargetingTags> pageList = kuaiShouTargetingTagsService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaiShouTargetingTags
+     * @return
+     */
+    @AutoLog(value = "快手-定向标签-添加")
+    @ApiOperation(value = "快手-定向标签-添加", notes = "快手-定向标签-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaiShouTargetingTags> add(@RequestBody KuaiShouTargetingTags kuaiShouTargetingTags) {
+        Result<KuaiShouTargetingTags> result = new Result<KuaiShouTargetingTags>();
+        try {
+            kuaiShouTargetingTagsService.save(kuaiShouTargetingTags);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaiShouTargetingTags
+     * @return
+     */
+    @AutoLog(value = "快手-定向标签-编辑")
+    @ApiOperation(value = "快手-定向标签-编辑", notes = "快手-定向标签-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaiShouTargetingTags> edit(@RequestBody KuaiShouTargetingTags kuaiShouTargetingTags) {
+        Result<KuaiShouTargetingTags> result = new Result<KuaiShouTargetingTags>();
+        KuaiShouTargetingTags kuaiShouTargetingTagsEntity = kuaiShouTargetingTagsService.getById(kuaiShouTargetingTags.getId());
+        if (kuaiShouTargetingTagsEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaiShouTargetingTagsService.updateById(kuaiShouTargetingTags);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "快手-定向标签-通过id删除")
+    @ApiOperation(value = "快手-定向标签-通过id删除", notes = "快手-定向标签-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaiShouTargetingTagsService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "快手-定向标签-批量删除")
+    @ApiOperation(value = "快手-定向标签-批量删除", notes = "快手-定向标签-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaiShouTargetingTags> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaiShouTargetingTags> result = new Result<KuaiShouTargetingTags>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaiShouTargetingTagsService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "快手-定向标签-通过id查询")
+    @ApiOperation(value = "快手-定向标签-通过id查询", notes = "快手-定向标签-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaiShouTargetingTags> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaiShouTargetingTags> result = new Result<KuaiShouTargetingTags>();
+        KuaiShouTargetingTags kuaiShouTargetingTags = kuaiShouTargetingTagsService.getById(id);
+        if (kuaiShouTargetingTags == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaiShouTargetingTags);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaiShouTargetingTags> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaiShouTargetingTags kuaiShouTargetingTags = JSON.parseObject(deString, KuaiShouTargetingTags.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouTargetingTags, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaiShouTargetingTags> pageList = kuaiShouTargetingTagsService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-定向标签列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaiShouTargetingTags.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("快手-定向标签列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaiShouTargetingTags> listKuaiShouTargetingTagss = ExcelImportUtil.importExcel(file.getInputStream(), KuaiShouTargetingTags.class, params);
+                kuaiShouTargetingTagsService.saveBatch(listKuaiShouTargetingTagss);
+                return Result.ok("文件导入成功!数据行数:" + listKuaiShouTargetingTagss.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaignDayBudget.java

@@ -62,7 +62,7 @@ public class KuaiShouCampaignDayBudget {
      */
     @Excel(name = "操作人id", width = 15)
     @ApiModelProperty(value = "操作人id")
-    private String loginId;
+    private String userId;
     /**
      * 创建时间
      */

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaignStatus.java

@@ -62,7 +62,7 @@ public class KuaiShouCampaignStatus {
      */
     @Excel(name = "操作人id", width = 15)
     @ApiModelProperty(value = "操作人id")
-    private String loginId;
+    private String userId;
     /**
      * 创建时间
      */

+ 77 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java

@@ -32,6 +32,7 @@ public class KuaiShouCreative {
     @TableId
     @ApiModelProperty(value = "id")
     private String id;
+
     /**
      * 账户ID
      */
@@ -56,6 +57,13 @@ public class KuaiShouCreative {
     @Excel(name = "广告创意ID", width = 15)
     @ApiModelProperty(value = "广告创意ID")
     private Long creativeId;
+
+
+    /**
+     * 素材类型
+     */
+    private Integer creativeMaterialType;
+
     /**
      * 广告创意名称
      */
@@ -63,6 +71,18 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "广告创意名称")
     private String creativeName;
     /**
+     * 单图创意ur
+     */
+    @Excel(name = "单图创意ur", width = 15)
+    @ApiModelProperty(value = "单图创意ur")
+    private String materialUrl;
+    /**
+     * 单图创意image_token
+     */
+    @Excel(name = "单图创意image_token", width = 15)
+    @ApiModelProperty(value = "单图创意image_token")
+    private String imageTokens;
+    /**
      * 视频作品ID
      */
     @Excel(name = "视频作品ID", width = 15)
@@ -75,6 +95,18 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "广告创意状态")
     private Integer status;
     /**
+     * 投放状态 1:投放中;2:暂停
+     */
+    @Excel(name = "投放状态 1:投放中;2:暂停", width = 15)
+    @ApiModelProperty(value = "投放状态 1:投放中;2:暂停")
+    private Integer putStatus;
+    /**
+     * 创建渠道  0:投放后台创建;1:Marketing API创建
+     */
+    @Excel(name = "创建渠道  0:投放后台创建;1:Marketing API创建", width = 15)
+    @ApiModelProperty(value = "创建渠道  0:投放后台创建;1:Marketing API创建")
+    private Integer createChannel;
+    /**
      * 审核拒绝理由
      */
     @Excel(name = "审核拒绝理由", width = 15)
@@ -87,6 +119,12 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "封面URL")
     private String coverUrl;
     /**
+     * 视频封面token  若创意使用系统自动生成的首帧图片作为封面,该token无法复用
+     */
+    @Excel(name = "视频封面token  若创意使用系统自动生成的首帧图片作为封面,该token无法复用", width = 15)
+    @ApiModelProperty(value = "视频封面token  若创意使用系统自动生成的首帧图片作为封面,该token无法复用")
+    private String imageToken;
+    /**
      * 封面图宽度
      */
     @Excel(name = "封面图宽度", width = 15)
@@ -99,10 +137,34 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "封面图高度")
     private String coverHeight;
     /**
-     * description
+     * 动态词包原始封面图片URL
+     */
+    @Excel(name = "动态词包原始封面图片URL", width = 15)
+    @ApiModelProperty(value = "动态词包原始封面图片URL")
+    private String overlayBgUrl;
+    /**
+     * 动态词包原始封面图片token
+     */
+    @Excel(name = "动态词包原始封面图片token", width = 15)
+    @ApiModelProperty(value = "动态词包原始封面图片token")
+    private String overlayBgImageToken;
+    /**
+     * stickerTitle
+     */
+    @Excel(name = "stickerTitle", width = 15)
+    @ApiModelProperty(value = "stickerTitle")
+    private String stickerTitle;
+    /**
+     * 贴纸样式类型
+     */
+    @Excel(name = "贴纸样式类型", width = 15)
+    @ApiModelProperty(value = "贴纸样式类型")
+    private String overlayType;
+    /**
+     * 广告语
      */
-    @Excel(name = "description", width = 15)
-    @ApiModelProperty(value = "description")
+    @Excel(name = "广告语", width = 15)
+    @ApiModelProperty(value = "广告语")
     private String description;
     /**
      * 行动号召按钮文案
@@ -117,6 +179,18 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "点击测试链接")
     private String clickTrackUrl;
     /**
+     * 第三方开始播放监测链接
+     */
+    @Excel(name = "第三方开始播放监测链接", width = 15)
+    @ApiModelProperty(value = "第三方开始播放监测链接")
+    private String impressionUrl;
+    /**
+     * 第三方有效播放监测链接
+     */
+    @Excel(name = "第三方有效播放监测链接", width = 15)
+    @ApiModelProperty(value = "第三方有效播放监测链接")
+    private String adPhotoPlayedT3sUrl;
+    /**
      * 创建时间
      */
     @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupBid.java

@@ -62,7 +62,7 @@ public class KuaiShouGroupBid {
      */
     @Excel(name = "操作人id", width = 15)
     @ApiModelProperty(value = "操作人id")
-    private String loginId;
+    private String userId;
     /**
      * 创建时间
      */

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupDayBudget.java

@@ -62,7 +62,7 @@ public class KuaiShouGroupDayBudget {
      */
     @Excel(name = "操作人id", width = 15)
     @ApiModelProperty(value = "操作人id")
-    private String loginId;
+    private String userId;
     /**
      * 创建时间
      */

+ 7 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -30,9 +29,9 @@ public class KuaiShouImageGet {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 账户ID
      */
@@ -50,32 +49,33 @@ public class KuaiShouImageGet {
      */
     @Excel(name = "宽", width = 15)
     @ApiModelProperty(value = "宽")
-    private Long width;
+    private Integer width;
     /**
      * 高
      */
     @Excel(name = "高", width = 15)
     @ApiModelProperty(value = "高")
-    private Long height;
+    private Integer height;
     /**
      * 图片大小
      */
     @Excel(name = "图片大小", width = 15)
     @ApiModelProperty(value = "图片大小")
-    private Long size;
+    private Integer size;
     /**
      * 图片格式
      */
     @Excel(name = "图片格式", width = 15)
     @ApiModelProperty(value = "图片格式")
     private String format;
+    private Integer materialType;
 
     /**
      * 图片 token
      */
     @Excel(name = "图片 token", width = 15)
     @ApiModelProperty(value = "图片 token")
-    private Object imageToken;
+    private String imageToken;
     /**
      * 图片 md5
      */

+ 71 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouTargetingTags.java

@@ -0,0 +1,71 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 快手-定向标签
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-19
+ */
+@Data
+@TableName("ctop_kuaishou_targeting_tags")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_targeting_tags对象", description = "快手-定向标签")
+public class KuaiShouTargetingTags {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 标签ID
+     */
+    @Excel(name = "标签ID", width = 15)
+    @ApiModelProperty(value = "标签ID")
+    private Long tagId;
+    /**
+     * 标签名称
+     */
+    @Excel(name = "标签名称", width = 15)
+    @ApiModelProperty(value = "标签名称")
+    private String tagName;
+    /**
+     * 投放结束时间
+     */
+    @Excel(name = "投放结束时间", width = 15)
+    @ApiModelProperty(value = "投放结束时间")
+    private String tagType;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 4 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java

@@ -71,9 +71,11 @@ public class KuaiShouVideoGet {
     /**
      * 视频首帧图片链接
      */
-    @Excel(name = "视频MD5值", width = 15)
-    @ApiModelProperty(value = "视频MD5值")
+
     private String signature;
+
+
+    private Integer materialType;
     /**
      * 创建时间
      */

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

@@ -10,4 +10,6 @@ public interface BatchMapper {
     BigDecimal getHourCost(@Param("accountId") Long accountId, @Param("statDate") String statDate);
 
     BigDecimal getBudget(@Param("accountId") Long accountId);
+
+    BigDecimal getProjectMaxBidByProject(@Param("projectId") Long projectId);
 }

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouTargetingTagsMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-定向标签
+ *
+ * @author: jeecg-boot
+ * @date: 2019-12-19
+ * @cersion: V1.0
+ */
+public interface KuaiShouTargetingTagsMapper extends BaseMapper<KuaiShouTargetingTags> {
+
+}

+ 9 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/BatchMapper.xml

@@ -43,4 +43,13 @@
     </select>
 
 
+    <select id="getProjectMaxBidByProject" resultType="java.math.BigDecimal">
+      select
+      max_bid
+      from
+      ctop_project
+      where id = #{projectId}
+    </select>
+
+
 </mapper>

+ 27 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -8,15 +8,28 @@
         unit_id,
         creative_id,
         creative_name,
+        creative_material_type,
         photo_id,
+        material_url,
+        image_tokens,
         status,
+        put_status,
+        create_channel,
         review_detail,
         cover_url,
+        image_token,
         cover_width,
         cover_height,
+        overlay_bg_url,
+        overlay_bg_image_token,
+        sticker_title,
+        overlay_type,
+        click_track_url,
+        impression_url,
+        ad_photo_played_t3s_url,
         description,
         action_bar_text,
-        click_track_url,
+
         create_time,
         update_time)
         values
@@ -27,15 +40,27 @@
             #{creative.unitId},
             #{creative.creativeId},
             #{creative.creativeName},
+            #{creative.creativeMaterialType},
             #{creative.photoId},
+            #{creative.materialUrl},
+            #{creative.imageTokens},
             #{creative.status},
+            #{creative.putStatus},
+            #{creative.createChannel},
             #{creative.reviewDetail},
             #{creative.coverUrl},
+            #{creative.imageToken},
             #{creative.coverWidth},
             #{creative.coverHeight},
+            #{creative.overlayBgUrl},
+            #{creative.overlayBgImageToken},
+            #{creative.stickerTitle},
+            #{creative.overlayType},
+            #{creative.clickTrackUrl},
+            #{creative.impressionUrl},
+            #{creative.adPhotoPlayedT3sUrl},
             #{creative.description},
             #{creative.actionBarText},
-            #{creative.clickTrackUrl},
             #{creative.createTime},
             #{creative.updateTime})
         </foreach>

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouImageGetMapper.xml

@@ -4,12 +4,14 @@
 
     <insert id="replaceBatch">
         replace into ctop_kuaishou_image_get(
+        id,
         account_id,
         url,
         width,
         height,
         size,
         format,
+        material_type,
         signature,
         image_token,
         create_time,
@@ -18,12 +20,14 @@
         values
         <foreach collection="images" item="image" separator=",">
             (
+            #{image.id},
             #{image.accountId},
             #{image.url},
             #{image.width},
             #{image.height},
             #{image.size},
             #{image.format},
+            #{image.materialType},
             #{image.signature},
             #{image.imageToken},
             #{image.createTime},

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouTargetingTagsMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper">
+
+</mapper>

+ 11 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -10,21 +10,27 @@
         height,
         url,
         cover_url,
+        material_type,
+        signature,
         create_time,
-        update_time,
-        signature)
+        update_time
+       )
         values
         <foreach collection="videos" item="video" separator=",">
-            (#{video.id},
+            (
+            #{video.id},
             #{video.accountId},
             #{video.photoId},
             #{video.width},
             #{video.height},
             #{video.url},
             #{video.coverUrl},
+            #{video.materialType},
+            #{video.signature},
             #{video.createTime},
-            #{video.updateTime},
-            #{video.signature})
+            #{video.updateTime}
+
+            )
         </foreach>
     </insert>
 </mapper>

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

@@ -1,5 +1,10 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import com.alibaba.fastjson.JSONObject;
+
 import java.math.BigDecimal;
 
 public interface IBatchService {
@@ -18,4 +23,66 @@ public interface IBatchService {
      * @return
      */
     BigDecimal getBudget(Long accountId);
+
+    /**
+     * 获取计划信息
+     *
+     * @param accountId
+     * @param campaignId
+     * @return
+     */
+    KuaiShouCampaign getCampaignInfo(Long accountId, Long campaignId);
+
+
+    /**
+     * 获取项目最高出价
+     *
+     * @param accountId
+     * @return
+     */
+    BigDecimal getProjectMaxBid(Long accountId);
+
+    /**
+     * 校验广告组名称是否重复
+     *
+     * @param campaignId
+     * @param unitName
+     * @return
+     */
+    Boolean checkUnitName(Long campaignId, String unitName);
+
+    /**
+     * 批量创建广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    JSONObject createUnit(JSONObject requestJson) throws Exception;
+
+
+    /**
+     * 获取广告组信息
+     *
+     * @param accountId
+     * @param unitId
+     * @return
+     */
+    KuaiShouGroup getUnitInfo(Long accountId, Long unitId);
+
+    /**
+     * 创建创意
+     *
+     * @param requestJson
+     * @return
+     */
+    JSONObject createCreative(JSONObject requestJson) throws Exception;
+
+    /**
+     * 获取创意信息
+     *
+     * @param accountId
+     * @param creativeId
+     * @return
+     */
+    KuaiShouCreative getCreativeInfo(Long accountId, Long creativeId);
 }

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

@@ -1,8 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImage;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 快手-定向标签
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-19
+ */
+public interface IKuaiShouTargetingTagsService extends IService<KuaiShouTargetingTags> {
+
+}

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

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 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 com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -125,6 +126,8 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> getDeepConversionInfos(Long advertiserId, String accessToken);
 
+    JSONObject getDeepConversionInfosV2(Long advertiserId, String accessToken);
+
 
     /**
      * 创建广告创意
@@ -135,6 +138,8 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> creativeCreate(String accessToken, Long advertiserId, JSONObject requestJson);
 
+    void getCreativeByCreativeId(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page, Long creativeId);
+
     /**
      * 文件上传
      *
@@ -278,6 +283,10 @@ public interface IKuaishouInterfaceService {
      */
     void getImageList(CtopOauthToken token, Date startDate, Date endDate);
 
+
+    void getImageList2(CtopOauthToken token, Date startDate, Date endDate, Integer page);
+
+
     /**
      * 获取快手图片列表--测试使用
      *
@@ -304,4 +313,41 @@ public interface IKuaishouInterfaceService {
      * @param token
      */
     void getDailyFlows(CtopOauthToken token);
+
+
+    /**
+     * 获取人群包接口
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONArray getPopulationList(Long accountId, String accessToken);
+
+
+    /**
+     * 获取定向标签
+     *
+     * @param accountId
+     * @param accessToken
+     */
+    void getTargetingTags(Long accountId, String accessToken);
+
+
+    /**
+     * 获取可选的应用定向
+     *
+     * @param accountId
+     * @param accessToken
+     * @param appName
+     * @return
+     */
+    JSONArray getAppSearch(Long accountId, String accessToken, String appName);
+
+
+    void getVideoList2(CtopOauthToken token, Date startDate, Date endDate, Integer page);
+
+    void getCreativeList2(CtopOauthToken token, Date startDate, Date endDate, Integer page);
+
+    void getCreative(String token, Long advertiserId, Long creativeId);
 }

+ 12 - 16
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java

@@ -37,12 +37,10 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
     public void accountWarning(Long accountId, String statDate, String anotherDay) {
         try {
 
-
             Integer maxHour = hourlyAccountMapper.selectMaxHour(accountId, statDate);
             if (Check.isNull(maxHour)) {
                 return;
             }
-
             QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
             userAllocationQueryWrapper.eq("account_id", accountId);
             userAllocationQueryWrapper.eq("media_id", 2);
@@ -51,7 +49,6 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
             UserAllocation userAllocation = userAllocationMapper.selectOne(userAllocationQueryWrapper);
             if (Check.isNull(userAllocation)) {
                 return;
-
             }
             BigDecimal warningAmount = userAllocation.getWarningAmount();
             BigDecimal warningProportion = userAllocation.getWarningProportion();
@@ -64,26 +61,22 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
                             BigDecimal subtract = nowCost.subtract(lastHourCost);
                             BigDecimal divide = nowCost.divide(lastHourCost, 2, RoundingMode.HALF_UP);
                             if (subtract.compareTo(warningAmount) > -1 && divide.compareTo(warningProportion) > -1) {
-                                sendMessage(accountId, userAllocation.getAuthName(), maxHour, nowCost, userAllocation.getProjectId());
+                                sendMessage(accountId, userAllocation.getAuthName(), maxHour, nowCost, userAllocation.getProjectId(), userAllocation.getProjectName());
                             }
                         }
-
                     }
-
                 }
             }
 
-
             if (!Check.isNull(nowCost) && nowCost.compareTo(new BigDecimal(0)) != 0) {
                 BigDecimal yesterdayHourCost = hourlyAccountMapper.getCost(accountId, maxHour, anotherDay);
                 if (!Check.isNull(yesterdayHourCost) && yesterdayHourCost.compareTo(new BigDecimal(0)) != 0) {
                     BigDecimal subtract = nowCost.subtract(yesterdayHourCost);
                     BigDecimal divide = nowCost.divide(yesterdayHourCost, 2, RoundingMode.HALF_UP);
                     if (subtract.compareTo(warningAmount) > -1 && divide.compareTo(warningProportion) > -1) {
-                        sendYesterdayMessage(accountId, userAllocation.getAuthName(), maxHour, nowCost, userAllocation.getProjectId());
+                        sendYesterdayMessage(accountId, userAllocation.getAuthName(), maxHour, nowCost, userAllocation.getProjectId(), userAllocation.getProjectName());
                     }
                 }
-
             }
 
         } catch (Exception e) {
@@ -92,11 +85,13 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
 
     }
 
-    private void sendYesterdayMessage(Long accountId, String authName, Integer maxHour, BigDecimal nowCost, Long projectId) {
+    private void sendYesterdayMessage(Long accountId, String authName, Integer maxHour, BigDecimal nowCost, Long projectId, String projectName) {
 
         StringBuilder text = new StringBuilder();
-        text.append("较昨日同时段消耗预警").append("<br/>").append("您的账号:").append(accountId + ",").append("<br/>")
-                .append("授权名称为:" + authName + "相较于昨日").append(maxHour + "时").append("<br/>")
+        text.append("较昨日同时段消耗预警").append("<br/>")
+                .append("您的项目:" + projectName + "下的,").append("<br/>")
+                .append("账号:").append(accountId + ",").append("授权名称为:" + authName).append("<br/>")
+                .append("相较于昨日 " + maxHour + "时").append("<br/>")
                 .append("出现消耗暴涨,").append("消耗金额为:" + nowCost).append("<br/>")
                 .append("请您及时查看!");
 
@@ -132,15 +127,16 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
     }
 
 
-    private void sendMessage(Long accountId, String authName, Integer hour, BigDecimal amount, Long projectId) {
+    private void sendMessage(Long accountId, String authName, Integer hour, BigDecimal amount, Long projectId, String projectName) {
 
         StringBuilder text = new StringBuilder();
-        text.append("较上时段消耗预警").append("<br/>").append("您的账号:").append(accountId + ",").append("<br/>")
-                .append("授权名称为:" + authName + ",").append(hour + " 时").append("相较于 " + (hour - 1) + " 时").append("<br/>")
+        text.append("较上时段消耗预警").append("<br/>")
+                .append("您的项目:" + projectName + " 下的").append("<br/>")
+                .append("账号:").append(accountId + ",").append("授权名称为:" + authName).append("<br/>")
+                .append(hour + " 时").append("相较于 " + (hour - 1) + " 时").append("<br/>")
                 .append("出现消耗暴涨,").append("消耗金额为:" + amount).append("<br/>")
                 .append("请您及时查看!");
 
-
         QueryWrapper<MailLog> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("account_id", accountId);
         queryWrapper.eq("hour", hour);

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

@@ -1,7 +1,22 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.mapper.BatchMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,12 +24,17 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.Map;
 
 @Slf4j
 @Service
 public class BatchServiceImpl implements IBatchService {
     @Autowired
     private BatchMapper batchMapper;
+    @Autowired
+    private KuaiShouCampaignMapper campaignMapper;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
 
 
     /**
@@ -43,6 +63,472 @@ public class BatchServiceImpl implements IBatchService {
     }
 
 
+    /**
+     * 获取计划信息
+     *
+     * @param accountId
+     * @param campaignId
+     * @return
+     */
+    @Override
+    public KuaiShouCampaign getCampaignInfo(Long accountId, Long campaignId) {
+        QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
+        campaignQueryWrapper.eq("account_id", accountId);
+        campaignQueryWrapper.eq("campaign_id", campaignId);
+        campaignQueryWrapper.orderByDesc("create_time");
+        campaignQueryWrapper.last("limit 1");
+        KuaiShouCampaign campaign = campaignMapper.selectOne(campaignQueryWrapper);
+        return campaign;
+    }
+
+    /**
+     * 获取项目最高出价
+     *
+     * @param accountId
+     * @return
+     */
+
+    @Override
+    public BigDecimal getProjectMaxBid(Long accountId) {
+        QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+        userAllocationQueryWrapper.eq("account_id", accountId);
+        userAllocationQueryWrapper.eq("media_id", "2");
+        userAllocationQueryWrapper.orderByDesc("create_time");
+        userAllocationQueryWrapper.last("limit 1");
+        UserAllocation userAllocation = userAllocationMapper.selectOne(userAllocationQueryWrapper);
+        if (!Check.isNull(userAllocation)) {
+            return batchMapper.getProjectMaxBidByProject(userAllocation.getProjectId());
+        }
+        return new BigDecimal(0);
+    }
+
+
+    /**
+     * 校验广告组名称是否重复
+     *
+     * @param campaignId
+     * @param unitName
+     * @return
+     */
+    @Autowired
+    private KuaiShouGroupMapper kuaiShouGroupMapper;
+
+    @Override
+    public Boolean checkUnitName(Long campaignId, String unitName) {
+        QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
+        groupQueryWrapper.eq("campaign_id", campaignId);
+        groupQueryWrapper.eq("unit_name", unitName);
+        groupQueryWrapper.orderByDesc("create_time");
+        groupQueryWrapper.last("limit 1");
+        KuaiShouGroup kuaiShouGroup = kuaiShouGroupMapper.selectOne(groupQueryWrapper);
+        if (!Check.isNull(kuaiShouGroup)) {
+            return false;
+        }
+        return true;
+    }
+
+
+    /**
+     * 批量创建广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @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("未获取到账户信息");
+        }
+
+        Long campaignId = requestJson.getLong("campaignId");
+        if (Check.isNull(campaignId)) {
+            throw new Exception("请选择广告计划");
+        }
+
+        JSONObject unitJson = new JSONObject();
+        unitJson.put("campaign_id", campaignId);
+
+        // 资源位置
+        JSONArray scene_id = requestJson.getJSONArray("scene_id");
+        if (!Check.isNull(scene_id)) {
+            unitJson.put("scene_id", scene_id);
+        }
+
+        // 资源创作方式
+        if (!Check.isNull(requestJson.getInteger("unit_type"))) {
+            unitJson.put("unit_type", requestJson.getInteger("unit_type"));
+        }
+
+        //投放开始时间
+        if (!Check.isNull(requestJson.getString("begin_time"))) {
+            unitJson.put("begin_time", requestJson.getString("begin_time"));
+        }
+        // 投放结束时间
+        if (!Check.isNull(requestJson.getString("end_time"))) {
+            unitJson.put("end_time", requestJson.getString("end_time"));
+        }
+        // 投放时间段
+        if (!Check.isNull(requestJson.getString("schedule_time"))) {
+            unitJson.put("schedule_time", requestJson.getString("schedule_time"));
+        }
+        // 广告组单日预算
+        if (!Check.isNull(requestJson.getLong("day_budget"))) {
+            unitJson.put("day_budget", requestJson.getLong("day_budget"));
+        }
+        // url类型
+        if (!Check.isNull(requestJson.getInteger("url_type"))) {
+            unitJson.put("url_type", requestJson.getInteger("url_type"));
+        }
+        // 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("show_mode"))) {
+            unitJson.put("show_mode", requestJson.getInteger("show_mode"));
+        }
+        if (!Check.isNull(requestJson.getInteger("speed"))) {
+            unitJson.put("speed", requestJson.getInteger("speed"));
+        }
+
+
+        // -----------------用户定向-----------
+        JSONObject targetJson = new JSONObject();
+
+        // 地域
+        if (!Check.isNull(requestJson.getJSONArray("region"))) {
+            targetJson.put("region", requestJson.getJSONArray("region"));
+        }
+
+        // 自定义年龄段
+        JSONArray ageArr = requestJson.getJSONArray("age");
+        if (!Check.isNull(ageArr)) {
+            JSONObject ageJson = new JSONObject();
+            ageJson.put("min", ageArr.get(0));
+            ageJson.put("max", ageArr.get(1));
+            targetJson.put("age", ageJson);
+        }
+        // 固定年龄段
+        if (!Check.isNull(requestJson.getJSONArray("ages_range"))) {
+            targetJson.put("ages_range", requestJson.getJSONArray("ages_range"));
+        }
+        // 性别
+        if (!Check.isNull(requestJson.getInteger("gender"))) {
+            targetJson.put("gender", requestJson.getInteger("gender"));
+        }
+        //操作系统
+        if (!Check.isNull(requestJson.getInteger("platform_os"))) {
+            targetJson.put("platform_os", requestJson.getInteger("platform_os"));
+        }
+        //Android版本
+        if (!Check.isNull(requestJson.getInteger("android_osv"))) {
+            targetJson.put("android_osv", requestJson.getInteger("android_osv"));
+        }
+        // iOS版本
+        if (!Check.isNull(requestJson.getInteger("ios_osv"))) {
+            targetJson.put("ios_osv", requestJson.getInteger("ios_osv"));
+        }
+        //网络环境
+        if (!Check.isNull(requestJson.getInteger("network"))) {
+            targetJson.put("network", requestJson.getInteger("network"));
+        }
+        //设备品牌
+        if (!Check.isNull(requestJson.getJSONArray("device_brand"))) {
+            targetJson.put("device_brand", requestJson.getJSONArray("device_brand"));
+        }
+        //设备价格
+        if (!Check.isNull(requestJson.getJSONArray("device_price"))) {
+            targetJson.put("device_price", requestJson.getJSONArray("device_price"));
+        }
+        //商业兴趣类型
+        if (!Check.isNull(requestJson.getInteger("business_interest_type"))) {
+            targetJson.put("business_interest_type", requestJson.getInteger("business_interest_type"));
+        }
+        // 商业兴趣
+        if (!Check.isNull(requestJson.getJSONArray("business_interest"))) {
+            targetJson.put("business_interest", requestJson.getJSONArray("business_interest"));
+        }
+        //网红粉丝
+        if (!Check.isNull(requestJson.getJSONArray("fans_star"))) {
+            targetJson.put("fans_star", requestJson.getJSONArray("fans_star"));
+        }
+        //兴趣视频用户
+        if (!Check.isNull(requestJson.getJSONArray("interest_video"))) {
+            targetJson.put("interest_video", requestJson.getJSONArray("interest_video"));
+        }
+        // APP行为-按分类
+        if (!Check.isNull(requestJson.getJSONArray("app_interest"))) {
+            targetJson.put("app_interest", requestJson.getJSONArray("app_interest"));
+        }
+        // APP行为-按APP名称
+        if (!Check.isNull(requestJson.getJSONArray("app_ids"))) {
+            targetJson.put("app_ids", requestJson.getJSONArray("app_ids"));
+        }
+        // 人群包定向
+        if (!Check.isNull(requestJson.getJSONArray("population"))) {
+            targetJson.put("population", requestJson.getJSONArray("population"));
+        }
+        // 人群包排除
+        if (!Check.isNull(requestJson.getJSONArray("exclude_population"))) {
+            targetJson.put("exclude_population", requestJson.getJSONArray("exclude_population"));
+        }
+
+        JSONObject intelliExtendJson = new JSONObject();
+
+        // 开启智能扩量
+        if (!Check.isNull(requestJson.getInteger("is_open"))) {
+            intelliExtendJson.put("is_open", requestJson.getInteger("is_open"));
+        }
+        //不可突破年龄
+        if (!Check.isNull(requestJson.getInteger("no_age_break"))) {
+            intelliExtendJson.put("no_age_break", requestJson.getInteger("no_age_break"));
+        }
+        //不可突破性别
+        if (!Check.isNull(requestJson.getInteger("no_gender_break"))) {
+            intelliExtendJson.put("no_gender_break", requestJson.getInteger("no_gender_break"));
+        }
+        // 不可突破地域
+        if (!Check.isNull(requestJson.getInteger("no_area_break"))) {
+            intelliExtendJson.put("no_area_break", requestJson.getInteger("no_area_break"));
+        }
+        if (!Check.isNull(intelliExtendJson)) {
+            targetJson.put("intelli_extend", intelliExtendJson);
+        }
+
+        unitJson.put("target", targetJson);
+
+
+        JSONArray groupArr = requestJson.getJSONArray("groupArr");
+        if (Check.isNull(groupArr)) {
+            throw new Exception("请输入需要创建的广告组");
+        }
+
+
+        JSONObject returnJson = new JSONObject();
+        // 创建条数
+        returnJson.put("total", groupArr.size());
+        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"));
+                }
+                // 出价类型
+                Integer bidType = groupJson.getInteger("bid_type");
+                if (!Check.isNull(bidType)) {
+                    unitJson.put("bid_type", bidType);
+                }
+                // 深度转化出价
+                if (!Check.isNull(groupJson.getLong("cpa_bid"))) {
+                    unitJson.put("cpa_bid", groupJson.getLong("cpa_bid"));
+                }
+                // 深度转化目标出价
+                if (!Check.isNull(groupJson.getLong("deep_conversion_bid"))) {
+                    unitJson.put("deep_conversion_bid", groupJson.getLong("deep_conversion_bid"));
+                }
+                // 深度转化目标
+                if (!Check.isNull(groupJson.getInteger("deep_conversion_type"))) {
+                    unitJson.put("deep_conversion_type", groupJson.getInteger("deep_conversion_type"));
+                }
+                // 优化目标
+                Integer ocpx_action_type = groupJson.getInteger("ocpx_action_type");
+                if (!Check.isNull(ocpx_action_type)) {
+                    unitJson.put("ocpx_action_type", ocpx_action_type);
+                }
+                String unitName = groupJson.getString("unitName");
+                if (!Check.isNull(unitName)) {
+                    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) {
+                        JSONObject successJson = new JSONObject();
+                        successJson.put("unit_id", returnUnitMap.get("unitId"));
+                        successJson.put("unit_name", unitName);
+                        successJson.put("scene_id", scene_id);
+                        successJson.put("ocpx_action_type", ocpx_action_type);
+                        successArr.add(successJson);
+                    } else {
+                        JSONObject failJson = new JSONObject();
+                        failJson.put("unit_name", unitName);
+                        failJson.put("failMessage", returnUnitMap.get("message"));
+                        failArr.add(failJson);
+                    }
+
+                }
+
+            }
+
+        }
+
+        returnJson.put("success", successArr);
+        returnJson.put("fail", failArr);
+        return returnJson;
+    }
+
+    /**
+     * 获取广告组信息
+     *
+     * @param accountId
+     * @param unitId
+     * @return
+     */
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+
+    @Override
+    public KuaiShouGroup getUnitInfo(Long accountId, Long unitId) {
+        QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
+        groupQueryWrapper.eq("account_id", accountId);
+        groupQueryWrapper.eq("unit_id", unitId);
+        groupQueryWrapper.orderByDesc("create_time");
+        groupQueryWrapper.last("limit 1");
+        KuaiShouGroup group = groupMapper.selectOne(groupQueryWrapper);
+        return group;
+    }
+
+
+    /**
+     * 创建创意
+     *
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject createCreative(JSONObject requestJson) throws Exception {
+        System.err.println(requestJson);
+
+        if (Check.isNull(requestJson)) {
+            throw new Exception("入参为空");
+        }
+
+
+        Long accountId = requestJson.getLong("accountId");
+        if (Check.isNull(accountId)) {
+            throw new Exception("请输入需创建账号");
+        }
+
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        if (Check.isNull(oauthToken)) {
+            throw new Exception("未获取到账户信息");
+        }
+
+        Long unitId = requestJson.getLong("unitId");
+        if (Check.isNull(unitId)) {
+            throw new Exception("请选择广告组");
+        }
+
+
+        JSONObject creativeJson = new JSONObject();
+
+
+        creativeJson.put("advertiser_id", accountId);
+
+        creativeJson.put("unit_id", unitId);
+
+        // 素材类型
+        if (!Check.isNull(requestJson.get("creative_material_type"))) {
+            creativeJson.put("creative_material_type", requestJson.get("creative_material_type"));
+        }
+
+        String action_bar_text = requestJson.getString("action_bar_text");
+        // 视频id
+
+        String click_track_url = requestJson.getString("click_track_url");
+        JSONObject returnJson = new JSONObject();
+        JSONArray successArr = new JSONArray();
+        JSONArray failArr = new JSONArray();
+        JSONArray dataJsons = requestJson.getJSONArray("dataJson");
+        if (!Check.isNull(dataJsons)) {
+            for (int i = 0; i < dataJsons.size(); i++) {
+                JSONObject dataJson = dataJsons.getJSONObject(i);
+                if (!Check.isNull(dataJsons)) {
+                    String description = dataJson.getString("description");
+                    String photo_id = dataJson.getString("photo_id");
+                    JSONArray imageTokens = dataJson.getJSONArray("image_tokens");
+                    if (!Check.isNull(imageTokens)) {
+                        for (int j = 0; j < imageTokens.size(); j++) {
+                            JSONObject imageJson = imageTokens.getJSONObject(j);
+                            if (!Check.isNull(imageJson)) {
+                                String image = imageJson.getString("image");
+                                String name = imageJson.getString("name");
+                                creativeJson.put("action_bar_text", action_bar_text);
+                                creativeJson.put("description", description);
+                                creativeJson.put("image_token", image);
+                                creativeJson.put("creative_name", name);
+                                creativeJson.put("photo_id", photo_id);
+                                creativeJson.put("click_track_url", click_track_url);
+
+                                Map<String, Object> returnUnitMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson);
+                                if (!Check.isNullMap(returnUnitMap)) {
+                                    Integer code = (Integer) returnUnitMap.get("code");
+                                    if (code == 0) {
+                                        JSONObject successJson = new JSONObject();
+                                        successJson.put("creative_name", name);
+
+                                        successArr.add(successJson);
+                                    } else {
+                                        JSONObject failJson = new JSONObject();
+                                        failJson.put("creative_name", name);
+                                        failJson.put("failMessage", returnUnitMap.get("message"));
+                                        failArr.add(failJson);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+            }
+
+        }
+
+        returnJson.put("success", successArr);
+        returnJson.put("fail", failArr);
+        return returnJson;
+    }
+
+    @Autowired
+    private KuaiShouCreativeMapper creativeMapper;
+
+
+    /**
+     * 获取创意信息
+     *
+     * @param accountId
+     * @param creativeId
+     * @return
+     */
+    @Override
+    public KuaiShouCreative getCreativeInfo(Long accountId, Long creativeId) {
+        QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
+        creativeQueryWrapper.eq("account_id", accountId);
+        creativeQueryWrapper.eq("creative_id", creativeId);
+        creativeQueryWrapper.orderByDesc("create_time");
+        creativeQueryWrapper.last("limit 1");
+        KuaiShouCreative creative = creativeMapper.selectOne(creativeQueryWrapper);
+        return creative;
+    }
+
+
 }
 
 

+ 19 - 17
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreateAppTemplateServiceImpl.java

@@ -1,13 +1,15 @@
 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.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreateAppTemplate;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreateAppTemplateMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreateAppTemplateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -25,13 +27,15 @@ import java.util.Map;
  */
 @Service
 public class KuaiShouCreateAppTemplateServiceImpl extends ServiceImpl<KuaiShouCreateAppTemplateMapper, KuaiShouCreateAppTemplate> implements IKuaiShouCreateAppTemplateService {
-    @Autowired
-    private KuaiShouCreateAppTemplateMapper appTemplateMapper;
+
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
     @Autowired
     private IKuaishouInterfaceService interfaceService;
 
+    @Autowired
+    private KuaiShouAppListMapper appListMapper;
+
     @Override
     public Map<String, Object> insert(KuaiShouCreateAppTemplate appTemplate) {
         Map<String, Object> resultMap = new HashMap<>();
@@ -42,15 +46,14 @@ public class KuaiShouCreateAppTemplateServiceImpl extends ServiceImpl<KuaiShouCr
                 throw new Exception("未获取到token信息");
             }
             String accessToken = cTopOauthToken.getAccessToken();
-            String loginId = appTemplate.getLoginId();
             String appVersion = appTemplate.getAppVersion();
-            QueryWrapper<KuaiShouCreateAppTemplate> queryWrapper = new QueryWrapper<>();
+            QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("app_version", appVersion);
-            queryWrapper.eq("login_id", loginId);
+            queryWrapper.eq("account_id", accountId);
             queryWrapper.orderByDesc("create_time");
             queryWrapper.last("limit 1");
-            KuaiShouCreateAppTemplate kuaiShouCreateAppTemplate = appTemplateMapper.selectOne(queryWrapper);
-            if (!Check.isNull(kuaiShouCreateAppTemplate)) {
+            KuaiShouAppList kuaiShouAppList = appListMapper.selectOne(queryWrapper);
+            if (!Check.isNull(kuaiShouAppList)) {
                 resultMap.put("success", false);
                 resultMap.put("message", "应用标记重复");
                 resultMap.put("code", -1);
@@ -80,13 +83,13 @@ public class KuaiShouCreateAppTemplateServiceImpl extends ServiceImpl<KuaiShouCr
                 }
                 if ("1".equals(platform) && appTemplate.getUploadType() == 1) {
                     apkJson.put("file", appTemplate.getFile());
-                    Thread thread = new Thread() {
-                        @Override
-                        public void run() {
-                            interfaceService.appCreate(accountId, accessToken, apkJson);
-                        }
-                    };
-                    thread.start();
+
+                    Map<String, Object> appMap = interfaceService.appCreate(accountId, accessToken, apkJson);
+                    if ((Integer) appMap.get("code") != 0) {
+                        return appMap;
+
+                    }
+
                 } else {
                     apkJson.put("url", appTemplate.getUrl());
                     Map<String, Object> appMap = interfaceService.urlAppCreate(accountId, accessToken, apkJson);
@@ -94,7 +97,6 @@ public class KuaiShouCreateAppTemplateServiceImpl extends ServiceImpl<KuaiShouCr
                         return appMap;
                     }
                 }
-                appTemplateMapper.insert(appTemplate);
                 resultMap.put("success", true);
                 resultMap.put("message", "创建应用成功");
                 resultMap.put("code", 0);

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouTargetingTagsServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouTargetingTagsService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手-定向标签
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-19
+ */
+@Service
+public class KuaiShouTargetingTagsServiceImpl extends ServiceImpl<KuaiShouTargetingTagsMapper, KuaiShouTargetingTags> implements IKuaiShouTargetingTagsService {
+
+}

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

@@ -57,7 +57,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                     QueryWrapper<KuaiShouCampaign> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("accountId", advertiserId);
+                    queryWrapper.eq("account_id", advertiserId);
                     queryWrapper.eq("campaign_id", campaignId);
                     queryWrapper.orderByDesc("create_time");
                     queryWrapper.last("limit 1");
@@ -66,7 +66,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     KuaiShouCampaignDayBudget campaignDayBudget = new KuaiShouCampaignDayBudget();
                     campaignDayBudget.setAccountId(advertiserId);
                     campaignDayBudget.setCampaignId(campaignId);
-                    campaignDayBudget.setLoginId(loginId);
+                    campaignDayBudget.setUserId(loginId);
                     campaignDayBudget.setDayBudget(campaign.getDayBudget());
                     campaignDayBudget.setUpdateDayBudget(dayBudget);
                     int i = campaignDayBudgetMapper.insert(campaignDayBudget);
@@ -131,7 +131,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                     QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("accountId", advertiserId);
+                    queryWrapper.eq("account_id", advertiserId);
                     queryWrapper.eq("unit_id", unitId);
                     queryWrapper.orderByDesc("create_time");
                     queryWrapper.last("limit 1");
@@ -142,7 +142,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     groupDayBudget.setUnitId(unitId);
                     groupDayBudget.setDayBudget(group.getDayBudget());
                     groupDayBudget.setUpdateDayBudget(dayBudget);
-                    groupDayBudget.setLoginId(loginId);
+                    groupDayBudget.setUserId(loginId);
                     int i = groupDayBudgetMapper.insert(groupDayBudget);
                     if (i > 0) {
                         log.info("修改广告组预算本地记录添加成功,unitId:{}", unitId);
@@ -205,7 +205,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 if (code == 0) {
                     QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("unit_id", unitId);
-                    queryWrapper.eq("accountId", advertiserId);
+                    queryWrapper.eq("account_id", advertiserId);
                     queryWrapper.orderByDesc("create_time");
                     queryWrapper.last("limit 1");
                     KuaiShouGroup group = groupMapper.selectOne(queryWrapper);
@@ -215,13 +215,15 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     groupBid.setUnitId(unitId);
                     groupBid.setBid(group.getBid());
                     groupBid.setUpdateBid(bid);
-                    groupBid.setLoginId(loginId);
+                    groupBid.setUserId(loginId);
                     int i = groupBidMapper.insert(groupBid);
                     if (i > 0) {
                         log.info("修改广告组出价本地记录添加成功,unitId:{}", unitId);
                     }
                     // 重新请求数据
                     interfaceService.getGroup(token, advertiserId, unitId);
+                    returnMap.put("code", 0);
+                    returnMap.put("success", true);
                 } else {
                     log.error("修改广告组出价失败,advertiserId:{},unitId:{},返回信息:{}", advertiserId, unitId, resultJson);
                     returnMap.put("code", -1);
@@ -256,6 +258,9 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
      * @param putStatus
      * @return
      */
+    @Autowired
+    private KuaiShouCampaignMapper kuaiShouCampaignMapper;
+
     @Override
     public Map<String, Object> updateCampaignStatus(String token, Long advertiserId, Long campaignId, int putStatus, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -277,7 +282,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
 
                     QueryWrapper<KuaiShouCampaign> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("campaign_id", campaignId);
-                    queryWrapper.eq("accountId", advertiserId);
+                    queryWrapper.eq("account_id", advertiserId);
                     queryWrapper.orderByDesc("create_time");
                     queryWrapper.last("limit 1");
                     // 查询本地记录信息
@@ -288,13 +293,20 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     campaignStatus.setCampaignId(campaignId);
                     campaignStatus.setPutStatus(campaign.getStatus());
                     campaignStatus.setUpdatePutStatus(putStatus);
-                    campaignStatus.setLoginId(loginId);
+                    campaignStatus.setUserId(loginId);
                     int i = campaignStatusMapper.insert(campaignStatus);
                     if (i > 0) {
                         log.info("修改广告计划状态本地记录添加成功,campaignId:{}", campaignId);
                     }
 
-                    interfaceService.getCampaign(token, advertiserId, campaignId);
+                    if (putStatus == 3) {
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("account_id", advertiserId);
+                        deleteMap.put("campaign_id", campaignId);
+                        kuaiShouCampaignMapper.deleteByMap(deleteMap);
+                    } else {
+                        interfaceService.getCampaign(token, advertiserId, campaignId);
+                    }
                     returnMap.put("code", 0);
                     returnMap.put("success", true);
                     returnMap.put("message", "修改成功");
@@ -325,7 +337,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
 
     /**
      * TODO
-     * 修广告组状态
+     * 修广告组状态
      *
      * @param token
      * @param advertiserId
@@ -353,6 +365,16 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     returnMap.put("code", 0);
                     returnMap.put("success", true);
                     returnMap.put("message", "修改成功");
+                    if (putStatus == 3) {
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("account_id", advertiserId);
+                        deleteMap.put("unit_id", unitId);
+                        groupMapper.deleteByMap(deleteMap);
+                    } else {
+                        interfaceService.getGroup(token, advertiserId, unitId);
+                    }
+
+
                 } else {
                     log.error("修改广告组状态失败,advertiserId:{},unitId:{},返回信息:{}", advertiserId, unitId, resultJson);
                     returnMap.put("code", -1);
@@ -386,6 +408,9 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
      * @param putStatus
      * @return
      */
+    @Autowired
+    private KuaiShouCreativeMapper creativeMapper;
+
     @Override
     public Map<String, Object> updateCreativeStatus(String token, Long advertiserId, Long creativeId, int putStatus, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -403,6 +428,15 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
+                    if (putStatus == 3) {
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("account_id", advertiserId);
+                        deleteMap.put("creative_id", creativeId);
+                        creativeMapper.deleteByMap(deleteMap);
+                    } else {
+                        interfaceService.getCreative(token, advertiserId, creativeId);
+                    }
+
                     returnMap.put("code", 0);
                     returnMap.put("success", true);
                     returnMap.put("message", "修改成功");

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 869 - 206
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java


+ 30 - 2
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml

@@ -85,6 +85,13 @@
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
+        sum(event_register) eventRegister, -- 注册数
+        (case
+        when sum(event_register) != 0
+        then (sum(charge) / sum(event_register))
+        else 0
+        end
+        ) eventRegisterCost, -- 注册成本
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
         from
@@ -152,6 +159,13 @@
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        sum(event_register) eventRegister, -- 注册数
+        (case
+        when sum(event_register) != 0
+        then (sum(charge) / sum(event_register))
+        else 0
+        end
+        ) eventRegisterCost, -- 注册成本
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
         from
@@ -409,7 +423,14 @@
         ELSE
         0
         END
-        ) discountConversionPrice
+        ) discountConversionPrice,
+        sum(event_register) eventRegister, -- 注册数
+        (case
+        when sum(event_register) != 0
+        then (sum(charge) / sum(event_register))
+        else 0
+        end
+        ) eventRegisterCost -- 注册成本
 
         from
         ctop_kuaishou_report_daily_account
@@ -503,7 +524,14 @@
         ELSE
         0
         END
-        ) discountConversionPrice
+        ) discountConversionPrice,
+        sum(event_register) eventRegister, -- 注册数
+        (case
+        when sum(event_register) != 0
+        then (sum(charge) / sum(event_register))
+        else 0
+        end
+        ) eventRegisterCost -- 注册成本
 
         from
         ctop_kuaishou_report_hourly_account

+ 2 - 2
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java

@@ -61,7 +61,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
                 // 昨日 小时汇总数据
                 JSONObject yesterdayJson = accountReportMapper.selectSumDayHourlyByHourAndDate(anotherDay, maxHourStr, accountIds);
                 accountJson.put("maxHour", maxHour);
-                if (!Check.isNull(accountJson)) {
+                if (!Check.isNull(accountJson) && !Check.isNull(yesterdayJson)) {
                     // 今日消耗
                     BigDecimal cost = accountJson.getBigDecimal("cost");
                     // 昨日消耗
@@ -331,7 +331,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
                         Long nowAClick = nowAccountSummary.getLong("aclick");
                         Long yesterdayAClick = yesterdayAccountSummary.getLong("aclick");
                         //爆光环比
-                        if (!Check.isNull(nowAClick) && !Check.isNull(nowAClick)) {
+                        if (!Check.isNull(nowAClick) && !Check.isNull(yesterdayAClick)) {
                             if (yesterdayAClick != 0L) {
                                 double aClickProportion = (nowAClick.doubleValue() - yesterdayAClick.doubleValue()) / yesterdayAClick.doubleValue();
                                 chainRatioJson.put("aClickProportion", aClickProportion);