瀏覽代碼

Merge branch 'V1.1.3'

syh 4 年之前
父節點
當前提交
6a18c108cb
共有 55 個文件被更改,包括 3375 次插入121 次删除
  1. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 1 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountAuthController.java
  3. 9 10
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  4. 6 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialCutFrameController.java
  5. 126 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  6. 31 2
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  7. 246 0
      module-common/src/main/java/cn/com/ctop/common/module/controller/OauthConfigController.java
  8. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/CtopOauthToken.java
  9. 94 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/OauthConfig.java
  10. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialCutFrameMapper.java
  11. 23 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/OauthConfigMapper.java
  12. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  13. 28 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialCutFrameMapper.xml
  14. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/OauthConfigMapper.xml
  15. 4 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IBindAccountAuthService.java
  16. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  17. 9 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameService.java
  18. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IOauthConfigService.java
  19. 21 15
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java
  20. 4 10
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  21. 9 7
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java
  22. 52 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/OauthConfigServiceImpl.java
  23. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java
  24. 130 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreativeRefusalController.java
  25. 298 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchCampaignPreviewController.java
  26. 274 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchCreativePreviewController.java
  27. 255 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchGroupPreviewController.java
  28. 25 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  29. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouBatchGroupTemplate.java
  30. 117 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCampaignPreview.java
  31. 201 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCreativePreview.java
  32. 236 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchGroupPreview.java
  33. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouStrategy.java
  34. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouBatchCampaignPreviewMapper.java
  35. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouBatchCreativePreviewMapper.java
  36. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouBatchGroupPreviewMapper.java
  37. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouBatchCampaignPreviewMapper.xml
  38. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouBatchCreativePreviewMapper.xml
  39. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouBatchGroupPreviewMapper.xml
  40. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouStrategyMapper.xml
  41. 0 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouBatchCampaignTemplateService.java
  42. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java
  43. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouBatchCampaignPreviewService.java
  44. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouBatchCreativePreviewService.java
  45. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouBatchGroupPreviewService.java
  46. 3 12
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  47. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateService.java
  48. 0 26
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouBatchCampaignTemplateServiceImpl.java
  49. 10 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  50. 3 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  51. 475 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchCampaignPreviewServiceImpl.java
  52. 476 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchCreativePreviewServiceImpl.java
  53. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchGroupPreviewServiceImpl.java
  54. 10 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  55. 7 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java

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

@@ -185,6 +185,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/kuaishou/create/*", "anon");
         filterChainDefinitionMap.put("/template/**", "anon");
         filterChainDefinitionMap.put("/batch/kuaiShouGroupTemplate/*", "anon");
+        filterChainDefinitionMap.put("/kuaishouBatch/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

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

@@ -54,10 +54,8 @@ public class BindAccountAuthController {
             }
 
             String authorizationType = json.getString("authorizationType");
-            // 0 三方代理商 1 本代理商
-            Integer agentType = json.getInteger("agentType");
             if ("kuaishou".equals(authorizationType)) {
-                codeUrl = bindAccountAuthService.getKuaishouCodeUrl(json.toJSONString(), agentType);
+                codeUrl = bindAccountAuthService.getKuaishouCodeUrl(json);
             }
             if ("bytedance".equals(authorizationType)) {
                 codeUrl = bindAccountAuthService.getByteDanceCodeUrl(json.toJSONString());

+ 9 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -119,8 +119,9 @@ public class CallbackController {
             log.info("快手授权返回信息:{}", json);
             log.info("快手授权返回oauthCode:{}", authCode);
             Integer agentType = json.getInteger("agentType");
+            Long appId = json.getLong("appId");
             if (StringUtils.isNotBlank(authCode)) {
-                KuaishouResultToken accessToken = kuaishouInterfaceService.getAccessToken(authCode, agentType);
+                KuaishouResultToken accessToken = kuaishouInterfaceService.getAccessToken(authCode, appId);
                 if (accessToken.getCode() != 0) {
                     throw new Exception("快手回调token返回错误");
                 }
@@ -131,11 +132,14 @@ public class CallbackController {
                         return "授权绑定失败!";
                     }
 
+                    Map<String, Object> advertiseBaseInfoMap = kuaishouInterfaceService.advertiserInfo(accountId, token.getAccessToken());
+                    if ((Integer) advertiseBaseInfoMap.get("code") != 0) {
+                        return "授权绑定失败,失败原因:" + advertiseBaseInfoMap.get("message");
+                    }
                     String advertiserId = json.getString("advertiserId");
                     //指定分配人姓名
                     String userName = json.getString("userName");
-                    // 广告主名称
-                    String advertiserName = json.getString("advertiser_name");
+
                     // 媒体类型: 1 头条 2 快手
                     String mediaId = json.getString("mediaId");
                     //创建人
@@ -147,6 +151,7 @@ public class CallbackController {
 
                     CtopOauthToken topOauthToken = new CtopOauthToken();
                     topOauthToken.setId(String.valueOf(accountId));
+                    topOauthToken.setAppId(json.getLong("appId"));
                     topOauthToken.setAccountId(accountId);
                     topOauthToken.setMediaId("2");
                     topOauthToken.setAdvertiserId(advertiserId);
@@ -162,8 +167,6 @@ public class CallbackController {
                     topOauthToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
                     topOauthToken.setUpdateTime(new Date());
                     ctopOauthTokenService.saveOrUpdate(topOauthToken);
-
-
                     QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
                     userAllocationQueryWrapper.eq("account_id", accountId);
                     userAllocationQueryWrapper.eq("media_id", 2);
@@ -179,10 +182,7 @@ public class CallbackController {
                     userAllocation.setAdvertiserId(advertiserId);
                     userAllocation.setSystemType(systemType);
                     // 获取快手昵称
-                    Map<String, Object> advertiseBaseInfoMap = kuaishouInterfaceService.advertiserInfo(accountId, token.getAccessToken());
-                    if ((Integer) advertiseBaseInfoMap.get("code") == 0) {
-                        userAllocation.setAuthName((String) advertiseBaseInfoMap.get("userName"));
-                    }
+                    userAllocation.setAuthName((String) advertiseBaseInfoMap.get("userName"));
                     userAllocation.setMediaId(mediaId);
                     userAllocation.setAccountId(accountId);
                     userAllocation.setProjectId(projectId);
@@ -199,7 +199,6 @@ public class CallbackController {
                     if (i > 0) {
                         log.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
                     }
-
                     //账号绑定
                     bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, advertiserId);
                     Thread t = new Thread() {

+ 6 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialCutFrameController.java

@@ -2,14 +2,14 @@ package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
-import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
-import cn.com.ctop.common.module.entity.MaterialInfo;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
 import cn.com.ctop.common.module.service.IMaterialInfoService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -19,13 +19,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.Arrays;
 import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 
 /**

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.common.module.vo.ResFileDTO;
@@ -11,6 +12,8 @@ import cn.com.ctop.crawler.modules.douyin.service.DouyinMusicService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
+import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
@@ -29,11 +32,15 @@ import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.InputStream;
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -102,6 +109,123 @@ public class TestController {
     private IBytedanceAccountReportTaskRecordService reportTaskRecordService;
     @Resource
     private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
+    @Autowired
+    private ICtopOauthTokenService ctopOauthTokenService;
+
+    @Autowired
+    private IBindAccountAuthService bindAccountAuthService;
+    @Autowired
+    private UserAllocationMapper allocationMapper;
+
+    @GetMapping("/testKuaishou")
+    public String kuaishouCallback( @RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
+        try {
+            JSONObject json = JSONObject.parseObject(state);
+            if (Check.isNull(json)) {
+                throw new Exception("回调信息为空");
+            }
+            log.info("快手授权返回信息:{}", json);
+            log.info("快手授权返回oauthCode:{}", authCode);
+            Integer agentType = json.getInteger("agentType");
+            Long appId = json.getLong("appId");
+            if (org.apache.commons.lang.StringUtils.isNotBlank(authCode)) {
+                KuaishouResultToken accessToken = kuaishouInterfaceService.getAccessToken(authCode, appId);
+                if (accessToken.getCode() != 0) {
+                    throw new Exception("快手回调token返回错误");
+                }
+                KuaishouAccessToken token = accessToken.getData();
+                if (token != null) {
+                    Long accountId = token.getAccountId();
+                    if (Check.isNull(accountId)) {
+                        return "授权绑定失败!";
+                    }
+                    Map<String, Object> advertiseBaseInfoMap = kuaishouInterfaceService.advertiserInfo(accountId, token.getAccessToken());
+                    if ((Integer) advertiseBaseInfoMap.get("code") != 0) {
+                        return "授权绑定失败,失败原因:" + advertiseBaseInfoMap.get("message");
+                    }
+                    String advertiserId = json.getString("advertiserId");
+                    //指定分配人姓名
+                    String userName = json.getString("userName");
+                    // 媒体类型: 1 头条 2 快手
+                    String mediaId = json.getString("mediaId");
+                    //创建人
+                    String userId = json.getString("userId");
+                    Long projectId = json.getLong("projectId");
+                    BigDecimal warningProportion = json.getBigDecimal("WarningProportion");
+                    BigDecimal warningAmount = json.getBigDecimal("WarningAmount");
+                    String systemType = json.getString("systemType");
+                    CtopOauthToken topOauthToken = new CtopOauthToken();
+                    topOauthToken.setId(String.valueOf(accountId));
+                    topOauthToken.setAppId(json.getLong("appId"));
+                    topOauthToken.setAccountId(accountId);
+                    topOauthToken.setMediaId("2");
+                    topOauthToken.setAdvertiserId(advertiserId);
+                    topOauthToken.setAgentType(agentType);
+                    topOauthToken.setAccessToken(token.getAccessToken());
+                    long accessTokenExpireIn = token.getAccessTokenExpiresIn() * 1000L;
+                    long now = System.currentTimeMillis();
+                    Date accessTokenExpireInDate = new Date(now + accessTokenExpireIn);
+                    topOauthToken.setAccessTokenExpiresIn(accessTokenExpireInDate);
+                    topOauthToken.setRefreshToken(token.getRefreshToken());
+                    long refreshTokenExpireIn = token.getRefreshTokenExpiresIn() * 1000L;
+                    Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
+                    topOauthToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
+                    topOauthToken.setUpdateTime(new Date());
+                    ctopOauthTokenService.saveOrUpdate(topOauthToken);
+                    QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                    userAllocationQueryWrapper.eq("account_id", accountId);
+                    userAllocationQueryWrapper.eq("media_id", 2);
+                    userAllocationQueryWrapper.orderByDesc("create_time");
+                    userAllocationQueryWrapper.last("limit 1");
+                    UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
+                    if (!Check.isNull(checkUserAllocation)) {
+                        return "授权失败,该账号已被:" + checkUserAllocation.getUserName() + " 绑定!";
+                    }
+                    UserAllocation userAllocation = new UserAllocation();
+                    userAllocation.setUserName(userName);
+                    userAllocation.setUserId(userId);
+                    userAllocation.setAdvertiserId(advertiserId);
+                    userAllocation.setSystemType(systemType);
+                    // 获取快手昵称
+                    userAllocation.setAuthName((String) advertiseBaseInfoMap.get("userName"));
+                    userAllocation.setMediaId(mediaId);
+                    userAllocation.setAccountId(accountId);
+                    userAllocation.setProjectId(projectId);
+                    userAllocation.setWarningProportion(warningProportion);
+                    userAllocation.setWarningAmount(warningAmount);
+                    userAllocation.setCreateTime(new Date());
+                    userAllocation.setUpdateTime(new Date());
+                    allocationMapper.deleteById(userAllocation.getId());
+                    Map<String, Object> deleteUserMap = new HashMap<>();
+                    deleteUserMap.put("advertiser_id", advertiserId);
+                    deleteUserMap.put("account_id", accountId);
+                    allocationMapper.deleteByMap(deleteUserMap);
+                    int i = allocationMapper.insert(userAllocation);
+                    if (i > 0) {
+                        log.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
+                    }
+                    //账号绑定
+                    bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, advertiserId);
+                    Thread t = new Thread() {
+                        @Override
+                        public void run() {
+                            try {
+                                kuaishouInterfaceService.loadKuaishouDataSingle(topOauthToken);
+                            } catch (ParseException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    };
+                    t.start();
+                }
+                return "授权绑定成功";
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "授权绑定失败!";
+    }
+
 
     @GetMapping("/getBytedanceMatReport")
     public Map<String,Object>getData(){
@@ -710,11 +834,11 @@ public class TestController {
     }
 
 
-    @GetMapping(value = "/getToken")
+   /* @GetMapping(value = "/getToken")
     public String getToken(Long accountId, String token, String refreshToken, Integer agentType) {
         oauthTokenService.getKuaiShouRefreshToken(accountId, token, refreshToken, agentType);
         return "Success";
-    }
+    }*/
 
 
     @GetMapping(value = "/getAccountReport")

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

@@ -3,8 +3,10 @@ package org.jeecg;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
@@ -25,6 +27,7 @@ import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecor
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
+import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.catalina.User;
 import org.jeecg.common.util.DateUtils;
@@ -70,12 +73,38 @@ public class SampleTest {
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+    @Autowired
+    private IOauthConfigService configService;
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
 
 
     @Test
     public void loadBytedanceCreativeData() throws ParseException {
 
-        List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
+
+        List<CtopOauthToken> oauthTokens = oauthTokenMapper.selectKuaiShouTokens(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        if (!Check.isNull(oauthTokens)) {
+            Map<Long, String> configMap = configService.getConfigMapByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
+            for (CtopOauthToken oauthToken : oauthTokens) {
+                XxlJobHelper.log("刷新token,accountId:{}", oauthToken.getAccountId());
+                //快手
+                if (CtopAdConstant.PLATFORM_TYPE_KUAISHOU.equals(oauthToken.getMediaId().trim())) {
+                    String secret = configMap.get(oauthToken.getAppId());
+                    System.err.println(secret);
+                    oauthTokenService.getKuaiShouRefreshToken(oauthToken.getAccountId(), oauthToken.getAccessToken(), oauthToken.getRefreshToken(), oauthToken.getAppId(), secret);
+                }
+            }
+        } else {
+            XxlJobHelper.log("----------------------刷新token获取数据返回结果为空----------------------------------");
+        }
+
+
+      /*  Map<Long, String> configMap = configService.getConfigMapByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
+        System.err.println(configMap);*/
+
+
+      /*  List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
         if (!Check.isNull(KuaiShouVideoGets)) {
             JSONArray dateList = new JSONArray();
             JSONArray photoIds = new JSONArray();
@@ -96,7 +125,7 @@ public class SampleTest {
             }
             dateList.add(photoIds);
             kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
-        }
+        }*/
     }
 
     @Test

+ 246 - 0
module-common/src/main/java/cn/com/ctop/common/module/controller/OauthConfigController.java

@@ -0,0 +1,246 @@
+package cn.com.ctop.common.module.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.OauthConfig;
+import cn.com.ctop.common.module.service.IOauthConfigService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.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 2021-01-26
+ */
+@Slf4j
+@Api(tags = "授权配置信息")
+@RestController
+@RequestMapping("/auth/oauthConfig")
+public class OauthConfigController {
+    @Autowired
+    private IOauthConfigService oauthConfigService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param oauthConfig
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "授权配置信息-分页列表查询")
+    @ApiOperation(value = "授权配置信息-分页列表查询", notes = "授权配置信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<List<OauthConfig>> queryPageList(OauthConfig oauthConfig,
+                                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                   HttpServletRequest req) {
+        Result<List<OauthConfig>> result = new Result<>();
+        QueryWrapper<OauthConfig> queryWrapper = QueryGenerator.initQueryWrapper(oauthConfig, req.getParameterMap());
+        queryWrapper.orderByAsc("rank");
+        List<OauthConfig> pageList = oauthConfigService.list(queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param oauthConfig
+     * @return
+     */
+    @AutoLog(value = "授权配置信息-添加")
+    @ApiOperation(value = "授权配置信息-添加", notes = "授权配置信息-添加")
+    @PostMapping(value = "/add")
+    public Result<OauthConfig> add(@RequestBody OauthConfig oauthConfig) {
+        Result<OauthConfig> result = new Result<>();
+        try {
+            oauthConfigService.save(oauthConfig);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param oauthConfig
+     * @return
+     */
+    @AutoLog(value = "授权配置信息-编辑")
+    @ApiOperation(value = "授权配置信息-编辑", notes = "授权配置信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<OauthConfig> edit(@RequestBody OauthConfig oauthConfig) {
+        Result<OauthConfig> result = new Result<OauthConfig>();
+        OauthConfig oauthConfigEntity = oauthConfigService.getById(oauthConfig.getId());
+        if (oauthConfigEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = oauthConfigService.updateById(oauthConfig);
+            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 {
+            oauthConfigService.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<OauthConfig> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<OauthConfig> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.oauthConfigService.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<OauthConfig> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<OauthConfig> result = new Result<>();
+        OauthConfig oauthConfig = oauthConfigService.getById(id);
+        if (oauthConfig == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(oauthConfig);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<OauthConfig> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                OauthConfig oauthConfig = JSON.parseObject(deString, OauthConfig.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(oauthConfig, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<OauthConfig> pageList = oauthConfigService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "授权配置信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, OauthConfig.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<OauthConfig> listOauthConfigs = ExcelImportUtil.importExcel(file.getInputStream(), OauthConfig.class, params);
+                oauthConfigService.saveBatch(listOauthConfigs);
+                return Result.ok("文件导入成功!数据行数:" + listOauthConfigs.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 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/CtopOauthToken.java

@@ -76,6 +76,7 @@ public class CtopOauthToken {
 
 
     private Integer agentType;
+    private Long appId;
 
     /**
      * 刷新令牌有效期

+ 94 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/OauthConfig.java

@@ -0,0 +1,94 @@
+package cn.com.ctop.common.module.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 2021-01-26
+ */
+@Data
+@TableName("ctop_oauth_config")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_oauth_config对象", description = "授权配置信息")
+public class OauthConfig {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键ID")
+    private Long id;
+
+
+    private Integer mediaId;
+    /**
+     * 代理商名称
+     */
+    @Excel(name = "代理商名称", width = 15)
+    @ApiModelProperty(value = "代理商名称")
+    private String agentName;
+    /**
+     * appid
+     */
+    @Excel(name = "appid", width = 15)
+    @ApiModelProperty(value = "appid")
+    private Integer appId;
+    /**
+     * secret
+     */
+    @Excel(name = "secret", width = 15)
+    @ApiModelProperty(value = "secret")
+    private String secret;
+    /**
+     * 回调地址
+     */
+    @Excel(name = "回调地址", width = 15)
+    @ApiModelProperty(value = "回调地址")
+    private String redirectUri;
+
+
+    private Integer status;
+
+    private Integer oauthType;
+
+    /**
+     * 排序
+     */
+    @Excel(name = "排序", width = 15)
+    @ApiModelProperty(value = "排序")
+    private Integer rank;
+
+    String callbackUrl;
+    /**
+     * 创建时间
+     */
+    @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;
+}

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialCutFrameMapper.java

@@ -21,4 +21,6 @@ public interface MaterialCutFrameMapper extends BaseMapper<MaterialCutFrame> {
     List<MaterialCutFrame> getListByVideoSignature(@Param(value = "videoSignature") String signature);
 
     List<JSONObject> getProgramCreativeCover(@Param("signature") String signature);
+
+    JSONObject getCutFrameByVideoMd5(@Param("photoId") String photoId,@Param("imageToken") String imageToken);
 }

+ 23 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/OauthConfigMapper.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.OauthConfig;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 授权配置信息
+ *
+ * @author: jeecg-boot
+ * @date: 2021-01-26
+ * @cersion: V1.0
+ */
+public interface OauthConfigMapper extends BaseMapper<OauthConfig> {
+
+    Map<Long, String> getConfigMapByMediaId(@Param("mediaId") int mediaId);
+
+    List<JSONObject> getListByMediaId(@Param("mediaId") int mediaId);
+}

+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -12,12 +12,13 @@
         <result column="access_token_expires_in" property="accessTokenExpiresIn" jdbcType="TIMESTAMP"/>
         <result column="refresh_token_expires_in" property="refreshTokenExpiresIn" jdbcType="TIMESTAMP"/>
         <result column="agent_type" property="agentType" jdbcType="INTEGER"/>
+        <result column="app_id" property="appId" jdbcType="INTEGER"/>
         <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
         <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
     </resultMap>
 
     <sql id="Base_Column_List">
-        id,media_id,advertiser_id,account_id,access_token,refresh_token,access_token_expires_in,refresh_token_expires_in,agent_type,create_time,update_time
+        id,media_id,advertiser_id,account_id,access_token,refresh_token,access_token_expires_in,refresh_token_expires_in,agent_type,app_id,create_time,update_time
    </sql>
 
     <select id="selectByteDanceTokens" resultMap="BaseResultMap">

+ 28 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialCutFrameMapper.xml

@@ -34,4 +34,32 @@
       ORDER BY RAND() LIMIT 5;
     </select>
 
+    <select id="getCutFrameByVideoMd5" resultType="com.alibaba.fastjson.JSONObject">
+      SELECT
+	   url as 'url',
+	   signature as 'signature'
+        FROM
+	    ctop_material_cut_frame
+        WHERE
+	video_signature = (
+		SELECT
+			signature
+		FROM
+			ctop_kuaishou_video_get
+		WHERE
+			photo_id = #{photoId}
+		LIMIT 1
+	    )
+        AND signature != (
+	SELECT
+		signature
+	FROM
+		ctop_kuaishou_image_get
+	WHERE
+		image_token = #{imageToken}
+	LIMIT 1
+        )
+        LIMIT 1
+    </select>
+
 </mapper>

+ 19 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/OauthConfigMapper.xml

@@ -0,0 +1,19 @@
+<?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.common.module.mapper.OauthConfigMapper">
+
+    <select id="getConfigMapByMediaId" resultType="map">
+       select
+       app_id,
+       secret
+       from ctop_oauth_config
+       where media_id = #{mediaId}
+    </select>
+    <select id="getListByMediaId" resultType="com.alibaba.fastjson.JSONObject">
+       select
+       app_id,
+       secret
+       from ctop_oauth_config
+       where media_id = #{mediaId}
+    </select>
+</mapper>

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.BindAccountAuth;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.io.UnsupportedEncodingException;
@@ -20,10 +21,11 @@ public interface IBindAccountAuthService extends IService<BindAccountAuth> {
      * @return
      * @throws UnsupportedEncodingException
      */
-    String getKuaishouCodeUrl(String state,Integer  agentType ) throws UnsupportedEncodingException;
+    String getKuaishouCodeUrl(JSONObject state) throws UnsupportedEncodingException;
 
     /**
      * 获取头条url
+     *
      * @param state
      * @return
      * @throws UnsupportedEncodingException
@@ -32,6 +34,7 @@ public interface IBindAccountAuthService extends IService<BindAccountAuth> {
 
     /**
      * 绑定账号
+     *
      * @param accountId
      * @param type
      * @param state

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -20,7 +20,7 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
 
     Map<String, Object> getByteDanceAccessToken(CtopOauthToken token);
 
-    void getKuaiShouRefreshToken(Long accountId, String token, String refreshToken, Integer agentType);
+    void getKuaiShouRefreshToken(Long accountId, String token, String refreshToken, Long appId, String secret);
 
     List<CtopOauthToken> getTokenListByType(String platformTypeBytedance);
 

+ 9 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameService.java

@@ -29,4 +29,13 @@ public interface IMaterialCutFrameService extends IService<MaterialCutFrame> {
     List<JSONObject> getProgramCreativeCover(String signature);
 
     MaterialCutFrame selectByMd5(String md5);
+
+    /**
+     * 根基photoId imageToken 获取单张封面
+     *
+     * @param photoId
+     * @param imageToken
+     * @return
+     */
+    JSONObject getCutFrameByVideoMd5(String photoId, String imageToken);
 }

+ 19 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IOauthConfigService.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.OauthConfig;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Map;
+
+/**
+ * @Description: 授权配置信息
+ * @Author: jeecg-boot
+ * @Date: 2021-01-26
+ * @Version: V1.0
+ */
+public interface IOauthConfigService extends IService<OauthConfig> {
+
+    OauthConfig getConfigByAppId(Long appId);
+
+    Map<Long, String> getConfigMapByMediaId(int mediaId);
+}

+ 21 - 15
module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java

@@ -1,11 +1,14 @@
 package cn.com.ctop.common.module.service.impl;
 
 import cn.com.ctop.common.module.entity.BindAccountAuth;
+import cn.com.ctop.common.module.entity.OauthConfig;
 import cn.com.ctop.common.module.mapper.BindAccountAuthMapper;
 import cn.com.ctop.common.module.service.IBindAccountAuthService;
+import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.utils.BytedanceInterfaceConstant;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,23 +67,26 @@ public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMappe
     }
 
 
+    @Autowired
+    private IOauthConfigService oauthConfigService;
+
     @Override
-    public String getKuaishouCodeUrl(String state, Integer agentType) throws UnsupportedEncodingException {
+    public String getKuaishouCodeUrl(JSONObject state) throws UnsupportedEncodingException {
         StringBuffer sb = new StringBuffer();
-        if (agentType == 1) {
-            sb.append(PropertiesUtils.getValue("kuaishou_config", "kuaishou_auth_url"))
-                    .append(KuaishouInterfaceConstant.AUTH_PATH)
-                    .append("?app_id=" + PropertiesUtils.getValue("kuaishou_config", "kuaishou_appid"))
-                    .append("&state=" + URLEncoder.encode(URLEncoder.encode(state)))
-                    .append("&scope=%5B%22report_service%22%2C%22ad_query%22%2C%22account_service%22%2C%22ad_manage%22%5D")
-                    .append("&redirect_uri=" + URLEncoder.encode(PropertiesUtils.getValue("kuaishou_config", "kuaishou_callback_url"), "UTF-8"));
-        } else if (agentType == 0) {
-            sb.append(PropertiesUtils.getValue("kuaishou_config", "kuaishou_auth_url"))
-                    .append(KuaishouInterfaceConstant.AUTH_PATH)
-                    .append ("?app_id=" + PropertiesUtils.getValue("kuaishou_config", "kuaishou_third_appid"))
-                    .append("&state=" + URLEncoder.encode(URLEncoder.encode(state)))
-                    .append("&scope=%5B%22report_service%22%2C%22ad_query%22%2C%22account_service%22%2C%22ad_manage%22%5D")
-                    .append("&redirect_uri=" + URLEncoder.encode(PropertiesUtils.getValue("kuaishou_config", "kuaishou_third_callback_url"), "UTF-8"));
+        Long id = state.getLong("id");
+
+        OauthConfig config = oauthConfigService.getById(id);
+        state.put("appId", config.getAppId());
+        state.put("callbackUrl", config.getCallbackUrl());
+        sb.append(PropertiesUtils.getValue("kuaishou_config", "kuaishou_auth_url"))
+                .append(KuaishouInterfaceConstant.AUTH_PATH)
+                .append("?app_id=" + config.getAppId())
+                .append("&state=" + URLEncoder.encode(URLEncoder.encode(state.toJSONString())))
+                .append("&redirect_uri=" + URLEncoder.encode(config.getRedirectUri(), "UTF-8"));
+        if (config.getOauthType() != 1) {
+            sb.append("&scope=%5B%22report_service%22%2C%22ad_query%22%2C%22account_service%22%2C%22ad_manage%22%5D");
+        } else {
+            sb.append("&scope=%5B%22report_service%22%2C%22ad_query%22%2C%22ad_manage%22%5D");
         }
         return sb.toString();
     }

+ 4 - 10
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -121,20 +121,14 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
      * @return
      */
     @Override
-    public void getKuaiShouRefreshToken(Long accountId, String token, String refreshToken, Integer agentType) {
+    public void getKuaiShouRefreshToken(Long accountId, String token, String refreshToken, Long appId, String secret) {
         log.info("快手刷新token入参,accountId:{},token:{},refreshToken:{}", accountId, token, refreshToken);
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + "/rest/openapi/oauth2/authorize/refresh_token";
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", " application/json");
         Map<String, Object> param = new HashMap<>();
-        if (agentType == 1) {
-            param.put("app_id", PropertiesUtils.getConfig("kuaishou_appid"));
-            param.put("secret", PropertiesUtils.getConfig("kuaishou_secret"));
-        } else if (agentType == 0) {
-            param.put("app_id", PropertiesUtils.getConfig("kuaishou_third_appid"));
-            param.put("secret", PropertiesUtils.getConfig("kuaishou_third_secret"));
-        }
-
+        param.put("app_id", appId);
+        param.put("secret", secret);
         param.put("refresh_token", refreshToken);
         try {
             CtopOauthToken oauthToken = ctopOauthTokenMapper.selectByAccountId(accountId);
@@ -142,7 +136,7 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
                 log.error("查询token信息返回结果为空,accountId:{}", accountId);
                 return;
             }
-            XxlJobHelper.log("刷新token,入參:{},token:{}", param,headers);
+            XxlJobHelper.log("刷新token,入參:{},token:{}", param, headers);
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             log.info("快手刷新token返回结果:{}", refreshToken);

+ 9 - 7
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java

@@ -1,26 +1,23 @@
 package cn.com.ctop.common.module.service.impl;
 
-import cn.com.ctop.common.module.constant.OssConstant;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
 import cn.com.ctop.common.module.mapper.MaterialCutFrameMapper;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
-import cn.com.ctop.common.module.utils.*;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CloudVideoProcessUtil;
+import cn.com.ctop.common.module.utils.LoadFileUtil;
+import cn.com.ctop.common.module.utils.MpsUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.DefaultAcsClient;
 import com.aliyuncs.IAcsClient;
-import com.aliyuncs.mts.model.v20140618.QuerySnapshotJobListRequest;
-import com.aliyuncs.mts.model.v20140618.QuerySnapshotJobListResponse;
 import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobRequest;
 import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobResponse;
 import com.aliyuncs.profile.DefaultProfile;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -272,5 +269,10 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
 
     }
 
+    @Override
+    public JSONObject getCutFrameByVideoMd5(String photoId, String imageToken) {
+        return materialCutFrameMapper.getCutFrameByVideoMd5(photoId, imageToken);
+    }
+
 
 }

+ 52 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/OauthConfigServiceImpl.java

@@ -0,0 +1,52 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.OauthConfig;
+import cn.com.ctop.common.module.mapper.OauthConfigMapper;
+import cn.com.ctop.common.module.service.IOauthConfigService;
+import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 授权配置信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-26
+ */
+@Service
+public class OauthConfigServiceImpl extends ServiceImpl<OauthConfigMapper, OauthConfig> implements IOauthConfigService {
+    @Autowired
+    private OauthConfigMapper configMapper;
+
+    @Override
+    public OauthConfig getConfigByAppId(Long appId) {
+        QueryWrapper<OauthConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("app_id", appId);
+        OauthConfig config = this.getOne(queryWrapper);
+        return config;
+    }
+
+    @Override
+    public Map<Long, String> getConfigMapByMediaId(int mediaId) {
+
+        Map<Long, String> map = new HashMap<>();
+        List<JSONObject> list = configMapper.getListByMediaId(mediaId);
+        if (!Check.isNull(list)) {
+            for (int i = 0; i < list.size(); i++) {
+                JSONObject jsonObject = list.get(i);
+                map.put(jsonObject.getLong("app_id"), jsonObject.getString("secret"));
+            }
+
+        }
+
+        return map;
+    }
+}

+ 9 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.entity.OauthAgentToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IOauthAgentTokenService;
+import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.service.IRefreshTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
@@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @Service
@@ -25,6 +27,8 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
     private ICtopOauthTokenService oauthTokenService;
     @Autowired
     private IOauthAgentTokenService agentTokenService;
+    @Autowired
+    private IOauthConfigService configService;
 
     /**
      * 获取所有token
@@ -33,13 +37,17 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
      */
     @Override
     public void getKuaiShouRefresh() {
+
+
         List<CtopOauthToken> oauthTokens = oauthTokenMapper.selectKuaiShouTokens(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
         if (!Check.isNull(oauthTokens)) {
+            Map<Long, String> configMap = configService.getConfigMapByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
             for (CtopOauthToken oauthToken : oauthTokens) {
                 XxlJobHelper.log("刷新token,accountId:{}", oauthToken.getAccountId());
                 //快手
                 if (CtopAdConstant.PLATFORM_TYPE_KUAISHOU.equals(oauthToken.getMediaId().trim())) {
-                    oauthTokenService.getKuaiShouRefreshToken(oauthToken.getAccountId(), oauthToken.getAccessToken(), oauthToken.getRefreshToken(), oauthToken.getAgentType());
+                    String secret = configMap.get(oauthToken.getAppId());
+                    oauthTokenService.getKuaiShouRefreshToken(oauthToken.getAccountId(), oauthToken.getAccessToken(), oauthToken.getRefreshToken(), oauthToken.getAppId(), secret);
                 }
             }
         } else {

+ 130 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreativeRefusalController.java

@@ -0,0 +1,130 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Api(tags = "快手-创意拒审重提")
+@RestController
+@RequestMapping("/kuaishou/creative/")
+public class KuaiShouCreativeRefusalController {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaiShouCreativeService creativeService;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
+    @Autowired
+    private IMaterialCutFrameService cutFrameService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouMaterialUploadService uploadService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(50);
+
+    /**
+     * 吃创意拒审重提
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "again")
+    public JSONObject campaignCreate(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请输入账户id");
+            }
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONArray creativeIds = requestJson.getJSONArray("creativeIds");
+            if (Check.isNull(creativeIds)) {
+                throw new Exception("请传入需要重提的创意id列表");
+            }
+            for (int i = 0; i < creativeIds.size(); i++) {
+                Long creativeId = creativeIds.getLong(i);
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        KuaiShouCreative creative = creativeService.getCreativeByCreativeId(creativeId);
+                        if (!Check.isNull(creative)) {
+                            JSONObject cutJson = cutFrameService.getCutFrameByVideoMd5(creative.getPhotoId(), creative.getImageToken());
+                            if (!Check.isNull(cutJson)) {
+                                String signature = cutJson.getString("signature");
+                                String url = cutJson.getString("url");
+                                String imageToken = getImageToken(signature, accountId, oauthToken.getAccessToken(), url);
+                                if (!Check.isNull(imageToken)) {
+                                    JSONObject updateJson = new JSONObject();
+                                    updateJson.put("creativeId", creativeId);
+                                    updateJson.put("imageToken", imageToken);
+                                    Map<String, Object> creativeMap = updateService.updateCreative(oauthToken.getAccessToken(), accountId, requestJson);
+                                    Integer code = (Integer) creativeMap.get("code");
+                                    if (code == 0) {
+                                        log.info("自动投放拒审重提成功,accountId:{},creativeId:{}", accountId, creativeId);
+                                    } else {
+                                        log.info("自动投放拒审重提失败,accountId:{},creativeId:{}", accountId, creativeId);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                });
+            }
+            returnJson.put("code", 0);
+            returnJson.put("message", "异步提交中");
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", 0);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    private String getImageToken(String md5, Long accountId, String accessToken, String url) {
+        String imageToken = null;
+        QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("signature", md5);
+        queryWrapper.last("limit 1");
+        KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
+        if (!Check.isNull(imageGet)) {
+            imageToken = imageGet.getImageToken();
+        } else {
+            imageToken = uploadService.kuauiShouImageUpload(url, md5, accountId, accessToken);
+        }
+
+
+        return imageToken;
+
+    }
+
+}

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

@@ -0,0 +1,298 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCampaignPreviewService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+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.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.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+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 2021-01-26
+ */
+@Slf4j
+@Api(tags = "快手-广告计划预览信息")
+@RestController
+@RequestMapping("/kuaishouBatch/campaignPreview")
+public class KuaishouBatchCampaignPreviewController {
+    @Autowired
+    private IKuaishouBatchCampaignPreviewService kuaishouBatchCampaignPreviewService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouBatchCampaignPreview
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-广告计划预览信息-分页列表查询")
+    @ApiOperation(value = "快手-广告计划预览信息-分页列表查询", notes = "快手-广告计划预览信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouBatchCampaignPreview>> queryPageList(KuaishouBatchCampaignPreview kuaishouBatchCampaignPreview,
+                                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                     HttpServletRequest req) {
+        Result<IPage<KuaishouBatchCampaignPreview>> result = new Result<>();
+        QueryWrapper<KuaishouBatchCampaignPreview> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouBatchCampaignPreview, req.getParameterMap());
+        Page<KuaishouBatchCampaignPreview> page = new Page<KuaishouBatchCampaignPreview>(pageNo, pageSize);
+        IPage<KuaishouBatchCampaignPreview> pageList = kuaishouBatchCampaignPreviewService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouBatchCampaignPreview
+     * @return
+     */
+    @AutoLog(value = "快手-广告计划预览信息-添加")
+    @ApiOperation(value = "快手-广告计划预览信息-添加", notes = "快手-广告计划预览信息-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouBatchCampaignPreview> add(@RequestBody KuaishouBatchCampaignPreview kuaishouBatchCampaignPreview) {
+        Result<KuaishouBatchCampaignPreview> result = new Result<>();
+        try {
+            kuaishouBatchCampaignPreviewService.save(kuaishouBatchCampaignPreview);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouBatchCampaignPreview
+     * @return
+     */
+    @AutoLog(value = "添加预览数据")
+    @ApiOperation(value = "添加预览数据", notes = "添加预览数据")
+    @PostMapping(value = "/addPreviewData")
+    public Result<Object> addPreviewData(@RequestBody JSONObject data) {
+        Result<Object> result = new Result<>();
+        try {
+            kuaishouBatchCampaignPreviewService.addPreviewData(data);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败," + e.getMessage());
+        }
+        return result;
+    }
+
+    @AutoLog(value = "通过账户和批次标识查询预览数据")
+    @ApiOperation(value = "通过账户和批次标识查询预览数据", notes = "通过账户和批次标识查询预览数据")
+    @GetMapping(value = "/queryByBatchId")
+    public Result<Object> queryByBatchId(String batchId, String accountId) {
+        try {
+            if (Check.isNull(batchId)) {
+                return Result.error("批次号为空");
+            }
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择账户");
+            }
+            JSONObject obj = kuaishouBatchCampaignPreviewService.queryByBatchId(batchId, accountId);
+            return Result.ok(obj);
+        } catch (Exception e) {
+            log.error("queryByBatchId is error", e);
+            return Result.error(e.getMessage());
+        }
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouBatchCampaignPreview
+     * @return
+     */
+    @AutoLog(value = "快手-广告计划预览信息-编辑")
+    @ApiOperation(value = "快手-广告计划预览信息-编辑", notes = "快手-广告计划预览信息-编辑")
+    @PostMapping(value = "/edit")
+    public Result<KuaishouBatchCampaignPreview> edit(@RequestBody KuaishouBatchCampaignPreview kuaishouBatchCampaignPreview) {
+        Result<KuaishouBatchCampaignPreview> result = new Result<KuaishouBatchCampaignPreview>();
+        KuaishouBatchCampaignPreview kuaishouBatchCampaignPreviewEntity = kuaishouBatchCampaignPreviewService.getById(kuaishouBatchCampaignPreview.getId());
+        if (kuaishouBatchCampaignPreviewEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouBatchCampaignPreviewService.updateById(kuaishouBatchCampaignPreview);
+            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 {
+            kuaishouBatchCampaignPreviewService.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<KuaishouBatchCampaignPreview> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouBatchCampaignPreview> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouBatchCampaignPreviewService.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<KuaishouBatchCampaignPreview> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouBatchCampaignPreview> result = new Result<>();
+        KuaishouBatchCampaignPreview kuaishouBatchCampaignPreview = kuaishouBatchCampaignPreviewService.getById(id);
+        if (kuaishouBatchCampaignPreview == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouBatchCampaignPreview);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouBatchCampaignPreview> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouBatchCampaignPreview kuaishouBatchCampaignPreview = JSON.parseObject(deString, KuaishouBatchCampaignPreview.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouBatchCampaignPreview, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouBatchCampaignPreview> pageList = kuaishouBatchCampaignPreviewService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-广告计划预览信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouBatchCampaignPreview.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<KuaishouBatchCampaignPreview> listKuaishouBatchCampaignPreviews = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouBatchCampaignPreview.class, params);
+                kuaishouBatchCampaignPreviewService.saveBatch(listKuaishouBatchCampaignPreviews);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouBatchCampaignPreviews.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("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,274 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCreativePreviewService;
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+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 com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 快手-广告创意预览信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-26
+ */
+@Slf4j
+@Api(tags = "快手-广告创意预览信息")
+@RestController
+@RequestMapping("/kuaishouBatch/creativePreview")
+public class KuaishouBatchCreativePreviewController {
+    @Autowired
+    private IKuaishouBatchCreativePreviewService kuaishouBatchCreativePreviewService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouBatchCreativePreview
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-广告创意预览信息-分页列表查询")
+    @ApiOperation(value = "快手-广告创意预览信息-分页列表查询", notes = "快手-广告创意预览信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouBatchCreativePreview>> queryPageList(KuaishouBatchCreativePreview kuaishouBatchCreativePreview,
+                                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                     HttpServletRequest req) {
+        Result<IPage<KuaishouBatchCreativePreview>> result = new Result<>();
+        QueryWrapper<KuaishouBatchCreativePreview> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouBatchCreativePreview, req.getParameterMap());
+        Page<KuaishouBatchCreativePreview> page = new Page<KuaishouBatchCreativePreview>(pageNo, pageSize);
+        IPage<KuaishouBatchCreativePreview> pageList = kuaishouBatchCreativePreviewService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouBatchCreativePreview
+     * @return
+     */
+    @AutoLog(value = "快手-广告创意预览信息-添加")
+    @ApiOperation(value = "快手-广告创意预览信息-添加", notes = "快手-广告创意预览信息-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouBatchCreativePreview> add(@RequestBody KuaishouBatchCreativePreview kuaishouBatchCreativePreview) {
+        Result<KuaishouBatchCreativePreview> result = new Result<>();
+        try {
+            kuaishouBatchCreativePreviewService.save(kuaishouBatchCreativePreview);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+    /**
+     * 添加
+     *
+     * @param kuaishouBatchCreativePreview
+     * @return
+     */
+    @AutoLog(value = "根据预览信息创建广告计划、组、创意")
+    @ApiOperation(value = "根据预览信息创建广告计划、组、创意", notes = "根据预览信息创建广告计划、组、创意")
+    @PostMapping(value = "/createAdcampaignAndGroups")
+    public Result<KuaishouBatchCreativePreview> createAdcampaignAndGroups(@RequestBody JSONObject data) {
+        Result<KuaishouBatchCreativePreview> result = new Result<>();
+        try {
+            kuaishouBatchCreativePreviewService.createAdcampaignAndGroups(data);
+            result.success("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouBatchCreativePreview
+     * @return
+     */
+    @AutoLog(value = "快手-广告创意预览信息-编辑")
+    @ApiOperation(value = "快手-广告创意预览信息-编辑", notes = "快手-广告创意预览信息-编辑")
+    @PostMapping(value = "/edit")
+    public Result<KuaishouBatchCreativePreview> edit(@RequestBody KuaishouBatchCreativePreview kuaishouBatchCreativePreview) {
+        Result<KuaishouBatchCreativePreview> result = new Result<KuaishouBatchCreativePreview>();
+        KuaishouBatchCreativePreview kuaishouBatchCreativePreviewEntity = kuaishouBatchCreativePreviewService.getById(kuaishouBatchCreativePreview.getId());
+        if (kuaishouBatchCreativePreviewEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouBatchCreativePreviewService.updateById(kuaishouBatchCreativePreview);
+            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 {
+            kuaishouBatchCreativePreviewService.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<KuaishouBatchCreativePreview> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouBatchCreativePreview> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouBatchCreativePreviewService.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<KuaishouBatchCreativePreview> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouBatchCreativePreview> result = new Result<>();
+        KuaishouBatchCreativePreview kuaishouBatchCreativePreview = kuaishouBatchCreativePreviewService.getById(id);
+        if (kuaishouBatchCreativePreview == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouBatchCreativePreview);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouBatchCreativePreview> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouBatchCreativePreview kuaishouBatchCreativePreview = JSON.parseObject(deString, KuaishouBatchCreativePreview.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouBatchCreativePreview, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouBatchCreativePreview> pageList = kuaishouBatchCreativePreviewService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-广告创意预览信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouBatchCreativePreview.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<KuaishouBatchCreativePreview> listKuaishouBatchCreativePreviews = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouBatchCreativePreview.class, params);
+                kuaishouBatchCreativePreviewService.saveBatch(listKuaishouBatchCreativePreviews);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouBatchCreativePreviews.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("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,255 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchGroupPreviewService;
+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.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.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+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 2021-01-26
+ */
+@Slf4j
+@Api(tags = "快手-广告组预览信息")
+@RestController
+@RequestMapping("/kuaishouBatch/groupPreview")
+public class KuaishouBatchGroupPreviewController {
+    @Autowired
+    private IKuaishouBatchGroupPreviewService kuaishouBatchGroupPreviewService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouBatchGroupPreview
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-广告组预览信息-分页列表查询")
+    @ApiOperation(value = "快手-广告组预览信息-分页列表查询", notes = "快手-广告组预览信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouBatchGroupPreview>> queryPageList(KuaishouBatchGroupPreview kuaishouBatchGroupPreview,
+                                                                  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                  HttpServletRequest req) {
+        Result<IPage<KuaishouBatchGroupPreview>> result = new Result<>();
+        QueryWrapper<KuaishouBatchGroupPreview> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouBatchGroupPreview, req.getParameterMap());
+        Page<KuaishouBatchGroupPreview> page = new Page<KuaishouBatchGroupPreview>(pageNo, pageSize);
+        IPage<KuaishouBatchGroupPreview> pageList = kuaishouBatchGroupPreviewService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouBatchGroupPreview
+     * @return
+     */
+    @AutoLog(value = "快手-广告组预览信息-添加")
+    @ApiOperation(value = "快手-广告组预览信息-添加", notes = "快手-广告组预览信息-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouBatchGroupPreview> add(@RequestBody KuaishouBatchGroupPreview kuaishouBatchGroupPreview) {
+        Result<KuaishouBatchGroupPreview> result = new Result<>();
+        try {
+            kuaishouBatchGroupPreviewService.save(kuaishouBatchGroupPreview);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouBatchGroupPreview
+     * @return
+     */
+    @AutoLog(value = "快手-广告组预览信息-编辑")
+    @ApiOperation(value = "快手-广告组预览信息-编辑", notes = "快手-广告组预览信息-编辑")
+    @PostMapping(value = "/edit")
+    public Result<KuaishouBatchGroupPreview> edit(@RequestBody KuaishouBatchGroupPreview kuaishouBatchGroupPreview) {
+        Result<KuaishouBatchGroupPreview> result = new Result<KuaishouBatchGroupPreview>();
+        KuaishouBatchGroupPreview kuaishouBatchGroupPreviewEntity = kuaishouBatchGroupPreviewService.getById(kuaishouBatchGroupPreview.getId());
+        if (kuaishouBatchGroupPreviewEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouBatchGroupPreviewService.updateById(kuaishouBatchGroupPreview);
+            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 {
+            kuaishouBatchGroupPreviewService.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<KuaishouBatchGroupPreview> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouBatchGroupPreview> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouBatchGroupPreviewService.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<KuaishouBatchGroupPreview> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouBatchGroupPreview> result = new Result<>();
+        KuaishouBatchGroupPreview kuaishouBatchGroupPreview = kuaishouBatchGroupPreviewService.getById(id);
+        if (kuaishouBatchGroupPreview == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouBatchGroupPreview);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouBatchGroupPreview> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouBatchGroupPreview kuaishouBatchGroupPreview = JSON.parseObject(deString, KuaishouBatchGroupPreview.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouBatchGroupPreview, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouBatchGroupPreview> pageList = kuaishouBatchGroupPreviewService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-广告组预览信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouBatchGroupPreview.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<KuaishouBatchGroupPreview> listKuaishouBatchGroupPreviews = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouBatchGroupPreview.class, params);
+                kuaishouBatchGroupPreviewService.saveBatch(listKuaishouBatchGroupPreviews);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouBatchGroupPreviews.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("文件导入失败!");
+    }
+
+}

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

@@ -143,6 +143,31 @@ public class KuaishouTemplateController {
     }
 
 
+    @PostMapping(value = "/updateTemplate")
+    public Result<JSONObject> updateTemplate(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请选择账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject returnJson = kuaishouTemplateService.updateTemplate(accountId, oauthToken.getAccessToken(), requestJson);
+            result.setSuccess(true);
+            result.setResult(returnJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
     /**
      * 添加
      *

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

@@ -113,6 +113,12 @@ public class KuaiShouBatchGroupTemplate {
     @ApiModelProperty(value = "出价")
     private Integer bid;
     /**
+     * OCPC出价
+     */
+    @Excel(name = "OCPC出价", width = 15)
+    @ApiModelProperty(value = "OCPC出价")
+    private Integer cpaBid;
+    /**
      * OCPX行为类型   1: CPM, 2: CPC,
      */
     @Excel(name = "OCPX行为类型   1: CPM, 2: CPC,", width = 15)

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

@@ -0,0 +1,117 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+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 javax.persistence.Table;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 快手-广告计划预览信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-26
+ */
+@Data
+@TableName("ctop_kuaishou_batch_campaign_preview")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_batch_campaign_preview对象", description = "快手-广告计划预览信息")
+public class KuaishouBatchCampaignPreview {
+
+    /**
+     * id
+     */
+    @TableId
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 计划名称
+     */
+    @Excel(name = "计划名称", width = 15)
+    @ApiModelProperty(value = "计划名称")
+    private String campaignName;
+    /**
+     * 2 - 提升应用安装;
+     */
+    @Excel(name = "2 - 提升应用安装;", width = 15)
+    @ApiModelProperty(value = "2 - 提升应用安装;")
+    private Integer campaignType;
+
+    /**
+     * 是否定时启动 1 是 2 否
+     */
+    private Integer isTime;
+    /**
+     * 投放状态 1:投放中;2:暂停
+     */
+    @Excel(name = "投放状态 1:投放中;2:暂停", width = 15)
+    @ApiModelProperty(value = "投放状态 1:投放中;2:暂停")
+    private Integer putStatus;
+    /**
+     * 每日预算
+     */
+    @Excel(name = "每日预算", width = 15)
+    @ApiModelProperty(value = "每日预算")
+    private Integer dayBudget;
+    /**
+     * dayBudgetSchedule
+     */
+    @Excel(name = "dayBudgetSchedule", width = 15)
+    @ApiModelProperty(value = "dayBudgetSchedule")
+    private String dayBudgetSchedule;
+    /**
+     * 广告投放时间
+     */
+    @Excel(name = "投放启动时间", width = 15)
+    @ApiModelProperty(value = "投放启动时间")
+    private String timeStart;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+    /**
+     * 批次标识
+     */
+    @Excel(name = "批次标识", width = 15)
+    @ApiModelProperty(value = "批次标识")
+    private String batchId;
+    /**
+     * 是否创建成功 0 失败,1成功
+     */
+    private int isSuccess;
+
+    /**
+     * 操作说明
+     */
+    private String message;
+    /**
+     * 创建成功后的计划ID
+     */
+    private Long campaignId;
+
+    @TableField(exist = false)
+    private List<KuaishouBatchGroupPreview>  kuaishouBatchGroupPreviews;
+
+}

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

@@ -0,0 +1,201 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+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 2021-01-26
+ */
+@Data
+@TableName("ctop_kuaishou_batch_creative_preview")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_batch_creative_preview对象", description = "快手-广告创意预览信息")
+public class KuaishouBatchCreativePreview {
+
+    /**
+     * id
+     */
+    @TableId
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 广告计划ID
+     */
+    @Excel(name = "广告计划ID", width = 15)
+    @ApiModelProperty(value = "广告计划ID")
+    private String planId;
+    /**
+     * 广告组ID
+     */
+    @Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+    private String groupId;
+    /**
+     * 广告创意名称
+     */
+    @Excel(name = "广告创意名称", width = 15)
+    @ApiModelProperty(value = "广告创意名称")
+    private String creativeName;
+    /**
+     * 视频作品ID
+     */
+    @Excel(name = "视频作品ID", width = 15)
+    @ApiModelProperty(value = "视频作品ID")
+    private String photoId;
+    /**
+     * 封面图片MD5
+     */
+    @Excel(name = "封面图片MD5", width = 15)
+    @ApiModelProperty(value = "封面图片MD5")
+    private String imageSignature;
+    /**
+     * 封面图片URL
+     */
+    @Excel(name = "封面图片URL", width = 15)
+    @ApiModelProperty(value = "封面图片URL")
+    private String imageUrl;
+    /**
+     * stickerTitle
+     */
+    @Excel(name = "stickerTitle", width = 15)
+    @ApiModelProperty(value = "stickerTitle")
+    private String stickerTitle;
+    /**
+     * 贴纸样式类型
+     */
+    @Excel(name = "贴纸样式类型", width = 15)
+    @ApiModelProperty(value = "贴纸样式类型")
+    private String overlayType;
+    /**
+     * 广告语
+     */
+    @Excel(name = "广告语", width = 15)
+    @ApiModelProperty(value = "广告语")
+    private String description;
+    /**
+     * 行动号召按钮文案
+     */
+    @Excel(name = "行动号召按钮文案", width = 15)
+    @ApiModelProperty(value = "行动号召按钮文案")
+    private String actionBarText;
+    /**
+     * 点击测试链接
+     */
+    @Excel(name = "点击测试链接", width = 15)
+    @ApiModelProperty(value = "点击测试链接")
+    private String clickTrackUrl;
+    /**
+     * 视频封面来源 1:首帧,0:非首帧
+     */
+    @Excel(name = "视频封面来源 1:首帧,0:非首帧", width = 15)
+    @ApiModelProperty(value = "视频封面来源 1:首帧,0:非首帧")
+    private Integer firstFrameType;
+    /**
+     * 安卓下载中间页
+     */
+    @Excel(name = "安卓下载中间页", width = 15)
+    @ApiModelProperty(value = "安卓下载中间页")
+    private Integer siteId;
+    /**
+     * 便利贴创意短广告语
+     */
+    @Excel(name = "便利贴创意短广告语", width = 15)
+    @ApiModelProperty(value = "便利贴创意短广告语")
+    private String shortSlogan;
+    /**
+     * 第三方开始播放监测链接
+     */
+    @Excel(name = "第三方开始播放监测链接", width = 15)
+    @ApiModelProperty(value = "第三方开始播放监测链接")
+    private String impressionUrl;
+    /**
+     * 第三方有效播放监测链接
+     */
+    @Excel(name = "第三方有效播放监测链接", width = 15)
+    @ApiModelProperty(value = "第三方有效播放监测链接")
+    private String adPhotoPlayedT3sUrl;
+    /**
+     * 创意分类
+     */
+    @Excel(name = "创意分类", width = 15)
+    @ApiModelProperty(value = "创意分类")
+    private Integer creativeCategory;
+    /**
+     * 创意标签
+     */
+    @Excel(name = "创意标签", width = 15)
+    @ApiModelProperty(value = "创意标签")
+    private String creativeTag;
+    /**
+     * 第三方点击按钮监测链接
+     */
+    @Excel(name = "第三方点击按钮监测链接", width = 15)
+    @ApiModelProperty(value = "第三方点击按钮监测链接")
+    private String actionbarClickUrl;
+    /**
+     * 创建时间
+     */
+    @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;
+    /**
+     * updateTime
+     */
+    @Excel(name = "updateTime", 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 = "updateTime")
+    private Date updateTime;
+    /**
+     * 批次标识
+     */
+    @Excel(name = "批次标识", width = 15)
+    @ApiModelProperty(value = "批次标识")
+    private String batchId;
+
+    /**
+     * 是否创建成功 0 失败,1成功
+     */
+    private int isSuccess;
+
+    /**
+     * 操作说明
+     */
+    private String message;
+    /**
+     * 创建成功后的计划ID
+     */
+    private Long campaignId;
+    /**
+     * 创建成功后的组ID
+     */
+    private Long unitId;
+    /**
+     * 创建成功后的创意ID
+     */
+    private Long creativeId;
+
+}

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

@@ -0,0 +1,236 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+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;
+import java.util.List;
+
+/**
+ * 快手-广告组预览信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-26
+ */
+@Data
+@TableName("ctop_kuaishou_batch_group_preview")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_batch_group_preview对象", description = "快手-广告组预览信息")
+public class KuaishouBatchGroupPreview {
+
+    /**
+     * id
+     */
+    @TableId
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 定向模板id
+     */
+    private Long templateId;
+    /**
+     * 广告活动ID
+     */
+    @Excel(name = "广告活动ID", width = 15)
+    @ApiModelProperty(value = "广告活动ID")
+    private String planId;
+    /**
+     * 广告组名称
+     */
+    @Excel(name = "广告组名称", width = 15)
+    @ApiModelProperty(value = "广告组名称")
+    private String unitName;
+    /**
+     * 投放状态 1:投放中;2:暂停
+     */
+    @Excel(name = "投放状态 1:投放中;2:暂停", width = 15)
+    @ApiModelProperty(value = "投放状态 1:投放中;2:暂停")
+    private Integer putStatus;
+    /**
+     * 出价类型
+     */
+    @Excel(name = "出价类型", width = 15)
+    @ApiModelProperty(value = "出价类型")
+    private Integer bidType;
+    /**
+     * 出价
+     */
+    @Excel(name = "出价", width = 15)
+    @ApiModelProperty(value = "出价")
+    private Integer bid;
+    /**
+     * OCPC出价
+     */
+    @Excel(name = "OCPC出价", width = 15)
+    @ApiModelProperty(value = "OCPC出价")
+    private Integer cpaBid;
+    /**
+     * OCPX行为类型   1: CPM, 2: CPC,
+     */
+    @Excel(name = "OCPX行为类型   1: CPM, 2: CPC,", width = 15)
+    @ApiModelProperty(value = "OCPX行为类型   1: CPM, 2: CPC,")
+    private Integer ocpxActionType;
+    /**
+     * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
+     */
+    @Excel(name = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无", width = 15)
+    @ApiModelProperty(value = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无")
+    private Integer deepConversionType;
+    /**
+     * 深度转化目标出价
+     */
+    @Excel(name = "深度转化目标出价", width = 15)
+    @ApiModelProperty(value = "深度转化目标出价")
+    private Integer deepConversionBid;
+    /**
+     * 单日预算
+     */
+    @Excel(name = "单日预算", width = 15)
+    @ApiModelProperty(value = "单日预算")
+    private Integer dayBudget;
+    /**
+     * 投放方式  0:未知, 1:正常投
+     */
+    @Excel(name = "投放方式  0:未知, 1:正常投", width = 15)
+    @ApiModelProperty(value = "投放方式  0:未知, 1:正常投")
+    private Integer speed;
+    /**
+     * 投放开始时间
+     */
+    @Excel(name = "投放开始时间", width = 15)
+    @ApiModelProperty(value = "投放开始时间")
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    @Excel(name = "投放结束时间", width = 15)
+    @ApiModelProperty(value = "投放结束时间")
+    private String endTime;
+    /**
+     * 投放时段
+     */
+    @Excel(name = "投放时段", width = 15)
+    @ApiModelProperty(value = "投放时段")
+    private String scheduleTime;
+    /**
+     * 广告位 1:优选广告位;
+     */
+    @Excel(name = "广告位 1:优选广告位;", width = 15)
+    @ApiModelProperty(value = "广告位 1:优选广告位;")
+    private String sceneId;
+    /**
+     * 创意展现方式  0:未知, 1:轮播,
+     */
+    @Excel(name = "创意展现方式  0:未知, 1:轮播,", width = 15)
+    @ApiModelProperty(value = "创意展现方式  0:未知, 1:轮播,")
+    private Integer showMode;
+    /**
+     * 创意制作方式 4: 自定义
+     */
+    @Excel(name = "创意制作方式 4: 自定义", width = 15)
+    @ApiModelProperty(value = "创意制作方式 4: 自定义")
+    private Integer unitType;
+    /**
+     * 当计划类型为3时(获取电商下单)时有返回。
+     */
+    @Excel(name = "当计划类型为3时(获取电商下单)时有返回。", width = 15)
+    @ApiModelProperty(value = "当计划类型为3时(获取电商下单)时有返回。")
+    private Integer urlType;
+    /**
+     * 落地页链接
+     */
+    @Excel(name = "落地页链接", width = 15)
+    @ApiModelProperty(value = "落地页链接")
+    private String url;
+    /**
+     * APP ID
+     */
+    @Excel(name = "APP ID", width = 15)
+    @ApiModelProperty(value = "APP ID")
+    private Integer appId;
+    /**
+     * APP图标存储地址
+     */
+    @Excel(name = "APP图标存储地址", width = 15)
+    @ApiModelProperty(value = "APP图标存储地址")
+    private String appIconUrl;
+    /**
+     * 转化目标
+     */
+    @Excel(name = "转化目标", width = 15)
+    @ApiModelProperty(value = "转化目标")
+    private Integer convertId;
+    /**
+     * 优先从系统应用商店下载
+     */
+    @Excel(name = "优先从系统应用商店下载", width = 15)
+    @ApiModelProperty(value = "优先从系统应用商店下载")
+    private Integer useAppMarket;
+    /**
+     * 应用列表
+     */
+    @Excel(name = "应用列表", width = 15)
+    @ApiModelProperty(value = "应用列表")
+    private String appStore;
+    /**
+     * 创建时间
+     */
+    @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;
+    /**
+     * 批次标识
+     */
+    @Excel(name = "批次标识", width = 15)
+    @ApiModelProperty(value = "批次标识")
+    private String batchId;
+
+    @TableField(exist = false)
+    private List<KuaishouBatchCreativePreview> kuaishouBatchCreativePreviews;
+
+    /**
+     * 是否创建成功 0 失败,1成功
+     */
+    private int isSuccess;
+
+    /**
+     * 操作说明
+     */
+    private String message;
+    /**
+     * 创建成功后的计划ID
+     */
+    private Long campaignId;
+    /**
+     * 创建成功后的组ID
+     */
+    private Long unitId;
+
+}

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

@@ -31,7 +31,6 @@ public class KuaishouStrategy {
      * id
      */
     @TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "id")
     private Long id;
     private String createBy;
     private String creativeTag;
@@ -242,4 +241,6 @@ public class KuaishouStrategy {
      */
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
+
+    private Integer timerTaskStatus;
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-广告计划预览信息
+ *
+ * @author: jeecg-boot
+ * @date: 2021-01-26
+ * @cersion: V1.0
+ */
+public interface KuaishouBatchCampaignPreviewMapper extends BaseMapper<KuaishouBatchCampaignPreview> {
+
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-广告创意预览信息
+ *
+ * @author: jeecg-boot
+ * @date: 2021-01-26
+ * @cersion: V1.0
+ */
+public interface KuaishouBatchCreativePreviewMapper extends BaseMapper<KuaishouBatchCreativePreview> {
+
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-广告组预览信息
+ *
+ * @author: jeecg-boot
+ * @date: 2021-01-26
+ * @cersion: V1.0
+ */
+public interface KuaishouBatchGroupPreviewMapper extends BaseMapper<KuaishouBatchGroupPreview> {
+
+}

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouBatchCampaignPreviewMapper.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.KuaishouBatchCampaignPreviewMapper">
+
+</mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouBatchCreativePreviewMapper.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.KuaishouBatchCreativePreviewMapper">
+
+</mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouBatchGroupPreviewMapper.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.KuaishouBatchGroupPreviewMapper">
+
+</mapper>

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouStrategyMapper.xml

@@ -13,7 +13,7 @@
 
     <select id="queryActiveAccount" resultType="java.lang.Long">
         SELECT account_id FROM ctop_ai_kuaishou_advertiser_strategy
-        WHERE status = 1
+        WHERE timer_task_status = 1
         GROUP BY account_id
     </select>
 </mapper>

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

@@ -12,6 +12,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouBatchCampaignTemplateService extends IService<KuaiShouBatchCampaignTemplate> {
 
-    String previewLogic(JSONObject data);
-
 }

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

@@ -55,4 +55,6 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
     void delAllCreativesByCampaignId(Long accountId, Long campaignId);
 
     List<KuaiShouCreative> queryCreativeInfoByCampaignId(Long accountId, Long campaignId);
+
+    KuaiShouCreative getCreativeByCreativeId(Long creativeId);
 }

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-广告计划预览信息
+ * @Author: jeecg-boot
+ * @Date: 2021-01-26
+ * @Version: V1.0
+ */
+public interface IKuaishouBatchCampaignPreviewService extends IService<KuaishouBatchCampaignPreview> {
+
+    void addPreviewData(JSONObject data) throws Exception;
+
+    JSONObject queryByBatchId(String batchId, String accountId);
+}

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

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-广告创意预览信息
+ * @Author: jeecg-boot
+ * @Date: 2021-01-26
+ * @Version: V1.0
+ */
+public interface IKuaishouBatchCreativePreviewService extends IService<KuaishouBatchCreativePreview> {
+
+    void createAdcampaignAndGroups(JSONObject data) throws Exception;
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-广告组预览信息
+ * @Author: jeecg-boot
+ * @Date: 2021-01-26
+ * @Version: V1.0
+ */
+public interface IKuaishouBatchGroupPreviewService extends IService<KuaishouBatchGroupPreview> {
+
+}

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

@@ -8,7 +8,6 @@ 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 com.google.gson.JsonArray;
 
 import java.text.ParseException;
 import java.util.Date;
@@ -21,7 +20,7 @@ import java.util.Map;
  */
 public interface IKuaishouInterfaceService {
 
-    KuaishouResultToken getAccessToken(String authCode, Integer agentType);
+    KuaishouResultToken getAccessToken(String authCode, Long appId);
 
 
     /**
@@ -152,7 +151,6 @@ public interface IKuaishouInterfaceService {
     void getCreativeList(CtopOauthToken token, Date startDate, Date endDate);
 
 
-
     /**
      * 根据组id,获取创意列表
      *
@@ -162,7 +160,7 @@ public interface IKuaishouInterfaceService {
      * @param endDate
      * @param timeFilterType
      */
-    JSONArray getCreativeList(CtopOauthToken token, Long unitId, Date startDate, Date endDate,int timeFilterType);
+    JSONArray getCreativeList(CtopOauthToken token, Long unitId, Date startDate, Date endDate, int timeFilterType);
 
 
     /**
@@ -359,7 +357,6 @@ public interface IKuaishouInterfaceService {
     void getCampaignList(CtopOauthToken token, Date startDate, Date endDate);
 
 
-
     /**
      * 获取计划列表,新增一个参数 按创建时间,还是更新时间进行筛选
      *
@@ -381,7 +378,6 @@ public interface IKuaishouInterfaceService {
     void getGroupList(CtopOauthToken token, Date startDate, Date endDate);
 
 
-
     /**
      * 获取指定广告计划下的广告组列表
      *
@@ -391,12 +387,7 @@ public interface IKuaishouInterfaceService {
      * @param endDate
      * @param time_filter_type
      */
-    JSONArray getGroupList(CtopOauthToken token, Long campaignId, Date startDate, Date endDate,int time_filter_type);
-
-
-
-
-
+    JSONArray getGroupList(CtopOauthToken token, Long campaignId, Date startDate, Date endDate, int time_filter_type);
 
 
     /**

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

@@ -16,6 +16,5 @@ public interface IKuaishouTemplateService extends IService<KuaishouTemplate> {
 
     JSONObject createTemplate(Long accountId, String accessToken, JSONObject requestJson);
 
-
     JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson);
 }

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

@@ -22,30 +22,4 @@ import org.springframework.stereotype.Service;
 @Service
 public class KuaiShouBatchCampaignTemplateServiceImpl extends ServiceImpl<KuaiShouBatchCampaignTemplateMapper, KuaiShouBatchCampaignTemplate> implements IKuaiShouBatchCampaignTemplateService {
 
-    @Autowired
-    IKuaiShouBatchGroupTemplateService kuaiShouBatchGroupTemplateService;
-
-    @Autowired
-    IKuaiShouBatchCreativeTemplateService kuaiShouBatchCreativeTemplateService;
-
-    @Override
-    public String previewLogic(JSONObject data) {
-
-
-        return null;
-    }
-
-    private JSONObject getCampaignsAndGroups(Integer type, JSONArray orientatPkg, JSONArray creativeGroup) {
-        JSONObject ob = new JSONObject();
-        //分组规则 1定向,2创意组
-        if (NoEn.NO1.valueInt() == type) {
-            for (int i = 0; i < orientatPkg.size(); i++) {
-
-            }
-        } else if (NoEn.NO2.valueInt() == type) {
-
-        }
-        return null;
-    }
-
 }

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

@@ -195,7 +195,16 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
 
     @Override
     public List<KuaiShouCreative> queryCreativeInfoByCampaignId(Long accountId, Long campaignId) {
-        return kuaiShouCreativeMapper.queryCreativeInfoByCampaignId(accountId,campaignId);
+        return kuaiShouCreativeMapper.queryCreativeInfoByCampaignId(accountId, campaignId);
+    }
+
+    @Override
+    public KuaiShouCreative getCreativeByCreativeId(Long creativeId) {
+        QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
+        creativeQueryWrapper.eq("creative_id", creativeId);
+        creativeQueryWrapper.last("limit 1");
+        KuaiShouCreative creative = kuaiShouCreativeMapper.selectOne(creativeQueryWrapper);
+        return creative;
     }
 
 

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

@@ -477,7 +477,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             header.put("Access-Token", token);
             header.put("Content-Type", "application/json");
             JSONObject params = new JSONObject();
-
             params.put("advertiser_id", advertiserId);
             String creativeId = requestJson.getString("creativeId");
             String creativeName = requestJson.getString("creativeName");
@@ -495,8 +494,9 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             if (!Check.isNull(action_bar_text)) {
                 params.put("action_bar_text", action_bar_text);
             }
-
-
+            if (!Check.isNull(requestJson.getString("imageToken"))) {
+                params.put("image_token", requestJson.getString("imageToken"));
+            }
             String result = HttpUtils.httpPostRequest(url, params, header);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {

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

@@ -0,0 +1,475 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCampaignPreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCreativePreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCampaignPreviewService;
+import com.alibaba.excel.util.CollectionUtils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 快手-广告计划预览信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-26
+ */
+@Service
+public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<KuaishouBatchCampaignPreviewMapper, KuaishouBatchCampaignPreview> implements IKuaishouBatchCampaignPreviewService {
+
+
+    @Autowired
+    KuaishouBatchCampaignPreviewMapper campaignPreviewMapper;
+    @Autowired
+    KuaishouBatchGroupPreviewMapper groupPreviewMapper;
+    @Autowired
+    KuaishouBatchCreativePreviewMapper creativePreviewMapper;
+
+    @Override
+    public JSONObject queryByBatchId(String batchId, String accountId) {
+        JSONObject obj = new JSONObject();
+        QueryWrapper<KuaishouBatchCampaignPreview> campaignWrapper = new QueryWrapper<>();
+        campaignWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
+        List<KuaishouBatchCampaignPreview> campaignPreviewList = campaignPreviewMapper.selectList(campaignWrapper);
+        obj.put("campaignList", campaignPreviewList);
+        QueryWrapper<KuaishouBatchGroupPreview> groupWrapper = new QueryWrapper<>();
+        groupWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
+        List<KuaishouBatchGroupPreview> groupPreviewList = groupPreviewMapper.selectList(groupWrapper);
+        obj.put("groupList", groupPreviewList);
+        QueryWrapper<KuaishouBatchCreativePreview> creativeWrapper = new QueryWrapper<>();
+        creativeWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
+        List<KuaishouBatchCreativePreview> creativePreviewList = creativePreviewMapper.selectList(creativeWrapper);
+        obj.put("creativeList", creativePreviewList);
+        return obj;
+    }
+
+    @Override
+    public void addPreviewData(JSONObject data) throws Exception {
+        String batchId = data.getString("batchId");
+        if (Check.isNull(batchId)) {
+            throw new Exception("数据异常,未获取到批次标识");
+        }
+        //计划
+        JSONObject campaignJson = data.getJSONObject("campaignJson");
+        if (Check.isNull(campaignJson)) {
+            throw new Exception("数据异常,未获取到广告计划数据");
+        }
+        KuaishouBatchCampaignPreview campaignPreview = commonCampaign(campaignJson, batchId);
+        //组
+        JSONObject groupJson = data.getJSONObject("unitJson");
+        if (Check.isNull(groupJson)) {
+            throw new Exception("数据异常,未获取到广告组数据");
+        }
+        KuaishouBatchGroupPreview groupPreview = commonGroup(groupJson, batchId, campaignJson);
+        //创意
+        JSONObject creativeJson = data.getJSONObject("creativeJson");
+        if (Check.isNull(creativeJson)) {
+            throw new Exception("数据异常,未获取到广告创意数据");
+        }
+        KuaishouBatchCreativePreview creativePreview = commonCreative(creativeJson, batchId);
+        //素材数据
+        JSONObject materialArray = data.getJSONObject("materialArray");
+        if (Check.isNull(materialArray)) {
+            throw new Exception("数据异常,未获取到素材数据");
+        }
+        //创意组
+        JSONArray materialList = materialArray.getJSONArray("materialList");
+        if (Check.isNull(materialList)) {
+            throw new Exception("数据异常,未获取到创意组数据");
+        }
+        //应用数据
+        JSONObject appList = data.getJSONObject("appList");
+        if (Check.isNull(appList)) {
+            throw new Exception("数据异常,未获取到应用数据");
+        }
+        //定向包
+        JSONArray targetIds = data.getJSONArray("targetIds");
+        if (Check.isNull(targetIds)) {
+            throw new Exception("数据异常,未获取到应用数据");
+        }
+        //分组规则 1 定向 2 创意 3 落地页
+        Integer type = campaignJson.getInteger("groupRule");
+        insertCampaignsAndGroups(type, data, campaignPreview, groupPreview, creativePreview);
+    }
+
+
+    /**
+     * 插入预览信息
+     *
+     * @param
+     * @return com.alibaba.fastjson.JSONObject
+     * @throws
+     * @author ZHAOXA
+     */
+    private void insertCampaignsAndGroups(Integer type, JSONObject data, KuaishouBatchCampaignPreview campaignPreview, KuaishouBatchGroupPreview groupPreview, KuaishouBatchCreativePreview creativePreview) throws Exception {
+        //定向包
+        JSONArray targetIds = data.getJSONArray("targetIds");
+        //应用数据
+        JSONObject appList = data.getJSONObject("appList");
+        //应用分配方式 1 按账户,2按广告计划,3按广告组
+        Integer appAllocation = appList.getInteger("appAllocation");
+        Integer appId = null;
+        Integer siteId = null;
+        String url = null;
+        JSONArray appArr = appList.getJSONArray("appArr");
+        JSONArray urlArr = appList.getJSONArray("urlArr");
+        boolean appNoNull = isNotNull(appArr, null, 1);
+        boolean urlNoNull = isNotNull(urlArr, null, 1);
+
+        //监测链接分配方式 1 按账户,2按广告计划,3按广告组
+        Integer linkAllocation = appList.getInteger("linkAllocation");
+        JSONArray clickTrackUrlList = appList.getJSONArray("clickUrlList");
+        JSONArray actionbarClickUrlList = appList.getJSONArray("clickUrlActionList");
+        boolean tracknotNull = isNotNull(clickTrackUrlList, null, 1);
+        boolean barnotNull = isNotNull(actionbarClickUrlList, null, 1);
+        String clickTrackUrl = null;
+        String actionbarClickUrl = null;
+        //按账户
+        if (appAllocation == 1) {
+            if (appNoNull) {
+                appId = appArr.getJSONObject(0).getInteger("appId");
+                siteId = appArr.getJSONObject(0).getInteger("siteId");
+            }
+            if (urlNoNull) {
+                url = urlArr.getString(0);
+            }
+        }
+        if (linkAllocation == 1) {
+            if (tracknotNull) {
+                clickTrackUrl = clickTrackUrlList.getString(0);
+            }
+            if (barnotNull) {
+                actionbarClickUrl = actionbarClickUrlList.getString(0);
+            }
+        }
+
+        //素材数据
+        JSONObject materialArray = data.getJSONObject("materialArray");
+        //创意组
+        JSONArray materialList = materialArray.getJSONArray("materialList");
+
+        JSONObject materialInfo = materialArray.getJSONObject("materialInfo");
+        //广告语匹配方式  1自定义,2按创意,3按创意组
+        Integer matchingMethod = materialInfo.getInteger("matchingMethod");
+        JSONArray descriptionList = materialArray.getJSONArray("descriptionList");
+        if (!Check.isNull(descriptionList)) {
+            //创意组匹配
+            descriptionList = advertisingSlogan(descriptionList, materialList);
+        }
+        creativePreview.setAccountId(campaignPreview.getAccountId());
+        //分组规则 1定向,2创意组
+        int count = targetIds.size() * materialList.size();
+        int appCount = targetIds.size() * materialList.size();
+        if (NoEn.NO1.valueInt() == type) {
+            /**
+             *按照 定向包 分组
+             * 计划总数 = 定向包数(targetIds)
+             * 同一计划下广告组的定向包一样,创意不同
+             */
+            for (int i = 0; i < targetIds.size(); i++) {
+                if (appAllocation == 2) {
+                    if (appNoNull) {
+                        appId = appArr.getJSONObject(i).getInteger("appId");
+                        siteId = appArr.getJSONObject(i).getInteger("siteId");
+                    }
+                    if (urlNoNull) {
+                        url = urlArr.getString(i);
+                    }
+                }
+                if (linkAllocation == 2) {
+                    if (tracknotNull) {
+                        clickTrackUrl = clickTrackUrlList.getString(i);
+                    }
+                    if (barnotNull) {
+                        actionbarClickUrl = actionbarClickUrlList.getString(i);
+                    }
+                }
+                campaignPreview.setId(null);
+                campaignPreview.setCampaignName(campaignPreview.getCampaignName() + i);
+                campaignPreviewMapper.insert(campaignPreview);
+                for (int j = 0; j < materialList.size(); j++) {
+                    if (appAllocation == 3) {
+                        appCount--;
+                        if (appNoNull) {
+                            appId = appArr.getJSONObject(appCount).getInteger("appId");
+                            siteId = appArr.getJSONObject(appCount).getInteger("siteId");
+                        }
+                        if (urlNoNull) {
+                            url = urlArr.getString(appCount);
+                        }
+                    }
+                    if (linkAllocation == 3) {
+                        count--;
+                        if (tracknotNull) {
+                            clickTrackUrl = clickTrackUrlList.getString(count);
+                        }
+                        if (barnotNull) {
+                            actionbarClickUrl = actionbarClickUrlList.getString(count);
+                        }
+                    }
+                    groupPreview.setId(null);
+                    groupPreview.setAppId(appId);
+                    groupPreview.setPlanId(campaignPreview.getId());
+                    groupPreview.setTemplateId(targetIds.getLong(i));
+                    groupPreview.setUnitName(groupPreview.getUnitName() + j);
+                    groupPreview.setUrl(url);
+                    groupPreviewMapper.insert(groupPreview);
+                    JSONObject material = materialList.getJSONObject(j);
+                    JSONArray photoArr = material.getJSONArray("photoArr");
+                    if (matchingMethod == 2) {
+                        //创意匹配
+                        descriptionList = advertisingSlogan(descriptionList, photoArr);
+                    }
+                    for (int k = 0; k < photoArr.size(); k++) {
+                        creativePreview.setId(null);
+                        creativePreview.setSiteId(siteId);
+                        creativePreview.setClickTrackUrl(clickTrackUrl);
+                        creativePreview.setActionbarClickUrl(actionbarClickUrl);
+                        JSONObject photo = photoArr.getJSONObject(k);
+                        JSONObject image = photo.getJSONObject("image");
+                        creativePreview.setPlanId(campaignPreview.getId());
+                        creativePreview.setGroupId(groupPreview.getId());
+                        creativePreview.setPhotoId(photo.getString("photoId"));
+                        creativePreview.setCreativeName(photo.getString("creativeName") + k);
+                        creativePreview.setImageUrl(image.getString("url"));
+                        creativePreview.setImageSignature(image.getString("signature"));
+                        if (matchingMethod == 1) {
+                            creativePreview.setDescription(photo.getString("description"));
+                        } else if (matchingMethod == 2) {
+                            creativePreview.setDescription(descriptionList.getString(k));
+                        } else if (matchingMethod == 3) {
+                            creativePreview.setDescription(descriptionList.getString(j));
+                        }
+                        creativePreviewMapper.insert(creativePreview);
+                    }
+                }
+            }
+        } else if (NoEn.NO2.valueInt() == type) {
+            /**
+             *按照 创意组 分组
+             * 计划总数 = 创意组数
+             * 则同一广告计划内的创意完全相同,定向包不同
+             */
+            for (int i = 0; i < materialList.size(); i++) {
+                if (appAllocation == 2) {
+                    if (appNoNull) {
+                        appId = appArr.getJSONObject(i).getInteger("appId");
+                        siteId = appArr.getJSONObject(i).getInteger("siteId");
+                    }
+                    if (urlNoNull) {
+                        url = urlArr.getString(i);
+                    }
+                }
+                if (linkAllocation == 2) {
+                    if (tracknotNull) {
+                        clickTrackUrl = clickTrackUrlList.getString(i);
+                    }
+                    if (barnotNull) {
+                        actionbarClickUrl = actionbarClickUrlList.getString(i);
+                    }
+                }
+                campaignPreview.setId(null);
+                campaignPreview.setCampaignName(campaignPreview.getCampaignName() + i);
+                campaignPreviewMapper.insert(campaignPreview);
+                JSONObject material = materialList.getJSONObject(i);
+                JSONArray photoArr = material.getJSONArray("photoArr");
+                if (matchingMethod == 2) {
+                    //创意匹配
+                    descriptionList = advertisingSlogan(descriptionList, photoArr);
+                }
+                for (int j = 0; j < targetIds.size(); j++) {
+                    if (appAllocation == 3) {
+                        appCount--;
+                        if (appNoNull) {
+                            appId = appArr.getJSONObject(appCount).getInteger("appId");
+                            siteId = appArr.getJSONObject(appCount).getInteger("siteId");
+                        }
+                        if (urlNoNull) {
+                            url = urlArr.getString(appCount);
+                        }
+                    }
+                    if (linkAllocation == 3) {
+                        count--;
+                        if (tracknotNull) {
+                            clickTrackUrl = clickTrackUrlList.getString(count);
+                        }
+                        if (barnotNull) {
+                            actionbarClickUrl = actionbarClickUrlList.getString(count);
+                        }
+                    }
+                    groupPreview.setId(null);
+                    groupPreview.setAppId(appId);
+                    groupPreview.setPlanId(campaignPreview.getId());
+                    groupPreview.setTemplateId(targetIds.getLong(j));
+                    groupPreview.setUnitName(groupPreview.getUnitName() + j);
+                    groupPreview.setUrl(url);
+                    groupPreviewMapper.insert(groupPreview);
+                    for (int k = 0; k < photoArr.size(); k++) {
+                        creativePreview.setId(null);
+                        creativePreview.setSiteId(siteId);
+                        creativePreview.setClickTrackUrl(clickTrackUrl);
+                        creativePreview.setActionbarClickUrl(actionbarClickUrl);
+                        JSONObject photo = photoArr.getJSONObject(k);
+                        JSONObject image = photo.getJSONObject("image");
+                        creativePreview.setPlanId(campaignPreview.getId());
+                        creativePreview.setGroupId(groupPreview.getId());
+                        creativePreview.setPhotoId(photo.getString("photoId"));
+                        creativePreview.setCreativeName(photo.getString("creativeName") + k);
+                        creativePreview.setImageUrl(image.getString("url"));
+                        creativePreview.setImageSignature(image.getString("signature"));
+                        if (matchingMethod == 1) {
+                            creativePreview.setDescription(photo.getString("description"));
+                        } else if (matchingMethod == 2) {
+                            creativePreview.setDescription(descriptionList.getString(k));
+                        } else if (matchingMethod == 3) {
+                            creativePreview.setDescription(descriptionList.getString(i));
+                        }
+                        creativePreviewMapper.insert(creativePreview);
+                    }
+                }
+            }
+        }
+    }
+
+
+    private boolean isNotNull(JSONArray arr, JSONArray arr2, Integer num) {
+        if (num == 2) {
+            return !CollectionUtils.isEmpty(arr) && !CollectionUtils.isEmpty(arr2);
+        } else {
+            return !CollectionUtils.isEmpty(arr);
+        }
+    }
+
+    /**
+     * 广告语整理
+     *
+     * @param
+     * @return com.alibaba.fastjson.JSONArray
+     * @throws
+     * @author ZHAOXA
+     */
+    private static JSONArray advertisingSlogan(JSONArray descriptionList, JSONArray materialList) {
+        if (materialList.size() <= descriptionList.size()) {
+            return descriptionList;
+        }
+        JSONArray other = new JSONArray();
+        if (materialList.size() > descriptionList.size()) {
+            int num = materialList.size() / descriptionList.size();
+            for (int i = 0; i <= num; i++) {
+                other.addAll(descriptionList);
+            }
+        }
+        return other;
+    }
+
+    /**
+     * 整理通用广告计划数据
+     *
+     * @param
+     * @return cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview
+     * @throws
+     * @author ZHAOXA
+     */
+    private KuaishouBatchCampaignPreview commonCampaign(JSONObject campaignJson, String batchId) {
+        KuaishouBatchCampaignPreview campaignPreview = new KuaishouBatchCampaignPreview();
+        campaignPreview.setAccountId(campaignJson.getLong("accountId"));
+        campaignPreview.setCampaignName(campaignJson.getString("campaignName"));
+        campaignPreview.setCampaignType(campaignJson.getInteger("campaignType"));
+        campaignPreview.setPutStatus(campaignJson.getInteger("campaignStatus"));
+        campaignPreview.setDayBudget(campaignJson.getInteger("dayBudget"));
+        campaignPreview.setDayBudgetSchedule(campaignJson.getString("dayBudgetSchedule"));
+        campaignPreview.setTimeStart(campaignJson.getString("timeStart"));
+        campaignPreview.setIsTime(campaignJson.getInteger("isTime"));
+        campaignPreview.setBatchId(batchId);
+        return campaignPreview;
+    }
+
+    /**
+     * 整理通用广告组数据
+     *
+     * @param
+     * @return cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview
+     * @throws
+     * @author ZHAOXA
+     */
+    private KuaishouBatchGroupPreview commonGroup(JSONObject groupJson, String batchId, JSONObject campaignJson) {
+        KuaishouBatchGroupPreview groupPreview = new KuaishouBatchGroupPreview();
+        groupPreview.setAccountId(groupJson.getLong("accountId"));
+        groupPreview.setUnitName(groupJson.getString("unitName"));
+        groupPreview.setPutStatus(campaignJson.getInteger("unitStatus") == 2 ? 2 : null);
+        groupPreview.setBidType(groupJson.getInteger("bidType"));
+        if (groupJson.getInteger("bidType") == 2) {
+            int bid = getRandom(groupJson.getInteger("bidMax"), groupJson.getInteger("bidMin"));
+            if (bid > 0) {
+                groupJson.put("bid", bid);
+            }
+        }
+
+        if (groupJson.getInteger("bidType") == 10) {
+            groupPreview.setCpaBid(groupJson.getInteger("cpaBid"));
+        } else {
+            groupPreview.setBid(groupJson.getInteger("bid"));
+        }
+        groupPreview.setOcpxActionType(groupJson.getInteger("ocpxActionType"));
+        groupPreview.setDeepConversionType(groupJson.getInteger("deepConversionType"));
+        groupPreview.setDeepConversionBid(groupJson.getInteger("deepConversionBid"));
+        groupPreview.setDayBudget(groupJson.getInteger("dayBudget"));
+        groupPreview.setSpeed(groupJson.getInteger("speed"));
+        groupPreview.setBeginTime(groupJson.getString("beginTime"));
+        groupPreview.setEndTime(groupJson.getString("endTime"));
+        groupPreview.setScheduleTime(groupJson.getString("scheduleTime"));
+        groupPreview.setSceneId(groupJson.getString("sceneId"));
+        groupPreview.setShowMode(groupJson.getInteger("showMode"));
+        groupPreview.setUseAppMarket(groupJson.getInteger("useAppMarket"));
+        groupPreview.setAppStore(groupJson.getString("appStore"));
+        groupPreview.setBatchId(batchId);
+        groupPreview.setUnitType(groupJson.getInteger("unitType"));
+        return groupPreview;
+    }
+
+    private static int getRandom(int x, int y) {
+        int num = -1;
+        //说明:两个数在合法范围内,并不限制输入的数哪个更大一些
+        if (x < 0 || y < 0) {
+            return num;
+        } else {
+            int max = Math.max(x, y);
+            int min = Math.min(x, y);
+            int mid = max - min;//求差
+            //产生随机数
+            return (int) (Math.random() * (mid + 1)) + min;
+        }
+    }
+
+    /**
+     * 整理通用创意数据
+     *
+     * @param
+     * @return cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview
+     * @throws
+     * @author ZHAOXA
+     */
+    private KuaishouBatchCreativePreview commonCreative(JSONObject creativeJson, String batchId) {
+        KuaishouBatchCreativePreview creativePreview = new KuaishouBatchCreativePreview();
+        creativePreview.setActionBarText(creativeJson.getString("actionBarText"));
+        creativePreview.setOverlayType(creativeJson.getString("overlayType"));
+        creativePreview.setStickerTitle(creativeJson.getString("stickerTitle"));
+        creativePreview.setCreativeTag(creativeJson.getString("creativeTag"));
+        creativePreview.setCreativeCategory(creativeJson.getInteger("creativeCategory"));
+        creativePreview.setBatchId(batchId);
+        return creativePreview;
+    }
+
+}

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

@@ -0,0 +1,476 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCampaignPreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCreativePreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCreativePreviewService;
+import com.alibaba.fastjson.JSONObject;
+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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static java.lang.Integer.valueOf;
+
+/**
+ * 快手-广告创意预览信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-26
+ */
+@Slf4j
+@Service
+public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<KuaishouBatchCreativePreviewMapper, KuaishouBatchCreativePreview> implements IKuaishouBatchCreativePreviewService {
+
+    @Autowired
+    KuaishouBatchCampaignPreviewMapper campaignPreviewMapper;
+    @Autowired
+    KuaishouBatchGroupPreviewMapper groupPreviewMapper;
+    @Autowired
+    KuaishouBatchCreativePreviewMapper creativePreviewMapper;
+
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaiShouGroupTemplateService groupTemplateService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private IMaterialCutFrameService cutFrameService;
+    @Autowired
+    private IKuaiShouMaterialUploadService uploadService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+
+    static ExecutorService campaignService = Executors.newFixedThreadPool(10);
+    static ExecutorService unitService = Executors.newFixedThreadPool(20);
+    static ExecutorService creativeService = Executors.newFixedThreadPool(20);
+
+    @Override
+    public void createAdcampaignAndGroups(JSONObject data) throws Exception {
+        Long accountId = data.getLong("accountId");
+        JSONObject dataList = data.getJSONObject("dataList");
+        if (!Check.isNull(dataList)) {
+            List<String> compaignList = dataList.getJSONArray("campaigns").toJavaList(String.class);
+            List<String> groupList = dataList.getJSONArray("groups").toJavaList(String.class);
+            List<String> creativeList = dataList.getJSONArray("creatives").toJavaList(String.class);
+            List<KuaishouBatchCampaignPreview> campaignPreviewList = campaignPreviewMapper.selectBatchIds(compaignList);
+            List<KuaishouBatchGroupPreview> kuaishouBatchGroupPreviews = groupPreviewMapper.selectBatchIds(groupList);
+            List<KuaishouBatchCreativePreview> kuaishouBatchCreativePreviews = creativePreviewMapper.selectBatchIds(creativeList);
+            //待建计划
+            List<KuaishouBatchCampaignPreview> campaignList = getCampaignList(campaignPreviewList, kuaishouBatchGroupPreviews, kuaishouBatchCreativePreviews);
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            campaignList.forEach(campaign -> campaignService.submit(() -> {
+                try {
+                    creativeCampaign(oauthToken, campaign);
+                } catch (Exception e) {
+                    log.error("根据预览数据创建广告计划异常", e);
+                }
+            }));
+        }
+    }
+
+    /**
+     * 创建广告计划
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private List<KuaishouBatchCampaignPreview> getCampaignList(List<KuaishouBatchCampaignPreview> campaignPreviewList, List<KuaishouBatchGroupPreview> kuaishouBatchGroupPreviews, List<KuaishouBatchCreativePreview> kuaishouBatchCreativePreviews) {
+        List<KuaishouBatchGroupPreview> groups = new ArrayList<>();
+        for (KuaishouBatchGroupPreview groupPreview : kuaishouBatchGroupPreviews) {
+            List<KuaishouBatchCreativePreview> creatives = new ArrayList<>();
+            for (KuaishouBatchCreativePreview creativePreview : kuaishouBatchCreativePreviews) {
+                if (groupPreview.getPlanId().equals(creativePreview.getPlanId()) && creativePreview.getGroupId().equals(groupPreview.getId())) {
+                    creatives.add(creativePreview);
+                }
+            }
+            groupPreview.setKuaishouBatchCreativePreviews(creatives);
+            groups.add(groupPreview);
+        }
+        List<KuaishouBatchCampaignPreview> campaigns = new ArrayList<>();
+        for (KuaishouBatchCampaignPreview campaignPreview : campaignPreviewList) {
+            List<KuaishouBatchGroupPreview> groupList = new ArrayList<>();
+            for (KuaishouBatchGroupPreview group : groups) {
+                if (campaignPreview.getId().equals(group.getPlanId())) {
+                    groupList.add(group);
+                }
+            }
+            campaignPreview.setKuaishouBatchGroupPreviews(groupList);
+            campaigns.add(campaignPreview);
+        }
+        return campaigns;
+    }
+
+    /**
+     * 根据预览数据创建广告计划
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+
+    private void creativeCampaign(CtopOauthToken oauthToken, KuaishouBatchCampaignPreview campaign) throws Exception {
+        KuaishouBatchCampaignPreview updateStatus = new KuaishouBatchCampaignPreview();
+        updateStatus.setId(campaign.getId());
+        JSONObject campaignJson = new JSONObject();
+        campaignJson.put("campaign_name", campaign.getCampaignName());
+        campaignJson.put("type", campaign.getCampaignType());
+        if (!Check.isNull(campaign.getDayBudget())) {
+            campaignJson.put("day_budget", campaign.getDayBudget());
+        }
+        if (!Check.isNull(campaign.getDayBudgetSchedule())) {
+            campaignJson.put("day_budget_schedule", campaign.getDayBudgetSchedule());
+        }
+        Map<String, Object> campaignMap = kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), campaignJson);
+        Integer code = (Integer) campaignMap.get("code");
+        if (code != 0) {
+            updateStatus.setIsSuccess(0);
+            updateStatus.setMessage((String) campaignMap.get("message"));
+            campaignPreviewMapper.updateById(updateStatus);
+            throw new Exception((String) campaignMap.get("message"));
+        }
+        Long campaignId = (Long) campaignMap.get("campaignId");
+        /**
+         *更新预览数据状态
+         */
+        updateStatus.setIsSuccess(1);
+        updateStatus.setMessage((String) campaignMap.get("message"));
+        updateStatus.setCampaignId(campaignId);
+        campaignPreviewMapper.updateById(updateStatus);
+        //创意广告组
+        List<KuaishouBatchGroupPreview> groupPreviewList = campaign.getKuaishouBatchGroupPreviews();
+        groupPreviewList.forEach(group -> campaignService.submit(() -> {
+            try {
+                createCopyUnits(oauthToken, group, campaignId);
+            } catch (Exception e) {
+                log.error("根据预览数据创建广告组异常", e);
+            }
+        }));
+    }
+
+    /**
+     * 根据预览数据创建广告组
+     * detail
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void createCopyUnits(CtopOauthToken token, KuaishouBatchGroupPreview groupPreview, Long campaignId) throws Exception {
+        KuaishouBatchGroupPreview updateStatus = new KuaishouBatchGroupPreview();
+        try {
+            updateStatus.setId(groupPreview.getId());
+            updateStatus.setCampaignId(campaignId);
+            JSONObject unitJson = new JSONObject();
+            unitJson.put("campaign_id", campaignId);
+            // 资源位置
+            String sceneId = groupPreview.getSceneId();
+            JSONArray scene_id = JSONObject.parseArray(sceneId);
+            unitJson.put("scene_id", scene_id);
+            // 资源创作方式
+            unitJson.put("unit_type", groupPreview.getUnitType());
+            // 转化目标id
+            if (!Check.isNull(groupPreview.getConvertId())) {
+                unitJson.put("convert_id", groupPreview.getConvertId());
+            }
+            // 优先从系统应用商店下载
+            if (!Check.isNull(groupPreview.getUseAppMarket())) {
+                unitJson.put("use_app_market", groupPreview.getUseAppMarket());
+            }
+            // 应用商店列表
+            if (!Check.isNull(groupPreview.getAppStore())) {
+                unitJson.put("app_store", JSONObject.parseArray(groupPreview.getAppStore()));
+            }
+            //投放开始时间
+            String beginTime = groupPreview.getBeginTime();
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            boolean beginTimeBoolean = DateUtils.compare(beginTime, nowDate);
+            if (beginTimeBoolean) {
+                unitJson.put("begin_time", nowDate);
+            } else {
+                unitJson.put("begin_time", beginTime);
+            }
+            // 投放结束时间
+            String endTime = groupPreview.getEndTime();
+            if (!Check.isNull(endTime)) {
+                unitJson.put("end_time", endTime);
+            }
+            // 投放时间段
+            String scheduleTime = groupPreview.getScheduleTime();
+            if (!Check.isNull(scheduleTime)) {
+                unitJson.put("schedule_time", scheduleTime);
+            }
+            // 广告组单日预算
+            Integer dayBudget = groupPreview.getDayBudget();
+            if (!Check.isNull(dayBudget)) {
+                unitJson.put("day_budget", dayBudget);
+            }
+            // url类型
+            if (!Check.isNull(groupPreview.getUrlType())) {
+                unitJson.put("url_type", groupPreview.getUrlType());
+            }
+            // url
+            if (!Check.isNull(groupPreview.getUrl())) {
+                unitJson.put("url", groupPreview.getUrl());
+            }
+            // appId
+            if (!Check.isNull(groupPreview.getAppId())) {
+                unitJson.put("app_id", groupPreview.getAppId());
+            }
+            // 创意展现方式
+            if (!Check.isNull(groupPreview.getShowMode())) {
+                unitJson.put("show_mode", groupPreview.getShowMode());
+            }
+            //投放方式
+            Integer speed = groupPreview.getSpeed();
+            if (!Check.isNull(speed)) {
+                unitJson.put("speed", speed);
+            }
+            Integer firstSceneId = valueOf(scene_id.get(0).toString());
+            Long templateId = groupPreview.getTemplateId();
+            if (!Check.isNull(templateId)) {
+                if (firstSceneId != 5) {
+                    unitJson.put("template_id", templateId);
+                } else {
+                    JSONObject unionJson = groupTemplateService.getUnionJson(templateId);
+                    Integer code = unionJson.getInteger("code");
+                    if (code == 0) {
+                        JSONObject target = unionJson.getJSONObject("target");
+                        unitJson.put("target", target);
+                    }
+                }
+            }
+            // 出价
+            Integer bid = groupPreview.getBid();
+            if (!Check.isNull(bid)) {
+                unitJson.put("bid", bid);
+            }
+            // 出价类型
+            Integer bidType = groupPreview.getBidType();
+            if (!Check.isNull(bidType)) {
+                unitJson.put("bid_type", bidType);
+            }
+            // 深度转化出价
+            Integer cpaBid = groupPreview.getCpaBid();
+            if (!Check.isNull(cpaBid)) {
+                unitJson.put("cpa_bid", cpaBid);
+            }
+            // 深度转化目标出价
+            Integer deepConversionBid = groupPreview.getDeepConversionBid();
+            if (!Check.isNull(deepConversionBid)) {
+                unitJson.put("deep_conversion_bid", deepConversionBid);
+            }
+            // 深度转化目标
+            Integer deepConversionType = groupPreview.getDeepConversionType();
+            if (!Check.isNull(deepConversionType)) {
+                unitJson.put("deep_conversion_type", deepConversionType);
+            }
+            // 优化目标
+            Integer ocpxActionType = groupPreview.getOcpxActionType();
+            if (!Check.isNull(ocpxActionType)) {
+                unitJson.put("ocpx_action_type", ocpxActionType);
+            }
+            // 广告组的投放状态
+            Integer putStatus = groupPreview.getPutStatus();
+            if (!Check.isNull(putStatus)) {
+                unitJson.put("put_status", putStatus);
+            }
+            //快手广告组名
+            String unitName = groupPreview.getUnitName();
+            unitJson.put("unit_name", unitName);
+            Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitJson, 1);
+            if (!Check.isNullMap(returnUnitMap)) {
+                Integer code = (Integer) returnUnitMap.get("code");
+                if (code == 0) {
+                    Long unitId = (Long) returnUnitMap.get("unitId");
+                    updateStatus.setIsSuccess(1);
+                    updateStatus.setMessage((String) returnUnitMap.get("message"));
+                    updateStatus.setUnitId(unitId);
+                    createCopyCreatives(token, groupPreview.getKuaishouBatchCreativePreviews(), unitId, campaignId);
+                } else {
+                    updateStatus.setIsSuccess(0);
+                    updateStatus.setMessage((String) returnUnitMap.get("message"));
+                }
+            } else {
+                updateStatus.setIsSuccess(0);
+                updateStatus.setMessage((String) "返回map数据为空!");
+            }
+        } catch (Exception e) {
+            updateStatus.setIsSuccess(0);
+            updateStatus.setMessage("创建组过程中调用快手接口异常");
+            log.error("调用快手接口异常", e);
+        }
+        groupPreviewMapper.updateById(updateStatus);
+    }
+
+    /**
+     * 执行多线程创建创意
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void createCopyCreatives(CtopOauthToken token, List<KuaishouBatchCreativePreview> creativePreviewList, Long unitId, Long campaignId) {
+        creativePreviewList.forEach(creative -> campaignService.submit(() -> {
+            try {
+                createCreative(token, campaignId, unitId, creative);
+            } catch (Exception e) {
+                log.error("根据预览数据创建广告创意异常", e);
+            }
+        }));
+    }
+
+    /**
+     * 根据预览数据创建广告创意
+     *
+     * @param oauthToken
+     * @param unit_id
+     * @param creative_list
+     */
+    private void createCreative(CtopOauthToken oauthToken, Long campaignId, Long unitId, KuaishouBatchCreativePreview creativePreview) throws Exception {
+        KuaishouBatchCreativePreview updateStatus = new KuaishouBatchCreativePreview();
+        updateStatus.setId(creativePreview.getId());
+        updateStatus.setCampaignId(campaignId);
+        updateStatus.setUnitId(unitId);
+        try {
+            JSONObject createJson = new JSONObject();
+            createJson.put("advertiser_id", oauthToken.getAccountId());
+            createJson.put("unit_id", unitId);
+            createJson.put("creative_name", creativePreview.getCreativeName()); // 创意名称
+            if (!Check.isNull(creativePreview.getPhotoId())) {
+                createJson.put("photo_id", creativePreview.getPhotoId());  // 视频ID
+            }
+            KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(Long.valueOf(creativePreview.getPhotoId()));
+            if (!Check.isNull(video)) {
+                createJson.put("creative_material_type", video.getMaterialType());  // 素材类型
+            }
+            if (!Check.isNull(creativePreview.getActionBarText())) {
+                createJson.put("action_bar_text", creativePreview.getActionBarText());  // 行动号召按钮文案
+            }
+            if (!Check.isNull(creativePreview.getDescription())) {
+                createJson.put("description", creativePreview.getDescription());  // 广告语
+            }
+            if (!Check.isNull(creativePreview.getStickerTitle())) {
+                createJson.put("sticker_title", creativePreview.getStickerTitle());  // 封面广告语标题
+            }
+            if (!Check.isNull(creativePreview.getOverlayType())) {
+                createJson.put("overlay_type", creativePreview.getOverlayType());  // 贴纸样式类型
+            }
+                /*if (!Check.isNull(creativePreview.getCreativeTag())) {
+                    createJson.put("expose_tag", JSONObject.parseArray(creativePreview.getCreativeTag()));  // 广告标签
+                }
+                if (!Check.isNull(creativePreview.getJSONArray("new_expose_tag"))) {
+                    createJson.put("new_expose_tag", creativePreview.getJSONArray("new_expose_tag"));  // 广告标签2期
+                }*/
+            if (!Check.isNull(creativePreview.getSiteId())) {
+                createJson.put("site_id", creativePreview.getSiteId());  // 安卓下载中间页ID
+            }
+            if (!Check.isNull(creativePreview.getClickTrackUrl())) {
+                createJson.put("click_track_url", creativePreview.getClickTrackUrl());  // 第三方点击检测链接
+            }
+            if (!Check.isNull(creativePreview.getImpressionUrl())) {
+                createJson.put("impression_url", creativePreview.getImpressionUrl());  // 第三方开始播放监测链接
+            }
+            if (!Check.isNull(creativePreview.getAdPhotoPlayedT3sUrl())) {
+                createJson.put("ad_photo_played_t3s_url", creativePreview.getAdPhotoPlayedT3sUrl());  // 第三方有效播放监测链接
+            }
+            if (!Check.isNull(creativePreview.getActionbarClickUrl())) {
+                createJson.put("actionbar_click_url", creativePreview.getActionbarClickUrl());  // 第三方点击按钮监测链接
+            }
+            if (!Check.isNull(creativePreview.getCreativeCategory())) {
+                createJson.put("creative_category", creativePreview.getCreativeCategory());  // 创意分类
+            }
+            if (!Check.isNull(creativePreview.getCreativeTag())) {
+                createJson.put("creative_tag", JSONObject.parseArray(creativePreview.getCreativeTag()));  // 创意标签
+            }
+            String image_md5 = creativePreview.getImageSignature();
+            String imageToken = null;
+            if (!Check.isNull(image_md5)) {
+                imageToken = getImageToken(image_md5, oauthToken.getAccountId(), oauthToken.getAccessToken());
+            }
+            if (!Check.isNull(imageToken)) {
+                createJson.put("image_token", imageToken); // 自定义创意封面token
+            }
+            Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
+            JSONObject returnJson = new JSONObject();
+            Integer code = (Integer) creativeMap.get("code");
+            if (code == 0) {
+                Long creativeId = (Long) creativeMap.get("creativeId");
+                updateStatus.setIsSuccess(1);
+                updateStatus.setMessage((String) creativeMap.get("message"));
+                updateStatus.setCreativeId(creativeId);
+            } else {
+                updateStatus.setIsSuccess(0);
+                updateStatus.setMessage((String) creativeMap.get("message"));
+            }
+        } catch (Exception e) {
+            log.error("创建广告创意过程中调用快手接口异常", e);
+            updateStatus.setIsSuccess(0);
+            updateStatus.setMessage("创建广告创意过程中调用快手接口异常");
+        }
+        creativePreviewMapper.updateById(updateStatus);
+    }
+
+    /**
+     * 根据封面MD5 获取imageToken
+     *
+     * @param md5
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    private String getImageToken(String md5, Long accountId, String accessToken) {
+        String imageToken = null;
+        QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("signature", md5);
+        queryWrapper.last("limit 1");
+        KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
+        if (!Check.isNull(imageGet)) {
+            imageToken = imageGet.getImageToken();
+        } else {
+            MaterialCutFrame cutFrame = cutFrameService.selectByMd5(md5);
+            if (!Check.isNull(cutFrame)) {
+                imageToken = uploadService.kuauiShouImageUpload(cutFrame.getUrl(), md5, accountId, accessToken);
+            }
+        }
+        return imageToken;
+    }
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchGroupPreviewService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手-广告组预览信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-26
+ */
+@Service
+public class KuaishouBatchGroupPreviewServiceImpl extends ServiceImpl<KuaishouBatchGroupPreviewMapper, KuaishouBatchGroupPreview> implements IKuaishouBatchGroupPreviewService {
+
+}

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

@@ -2,9 +2,11 @@ package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.entity.OauthConfig;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
@@ -1875,20 +1877,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param authCode
      * @return
      */
+    @Autowired
+    private IOauthConfigService configService;
+
     @Override
-    public KuaishouResultToken getAccessToken(String authCode, Integer agentType) {
+    public KuaishouResultToken getAccessToken(String authCode, Long appId) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.AUTH_TOKEN;
         JSONObject requestJson = new JSONObject();
         requestJson.put("auth_code", authCode);
 
-        if (agentType == 1) { // 本代理商开户
-            requestJson.put("app_id", PropertiesUtils.getConfig("kuaishou_appid"));
-            requestJson.put("secret", PropertiesUtils.getConfig("kuaishou_secret"));
-        } else if (agentType == 0) {
-            requestJson.put("app_id", PropertiesUtils.getConfig("kuaishou_third_appid"));
-            requestJson.put("secret", PropertiesUtils.getConfig("kuaishou_third_secret"));
-        }
-
+        OauthConfig config = configService.getConfigByAppId(appId);
+        requestJson.put("app_id", config.getAppId());
+        requestJson.put("secret", config.getSecret());
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", " application/json");
         KuaishouResultToken kuaiShouResult = null;
@@ -2980,7 +2980,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     @Override
                     public void run() {
                         List<MaterialCutFrame> cutFrames = cutFrameService.getListByVideoSignature(md5);
-                        if(null==cutFrames||cutFrames.isEmpty()){
+                        if (null == cutFrames || cutFrames.isEmpty()) {
                             videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
                         }
                     }

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

@@ -46,6 +46,9 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
         JSONObject resultJson = JSONObject.parseObject(result);
         if (!Check.isNull(resultJson)) {
             Integer code = resultJson.getInteger("code");
+         /*   Map<String, Object> deleteMap = new HashMap<>();
+            deleteMap.put("account_id", accountId);
+            this.removeByMap(deleteMap);*/
             if (code == 0) {
                 JSONObject dataJson = resultJson.getJSONObject("data");
                 if (Check.isNull(dataJson)) {
@@ -344,14 +347,16 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             if (Check.isNull(requestJson.getString("templateName"))) {
                 throw new Exception("定向模板名称为必传项");
             }
+            if (Check.isNull(requestJson.getLong("templateId"))) {
+                throw new Exception("定向模板id为必传项");
+            }
 
             JSONObject param = new JSONObject();
             param.put("template_id", requestJson.getLong("templateId"));
             param.put("advertiser_id", accountId);
-            if(!Check.isNull(requestJson.getString("templateName"))){
+            if (!Check.isNull(requestJson.getString("templateName"))) {
                 param.put("template_name", requestJson.getString("templateName"));
             }
-
             JSONObject targetJson = new JSONObject();
             if (!Check.isNull(requestJson.getJSONArray("region"))) {
                 targetJson.put("region", requestJson.getJSONArray("region"));
@@ -449,15 +454,12 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             if (!Check.isNull(targetJson)) {
                 param.put("target", targetJson);
             }
-
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
-            System.err.println("入参:" + param.toJSONString());
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
-            System.err.println("返回:" + resultJson.toJSONString());
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {