Explorar o código

Merge branch 'master' into zzy

yangzian %!s(int64=3) %!d(string=hai) anos
pai
achega
67a9963321
Modificáronse 74 ficheiros con 2746 adicións e 876 borrados
  1. 8 1
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 1 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  3. 13 6
      jeecg-boot-material-view/src/main/resources/application-dev.yml
  4. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/constant/CtopRoleCodeConstant.java
  5. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/Project.java
  6. 13 9
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml
  7. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java
  8. 60 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoDoController.java
  9. 79 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java
  10. 4 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoTargetController.java
  11. 19 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java
  12. 8 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoVideo.java
  13. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCreativeLevelOperationRecord.java
  14. 25 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouProgramCreativeLevelOperationRecord.java
  15. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoTargetMapper.java
  16. 7 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoVideoMapper.java
  17. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoTargetMapper.xml
  18. 63 30
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml
  19. 7 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoDoService.java
  20. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoTargetService.java
  21. 4 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoVideoService.java
  22. 759 322
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java
  23. 9 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoTargetServiceImpl.java
  24. 24 17
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoVideoServiceImpl.java
  25. 37 40
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  26. 3 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupTemplateController.java
  27. 35 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouTitleCollectionController.java
  28. 135 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java
  29. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java
  30. 20 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/KuaiShouVideoGetVo.java
  31. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java
  32. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTemplateMapper.java
  33. 12 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java
  34. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java
  35. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouAppListMapper.xml
  36. 27 19
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  37. 6 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml
  38. 162 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  39. 14 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  40. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java
  41. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupTemplateService.java
  42. 12 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java
  43. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  44. 0 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java
  45. 6 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCampaignServiceImpl.java
  46. 116 76
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  47. 254 29
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java
  48. 30 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  49. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  50. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  51. 327 134
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  52. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/WarningOperationServiceImpl.java
  53. 8 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelMapper.java
  54. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelCreateStrategyMapper.xml
  55. 107 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml
  56. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java
  57. 119 62
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java
  58. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/DocumentLibraryMapper.java
  59. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/xml/DocumentLibraryMapper.xml
  60. 18 12
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/impl/DocumentLibraryServiceImpl.java
  61. 6 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/controller/KuaishouHostingTemplateController.java
  62. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTask.java
  63. 6 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTemplate.java
  64. 4 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/xml/KuaishouHostingTaskMapper.xml
  65. 13 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/impl/KuaishouHostingTaskServiceImpl.java
  66. 17 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java
  67. 32 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  68. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/PerformanceAreaController.java
  69. 5 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  70. 20 27
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  71. 6 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  72. 10 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ProjectMember.java
  73. 9 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  74. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java

+ 8 - 1
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -573,6 +573,13 @@ public class DateUtils extends PropertyEditorSupport {
         return getSDFormat(pattern).format(date);
     }
 
+    public static String formatDate(String date, String pattern) throws ParseException {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+        Date parse = simpleDateFormat.parse(date);
+        return simpleDateFormat.format(parse);
+    }
+
+
     // ////////////////////////////////////////////////////////////////////////////
     // formatTime
     // 将日期按照一定的格式转化为字符串
@@ -919,7 +926,7 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
     public static Date getStartDate(String date) {
-       String temp =  date + " 00:00:00";
+        String temp = date + " 00:00:00";
         try {
             return format1.parse(temp);
         } catch (Exception e) {

+ 1 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -239,6 +239,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/cwjsSaleAssistantInfo/**", "anon");
         filterChainDefinitionMap.put("/overView/**", "anon");
         filterChainDefinitionMap.put("/agent/**", "anon");
+        filterChainDefinitionMap.put("/auto/**", "anon");
         filterChainDefinitionMap.put("/task/kuaishouHostingTask/**", "anon");
         filterChainDefinitionMap.put("/audienceReport/**", "anon");
         filterChainDefinitionMap.put("/stare/**", "anon");

+ 13 - 6
jeecg-boot-material-view/src/main/resources/application-dev.yml

@@ -106,15 +106,15 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://111.206.86.186:3390/application?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&serverTimezone=GMT%2B8
-          username: hcst
-          password: hcst@2021
+#          url: jdbc:mysql://111.206.86.186:3390/application?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&serverTimezone=GMT%2B8
+#          username: hcst
+#          password: hcst@2021
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:
-          #url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-          #username: root
-          #password: root
+          url: jdbc:mysql://192.168.0.184:3390/jeecg-boot?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          username: hcst
+          password: hcst@2021
           #driver-class-name: com.mysql.cj.jdbc.Driver
   #redis 配置
   redis:
@@ -147,6 +147,13 @@ mybatis-plus:
     call-setters-on-nulls: true
 #jeecg专用配置
 jeecg :
+  oss:
+    secretKey:
+    accessKey:
+  path:
+    webapp:
+    upload:
+
   elasticsearch:
     cluster-name: jeecg-ES
     cluster-nodes: 127.0.0.1:9200

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/constant/CtopRoleCodeConstant.java

@@ -1,5 +1,5 @@
 package cn.com.ctop.common.module.constant;
 
-public class  CtopRoleCodeConstant {
+public class CtopRoleCodeConstant {
     public static final String COMMON_ROLE_CODE_ADMIN = "admin";
 }

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/Project.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.common.module.entity;
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -116,9 +117,15 @@ public class Project {
     private Date updateTime;
 
 
+    //优化目标出价类型
     private String bidType;
+
+    //转化目标
     private String ocpxActionType;
 
+    //深度转化目标
+    private String deepConversionType;
+
     @TableField(exist = false)
     private String responsibleId_dictText; // 运营负责人
 
@@ -135,4 +142,12 @@ public class Project {
     private Integer needExamine;
     @TableField(exist = false)
     private String supplierCode_dictText;
+
+    //转化目标
+    @TableField(exist = false)
+    private JSONArray ocpxActionTypeArray;
+
+    //深度转化目标
+    @TableField(exist = false)
+    private JSONArray deepConversionTypeArray;
 }

+ 13 - 9
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml

@@ -16,14 +16,15 @@
     </select>
 
     <select id="getWarningInfoByProjectId" resultType="com.alibaba.fastjson.JSONObject">
-     select
-     id projectId,
-     project_name projectName,
-     max_bid maxBid,
-     bid_type bidType,
-     ocpx_action_type ocpxActionType
-     from ctop_project
-     where id = #{projectId}
+        select
+            id projectId,
+            project_name projectName,
+            max_bid maxBid,
+            bid_type bidType,
+            ocpx_action_type ocpxActionType,
+            deep_conversion_type deepConversionType
+        from ctop_project
+        where id = #{projectId}
     </select>
 
     <select id="querySupplierCodeById" resultType="java.lang.String">
@@ -37,7 +38,10 @@
         responsible_id as 'responsibleId',
         design_responsible_id as 'designResponsibleId',
         media_id as 'mediaId',
-        max_bid as 'maxBid'
+        max_bid as 'maxBid',
+        bid_type as 'bidType',
+        ocpx_action_type as 'ocpxActionType',
+        deep_conversion_type as 'deepConversionType'
         from ctop_project
         where id in
         <foreach collection="ids" item="item" separator=","

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java

@@ -69,7 +69,9 @@ public enum StatusCode {
     KUAISHOU_CRAWLER_APP_TASK_END("爬虫任务运行结束", 1, true),
     KUAISHOU_CRAWLER_APP_JOB_StART("任务开始执行开始", 0, true),
     KUAISHOU_CRAWLER_APP_JOB_END("任务运行结束", 1, true),
-    MODEL_VIDEO_NOT_EXIST("模板视频不存在或者已经被删除", 0, false);
+    MODEL_VIDEO_NOT_EXIST("模板视频不存在或者已经被删除", 0, false),
+
+    KUAISHOU_AUTO_STRATEGY_UPDATE("修改失败,该账户新版自动投放策略已运行", 500, false);
     private String desc;
     private int code;
     private boolean flag;

+ 60 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoDoController.java

@@ -28,7 +28,65 @@ public class AiKuaishouAccountAutoDoController {
     static ExecutorService programService = Executors.newFixedThreadPool(8);
 
     /**
-     * 创建自定义广告创意
+     * 创建自定义上新广告创意 、频率 20分钟/次
+     */
+    @GetMapping(value = "/createCustomUpNewCreative")
+    public JSONObject createCustomUpNewCreative(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("主键id不能为空");
+            }
+            AiKuaishouAccountAutoStrategy strategy = strategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Boolean unitOverrun = autoDoService.getUnitOverrun(strategy.getAccountId());
+            if (unitOverrun) {
+                log.error("****** 广告组创建超限,accountId:{}", strategy.getAccountId());
+                throw new Exception("今日广告组创建已超限");
+            }
+            customService.submit(() -> autoDoService.createCustomUpNewCreative(strategy));
+            returnJson.put("code", 0);
+            returnJson.put("message", "异步创建中");
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 每日补充创建创意 、频率 每天22点05分钟执行1次
+     */
+    @GetMapping(value = "/supplementTodayCreatives")
+    public JSONObject supplementTodayCreatives(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("主键id不能为空");
+            }
+            AiKuaishouAccountAutoStrategy strategy = strategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Boolean unitOverrun = autoDoService.getUnitOverrun(strategy.getAccountId());
+            if (unitOverrun) {
+                log.error("****** 广告组创建超限,accountId:{}", strategy.getAccountId());
+                throw new Exception("今日广告组创建已超限");
+            }
+            customService.submit(() -> autoDoService.supplementTodayCreatives(strategy));
+            returnJson.put("code", 0);
+            returnJson.put("message", "异步创建中");
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 创建自定义非上新广告创意 、频率 60分钟/次
      */
     @GetMapping(value = "/createCustomCreative")
     public JSONObject createCustomCreative(String id) {
@@ -58,7 +116,7 @@ public class AiKuaishouAccountAutoDoController {
     }
 
     /**
-     * 创建程序化广告创意
+     * 创建程序化广告创意 频率 60分钟/次
      */
     @GetMapping(value = "/createProgramCreative")
     public JSONObject createProgramCreative(String id) {

+ 79 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java

@@ -20,6 +20,8 @@ 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.DateUtils;
+import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -31,7 +33,6 @@ 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;
@@ -48,6 +49,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -81,6 +83,9 @@ public class AiKuaishouAccountAutoStrategyController {
     @Autowired
     private IAiKuaishouAdvertiserStrategyService aiKuaishouAdvertiserStrategyService;
 
+    @Autowired
+    private RedisUtil redisUtil;
+
     /**
      * 分页列表查询
      *
@@ -96,7 +101,7 @@ public class AiKuaishouAccountAutoStrategyController {
                                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                          HttpServletRequest req) {
         Result<PageInfo<AiKuaishouAccountAutoStrategy>> result = new Result<>();
-        if(Check.isNull(aiKuaishouAccountAutoStrategy.getUserId())){
+        if (Check.isNull(aiKuaishouAccountAutoStrategy.getUserId())) {
             result.setSuccess(false);
             result.setMessage("请选择用户");
             return result;
@@ -109,6 +114,7 @@ public class AiKuaishouAccountAutoStrategyController {
         PageInfo<AiKuaishouAccountAutoStrategy> pageInfo = aiKuaishouAccountAutoStrategyService.queryList(aiKuaishouAccountAutoStrategy);
         List<AiKuaishouAccountAutoStrategy> list = pageInfo.getList();
         List<AiKuaishouAccountAutoStrategy> setData = new ArrayList<>();
+        String date = DateUtils.formatDate(new Date());
         if (null != list && !list.isEmpty()) {
             list.forEach(record -> {
                 Long accountId = record.getAccountId();
@@ -116,6 +122,14 @@ public class AiKuaishouAccountAutoStrategyController {
                 if (null != allocation) {
                     record.setAuthName(allocation.getAuthName());
                 }
+                String customkey = date + "_auto_custom_cnt_" + accountId;
+                Integer customUnitCnt = (Integer) redisUtil.get(customkey);
+                customUnitCnt = Check.isNull(customUnitCnt) ? 0 : customUnitCnt;
+                record.setCustomCreatedUnitCnt(customUnitCnt);
+                String programkey = date + "_auto_program_cnt_" + accountId;
+                Integer programUnitCnt = (Integer) redisUtil.get(programkey);
+                programUnitCnt = Check.isNull(programUnitCnt) ? 0 : programUnitCnt;
+                record.setProgramCreatedUnitCnt(programUnitCnt);
             });
         }
         pageInfo.setList(list);
@@ -135,16 +149,18 @@ public class AiKuaishouAccountAutoStrategyController {
         }
         if (type == 1) {
             AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(accountId);
-            if (null != getEntity) {
-                return Result.error("该账户旧版自动投放配置信息已存在,请删除后再创建");
+            if (null != getEntity && getEntity.getStatus() == 1) {
+                return Result.error("该账户旧版自动投放策略已启动,请关闭后再创建");
             }
+
         } else {
             QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper();
             queryWrapper.eq("account_id", accountId).last("limit 1");
             AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
-            if (null != one) {
-                return Result.error("该账户重构版自动投放配置信息已存在,请删除后再创建");
+            if (null != one && one.getStatus() == 1) {
+                return Result.error("该账户重构版自动投放策略已启动,请关闭后再创建");
             }
+
         }
         return Result.ok("success");
     }
@@ -205,7 +221,7 @@ public class AiKuaishouAccountAutoStrategyController {
      * @return
      */
     @ApiOperation(value = "自动投放重构-账户策略表-编辑", notes = "自动投放重构-账户策略表-编辑")
-    @PutMapping(value = "/edit")
+    @PostMapping(value = "/edit")
     public Result<AiKuaishouAccountAutoStrategy> edit(@RequestBody AiKuaishouAccountAutoStrategy aiKuaishouAccountAutoStrategy) {
         Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
         AiKuaishouAccountAutoStrategy aiKuaishouAccountAutoStrategyEntity = aiKuaishouAccountAutoStrategyService.getById(aiKuaishouAccountAutoStrategy.getId());
@@ -213,7 +229,7 @@ public class AiKuaishouAccountAutoStrategyController {
             result.error500("未找到对应实体");
         } else {
             Integer singleAppId = aiKuaishouAccountAutoStrategy.getSingleAppid();
-            if (aiKuaishouAccountAutoStrategy.getCampaignType() == 2 || aiKuaishouAccountAutoStrategy.getCampaignType() == 7) {
+            if (aiKuaishouAccountAutoStrategyEntity.getCampaignType() == 2 || aiKuaishouAccountAutoStrategyEntity.getCampaignType() == 7) {
                 if (null != singleAppId && singleAppId == 1) {
                     Long appId = Long.valueOf(JSONArray.parseArray(aiKuaishouAccountAutoStrategy.getAppIdArray()).getString(0));
                     aiKuaishouAccountAutoStrategy.setAppId(appId);
@@ -230,6 +246,61 @@ public class AiKuaishouAccountAutoStrategyController {
     }
 
     /**
+     * 编辑
+     *
+     * @param aiKuaishouAccountAutoStrategy
+     * @return
+     */
+    @PostMapping(value = "/updateAppUrl")
+    public Result<AiKuaishouAccountAutoStrategy> updateAppUrl(@RequestBody AiKuaishouAccountAutoStrategy strategy) {
+        Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
+        if (Check.isNull(strategy.getAccountId())) {
+            result.error500("缺少账户数据");
+            return result;
+        }
+        QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", strategy.getAccountId()).last("limit 1");
+        AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
+        if (one == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = aiKuaishouAccountAutoStrategyService.update(strategy, queryWrapper);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 修改状态
+     *
+     * @return
+     */
+    @PostMapping(value = "/updateState")
+    public Result<AiKuaishouAccountAutoStrategy> updateState(@RequestBody AiKuaishouAccountAutoStrategy strategy) {
+        Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
+        AiKuaishouAccountAutoStrategy entity = aiKuaishouAccountAutoStrategyService.getById(strategy.getId());
+        if (entity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(entity.getAccountId());
+            if (null != getEntity && getEntity.getStatus() == strategy.getStatus() && strategy.getStatus() == 1) {
+                result.error500("修改失败,该账户旧版自动投放策略已运行");
+            } else {
+                boolean ok = aiKuaishouAccountAutoStrategyService.updateById(strategy);
+                if (ok) {
+                    result.success("修改成功!");
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /**
      * 通过id删除
      *
      * @param id

+ 4 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoTargetController.java

@@ -65,13 +65,13 @@ public class AiKuaishouAccountAutoTargetController {
      */
     @ApiOperation(value = "自动投放重构-本地定向表-分页列表查询", notes = "自动投放重构-本地定向表-分页列表查询")
     @GetMapping(value = "/list")
-    public Result<Object> queryPageList(Long accountId, String targetName, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+    public Result<Object> queryPageList(Long accountId, String targetName,Integer platformOs, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
-            if (Check.isNull(accountId)) {
-                return Result.error("请选择账户");
+            if (Check.isNull(accountId)||Check.isNull(platformOs)) {
+                return Result.error("缺少参数");
             }
-            return aiKuaishouAccountAutoTargetService.queryPageList(accountId, targetName, pageNo, pageSize);
+            return aiKuaishouAccountAutoTargetService.queryPageList(accountId, targetName,platformOs, pageNo, pageSize);
         } catch (Exception e) {
             log.error("查询异常,", e.getMessage());
             e.printStackTrace();

+ 19 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java

@@ -274,6 +274,11 @@ public class AiKuaishouAccountAutoStrategy {
     @Excel(name = "封面广告语标题", width = 15)
     @ApiModelProperty(value = "封面广告语标题")
     private String stickerTitle;
+
+    /**
+     * 行为意向-系统优选,0关闭,1开启
+     */
+    private Integer intentionTarget;
     /**
      * 贴纸样式类型
      */
@@ -335,10 +340,10 @@ public class AiKuaishouAccountAutoStrategy {
     @ApiModelProperty(value = "创意标签")
     private String creativeTag;
     /**
-     * 物料关联的封面个数
+     * 自定义创意数量
      */
-    @Excel(name = "物料关联的封面个数", width = 15)
-    @ApiModelProperty(value = "物料关联的封面个数")
+    @Excel(name = "自定义创意数量", width = 15)
+    @ApiModelProperty(value = "自定义创意数量")
     private Integer imageCnt;
     /**
      * 程序化创意2.0-是否开启智能抽帧
@@ -375,7 +380,7 @@ public class AiKuaishouAccountAutoStrategy {
      */
     @Excel(name = "深度转化出价", width = 15)
     @ApiModelProperty(value = "深度转化出价")
-    private BigDecimal deepConversionBid;
+    private String deepConversionBid;
     /**
      * 是否创建程序化创意
      */
@@ -491,4 +496,14 @@ public class AiKuaishouAccountAutoStrategy {
 
     @TableField(exist = false)
     private String authName;
+
+    @TableField(exist = false)
+    private int customCreatedUnitCnt;
+
+    @TableField(exist = false)
+    private int programCreatedUnitCnt;
+
+    //待建广告组数
+    @TableField(exist = false)
+    private int toBeBuiltCnt;
 }

+ 8 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoVideo.java

@@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.google.common.base.Objects;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -24,6 +25,7 @@ import java.util.Date;
  * @date 2021-10-20
  */
 @Data
+@AllArgsConstructor
 @TableName("ctop_ai_kuaishou_account_auto_video")
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
@@ -75,8 +77,8 @@ public class AiKuaishouAccountAutoVideo {
     /**
      * 使用时间
      */
-    @Excel(name = "使用时间", width = 15)
-    @ApiModelProperty(value = "使用时间")
+    @Excel(name = "素材创建时间", width = 15)
+    @ApiModelProperty(value = "素材创建时间")
     private String statDate;
     /**
      * MD5值
@@ -123,6 +125,10 @@ public class AiKuaishouAccountAutoVideo {
     @TableField(exist = false)
     private Long campaignId;
 
+    public AiKuaishouAccountAutoVideo() {
+
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o) {

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCreativeLevelOperationRecord.java

@@ -162,12 +162,13 @@ public class AiKuaishouCreativeLevelOperationRecord {
 
     }
 
-    public AiKuaishouCreativeLevelOperationRecord(AiKuaishouAccountAutoStrategy strategy, Integer creativeCode, JSONObject creativeParams, String creativeMessage, Long unitId, String uuid) {
+    public AiKuaishouCreativeLevelOperationRecord(AiKuaishouAccountAutoStrategy strategy, Integer creativeCode, JSONObject creativeParams, String creativeMessage,Long newCampaignId, Long unitId, String uuid) {
         BeanUtils.copyProperties(strategy, this);
         this.status = creativeCode;
         this.description = creativeParams.getString("description");
         this.photoId = creativeParams.getString("photo_id");
         this.message = creativeMessage;
+        this.campaignId = newCampaignId;
         this.unitId = unitId;
         this.aiStrategyUuid = uuid;
         this.createTime = new Date();

+ 25 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouProgramCreativeLevelOperationRecord.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.ai.entity;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -123,4 +124,28 @@ public class AiKuaishouProgramCreativeLevelOperationRecord {
      * 1:账户自动投放 2:项目自动投放
      */
     private Integer createType;
+
+    public AiKuaishouProgramCreativeLevelOperationRecord(){}
+
+    public AiKuaishouProgramCreativeLevelOperationRecord( JSONObject creativeParams ,Long campaignId, Long unitId, String uuid, String message) {
+        this.aiStrategyUuid = uuid;
+        this.accountId = creativeParams.getLong("advertiser_id");
+        this.campaignId = campaignId;
+        this.unitId = unitId;
+        this.packageName = creativeParams.getString("package_name");
+        this.horizontalPhotoIds = creativeParams.getString("hids");
+        this.verticalPhotoIds = creativeParams.getString("vids");
+        this.siteId = creativeParams.getInteger("site_id");
+        this.stickerStyles = creativeParams.getString("sticker_styles");
+        this.actionBar = creativeParams.getString("action_bar");
+        this.captions = creativeParams.getString("captions");
+        this.clickUrl = creativeParams.getString("click_url");
+        this.actionbarClickUrl = creativeParams.getString("actionbar_click_url");
+        this.creativeCategory = creativeParams.getInteger("creative_category");
+        this.creativeTag = creativeParams.getString("creative_tag");
+        this.createType = 3;
+        this.operationType = 1;
+        this.message = message;
+        this.createTime = new Date();
+    }
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoTargetMapper.java

@@ -15,7 +15,7 @@ import java.util.List;
  */
 public interface AiKuaishouAccountAutoTargetMapper extends BaseMapper<AiKuaishouAccountAutoTarget> {
 
-    List<AiKuaishouAccountAutoTarget> queryPageList(@Param("accountId") Long accountId, @Param("targetName") String targetName);
+    List<AiKuaishouAccountAutoTarget> queryPageList(@Param("accountId") Long accountId, @Param("targetName") String targetName,@Param("platformOs") Integer platformOs);
 
     List<AiKuaishouAccountAutoTarget> getAutoTargetByIds(@Param("ids") List<String> list);
 }

+ 7 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoVideoMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.ai.mapper;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,17 +18,19 @@ public interface AiKuaishouAccountAutoVideoMapper extends BaseMapper<AiKuaishouA
 
     void insertBatch(@Param("videoGetList") List<AiKuaishouAccountAutoVideo> videoGetList);
 
-    List<AiKuaishouAccountAutoVideo> getUpNewVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate, @Param("createType") String createType);
+    List<AiKuaishouAccountAutoVideo> getUpNewVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword")  List<String>  keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate, @Param("createType") String createType);
 
-    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("createType") String createType);
+    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword")  List<String>  keyword, @Param("videoCnt") Integer videoCnt, @Param("createType") String createType, @Param("statDate") String statDate);
 
-    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt);
+    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword")  List<String>  keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate);
 
-    List<AiKuaishouAccountAutoVideo> getZeroVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt);
+    List<AiKuaishouAccountAutoVideo> getZeroVideoByParams(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, @Param("statDate") String date);
 
     Integer getAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType);
 
     void addAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType, @Param("usageTimes") Integer usageTimes, @Param("date") String date);
 
     void updateAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType, @Param("usageTimes") Integer usageTimes, @Param("date") String date);
+
+    List<String> selectBatchByPhotoIds(@Param("details") JSONArray details, @Param("statDate") String statDate, @Param("accountId") Long accountId);
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoTargetMapper.xml

@@ -8,8 +8,9 @@
         FROM ctop_ai_kuaishou_account_auto_target
         where account_id = #{accountId}
         <if test="targetName != null">
-            and target_name = #{targetName}
+            and target_name LIKE CONCAT(CONCAT('%', #{targetName}), '%')
         </if>
+        AND (platform_os =0 or platform_os = #{platformOs})
         order by create_time desc
     </select>
 

+ 63 - 30
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml

@@ -5,25 +5,27 @@
     <insert id="insertBatch">
         replace into ctop_ai_kuaishou_account_auto_video(
         account_id,
+        custom_status,
+        program_status,
         photo_id,
-        status,
+        photo_name,
         material_type,
-        stat_date,
         channel_type,
-        signature,
-        photo_name
+        stat_date,
+        signature
         )
         values
         <foreach collection="videoGetList" item="video" separator=",">
             (
             #{video.accountId},
+            #{video.customStatus},
+            #{video.programStatus},
             #{video.photoId},
-            #{video.status},
+            #{video.photoName},
             #{video.materialType},
-            #{video.statDate},
             #{video.channelType},
-            #{video.signature},
-            #{video.photoName}
+            #{video.statDate},
+            #{video.signature}
             )
         </foreach>
     </insert>
@@ -32,20 +34,24 @@
     <select id="getUpNewVideos" resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo">
         SELECT * FROM ctop_ai_kuaishou_account_auto_video
         WHERE account_id = #{accountId}
-        <if test="createType ==custom">
+        <if test="createType == 'custom' ">
             AND custom_status = 1
         </if>
-        <if test="createType ==program">
+        <if test="createType == 'program'">
             AND program_status = 1
         </if>
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             AND channel_type = #{channelType}
         </if>
         <if test="statDate!=null">
             AND stat_date = #{statDate}
         </if>
-        <if test="keyword != null and keyword != '' ">
-            AND photo_name LIKE concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                photo_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         LIMIT #{videoCnt}
     </select>
@@ -54,15 +60,19 @@
         SELECT * FROM ctop_ai_kuaishou_account_auto_video
         WHERE custom_status = 1
         AND account_id = #{accountId}
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             AND channel_type = #{channelType}
         </if>
         <if test="statDate!=null">
             AND stat_date &lt; #{statDate}
             AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 7 day)
         </if>
-        <if test="keyword != null and keyword != '' ">
-            AND photo_name LIKE concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                photo_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         LIMIT #{videoCnt}
     </select>
@@ -76,31 +86,35 @@
         channel_type,
         material_type
         from ctop_material_top_cost
-        where t1.account_id = #{accountId}
+        where account_id = #{accountId}
         and md5 not in
         (
         SELECT signature FROM ctop_ai_kuaishou_account_auto_video_used
         WHERE account_id =#{accountId}
         AND video_type = 2
-        AND usage_times &lt;= 5
+        AND usage_times &gt;= 5
         <if test="createType !=null">
             AND create_type = #{createType}
         </if>
         AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 7 day)
         group by signature
         )
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             and channel_type = #{channelType}
         </if>
-        <if test="keyword != null and keyword != '' ">
-            and material_name like concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                material_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         group by signature
-        ORDER BY t2.7day_cost DESC
+        ORDER BY 7day_cost DESC
         LIMIT #{videoCnt}
     </select>
 
-    <select id="getHistoryCatchVideos" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+    <select id="getHistoryCatchVideos" resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo">
         select
         account_id,
         md5 as 'signature',
@@ -108,26 +122,30 @@
         material_name as 'photoName',
         channel_type,
         material_type
-        from ctop_material_top_cost
-        where t1.account_id = #{accountId}
+        from ctop_history_material_catch
+        where account_id = #{accountId}
         and md5 not in
         (
         SELECT signature FROM ctop_ai_kuaishou_account_auto_video_used
         WHERE account_id =#{accountId}
         AND video_type = 4
         AND create_type = 'custom'
-        AND usage_times &lt;= 2
+        AND usage_times &gt;= 2
         AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 60 day)
         group by signature
         )
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             and channel_type = #{channelType}
         </if>
-        <if test="keyword != null and keyword != '' ">
-            and material_name like concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                material_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         group by signature
-        ORDER BY t2.sum_cost DESC
+        ORDER BY sum_cost DESC
         LIMIT #{videoCnt}
     </select>
 
@@ -172,4 +190,19 @@
           AND video_type = #{videoType}
           AND create_type = #{createType}
     </update>
+
+    <select id="selectBatchByPhotoIds" resultType="java.lang.String">
+        SELECT photo_id
+        FROM ctop_ai_kuaishou_account_auto_video
+        WHERE account_id = #{accountId}
+        AND stat_date = #{statDate}
+        <if test="details!=null">
+            AND photo_id in
+            <foreach item="item" collection="details"
+                     open="(" separator="," close=")">
+                #{item.photo_id}
+            </foreach>
+        </if>
+    </select>
+
 </mapper>

+ 7 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoDoService.java

@@ -2,11 +2,12 @@ package cn.com.ctop.kuaishou.modules.ai.service;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoStrategy;
 
-import java.text.ParseException;
-
 public interface IAiKuaishouAccountAutoDoService {
 
-    //创建自定义广告创意
+    //创建自定义上新广告创意
+    void createCustomUpNewCreative(AiKuaishouAccountAutoStrategy strategy);
+
+    //创建自定义非上新广告创意
     void createCustomCreative(AiKuaishouAccountAutoStrategy strategy);
 
     //创建程序化广告创意
@@ -15,4 +16,7 @@ public interface IAiKuaishouAccountAutoDoService {
     // 组创建是否超限
     Boolean getUnitOverrun(Long accountId);
 
+    //每日补齐创建
+    void supplementTodayCreatives(AiKuaishouAccountAutoStrategy strategy);
+
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoTargetService.java

@@ -16,7 +16,7 @@ import java.util.List;
  */
 public interface IAiKuaishouAccountAutoTargetService extends IService<AiKuaishouAccountAutoTarget> {
 
-    Result<Object> queryPageList(Long accountId, String targetName, Integer pageNo, Integer pageSize);
+    Result<Object> queryPageList(Long accountId, String targetName,Integer platformOs, Integer pageNo, Integer pageSize);
 
     Result<Object> addLocalTarget(JSONObject requestJson);
 

+ 4 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoVideoService.java

@@ -15,16 +15,16 @@ import java.util.List;
 public interface IAiKuaishouAccountAutoVideoService extends IService<AiKuaishouAccountAutoVideo> {
 
     // 获取上新素材(自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType);
+    List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate, String createType);
 
     //获取7天高质量 (自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType);
+    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate, String createType);
 
     //获取遗漏素材:7天内未被创建过的素材(自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate);
+    List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate);
 
     //历史素材打捞(自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate);
+    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate);
 
     void insertAutoVideo(Long accountId);
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 759 - 322
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java


+ 9 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoTargetServiceImpl.java

@@ -29,9 +29,9 @@ public class AiKuaishouAccountAutoTargetServiceImpl extends ServiceImpl<AiKuaish
     private AiKuaishouAccountAutoTargetMapper accountAutoTargetMapper;
 
     @Override
-    public Result<Object> queryPageList(Long accountId, String targetName, Integer pageNo, Integer pageSize) {
+    public Result<Object> queryPageList(Long accountId, String targetName,Integer platformOs, Integer pageNo, Integer pageSize) {
         PageHelper.startPage(pageNo, pageSize);
-        List<AiKuaishouAccountAutoTarget> list = accountAutoTargetMapper.queryPageList(accountId, targetName);
+        List<AiKuaishouAccountAutoTarget> list = accountAutoTargetMapper.queryPageList(accountId, targetName,platformOs);
         return Result.ok(new PageInfo<>(list));
     }
 
@@ -62,12 +62,18 @@ public class AiKuaishouAccountAutoTargetServiceImpl extends ServiceImpl<AiKuaish
         wrapper.eq("target_name", requestJson.getString("targetName")).last("limit 1");
         AiKuaishouAccountAutoTarget one = this.getOne(wrapper);
         if (!Check.isNull(one) && one.getId() - requestJson.getLong("id") != 0) {
-            return Result.ok("账户下定向包名重复");
+            return Result.error("账户下定向包名重复");
         }
         AiKuaishouAccountAutoTarget target = JSONObject.toJavaObject(requestJson, AiKuaishouAccountAutoTarget.class);
         if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
             target.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
         }
+        if (!Check.isNull(target.getMax()) && target.getMax() == -1) {
+            target.setMax(null);
+        }
+        if (!Check.isNull(target.getMin()) && target.getMin() == -1) {
+            target.setMin(null);
+        }
         boolean update = this.saveOrUpdate(target);
         if (update) {
             return Result.ok("修改成功");

+ 24 - 17
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoVideoServiceImpl.java

@@ -43,23 +43,23 @@ public class AiKuaishouAccountAutoVideoServiceImpl extends ServiceImpl<AiKuaisho
     private ICtopOauthTokenService tokenService;
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType) {
+    public List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType, List<String> keyword, Integer videoCnt, String statDate, String createType) {
         return autoVideoMapper.getUpNewVideos(accountId, channelType, keyword, videoCnt, statDate, createType);
     }
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType) {
-        return autoVideoMapper.getHistoryTopVideos(accountId, channelType, keyword, videoCnt, createType);
+    public List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType, List<String> keyword, Integer videoCnt, String statDate, String createType) {
+        return autoVideoMapper.getHistoryTopVideos(accountId, channelType, keyword, videoCnt, createType, statDate);
     }
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate) {
-        return autoVideoMapper.getZeroVideoByParams(accountId, channelType, keyword, videoCnt);
+    public List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType, List<String> keyword, Integer videoCnt, String statDate) {
+        return autoVideoMapper.getZeroVideoByParams(accountId, channelType, keyword, videoCnt, statDate);
     }
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate) {
-        return autoVideoMapper.getHistoryCatchVideos(accountId, channelType, keyword, videoCnt);
+    public List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType, List<String> keyword, Integer videoCnt, String statDate) {
+        return autoVideoMapper.getHistoryCatchVideos(accountId, channelType, keyword, videoCnt, statDate);
     }
 
 
@@ -107,36 +107,43 @@ public class AiKuaishouAccountAutoVideoServiceImpl extends ServiceImpl<AiKuaisho
                 log.error("获取快手视频列表数据异常:{},accountId:{}", message, token.getAccountId());
                 return;
             }
-            JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
-            if (null == details || details.size() <= 0) {
+            JSONArray videoList = resultJson.getJSONObject("data").getJSONArray("details");
+            if (null == videoList || videoList.size() <= 0) {
                 log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
                 return;
             }
             Boolean doGet = true;
-            if (details.size() < pageSize) {
+            if (videoList.size() < pageSize) {
                 doGet = false;
             }
+            JSONArray details = new JSONArray();
+            for (int i = 0; i < videoList.size(); i++) {
+                JSONObject video = videoList.getJSONObject(i);
+                if (video != null && video.getInteger("new_status") == 1) {
+                    details.add(video);
+                }
+            }
+            if (Check.isNull(details) || details.isEmpty()) {
+                return;
+            }
 
             List<AiKuaishouAccountAutoVideo> videoGetList = new ArrayList<>();
+            Long accountId = token.getAccountId();
+            List<String> photoIds = autoVideoMapper.selectBatchByPhotoIds(details, date, accountId);
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detailJson = details.getJSONObject(i);
                 if (Check.isNull(detailJson)) {
                     continue;
                 }
                 String photoId = detailJson.getString("photo_id");
-                Long accountId = token.getAccountId();
-                QueryWrapper<AiKuaishouAccountAutoVideo> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("photo_id", photoId);
-                queryWrapper.eq("account_id", accountId).last("limit 1");
-                AiKuaishouAccountAutoVideo one = this.getOne(queryWrapper);
-                if (!Check.isNull(one)) {
+                if (!Check.isNull(photoIds) && photoIds.contains(photoId)) {
                     continue;
                 }
                 AiKuaishouAccountAutoVideo videoGet = new AiKuaishouAccountAutoVideo();
                 videoGet.setAccountId(accountId);
                 videoGet.setPhotoId(photoId);
                 videoGet.setPhotoName(detailJson.getString("photo_name"));
-                videoGet.setStatDate(date);
+                videoGet.setStatDate(DateUtils.formatDate(detailJson.getDate("create_time"), DateUtils.WEB_FORMAT));
                 String signature = detailJson.getString("signature");
                 videoGet.setSignature(signature);
                 Integer source = detailJson.getInteger("source");

+ 37 - 40
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -8,14 +8,35 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
-import cn.com.ctop.kuaishou.modules.ai.entity.*;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCampaignLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCreativeLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
-import cn.com.ctop.kuaishou.modules.ai.service.*;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreativeLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouUnitLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+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.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelService;
@@ -33,7 +54,14 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
 
 @Slf4j
 @Service
@@ -145,7 +173,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             //开始创建组+创意
                             String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appInfo.getAppId(), null);
                             JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId(), null);
-                            log.info("创建广告组入参:{}", unitParams);
                             Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                             Integer unitCode = (Integer) unitCreateResult.get("code");
                             String unitMessage = (String) unitCreateResult.get("message");
@@ -226,7 +253,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             unitParams.put("deep_conversion_bid", multipleBids.getDeepConversionBid());
                         }
                         strategy.setCpaBid(multipleBids.getCpaBid() + "");
-                        log.info("创建广告组入参:{}", unitParams);
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         String unitMessage = (String) unitCreateResult.get("message");
@@ -299,9 +325,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
                 if (null == newCampaignId) {
-                    if (!Check.isNull(channel)) {
-                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                    }
                     return videoCnt;
                 }
                 if (useChannel == 1) {
@@ -312,9 +335,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             if ("account".equals(level)) {
                                 usedchannel = channel;
                             } else {
-                                if (!Check.isNull(channel)) {
-                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                                }
                                 return videoCnt;
                             }
                         }
@@ -370,7 +390,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     }
                     String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, usedchannel);
                     JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
-                    log.info("创建广告组入参:{}", unitParams);
                     Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                     Integer unitCode = (Integer) unitCreateResult.get("code");
                     String unitMessage = (String) unitCreateResult.get("message");
@@ -389,9 +408,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     if (unitCode != 0) {
                         log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
@@ -399,7 +415,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     videoCnt--;
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
                     createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
@@ -411,9 +427,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("创建自定义广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         }
         return videoCnt;
@@ -514,7 +527,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             //创建组
                             String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appInfo.getAppId(), null);
                             JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId(), null);
-                            log.info("创建广告组入参:{}", unitParams);
                             Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                             Integer unitCode = (Integer) unitCreateResult.get("code");
                             String unitMessage = (String) unitCreateResult.get("message");
@@ -592,7 +604,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                                 unitParams.remove("deep_conversion_bid");
                                 unitParams.put("deep_conversion_bid", multipleBids.getDeepConversionBid());
                             }
-                            log.info("创建广告组入参:{}", unitParams);
                             Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                             Integer unitCode = (Integer) unitCreateResult.get("code");
                             String unitMessage = (String) unitCreateResult.get("message");
@@ -667,9 +678,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
                 if (null == newCampaignId) {
-                    if (!Check.isNull(channel)) {
-                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                    }
                     return;
                 }
                 if (useChannel == 1) {
@@ -680,9 +688,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             if ("account".equals(level)) {
                                 usedchannel = channel;
                             } else {
-                                if (!Check.isNull(channel)) {
-                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                                }
                                 return;
                             }
                         }
@@ -742,7 +747,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     //创建组
                     String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, usedchannel);
                     JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
-                    log.info("创建广告组入参:{}", unitParams);
                     Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                     Integer unitCode = (Integer) unitCreateResult.get("code");
                     String unitMessage = (String) unitCreateResult.get("message");
@@ -761,16 +765,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     if (unitCode != 0) {
                         log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
                     unitLevelOperationRecord.setUnitId(unitId);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
                     createProgramCreative(token, creativeParams, strategy);
@@ -778,9 +779,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("创建程序化广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         }
 
@@ -801,7 +799,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Long unitNum = customUnitCnt * hour / 20;
         log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -834,7 +832,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         log.info("{}当天可创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -853,7 +851,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
         String result = HttpUtils.kuaiShouhttpPostRequest(url, creativeParams.toJSONString(), headers);
         JSONObject resultJson = JSON.parseObject(result);
-        log.info("创建程序化创意返回结果:{}", resultJson);
         if (Check.isNull(resultJson)) {
             log.error("程序化创意创意异常:api接口返回为空");
             return;
@@ -1132,7 +1129,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         campaignId = (Long) campaignCreateResult.get("campaignId");
         if (!Check.isNull(channel)) {
-            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null, 1);
+            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null);
         }
         record.setCampaignId(campaignId);
         aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);

+ 3 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupTemplateController.java

@@ -110,16 +110,14 @@ public class KuaiShouGroupTemplateController {
      * @return
      */
     @GetMapping(value = "/getApiCreateCount")
-    public Result<Integer> getApiCreateCount(Long accountId) {
-        Result<Integer> result = new Result<>();
+    public Result<Object> getApiCreateCount(Long accountId) {
+        Result<Object> result = new Result<>();
         try {
             if (Check.isNull(accountId)) {
                 throw new Exception("accountId参数不能为空");
             }
             String date = DateUtils.getNowDate("yyyy-MM-dd");
-            Integer count = kuaiShouGroupTemplateService.getApiCreateCount(accountId, date);
-            result.setSuccess(true);
-            result.setResult(count);
+            return kuaiShouGroupTemplateService.getApiCreateCount(accountId, date);
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);

+ 35 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouTitleCollectionController.java

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTitleCollection;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouTitleCollectionService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -19,7 +21,15 @@ 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.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;
@@ -97,6 +107,30 @@ public class KuaiShouTitleCollectionController {
     }
 
     /**
+     * 添加
+     *
+     * @param kuaiShouTitleCollection
+     * @return
+     */
+    @PostMapping(value = "/addMore")
+    public Result<KuaiShouTitleCollection> addMore(@RequestBody JSONObject data) {
+        Result<KuaiShouTitleCollection> result = new Result<>();
+        try {
+            JSONArray titles = data.getJSONArray("titles");
+            KuaiShouTitleCollection kuaiShouTitleCollection = JSONObject.parseObject(data.toJSONString(), KuaiShouTitleCollection.class);
+            for (Object title : titles) {
+                kuaiShouTitleCollection.setTitle(title.toString());
+                kuaiShouTitleCollectionService.save(kuaiShouTitleCollection);
+            }
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
      * 编辑
      *
      * @param kuaiShouTitleCollection

+ 135 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java

@@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -127,7 +128,6 @@ public class KuaiShouVideoGetController {
             if (Check.isNull(orderBy)) {
                 throw new Exception("请传入排序方式");
             }
-
             List<KuaiShouVideoGetVo> list = new ArrayList<>();
             PageHelper.startPage(pageNo, pageSize);
             Map<String, Object> requestMap = new HashMap<>();
@@ -167,6 +167,140 @@ public class KuaiShouVideoGetController {
     }
 
 
+    @GetMapping(value = "/getBatchV2VideoList")
+    public Result<PageInfo<KuaiShouVideoGetVo>> getBatchV2VideoList(Long accountId,
+                                                                    String startDate,
+                                                                    String endDate,
+                                                                    String signatures,
+                                                                    Long photoId,
+                                                                    String photoName,
+                                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    HttpServletRequest req) {
+        Result<PageInfo<KuaiShouVideoGetVo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入账户id");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("accountId", accountId);
+
+            if (!Check.isNull(signatures)) {
+                String[] signatureArray = signatures.split(",");
+                requestMap.put("signatureList", signatureArray);
+            }
+
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                requestMap.put("startDate", startDate);
+                requestMap.put("endDate", endDate);
+            }
+
+            if (!Check.isNull(photoId)) {
+                requestMap.put("photoId", photoId);
+            }
+
+            if (!Check.isNull(photoName)) {
+                requestMap.put("photoName", photoName);
+            }
+            List<KuaiShouVideoGetVo> list = kuaiShouReportDailyMaterialService.getBatchV2VideoList(requestMap);
+            PageInfo<KuaiShouVideoGetVo> pageInfo = new PageInfo<>(list);
+            result.setSuccess(true);
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    @GetMapping(value = "/getVideoListByCostType")
+    public Result<PageInfo<KuaiShouVideoGetVo>> getBatchV2VideoList(Long accountId,
+                                                                    Long photoId,
+                                                                    String photoName,
+                                                                    Integer costType,
+                                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    HttpServletRequest req) {
+        Result<PageInfo<KuaiShouVideoGetVo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入账户id");
+            }
+
+            if (Check.isNull(costType)) {
+                throw new Exception("请传入数据类型");
+            }
+
+            PageHelper.startPage(pageNo, pageSize);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("accountId", accountId);
+
+            if (!Check.isNull(photoId)) {
+                requestMap.put("photoId", photoId);
+            }
+
+            if (!Check.isNull(photoName)) {
+                requestMap.put("photoName", photoName);
+            }
+            List<KuaiShouVideoGetVo> list = new ArrayList<>();
+            if (costType == 1) {  // 昨日数据
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+                Integer date = Integer.valueOf(anotherDay.replace("-", ""));
+                requestMap.put("date", date);
+                list = kuaiShouReportDailyMaterialService.getYesterdayVideo(requestMap);
+            } else if (costType == 2) { // 近七天
+                list = kuaiShouReportDailyMaterialService.get7dayVideo(requestMap);
+            } else if (costType == 3) { // 近14天
+                list = kuaiShouReportDailyMaterialService.get14dayVideo(requestMap);
+            } else if (costType == 4) { // 近30天
+                list = kuaiShouReportDailyMaterialService.get30dayVideo(requestMap);
+            } else if (costType == 5) { // 近3个月
+                String endMonth = DateUtils.getNowDate("yyyy-MM");
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String startMonthStr = DateUtils.addMonth(nowDate, -2);
+                String startMonth = DateUtils.formatDate(startMonthStr, "yyyy-MM");
+                requestMap.put("startMonth", Integer.valueOf(startMonth.replace("-", "")));
+                requestMap.put("endMonth", Integer.valueOf(endMonth.replace("-", "")));
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            } else if (costType == 6) { // 近6个月
+                String endMonth = DateUtils.getNowDate("yyyy-MM");
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String startMonthStr = DateUtils.addMonth(nowDate, -5);
+                String startMonth = DateUtils.formatDate(startMonthStr, "yyyy-MM");
+                requestMap.put("startMonth", Integer.valueOf(startMonth.replace("-", "")));
+                requestMap.put("endMonth", Integer.valueOf(endMonth.replace("-", "")));
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            } else if (costType == 7) { // 近12个月
+                String endMonth = DateUtils.getNowDate("yyyy-MM");
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String startMonthStr = DateUtils.addMonth(nowDate, -11);
+                String startMonth = DateUtils.formatDate(startMonthStr, "yyyy-MM");
+                requestMap.put("startMonth", Integer.valueOf(startMonth.replace("-", "")));
+                requestMap.put("endMonth", Integer.valueOf(endMonth.replace("-", "")));
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            } else if (costType == 8) { // 全部
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            }
+
+
+            PageInfo<KuaiShouVideoGetVo> pageInfo = new PageInfo<>(list);
+            result.setSuccess(true);
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
     public static Map<String, Object> parseJSON2Map(String jsonStr) {
         Map<String, Object> map = new HashMap<String, Object>();
         JSONObject json = JSONObject.parseObject(jsonStr);

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java

@@ -192,8 +192,8 @@ public class KuaiShouGroupTemplate {
     /**
      * 0:未提交 1:创建成功 2:创建失败
      */
-    @Excel(name = "0:未提交 1:创建成功 2:创建失败", width = 15)
-    @ApiModelProperty(value = "0:未提交 1:创建成功 2:创建失败")
+    @Excel(name = "0:未提交 1:创建中 2:创建成功  3:创建失败", width = 15)
+    @ApiModelProperty(value = "0:未提交 1:创建中 2:创建成功  3:创建失败")
     private Integer taskStatus;
     /**
      * 失败原因

+ 20 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/KuaiShouVideoGetVo.java

@@ -31,6 +31,8 @@ public class KuaiShouVideoGetVo implements Serializable {
     @Excel(name = "视频预览链接", width = 15)
     @ApiModelProperty(value = "视频预览链接")
     private String url;
+    private String photoName;
+    private Integer channelType;
     /**
      * 视频首帧图片链接
      */
@@ -77,6 +79,22 @@ public class KuaiShouVideoGetVo implements Serializable {
         this.url = url;
     }
 
+    public String getPhotoName() {
+        return photoName;
+    }
+
+    public void setPhotoName(String photoName) {
+        this.photoName = photoName;
+    }
+
+    public Integer getChannelType() {
+        return channelType;
+    }
+
+    public void setChannelType(Integer channelType) {
+        this.channelType = channelType;
+    }
+
     public String getCoverUrl() {
         return coverUrl;
     }
@@ -108,6 +126,8 @@ public class KuaiShouVideoGetVo implements Serializable {
                 ", statDate='" + statDate + '\'' +
                 ", photoId='" + photoId + '\'' +
                 ", url='" + url + '\'' +
+                ", photoName='" + photoName + '\'' +
+                ", channelType=" + channelType +
                 ", coverUrl='" + coverUrl + '\'' +
                 ", signature='" + signature + '\'' +
                 ", materialType=" + materialType +

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -25,4 +26,6 @@ public interface KuaiShouCampaignMapper extends BaseMapper<KuaiShouCampaign> {
     Long getCampaignIdByAccountAndName(@Param("accountId") Long accountId, @Param("name") String replaceString);
 
     Long getCampaignIdByAccountAndNameAndDate(@Param("accountId") Long accountId, @Param("name") String replaceString, @Param("nowDate") String nowDate);
+
+    List<JSONObject> getCampaignIdsByParameters(@Param("accountId") Long accountId, @Param("typeName") String typeName, @Param("nowDate") String nowDate);
 }

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTemplateMapper.java

@@ -18,9 +18,9 @@ public interface KuaiShouGroupTemplateMapper extends BaseMapper<KuaiShouGroupTem
 
     JSONObject getMd5ByPhotoId(@Param("photoId") String photoId);
 
-    List<JSONObject> getImageListByMd5(@Param("md5") String md5,@Param("imageCount") Integer imageCount);
+    List<JSONObject> getImageListByMd5(@Param("md5") String md5, @Param("imageCount") Integer imageCount);
 
-    Integer getApiCreateCount(@Param("accountId") Long accountId, @Param("date") String date);
+    Integer getApiCreateCount(@Param("accountId") Long accountId, @Param("date") String date, @Param("unitType") Integer unitType);
 
     JSONObject getUrlByPhotoId(@Param("photoId") String photoId);
 

+ 12 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java

@@ -47,4 +47,16 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
     JSONObject labelMaterialAll(@Param("companyId") String companyId, @Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
     List<EtlKuaishouAccountMaterialReportDaily> getReportList(@Param("accountId") Long accountId,@Param("statDate") String statDate,@Param("projectId") Long projectId, @Param("projectName") String projectName);
+
+    List<KuaiShouVideoGetVo> getBatchV2VideoList(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> getYesterdayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get7dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get14dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get30dayVideo(Map<String, Object> requestMap);
+
+    void get3MonthVideo(Map<String, Object> requestMap);
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java

@@ -61,4 +61,6 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
     List<JSONObject> getVideoListByDate(@Param("startDate") Date startDate,@Param("endDate") Date endDate);
 
     List<String> getDateList();
+
+    List<KuaiShouVideoGet> getVideoListByPhotoIds(@Param("photoIds") JSONArray photoIds,@Param("accountId")Long accountId);
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouAppListMapper.xml

@@ -34,7 +34,7 @@
     </insert>
 
     <select id="getAppNames" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList">
-        SELECT account_id,app_id,app_version,app_name,package_name
+        SELECT account_id,app_id,app_version,app_name,package_name,platform
         FROM ctop_kuaishou_app_list
         WHERE app_id IN
         <foreach collection="appIds" item="item" separator=","

+ 27 - 19
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml

@@ -36,38 +36,46 @@
 
     <select id="queryIdsByPutStatus" resultType="java.lang.Long">
         SELECT campaign_id
-        FROM
-        ctop_kuaishou_campaign
+        FROM ctop_kuaishou_campaign
         WHERE account_id = #{accountId}
-        AND put_status = #{putStatus}
+          AND put_status = #{putStatus}
     </select>
     <select id="queryCampaignIdByAccountId" resultType="java.lang.Long">
         SELECT campaign_id
-        FROM
-        ctop_kuaishou_campaign
+        FROM ctop_kuaishou_campaign
         WHERE account_id = #{accountId}
     </select>
     <select id="getNewDataByAccountIdAndDate" resultType="java.lang.Integer">
-     select
-     count(1)
-     from ctop_kuaishou_campaign
-     where account_id = #{accountId}
-     and DATE_FORMAT(put_create_time,'%Y-%m-%d') = #{statDate}
+        select count(1)
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and DATE_FORMAT(put_create_time, '%Y-%m-%d') = #{statDate}
     </select>
     <select id="getCampaignIdByAccountAndName" resultType="java.lang.Long">
-        select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
-        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
-        order by put_create_time DESC
-        limit 1
+        select campaign_id
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and campaign_name like CONCAT('%', CONCAT(#{name}, '%'))
+        order by put_create_time DESC limit 1
 
 
     </select>
     <select id="getCampaignIdByAccountAndNameAndDate" resultType="java.lang.Long">
-          select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
-        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
-        and put_create_time &gt;= #{nowDate}
-        order by put_create_time DESC
-        limit 1
+        select campaign_id
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and campaign_name like CONCAT('%', CONCAT(#{name}, '%'))
+          and put_create_time &gt;= #{nowDate}
+        order by put_create_time DESC limit 1
 
     </select>
+
+    <select id="getCampaignIdsByParameters" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT campaign_id as 'campaignId',
+               (SELECT COUNT(1) FROM ctop_kuaishou_group WHERE campaign_id = t.campaign_id) AS 'count'
+        FROM ctop_kuaishou_campaign t
+        WHERE account_id = #{accountId}
+          AND campaign_name LIKE CONCAT('%', CONCAT(#{typeName}, '%'))
+          AND put_create_time &gt;= #{nowDate}
+    </select>
 </mapper>

+ 6 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml

@@ -31,11 +31,12 @@
 
 
     <select id="getApiCreateCount" resultType="java.lang.Integer">
-    select count(1)
-    from
-    ctop_kuaishou_creative
-    where  account_id = #{accountId}
-    and DATE_FORMAT(creative_create_time,'%Y-%m-%d') = #{date}
+        select count(1)
+        from
+            ctop_kuaishou_group
+        where  account_id = #{accountId}
+          and unit_type = #{unitType}
+          and DATE_FORMAT(group_create_time,'%Y-%m-%d') =  #{date}
     </select>
 
     <select id="getUrlByPhotoId" resultType="com.alibaba.fastjson.JSONObject">

+ 162 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -873,7 +873,8 @@
         ORDER BY k1.zhenren_charge DESC,k3.zhizuo_charge DESC
         )t
     </select>
-    <select id="getReportList" resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily">
+    <select id="getReportList"
+            resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily">
         SELECT
         #{projectId} as 'projectId',
         #{projectName} as 'projectName',
@@ -926,5 +927,165 @@
         GROUP BY
 	    t1.photo_id;
     </select>
+    <select id="getBatchV2VideoList" resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.photo_id AS 'photoId',
+        t1.url AS 'url',
+        t1.cover_url AS 'coverUrl',
+        t1.signature AS 'signature',
+        t1.stat_date as 'statDate',
+        t1.photo_name as 'photoName',
+        t1.channel_type as 'channelType'
+        FROM
+        ctop_kuaishou_video_get t1
+        where t1.account_id = #{accountId}
+        and t1.status = 0
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+
+        <if test="startDate != null and startDate != '' ">
+            and t1.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and t1.stat_date &lt;= #{endDate}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.photo_name like CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        <if test="signatureList != null and signatureList != '' ">
+            and t1.signature in
+            <foreach collection="signatureList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        order by t1.stat_date desc
+    </select>
+
+
+
+    <select id="getYesterdayVideo"
+            resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.kuaishou_material_video_report_daily_dw t1
+        WHERE
+        t1.account_id = #{accountId}
+        AND t1.stat_date = #{date}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get7dayVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.app_kuaishou_video_report_busi_7d t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get14dayVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.app_kuaishou_video_report_busi_14d t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get30dayVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.app_kuaishou_video_report_busi_30d t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get3MonthVideo">
+        SELECT
+        t.*
+        FROM
+        (
+        SELECT
+        t1.signature AS 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        sum( t1.charge ) AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoNaem'
+        FROM
+        `application`.app_kuaishou_video_report_busi_m t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="startMonth != null and startMonth != '' ">
+            and t1.stat_mon &gt;= #{startMonth}
+        </if>
+        <if test="endMonth != null and endMonth != '' ">
+            and t1.stat_mon &lt;= #{endMonth}
+        </if>
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        GROUP BY
+        t1.photo_id
+        ) t
+        ORDER BY
+        t.charge DESC
+    </select>
 </mapper>
 

+ 14 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -404,4 +404,18 @@
             #{videoGet.id}
         </foreach>
     </update>
+
+    <select id="getVideoListByPhotoIds" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+        SELECT
+            photo_id,
+            cover_url,
+            material_type
+        FROM ctop_kuaishou_video_get
+        WHERE account_id = #{accountId}
+          AND photo_id IN
+        <foreach item="phtotId" index="index" collection="photoIds" open="(" separator="," close=")">
+            #{phtotId}
+        </foreach>
+    </select>
+
 </mapper>

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -27,4 +28,6 @@ public interface IKuaiShouCampaignService extends IService<KuaiShouCampaign> {
     Long getCampaignIdByAccountAndName(Long accountId, String replaceString);
 
     Long getCampaignIdByAccountAndNameAndDate(Long accountId, String replaceString, String nowDate);
+
+    List<JSONObject> getCampaignIdsByParameters(Long accountId, String typeName, String nowDate);
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupTemplateService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
 
@@ -24,7 +25,7 @@ public interface IKuaiShouGroupTemplateService extends IService<KuaiShouGroupTem
      * @param accountId
      * @return
      */
-    Integer getApiCreateCount(Long accountId, String date);
+    Result<Object> getApiCreateCount(Long accountId, String date);
 
     /**
      * 通过photoId 获取 url

+ 12 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java

@@ -32,4 +32,16 @@ public interface IKuaiShouReportDailyMaterialService extends IService<KuaiShouRe
     Result<Object> labelMaterialList(String companyId,String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize);
 
     List<EtlKuaishouAccountMaterialReportDaily> getReportList(Long accountId, String statDate, Long projectId, String projectName);
+
+    List<KuaiShouVideoGetVo> getBatchV2VideoList(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> getYesterdayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get7dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get14dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get30dayVideo(Map<String, Object> requestMap);
+
+    void get3MonthVideo(Map<String, Object> requestMap);
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java

@@ -66,4 +66,6 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     List<JSONObject> getVideoListByDate(Date startDate, Date endDate);
 
     List<String> getDateList();
+
+    List<KuaiShouVideoGet> getVideoListByPhotoIds(JSONArray photoIds,Long accountId);
 }

+ 0 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java

@@ -500,9 +500,7 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         };
                         thread2.start();
                     }
-
                 } else {
-
                     if (code == 500000 && count <= 4) {
                         adUnitCreate(requestJson, count + 1);
                     }

+ 6 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCampaignServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 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 org.springframework.beans.factory.annotation.Autowired;
@@ -91,4 +92,9 @@ public class KuaiShouCampaignServiceImpl extends ServiceImpl<KuaiShouCampaignMap
         return campaignMapper.getCampaignIdByAccountAndNameAndDate(accountId, replaceString, nowDate);
     }
 
+    @Override
+    public List<JSONObject> getCampaignIdsByParameters(Long accountId, String typeName, String nowDate) {
+        return campaignMapper.getCampaignIdsByParameters(accountId, typeName, nowDate);
+    }
+
 }

+ 116 - 76
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -332,11 +332,41 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     private void addGroupV2(Long advertiserId, JSONArray details) {
 
         JSONObject json = warningOperationService.getBidTypeAndMaxBid(advertiserId);
-        Long maxBid = json.getLong("maxBid");// 最高出价
-        String bidTypeStr = json.getString("bidType"); // 出价方式
-        JSONArray bidTypeArr = JSONArray.parseArray(bidTypeStr);
-        String ocpxActionTypeStr = json.getString("ocpxActionType"); // 优化目标
-        JSONArray ocpxArr = JSONArray.parseArray(ocpxActionTypeStr);
+        if (Check.isNull(json) || Check.isNull(details)) {
+            return;
+        }
+
+        // 最高出价
+        Long maxBid = json.getLong("maxBid");
+
+        //优化目标集
+        List<Integer> bidList = null;
+        String bidTypeStr = json.getString("bidType");
+        if (!Check.isNull(bidTypeStr)) {
+            bidList = JSONArray.parseArray(bidTypeStr, Integer.class);
+        }
+
+        //转化目标map
+        Map<Integer, Long> ocpxMap = new HashMap<>();
+        String ocpxTypeStr = json.getString("ocpxActionType");
+        if (!Check.isNull(ocpxTypeStr)) {
+            JSONArray ocpxArr = JSONArray.parseArray(ocpxTypeStr);
+            for (int i = 0; i < ocpxArr.size(); i++) {
+                JSONObject obj = ocpxArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("ocpxCode"), obj.getLong("maxValue"));
+            }
+        }
+
+        //深度转化目标map
+        Map<Integer, Long> deepMap = new HashMap<>();
+        String deepTypeStr = json.getString("deepConversionType");
+        if (!Check.isNull(deepTypeStr)) {
+            JSONArray deepArr = JSONArray.parseArray(deepTypeStr);
+            for (int i = 0; i < deepArr.size(); i++) {
+                JSONObject obj = deepArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("deepCode"), obj.getLong("deepValue"));
+            }
+        }
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();
             List<KuaiShouAppInfo> appInfos = new ArrayList<>();
@@ -345,98 +375,108 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detail = JSONObject.parseObject(details.get(i).toString());
                 if (!Check.isNull(detail)) {
-                    Integer bid_type = detail.getInteger("bid_type");
+                    //优化目标
+                    Integer bidType = detail.getInteger("bid_type");
+                    //优化出价(只有单击时,才有值)
                     Long bid = detail.getLong("bid");
-                    Long cpa_bid = detail.getLong("cpa_bid");
-                    Long day_budget = detail.getLong("day_budget");
-                    Integer ocpx_action_type = detail.getInteger("ocpx_action_type");
+                    //转化目标
+                    Integer ocpxActionType = detail.getInteger("ocpx_action_type");
+                    //转化目标出价
+                    Long cpaBid = detail.getLong("cpa_bid");
+                    //深度转化目标
+                    Integer deepConversionType = detail.getInteger("deep_conversion_type");
+                    //深度转化目标出价
+                    Long deepConversionBid = detail.getLong("deep_conversion_bid");
+                    //单日预算
+                    Long dayBudget = detail.getLong("day_budget");
+                    //组ID
                     Long unitId = detail.getLong("unit_id");
-                    String unit_name = detail.getString("unit_name");
+                    //组名称
+                    String unitName = detail.getString("unit_name");
+                    //状态
                     Integer status = detail.getInteger("status");
-                    Integer put_status = detail.getInteger("put_status");
-                    if (put_status == 1) { // 组状态为 投放中的
-                        if (status != 15) { // 广告组状态为非暂停
-                            Boolean bidTypeTrueOrFalse = false;
-                            for (int j = 0; j < bidTypeArr.size(); j++) {
-                                Integer bidType = (Integer) bidTypeArr.get(j);
-                                if (bidType.equals(bid_type)) {
-                                    bidTypeTrueOrFalse = true;
-                                    break;
+                    //投放状态
+                    Integer putStatus = detail.getInteger("put_status");
+                    if (putStatus == 1 && status != 15) { // 组状态为 投放中的 and 广告组状态为非暂停
+                        Boolean typeFalg = true;
+                        Boolean bidFalg = true;
+
+                        //优化目标
+                        if (!bidList.isEmpty()) {
+                            if (!bidList.contains(bidType)) {
+                                //项目不包含该优化目标,则关停
+                                typeFalg = false;
+                            } else if (bidType == 2 && bid > maxBid) {
+                                //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
+                                bidFalg = false;
+                            }
+                        }
+                        //转化目标
+                        if (!Check.isNull(ocpxActionType) && ocpxActionType != 0) {
+                            //!=0是设置过转化目标
+                            if (!Check.isNullMap(ocpxMap)) {
+                                Long ocpxBid = ocpxMap.get(ocpxActionType);
+                                if (Check.isNull(ocpxBid)) {
+                                    if (ocpxActionType == 2 && dayBudget != 0 && dayBudget <= 500 * 1000) {
+                                        // 转化目标为2行为数,并且预算小于等于500且不是不限,则允许启动
+                                        typeFalg = true;
+                                    }else{
+                                        //通过key未获取值,说明不包含该目标,进行关停
+                                        typeFalg = false;
+                                    }
+                                } else {
+                                    if (cpaBid > ocpxBid) {
+                                        //组转化出价 大于 项目设置最大转化出价,则关停
+                                        bidFalg = false;
+                                    }
                                 }
+                            }else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
+                                // 转化目标为2行为数,并且预算大于500 或者不限,则关停
+                                typeFalg = false;
                             }
+                        }
 
-                            Boolean ocpxTrueOrFalse = false;
-                            if (ocpx_action_type == 0) {
-                                ocpxTrueOrFalse = true;
+                        //转化目标
+                        if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !deepMap.isEmpty()) {
+                            Long deepBid = deepMap.get(deepConversionType);
+                            if (Check.isNull(deepBid)) {
+                                //通过key未获取值,说明不包含该目标,进行关停
+                                typeFalg = false;
                             } else {
-                                for (int j = 0; j < ocpxArr.size(); j++) {
-                                    Integer ocpxActionType = (Integer) ocpxArr.get(j);
-                                    if (ocpxActionType.equals(ocpx_action_type)) {
-                                        ocpxTrueOrFalse = true;
-                                        break;
-                                    }
+                                if (deepConversionBid > deepBid) {
+                                    //组深度转化出价 大于 项目设置最大转化出价,则关停
+                                    bidFalg = false;
                                 }
                             }
+                        }
 
-
-                            if (!bidTypeTrueOrFalse || !ocpxTrueOrFalse) { // 出价方式设置非法
-                                if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
-                                    executorBidTypeService.submit(new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                        }
-                                    });
+                        if (!typeFalg) { // 出价方式设置非法
+                            executorBidTypeService.submit(new Runnable() {
+                                @Override
+                                public void run() {
+                                    warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unitName);
                                 }
-                            }
-                            if (bid > maxBid || cpa_bid > maxBid) {
-                                executorMaxBidService.submit(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                    }
-                                });
-                            }
+                            });
+                        }
+                        if (!bidFalg) {
+                            executorMaxBidService.submit(new Runnable() {
+                                @Override
+                                public void run() {
+                                    warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unitName);
+                                }
+                            });
                         }
                     }
 
-                    KuaiShouGroup group = new KuaiShouGroup();
+                    KuaiShouGroup group = JSONObject.parseObject(detail.toJSONString(), KuaiShouGroup.class);
                     group.setId("" + advertiserId + unitId);
                     group.setAccountId(advertiserId);
-                    group.setCampaignId(detail.getLong("campaign_id"));
-                    group.setUnitId(unitId);
-                    group.setUnitName(unit_name);
-                    group.setStatus(status);
-                    group.setPutStatus(put_status);
-                    group.setCreateChannel(detail.getInteger("create_channel"));
-                    group.setReviewDetail(detail.getString("review_detail"));
-                    group.setBidType(bid_type);
-                    group.setBid(bid);
-                    group.setCpaBid(detail.getLong("cpa_bid"));
-                    group.setOcpxActionType(ocpx_action_type);
-                    group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
-                    group.setDeepConversionBid(detail.getLong("deep_conversion_bid"));
-                    group.setDayBudget(detail.getLong("day_budget"));
-                    group.setSpeed(detail.getInteger("speed"));
-                    group.setBeginTime(detail.getString("begin_time"));
-                    group.setEndTime(detail.getString("end_time"));
-                    group.setScheduleTime(detail.getString("schedule_time"));
-                    group.setSceneId(detail.getJSONArray("scene_id") + "");
-                    group.setShowMode(detail.getInteger("show_mode"));
-                    group.setUnitType(detail.getInteger("unit_type"));
-                    group.setUrlType(detail.getInteger("url_type"));
-                    group.setUrl(detail.getString("url"));
-                    group.setSchemaUri(detail.getString("schema_uri"));
-                    group.setAppId(detail.getLong("app_id"));
-                    group.setAppIconUrl(detail.getString("app_icon_url"));
                     group.setGroupCreateTime(detail.getString("create_time"));
                     group.setGroupUpdateTime(detail.getString("update_time"));
-                    group.setConvertId(detail.getLong("convert_id"));
-                    group.setUseAppMarket(detail.getInteger("use_app_market"));
-                    group.setAppStore(detail.getJSONArray("app_store") + "");
                     group.setCreateTime(new Date());
                     group.setUpdateTime(new Date());
                     groups.add(group);
+
                     // 添加应用信息
                     JSONObject diverseJson = detail.getJSONObject("diverse_data");
                     if (!Check.isNull(diverseJson)) {

+ 254 - 29
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java

@@ -3,22 +3,38 @@ package cn.com.ctop.kuaishou.modules.batch.service.impl;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
 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.KuaishouTemplateTarget;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTemplateMapper;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+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.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -44,7 +60,8 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
     private IKuaiShouMaterialUploadService uploadService;
     @Autowired
     private IKuaishouTemplateTargetService templateTargetService;
-
+    @Autowired
+    private IKuaiShouVideoGetService kuaiShouVideoGetService;
     static ExecutorService executorService = Executors.newFixedThreadPool(5);
 
     /**
@@ -73,19 +90,30 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
             throw new Exception("请选择需要创建的视频");
         }
 
+        Integer imageCount = requestJson.getInteger("imageCount");
+
         Integer createType = requestJson.getInteger("createType"); // 创建类型 0 单品 1 混搭
-        if (Check.isNull(createType)) {
-            throw new Exception("请选择创意创建方式混搭、单品");
-        }
+        Integer unitType = requestJson.getInteger("unitType"); // 7程序化。4自定义
+        List<List<String>> photoIdsList = null;
+        if (unitType == 4) {
+            if (Check.isNull(createType)) {
+                throw new Exception("请选择创意创建方式混搭、单品");
+            }
 
-        if (createType == 0 && createCount != photoArr.size()) {
-            throw new Exception("单品视频数量必须和创建数量保持一致");
-        }
+            if (createType == 0 && createCount != photoArr.size()) {
+                throw new Exception("单品视频数量必须和创建数量保持一致");
+            }
 
-        if (createType == 1 && createCount * 15 != photoArr.size()) {
-            throw new Exception("混搭视频数量必须和创建数量保持倍数关系");
+            if (createType == 1 && createCount * 15 != photoArr.size()) {
+                throw new Exception("混搭视频数量必须和创建数量保持倍数关系");
+            }
+        } else {
+            List<String> photoIds = JSONArray.parseObject(photoArr.toJSONString(), List.class);
+            photoIdsList = Lists.newArrayList(Lists.partition(photoIds, imageCount));
+            if (createCount != photoIdsList.size()) {
+                throw new Exception("程序化视频数量必须和创建数量保持倍数关系");
+            }
         }
-
         JSONObject returnJson = new JSONObject();
         String userId = requestJson.getString("userId");
         String unitName = requestJson.getString("unitName");
@@ -125,22 +153,23 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                 startNumber = requestJson.getInteger("startNumber");
             }
         }
-        Integer imageCount = requestJson.getInteger("imageCount");
 
         List<KuaiShouGroupTemplate> templates = new ArrayList<>();
         for (int i = 0; i < createCount; i++) {
             KuaiShouGroupTemplate template = new KuaiShouGroupTemplate();
             template.setCreateType(createType);
-            if (createType == 0) { // 创建方式为单品
+            if (!Check.isNull(createType) && createType == 0) { // 创建方式为单品
                 Long photoId = photoArr.getLong(i);
                 template.setPhotoId(photoId);
-            } else if (createType == 1) { // 创建方式为混搭
+            } else if (!Check.isNull(createType) && createType == 1) { // 创建方式为混搭
                 JSONArray photoIds = getPhotoIds(photoArr, i);
                 if (Check.isNull(photoIds)) {
                     log.error("根据下标未获取到详细信息");
                     continue;
                 }
                 template.setPhotoIds(photoIds.toJSONString());
+            } else {
+                template.setPhotoIds(photoIdsList.get(i).toString());
             }
             String name = "";
             if (!unitName.contains("{{序号}}")) {
@@ -365,9 +394,6 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         if (!Check.isNull(template.getDeepConversionBid())) {
             createUnitJson.put("deep_conversion_bid", template.getDeepConversionBid()); //深度转化目标出价
         }
-        if (!Check.isNull(template.getUnitType())) {
-            createUnitJson.put("unit_type", template.getUnitType()); //创意制作方式
-        }
         if (!Check.isNull(template.getBeginTime())) {
             createUnitJson.put("begin_time", template.getBeginTime()); //投放开始时间
         }
@@ -402,6 +428,10 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         if (!Check.isNull(template.getSpeed())) {
             createUnitJson.put("speed", template.getSpeed()); // 投放方式
         }
+        if (!Check.isNull(template.getUnitType())) {
+            createUnitJson.put("unit_type", template.getUnitType()); //创意制作方式
+        }
+
         Map<String, Object> groupMap = iKuaishouInterfaceService.adUnitCreate(token.getAccessToken(), accountId, createUnitJson, 1);
         updateTemplate = new KuaiShouGroupTemplate();
         updateTemplate.setId(template.getId());
@@ -410,13 +440,23 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
             updateTemplate.setTaskStatus(2);
             Long unit = (Long) groupMap.get("unitId");
             updateTemplate.setUnitId((unit));
-            Thread thread = new Thread() {
-                @Override
-                public void run() {
-                    createCreative(token.getAccessToken(), unit, template);
-                }
-            };
-            thread.start();
+            if (template.getUnitType() == 4) {
+                Thread thread = new Thread() {
+                    @Override
+                    public void run() {
+                        createCreative(token.getAccessToken(), unit, template);
+                    }
+                };
+                thread.start();
+            } else {
+                Thread thread = new Thread() {
+                    @Override
+                    public void run() {
+                        createProgramCreative(token.getAccessToken(), unit, template);
+                    }
+                };
+                thread.start();
+            }
         } else {
             updateTemplate.setTaskStatus(3);
             updateTemplate.setReviewDetail((String) groupMap.get("message"));
@@ -564,8 +604,16 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
      * @return
      */
     @Override
-    public Integer getApiCreateCount(Long accountId, String date) {
-        return groupTemplateMapper.getApiCreateCount(accountId, date);
+    public Result<Object> getApiCreateCount(Long accountId, String date) {
+        //自定义
+        Integer ctmCount = groupTemplateMapper.getApiCreateCount(accountId, date, 4);
+        //程序化
+        Integer pgdCount = groupTemplateMapper.getApiCreateCount(accountId, date, 7);
+        JSONObject obj = new JSONObject();
+        obj.put("ctmCount", ctmCount);
+        obj.put("pgdCount", pgdCount);
+        return Result.ok(obj);
+
     }
 
     /**
@@ -608,6 +656,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
             createJson.put("creative_tag", JSONArray.parseArray(template.getCreativeTag()));
         }
 
+        JSONArray descriptionList = JSONArray.parseArray(template.getDescription());
         JSONArray creatives = new JSONArray();
         Integer createType = template.getCreateType();
         if (createType == 0) { // 单品
@@ -629,13 +678,14 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                 json.put("photo_id", template.getPhotoId());
                 json.put("creative_material_type", materialType);
                 json.put("action_bar_text", template.getActionBarText());
-                json.put("description", template.getDescription());
+                json.put("description", getOneDescription(descriptionList));
                 if (!Check.isNull(template.getSiteId())) {
                     json.put("site_id", template.getSiteId());
                 }
                 creatives.add(json);
             } else {
                 for (int i = 0; i < imageList.size(); i++) {
+
                     JSONObject imageJson = imageList.get(i);
                     if (Check.isNull(imageJson)) {
                         continue;
@@ -651,7 +701,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                     json.put("photo_id", template.getPhotoId());
                     json.put("creative_material_type", materialType);
                     json.put("action_bar_text", template.getActionBarText());
-                    json.put("description", template.getDescription());
+                    json.put("description", getOneDescription(descriptionList));
                     if (!Check.isNull(template.getSiteId())) {
                         json.put("site_id", template.getSiteId());
                     }
@@ -690,7 +740,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                 json.put("photo_id", photoId);
                 json.put("creative_material_type", materialType);
                 json.put("action_bar_text", template.getActionBarText());
-                json.put("description", template.getDescription());
+                json.put("description", getOneDescription(descriptionList));
                 if (!Check.isNull(template.getSiteId())) {
                     json.put("site_id", template.getSiteId());
                 }
@@ -711,6 +761,160 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         this.updateById(updateTemplate);
     }
 
+    private String getOneDescription(JSONArray descriptionList) {
+        if (!Check.isNull(descriptionList)) {
+            int number = new Random().nextInt(descriptionList.size());
+            return descriptionList.getString(number);
+        }
+        return null;
+    }
+
+    private void createProgramCreative(String accessToken, Long unitId, KuaiShouGroupTemplate template) {
+        KuaiShouGroupTemplate updateTemplate = new KuaiShouGroupTemplate();
+        updateTemplate.setId(template.getId());
+        updateTemplate.setCreativeStatus(1);
+        updateTemplate.setCreativeReviewDetail("创意创建中");
+        updateTemplate.setUnitId(unitId);
+        this.updateById(updateTemplate);
+        JSONObject createJson = new JSONObject();
+        Long accountId = template.getAccountId();
+        createJson.put("advertiser_id", accountId);
+        createJson.put("unit_id", unitId);
+        createJson.put("package_name", template.getCreativeName());
+
+        JSONArray photoIds = JSONArray.parseArray(template.getPhotoIds());
+        if (Check.isNull(photoIds)) {
+            updateTemplate.setCreativeStatus(3);
+            updateTemplate.setCreativeReviewDetail("未获取到PhotoIds");
+            this.updateById(updateTemplate);
+            return;
+        }
+        //素材列表
+        List<KuaiShouVideoGet> videos = kuaiShouVideoGetService.getVideoListByPhotoIds(photoIds, accountId);
+        if (Check.isNull(videos) || videos.isEmpty()) {
+            updateTemplate.setCreativeStatus(3);
+            updateTemplate.setCreativeReviewDetail("未获取到素材信息");
+            this.updateById(updateTemplate);
+            return;
+        }
+        // 程序化视频数
+        Integer imageCount = template.getImageCount();
+        if (imageCount < 3) {
+            log.error("视频数小于3个,不执行创建");
+            return;
+        }
+
+        //落地页 ID
+        if (!Check.isNull(template.getSiteId()) && !"-1".equals(template.getSiteId())) {
+            createJson.put("site_id", template.getSiteId());
+        }
+        //行动号召按钮
+        if (!Check.isNull(template.getActionBarText())) {
+            createJson.put("action_bar", template.getActionBarText());
+        }
+        //第三方点击检测链接
+        if (!Check.isNull(template.getClickTrackUrl())) {
+            createJson.put("click_url", template.getClickTrackUrl());
+        }
+        //第三方 ActionBar 点击监控链接
+        if (!Check.isNull(template.getActionbarClickUrl())) {
+            createJson.put("actionbar_click_url", template.getActionbarClickUrl());
+        }
+        //创意分类 与创意标签同时传或同时不传
+        if (!Check.isNull(template.getCreativeCategory())) {
+            createJson.put("creative_category", template.getCreativeCategory());
+            createJson.put("creative_tag", JSONArray.parseArray(template.getCreativeTag()));
+        }
+        //作品广告语
+        createJson.put("captions", getCaptions(template.getDescription()));
+
+        JSONArray photoList = new JSONArray();
+        for (KuaiShouVideoGet video : videos) {
+            JSONObject photo = new JSONObject();
+            photo.put("photo_id", video.getPhotoId());//视频 ID
+            photo.put("cover_image_token", null);//封面图片 token,通过上传图片接口获得,不传值则直接使用视频的首帧作为封面图片
+            photo.put("creative_material_type", video.getMaterialType());//1:竖版视频 2:横版视频
+            photoList.add(photo);
+        }
+        createJson.put("photo_list", photoList);
+        Map<String, Object> creativeMap = this.createProgramCreatives(accountId, accessToken, createJson, 1);
+        Integer code = (Integer) creativeMap.get("code");
+        if (code == 0) {
+            updateTemplate.setCreativeStatus(2);
+            updateTemplate.setCreativeReviewDetail("创建程序化2.0创意成功");
+        } else {
+            updateTemplate.setCreativeStatus(3);
+            updateTemplate.setCreativeReviewDetail((String) creativeMap.get("message"));
+        }
+        this.updateById(updateTemplate);
+    }
+
+    /**
+     * 创建程序化创意
+     */
+    private Map<String, Object> createProgramCreatives(Long accountId, String token, JSONObject creativeParams, int count) {
+        Map<String, Object> returnMap = new HashMap<>();
+        try {
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", token);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, creativeParams.toJSONString(), headers);
+            JSONObject resultJson = JSON.parseObject(result);
+            if (Check.isNull(resultJson)) {
+                log.error("程序化创意创意异常:api接口返回为空");
+                returnMap.put("code", -1);
+                returnMap.put("message", "程序化创意创意异常:api接口返回为空");
+                returnMap.put("success", false);
+                return returnMap;
+            }
+            Integer code = resultJson.getInteger("code");
+            String message = resultJson.getString("message");
+            Long unitId = creativeParams.getLong("unit_id");
+            if (code == 0) {
+                createLandPageAndUnit(creativeParams, resultJson.getJSONObject("data"));
+                returnMap.put("code", 0);
+                returnMap.put("message", "success");
+                returnMap.put("success", true);
+            } else {
+                log.error("批量2.0创建程序化创意失败,入参:{},返回结果:{}", creativeParams.toString(), resultJson.toString());
+                if ("系统错误".equals(message) && count <= 3) {
+                    log.info("第{}次重新创建程序化创意", count);
+                    //系统错误,则重新执行
+                    return createProgramCreatives(accountId, token, creativeParams, count + 1);
+                }
+                returnMap.put("code", -1);
+                returnMap.put("message", resultJson.getString("message"));
+                returnMap.put("success", false);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("执行创建程序化创意异常", e);
+            returnMap.put("code", -1);
+            returnMap.put("message", "执行创建程序化创意异常");
+            returnMap.put("success", false);
+        }
+        return returnMap;
+    }
+
+    /**
+     * 绑定落地页与广告组、创意的关系
+     */
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+
+    private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
+        if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                }
+            };
+            thread.start();
+        }
+    }
+
 
     private String getImageToken(String md5, Long accountId, String accessToken, String url) {
 
@@ -730,4 +934,25 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         return imageToken;
 
     }
+
+
+    /**
+     * 获取程序化广告语
+     */
+    private JSONArray getCaptions(String description) {
+        JSONArray jsonArray = JSONArray.parseArray(description);
+        if (jsonArray.size() <= 3) {
+            return jsonArray;
+        }
+        //重置顺序
+        Collections.shuffle(jsonArray);
+        JSONArray captions = new JSONArray();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            captions.add(jsonArray.getString(i));
+            if (captions.size() == 3) {
+                break;
+            }
+        }
+        return captions;
+    }
 }

+ 30 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java

@@ -15,7 +15,6 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -148,6 +147,36 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
     }
 
     @Override
+    public List<KuaiShouVideoGetVo> getBatchV2VideoList(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.getBatchV2VideoList(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> getYesterdayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.getYesterdayVideo(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> get7dayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.get7dayVideo(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> get14dayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.get14dayVideo(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> get30dayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.get30dayVideo(requestMap);
+    }
+
+    @Override
+    public void get3MonthVideo(Map<String, Object> requestMap) {
+        dailyMaterialMapper.get3MonthVideo(requestMap);
+    }
+
+    @Override
     public List<KuaiShouReportDailyMaterial> getSignatureByDate(String date) {
         return dailyMaterialMapper.getSignatureByDate(date);
     }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -381,10 +381,10 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         deleteMap.put("account_id", advertiserId);
                         deleteMap.put("unit_id", unitId);
                         groupMapper.deleteByMap(deleteMap);
+                        log.info("删除成功,accountId:{}。unitId:{}", advertiserId, unitId);
                     } else {
                         groupService.getGroupByUnitId(token, advertiserId, unitId);
                     }
-                    log.info("删除成功,accountId:{}。unitId:{}", advertiserId, unitId);
                 } else {
                     log.error("修改广告组状态失败,advertiserId:{},unitId:{},返回信息:{}", advertiserId, unitId, resultJson);
                     returnMap.put("code", -1);

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -359,4 +359,9 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     public List<String> getDateList() {
         return videoGetMapper.getDateList();
     }
+
+    @Override
+    public List<KuaiShouVideoGet> getVideoListByPhotoIds(JSONArray photoIds,Long accountId) {
+        return videoGetMapper.getVideoListByPhotoIds(photoIds, accountId);
+    }
 }

+ 327 - 134
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -8,18 +8,68 @@ import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 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.ai.service.*;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.JsonUtil;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiCreativeLimitService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListChildren;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAdvertiserBaseInfoMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListChildrenMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouOverRunSendMessageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.entity.*;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
-import cn.com.ctop.kuaishou.modules.report.service.*;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyAccountService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -54,7 +104,11 @@ import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -165,6 +219,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
         if (null == details || details.size() <= 0) {
+            log.error("快手时报返回详情为空,accountId:{}", token.getAccountId());
             return;
         }
         List<KuaishouReportHourlyAccount> addList = new ArrayList<>();
@@ -181,6 +236,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             addList.add(kuaishouReportHourlyAccount);
         }
         hourlyAccountService.replaceBatch(addList);
+        log.info("获取账户时报数据完成,accountId:{}", token.getAccountId());
     }
 
 
@@ -222,9 +278,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
                 return;
             }
-            Boolean doGet = true;
-            if (details.size() < page_size) {
-                doGet = false;
+            Boolean toGet = false;
+            if (details.size() >= page_size) {
+                toGet = true;
             }
 
             List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
@@ -270,16 +326,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             if (!Check.isNull(videoGetList)) {
                 videoGetService.replaceBatch(videoGetList);
             }
-            if (doGet) {
+
+            if (toGet) {
                 getVideoListByPage(token, startDate, endDate, page + 1);
             }
-
         } catch (Exception e) {
             e.printStackTrace();
         }
 
     }
 
+
     private void getCut(String token, Long accountId, String signature, String photo_id) {
         cutExecutorService.submit(new Runnable() {
             @Override
@@ -290,6 +347,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
+
     @Override
     public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate, String reportDims) {
         try {
@@ -978,7 +1036,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
 
                 } else {
-                    if (code == 400001 && "/rest/openapi/v2/ad_unit/create调用已超日限,次日可恢复调用".equals(resultJson.getString("message"))) {
+                    if (code == 400001 && resultJson.getString("message").equals("/rest/openapi/v2/ad_unit/create调用已超日限,次日可恢复调用")) {
                         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                         String key = advertiserId + "_" + nowDate + "unit_create_overrun";
                         redisUtil.set(key, 1, 60 * 60 * 24);
@@ -1197,6 +1255,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+    @Autowired
+    IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
     private void getGroupListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
@@ -1227,128 +1288,163 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             return;
         }
         addGroup(token.getAccountId(), details);
+        //   ruleKuaiShouPlanService.insertTarget(token.getAccountId(), details);
         getGroupListByPage(token, startDate, endDate, page + 1);
     }
 
     static ExecutorService executorBidTypeService = Executors.newFixedThreadPool(20);
     static ExecutorService executorMaxBidService = Executors.newFixedThreadPool(5);
 
-    private void addGroup(Long advertiserId, JSONArray details) {
-        JSONObject json = warningOperationService.getBidTypeAndMaxBid(advertiserId);
-        Long maxBid = json.getLong("maxBid");// 最高出价
-        String bidTypeStr = json.getString("bidType"); // 出价方式
-        JSONArray bidTypeArr = JSONArray.parseArray(bidTypeStr);
-        String ocpxActionTypeStr = json.getString("ocpxActionType"); // 优化目标
-        JSONArray ocpxArr = JSONArray.parseArray(ocpxActionTypeStr);
-        if (!Check.isNull(details)) {
-            List<KuaiShouGroup> groups = new ArrayList<>();
-            for (int i = 0; i < details.size(); i++) {
-                JSONObject detail = JSONObject.parseObject(details.get(i).toString());
-                if (!Check.isNull(detail)) {
-                    Integer bid_type = detail.getInteger("bid_type");
-                    Long bid = detail.getLong("bid");
-                    Long cpa_bid = detail.getLong("cpa_bid");
-                    Long day_budget = detail.getLong("day_budget");
-                    Integer ocpx_action_type = detail.getInteger("ocpx_action_type");
-                    Long unitId = detail.getLong("unit_id");
-                    String unit_name = detail.getString("unit_name");
-                    Integer status = detail.getInteger("status");
-                    Integer put_status = detail.getInteger("put_status");
-                    if (put_status == 1) { // 组状态为 投放中的
-                        if (status != 15) { // 广告组状态为非暂停
-                            Boolean bidTypeTrueOrFalse = false;
-                            for (int j = 0; j < bidTypeArr.size(); j++) {
-                                Integer bidType = (Integer) bidTypeArr.get(j);
-                                if (bidType.equals(bid_type)) {
-                                    bidTypeTrueOrFalse = true;
-                                    break;
+    private void addGroup(Long accountId, JSONArray details) {
+        JSONObject project = warningOperationService.getBidTypeAndMaxBid(accountId);
+        if (Check.isNull(project) || Check.isNull(details)) {
+            return;
+        }
+
+        // 最高出价
+        Long maxBid = project.getLong("maxBid");
+
+        //优化目标集
+        List<Integer> bidList = null;
+        String bidTypeStr = project.getString("bidType");
+        if (!Check.isNull(bidTypeStr)) {
+            bidList = JSONArray.parseArray(bidTypeStr, Integer.class);
+        }
+
+        //转化目标map
+        Map<Integer, Long> ocpxMap = new HashMap<>();
+        String ocpxTypeStr = project.getString("ocpxActionType");
+        if (!Check.isNull(ocpxTypeStr)) {
+            JSONArray ocpxArr = JSONArray.parseArray(ocpxTypeStr);
+            for (int i = 0; i < ocpxArr.size(); i++) {
+                JSONObject obj = ocpxArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("ocpxCode"), obj.getLong("maxValue"));
+            }
+        }
+
+        //深度转化目标map
+        Map<Integer, Long> deepMap = new HashMap<>();
+        String deepTypeStr = project.getString("deepConversionType");
+        if (!Check.isNull(deepTypeStr)) {
+            JSONArray deepArr = JSONArray.parseArray(deepTypeStr);
+            for (int i = 0; i < deepArr.size(); i++) {
+                JSONObject obj = deepArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("deepCode"), obj.getLong("deepValue"));
+            }
+        }
+        List<KuaiShouGroup> groups = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detail = JSONObject.parseObject(details.get(i).toString());
+            if (!Check.isNull(detail)) {
+                //优化目标
+                Integer bidType = detail.getInteger("bid_type");
+                //优化出价(只有单击时,才有值)
+                Long bid = detail.getLong("bid");
+                //转化目标
+                Integer ocpxActionType = detail.getInteger("ocpx_action_type");
+                //转化目标出价
+                Long cpaBid = detail.getLong("cpa_bid");
+                //深度转化目标
+                Integer deepConversionType = detail.getInteger("deep_conversion_type");
+                //深度转化目标出价
+                Long deepConversionBid = detail.getLong("deep_conversion_bid");
+                //单日预算
+                Long dayBudget = detail.getLong("day_budget");
+                //组ID
+                Long unitId = detail.getLong("unit_id");
+                //组名称
+                String unitName = detail.getString("unit_name");
+                //状态
+                Integer status = detail.getInteger("status");
+                //投放状态
+                Integer putStatus = detail.getInteger("put_status");
+                if (putStatus == 1 && status != 15) { // 组状态为 投放中的 and 广告组状态为非暂停
+                    Boolean typeFalg = true;
+                    Boolean bidFalg = true;
+
+                    //优化目标
+                    if (!bidList.isEmpty()) {
+                        if (!bidList.contains(bidType)) {
+                            //项目不包含该优化目标,则关停
+                            typeFalg = false;
+                        } else if (bidType == 2 && bid > maxBid) {
+                            //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
+                            bidFalg = false;
+                        }
+                    }
+                    //转化目标
+                    if (!Check.isNull(ocpxActionType) && ocpxActionType != 0) {
+                        //!=0是设置过转化目标
+                        if (!Check.isNullMap(ocpxMap)) {
+                            Long ocpxBid = ocpxMap.get(ocpxActionType);
+                            if (Check.isNull(ocpxBid)) {
+                                if (ocpxActionType == 2 && dayBudget != 0 && dayBudget <= 500 * 1000) {
+                                    // 转化目标为2行为数,并且预算小于等于500且不是不限,则允许启动
+                                    typeFalg = true;
+                                }else{
+                                //通过key未获取值,说明不包含该目标,进行关停
+                                typeFalg = false;
                                 }
-                            }
-                            Boolean ocpxTrueOrFalse = false;
-                            if (ocpx_action_type == 0) {
-                                ocpxTrueOrFalse = true;
                             } else {
-                                for (int j = 0; j < ocpxArr.size(); j++) {
-                                    Integer ocpxActionType = (Integer) ocpxArr.get(j);
-                                    if (ocpxActionType.equals(ocpx_action_type)) {
-                                        ocpxTrueOrFalse = true;
-                                        break;
-                                    }
+                                if (cpaBid > ocpxBid) {
+                                    //组转化出价 大于 项目设置最大转化出价,则关停
+                                    bidFalg = false;
                                 }
                             }
+                        }else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
+                            // 转化目标为2行为数,并且预算大于500 或者不限,则关停
+                            typeFalg = false;
+                        }
+                    }
 
-
-                            if (!bidTypeTrueOrFalse || !ocpxTrueOrFalse) { // 出价方式设置非法
-                                if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
-                                    executorBidTypeService.submit(new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                        }
-                                    });
-                                }
-                            }
-                            if (bid > maxBid || cpa_bid > maxBid) {
-                                executorMaxBidService.submit(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                    }
-                                });
+                    //转化目标
+                    if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !deepMap.isEmpty()) {
+                        Long deepBid = deepMap.get(deepConversionType);
+                        if (Check.isNull(deepBid)) {
+                            //通过key未获取值,说明不包含该目标,进行关停
+                            typeFalg = false;
+                        } else {
+                            if (deepConversionBid > deepBid) {
+                                //组深度转化出价 大于 项目设置最大转化出价,则关停
+                                bidFalg = false;
                             }
                         }
                     }
 
-                    KuaiShouGroup group = new KuaiShouGroup();
-                    group.setId("" + advertiserId + unitId);
-                    group.setAccountId(advertiserId);
-                    group.setCampaignId(detail.getLong("campaign_id"));
-                    group.setUnitId(unitId);
-                    group.setUnitName(unit_name);
-                    group.setStatus(status);
-                    group.setPutStatus(put_status);
-                    group.setStudyStatus(detail.getInteger("study_status"));
-                    group.setCreateChannel(detail.getInteger("create_channel"));
-                    group.setReviewDetail(detail.getString("review_detail"));
-                    group.setBidType(bid_type);
-                    group.setBid(bid);
-                    group.setStudyStatus(detail.getInteger("study_status"));
-                    group.setCpaBid(cpa_bid);
-                    group.setOcpxActionType(ocpx_action_type);
-                    group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
-                    group.setDeepConversionBid(detail.getLong("deep_conversion_bid"));
-                    group.setDayBudget(day_budget);
-                    group.setSpeed(detail.getInteger("speed"));
-                    group.setBeginTime(detail.getString("begin_time"));
-                    group.setEndTime(detail.getString("end_time"));
-                    group.setScheduleTime(detail.getString("schedule_time"));
-                    group.setSceneId(detail.getJSONArray("scene_id") + "");
-                    group.setShowMode(detail.getInteger("show_mode"));
-                    group.setUnitType(detail.getInteger("unit_type"));
-                    group.setUrlType(detail.getInteger("url_type"));
-                    group.setUrl(detail.getString("url"));
-                    group.setSchemaUri(detail.getString("schema_uri"));
-                    group.setAppId(detail.getLong("app_id"));
-                    group.setAppIconUrl(detail.getString("app_icon_url"));
-                    group.setGroupCreateTime(detail.getString("create_time"));
-                    group.setGroupUpdateTime(detail.getString("update_time"));
-                    group.setConvertId(detail.getLong("convert_id"));
-                    group.setUseAppMarket(detail.getInteger("use_app_market"));
-                    group.setAppStore(detail.getJSONArray("app_store") + "");
-                    group.setCreateTime(new Date());
-                    group.setUpdateTime(new Date());
-                    groups.add(group);
-                    // 添加应用信息
-                }
-            }
-            if (!Check.isNull(groups)) {
-                try {
-                    Thread.sleep(200L);
-                    groupMapper.replaceBatch(groups);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
+                    if (!typeFalg) { // 出价方式设置非法
+                        executorBidTypeService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                warningOperationService.kuaiShouWarningOperation(project.getLong("projectId"), project.getString("projectName"), accountId, unitId, unitName);
+                            }
+                        });
+                    }
+                    if (!bidFalg) {
+                        executorMaxBidService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                warningOperationService.kuaiShouBidWarningOperation(project.getLong("projectId"), project.getString("projectName"), accountId, unitId, unitName);
+                            }
+                        });
+                    }
                 }
 
+                KuaiShouGroup group = JSONObject.parseObject(detail.toJSONString(), KuaiShouGroup.class);
+                group.setId("" + accountId + unitId);
+                group.setAccountId(accountId);
+                group.setGroupCreateTime(detail.getString("create_time"));
+                group.setGroupUpdateTime(detail.getString("update_time"));
+                group.setCreateTime(new Date());
+                group.setUpdateTime(new Date());
+                groups.add(group);
+            }
+        }
+        if (!Check.isNull(groups)) {
+            try {
+                Thread.sleep(200L);
+                groupMapper.replaceBatch(groups);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
             }
         }
     }
@@ -1901,13 +1997,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNullMap(dataJson)) {
                         JSONObject returnJson = new JSONObject();
-                        returnJson.put("isAdWatch5times", dataJson.getInteger("is_ad_watch_5_times"));
-                        returnJson.put("isAdWatch20times", dataJson.getInteger("is_ad_watch_20_times"));
-                        returnJson.put("isAdWatch10Times", dataJson.getInteger("is_ad_watch_10_times"));
-                        returnJson.put("isSevenDayRoi", dataJson.getInteger("is_seven_day_roi"));
-                        returnJson.put("isAppointJumpClick", dataJson.getInteger("is_appoint_jump_click"));
-                        returnJson.put("isEventWeekPayTimes", dataJson.getInteger("is_event_week_pay_times"));
-                        returnJson.put("isAppointForm", dataJson.getInteger("is_appoint_form"));
                         returnJson.put("isActivate", dataJson.getInteger("is_activate"));
                         returnJson.put("isFormSubmit", dataJson.getInteger("is_form_submit"));
                         returnJson.put("isCreditGrant", dataJson.getInteger("is_credit_grant"));
@@ -1919,10 +2008,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnJson.put("isOrderSubmit", dataJson.getInteger("is_order_submit"));
                         returnJson.put("isAddWechat", dataJson.getInteger("is_add_wechat"));
                         returnJson.put("isAppInvoked", dataJson.getInteger("is_app_invoked"));
-                        returnJson.put("isMultiConversion", dataJson.getInteger("is_multi_conversion"));
                         returnJson.put("isAdWatchTimes", dataJson.getInteger("is_ad_watch_times"));
+                        returnJson.put("isMultiConversion", dataJson.getInteger("is_multi_conversion"));
                         returnJson.put("isOrderPaied", dataJson.getInteger("is_order_paied"));
+                        returnJson.put("isEventWeekPayTimes", dataJson.getInteger("is_event_week_pay_times"));
                         returnJson.put("isKeyAction", dataJson.getInteger("is_key_action"));
+                        returnJson.put("isAppointForm", dataJson.getInteger("is_appoint_form"));
+                        returnJson.put("isSevenDayRoi", dataJson.getInteger("is_seven_day_roi"));
+                        returnJson.put("isAdWatch10Times", dataJson.getInteger("is_ad_watch_10_times"));
+                        returnJson.put("isAdWatch20Times", dataJson.getInteger("is_ad_watch_20_times"));
+                        returnJson.put("isAdWatch5Times", dataJson.getInteger("is_ad_watch_5_times"));
 
                         JSONArray deep_conversion_types = dataJson.getJSONArray("deep_conversion_types");
                         JSONArray deepConversionTypes = new JSONArray();
@@ -2080,15 +2175,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 if (code == 0) {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
-                        JSONArray addCreativeIds = dataJson.getJSONArray("add_creative_ids");
-                        if (!Check.isNull(addCreativeIds)) {
+                        JSONArray add_creative_ids = dataJson.getJSONArray("add_creative_ids");
+                        if (!Check.isNull(add_creative_ids)) {
                             Thread thread = new Thread() {
                                 @Override
                                 public void run() {
                                     try {
                                         Thread.sleep(100);
-                                        getCreativeByCreativeIds(accessToken, advertiserId, addCreativeIds);
-                                        createLandPageAndUnit(requestJson, addCreativeIds);
+                                        getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
+                                        createLandPageAndUnit(requestJson, add_creative_ids);
                                     } catch (InterruptedException e) {
                                         e.printStackTrace();
                                     }
@@ -2102,8 +2197,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("code", 0);
                         returnMap.put("message", "success");
                         returnMap.put("success", true);
-                        returnMap.put("count", addCreativeIds.size());
-                        returnMap.put("ids",addCreativeIds);
+                        returnMap.put("count", add_creative_ids.size());
+                        returnMap.put("ids", add_creative_ids);
                     }
                 } else {
                     if (code == 500000 && count <= 4) {
@@ -2868,6 +2963,97 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouVideoGetService videoGetService;
     static ExecutorService suZhaoService = Executors.newFixedThreadPool(15);
 
+   /* @Override
+    public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("advertiser_id", accountId);
+        param.put("page", page);
+        param.put("page_size", 200);
+        if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+            param.put("start_date", startDate);
+            param.put("end_date", endDate);
+        }
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println(resultJson);
+        if (Check.isNull(resultJson)) {
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手素造列表数据异常:{},accountId:{}", message, accountId);
+            return;
+        }
+        JSONObject dataJson = resultJson.getJSONObject("data");
+        if (Check.isNull(dataJson)) {
+            return;
+        }
+
+
+        JSONArray details = dataJson.getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+
+        List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            if (Check.isNull(detailJson)) {
+                continue;
+            }
+            KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+            String photo_id = detailJson.getString("photo_id");
+            videoGet.setId(accountId + photo_id);
+            videoGet.setAccountId(accountId);
+            videoGet.setCoverUrl(detailJson.getString("cover_url"));
+            videoGet.setPhotoId(photo_id);
+            videoGet.setPhotoName(detailJson.getString("photo_name"));
+            videoGet.setStatDate(detailJson.getDate("upload_time"));
+            String signature = detailJson.getString("signature");
+            videoGet.setSignature(signature);
+            Integer source = detailJson.getInteger("source");
+            if (source == 2) {
+                videoGet.setChannelType(1);
+            } else {
+                videoGet.setChannelType(0);
+            }
+            Integer new_status = detailJson.getInteger("new_status");
+            if (new_status == 1) {
+                videoGet.setStatus(0);
+            } else {
+                videoGet.setStatus(1);
+            }
+            videoGet.setUrl(detailJson.getString("url"));
+            Integer width = detailJson.getInteger("width");
+            videoGet.setWidth(width);
+            Integer height = detailJson.getInteger("height");
+            videoGet.setHeight(height);
+            Integer type = MaterialEnum.getTypeBySize(width, height);
+            if (!Check.isNull(type)) {
+                videoGet.setMaterialType(type);
+            }
+            videoGetList.add(videoGet);
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    videoGetService.getKeyFrame(token, accountId, signature, photo_id);
+                }
+            };
+            thread.start();
+        }
+        if (!Check.isNull(videoGetList)) {
+            videoGetService.replaceBatch(videoGetList);
+        }
+
+        getSuZaoList(token, accountId, page + 1, startDate, endDate);
+
+    }*/
+
     @Autowired
     private IMaterialCutFrameService cutFrameService;
     private static ExecutorService executorService = Executors.newFixedThreadPool(10);
@@ -2884,6 +3070,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             JSONObject param = new JSONObject();
             param.put("advertiser_id", accountId);
             param.put("page_size", 200);
+
+           /* Map<String, Object> deleteMap = new HashMap<>();
+            deleteMap.put("account_id", accountId);
+            deleteMap.put("campaign_id", campaignId);
+            creativeService.removeByMap(deleteMap);*/
             QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
             groupQueryWrapper.eq("account_id", accountId);
             groupQueryWrapper.eq("campaign_id", campaignId);
@@ -2998,6 +3189,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             e.printStackTrace();
 
         }
+
+
     }
 
     /**
@@ -3182,11 +3375,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             appList.setAppId(dataJson.getLong("app_id"));
                             appList.setAppVersion(dataJson.getString("app_version"));
                             appList.setAppName(dataJson.getString("app_name"));
-                            appList.setAppPrivacyUrl(dataJson.getString("app_privacy_url"));
                             appList.setAppIconUrl(dataJson.getString("app_icon_url"));
                             appList.setImageToken(dataJson.getString("image_token"));
                             appList.setPackageName(dataJson.getString("package_name"));
                             appList.setReturnTime(DateUtils.timeStamp2Date(dataJson.getTimestamp("update_time")));
+                            appList.setAppPrivacyUrl(dataJson.getString("app_privacy_url"));
                             addList.add(appList);
                         }
                     }

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/WarningOperationServiceImpl.java

@@ -68,7 +68,7 @@ public class WarningOperationServiceImpl implements IWarningOperationService {
         warningOperationLog.setUserId(userId);
         warningOperationLog.setWarningType(1);
         warningOperationLogService.save(warningOperationLog);
-        log.info("暂停组成功,accountId:{},unitId:{}", advertiserId, unitId);
+        log.info("出价方式预警,暂停组成功,accountId:{},unitId:{}", advertiserId, unitId);
         try {
             String text = messageTemplate.getKuaiShouBidTypeMessage(projectName, advertiserId, unitId, unit_name);
 
@@ -97,6 +97,7 @@ public class WarningOperationServiceImpl implements IWarningOperationService {
         try {
             String text = messageTemplate.getKuaiShouBidMessage(projectName, advertiserId, unitId, unit_name);
             sendMessageService.sendMessage(userId, text);
+
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -111,6 +112,7 @@ public class WarningOperationServiceImpl implements IWarningOperationService {
         warningOperationLog.setUserId(userId);
         warningOperationLog.setWarningType(2);
         warningOperationLogService.save(warningOperationLog);
+        log.info("出价过高预警,暂停组成功,accountId:{},unitId:{}", advertiserId, unitId);
 
     }
 }

+ 8 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelMapper.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.kuaishou.modules.channel.mapper;
 
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
-import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelCreateStrategy;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -51,4 +50,12 @@ public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
     List<JSONObject> queryChannelList(@Param("accountId") Long accountId, @Param("appName") String appName);
 
     List<KuaishouChannel> queryChannelListByAccount(@Param("accountId") Long accountId);
+
+    List<KuaishouChannel> getAccountLevelRepeatChannel(@Param("accountId") Long accountId, @Param("appName") String appName);
+
+    List<KuaishouChannel> getAccountLevelNoRepeatChannel(@Param("accountId") Long accountId, @Param("appName") String appName);
+
+    KuaishouChannel getChannelEntity(@Param("accountId") Long accountId);
+
+    List<KuaishouChannel> queryNoAccountLevelNoRepeatChannel(@Param("usageLevel") String usageLevel, @Param("accountId") Long accountId, @Param("appName") String appName);
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelCreateStrategyMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.channel.mapper.KuaishouChannelCreateStrategyMapper">
 
     <select id="queryAllIdByAccountId" resultType="java.lang.Long">
-        SELECT *
+        SELECT id
         FROM (SELECT id
               FROM ctop_kuaishou_channel_create_strategy
               WHERE account_id = #{accountId}

+ 107 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml

@@ -131,6 +131,7 @@
         FROM `ctop_kuaishou_channel`
         WHERE account_id = #{accountId}
           AND state = 1
+          AND channel_state = 1
           AND id > #{usedId}
           AND usage_range = #{usageRange}
         ORDER BY channel_code, channel_number limit 10
@@ -146,6 +147,7 @@
         FROM `ctop_kuaishou_channel`
         WHERE account_id = #{accountId}
         AND state = 1
+        AND channel_state = 1
         <if test="isHaveItem != null">
             and is_have_item = #{isHaveItem}
         </if>
@@ -198,21 +200,115 @@
         WHERE t1.strategy_id IN
         <foreach collection="strategys" item="item" separator=","
                  open="(" close=")">
-            #{item.id}
+            #{item}
         </foreach>
             AND t1.state = 1
             AND t1.channel_state = 1
         <if test="usageTimes > 1">
             AND is_cycle = 1
           </if>
+        <if test="appName != null">
             AND app_id in (
-                SELECT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}
+                SELECT DISTINCT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}  and app_id is not null
             )
+        </if>
             AND t1.usage_times = #{usageTimes}
             and t1.usage_level = #{usageLevel}
             ORDER BY t1.create_time,t1.channel_number
     </select>
 
+    <select id="getAccountLevelRepeatChannel" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
+        SELECT t1.id,
+               t1.channel_code,
+               t1.usage_level,
+               t1.usage_range,
+               t1.usage_times,
+               t1.is_have_item,
+               t1.channel_name,
+               t1.click_track_url,
+               t1.actionbar_click_url,
+               t1.schema_uri
+        FROM `ctop_kuaishou_channel` t1
+        LEFT JOIN ctop_kuaishou_channel_rel t2 ON t1.account_id = t2.account_id AND t1.channel_code = t2.channel_code
+        WHERE
+            t1.account_id = #{accountId}
+          AND t1.state = 1
+          AND t1.channel_state = 1
+          AND t1.app_id is not null
+          and t1.usage_level = 'account'
+        <if test="appName != null">
+            AND t1.app_id in (
+            SELECT DISTINCT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}  and app_id is not null
+            )
+        </if>
+        GROUP BY t1.channel_code
+        ORDER BY t1.create_time,t1.channel_number
+            LIMIT 100
+    </select>
+
+    <select id="getAccountLevelNoRepeatChannel" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
+        SELECT t1.id,
+               t1.channel_code,
+               t1.usage_level,
+               t1.usage_range,
+               t1.usage_times,
+               t1.is_have_item,
+               t1.channel_name,
+               t1.click_track_url,
+               t1.actionbar_click_url,
+               t1.schema_uri
+        FROM `ctop_kuaishou_channel` t1
+        WHERE
+            t1.account_id = #{accountId}
+          AND t1.state = 1
+          AND t1.channel_state = 1
+          AND app_id is not null
+          AND t1.channel_code not in (
+            SELECT channel_code FROM ctop_kuaishou_channel_rel WHERE account_id = #{accountId}  AND unit_id is not null
+        )
+        <if test="appName != null">
+            AND t1.app_id in (
+            SELECT DISTINCT app_id FROM ctop_kuaishou_channel_app_info WHERE app_name = #{appName}  AND app_id is not null
+            )
+        </if>
+        ORDER BY t1.create_time,t1.channel_number
+            LIMIT 100
+    </select>
+
+    <select id="queryNoAccountLevelNoRepeatChannel" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
+        SELECT t1.id,
+               t1.channel_code,
+               t1.usage_level,
+               t1.usage_range,
+               t1.usage_times,
+               t1.is_have_item,
+               t1.channel_name,
+               t1.click_track_url,
+               t1.actionbar_click_url,
+               t1.schema_uri
+        FROM `ctop_kuaishou_channel` t1
+        WHERE  t1.account_id = #{accountId}
+          AND t1.state = 1
+          AND t1.channel_state = 1
+          AND app_id is not null
+        <if test="appName != null">
+            AND t1.app_id in (
+            SELECT DISTINCT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}  and app_id is not null
+            )
+        </if>
+          AND t1.usage_times = 0
+          and t1.usage_level = #{usageLevel}
+        ORDER BY t1.create_time,t1.channel_number
+            LIMIT 100
+    </select>
+
+    <select id="getChannelEntity" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
+        SELECT *
+        FROM `ctop_kuaishou_channel`
+        WHERE account_id = #{accountId}
+          AND state = 1
+          AND channel_state = 1 LIMIT 1
+    </select>
 
     <select id="queryUsedLevel" resultType="java.lang.Integer">
         SELECT usage_times
@@ -220,9 +316,10 @@
         where strategy_id in
         <foreach collection="strategys" item="item" separator=","
                  open="(" close=")">
-            #{item.id}
+            #{item}
         </foreach>
         AND state = 1
+        AND channel_state = 1
         group by usage_times
     </select>
 
@@ -246,17 +343,18 @@
   <select id="queryChannelList" resultType="com.alibaba.fastjson.JSONObject">
       SELECT
           t1.id,
-          channel_code,
-          channel_name,
+          channel_code as 'channelCode',
+          channel_name as 'channelName',
           t1.url,
-          schema_uri,
-          click_track_url,
-          actionbar_click_url
+          schema_uri as 'schemaUri',
+          click_track_url as 'clickTrackUrl',
+          actionbar_click_url as 'actionbarClickUrl'
       FROM
           ctop_kuaishou_channel t1
               LEFT JOIN ctop_kuaishou_channel_app_info t2 ON t1.app_id = t2.app_id
       WHERE
           t1.state = 1
+        AND t1.channel_state = 1
         AND t1.account_id = #{accountId}
         AND t2.app_name = #{appName}
 
@@ -285,6 +383,7 @@
         WHERE t2.account_id = #{accountId}
           AND t2.usage_level = #{level}
           AND t2.state = 1
+          AND t2.channel_state = 1
           AND t1.campaign_id = #{campaignId} LIMIT 1
     </select>
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java

@@ -32,7 +32,7 @@ public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
     Result<Object> queryChannelLevel(JSONObject request);
 
-    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId, Integer state);
+    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId);
 
     KuaishouChannel queryUsedChannel(Long accountId, Long newCampaignId, String level);
 

+ 119 - 62
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

@@ -168,16 +168,9 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
      * 校验渠道号是否重复
      */
     private boolean checkChannelCode(KuaishouChannelCreateStrategy strategy) {
-        String numberValue = strategy.getNumberValue();
-        Integer min = null;
-        Integer max = null;
-        if (numberValue.contains("-")) {
-            String[] split = numberValue.split("-");
-            min = Integer.valueOf(split[0]);
-            max = Integer.valueOf(split[1]);
-            strategy.setNumberMin(min);
-            strategy.setNumberMax(max);
-        }
+        String numberValue = strategy.getNumberValue().trim();
+        Integer min = strategy.getNumberMin();
+        Integer max = strategy.getNumberMax();
 
         QueryWrapper<KuaishouChannelCreateStrategy> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("product_id", strategy.getProductId());
@@ -243,6 +236,15 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             queryWrapper.eq("account_id", strategy.getAccountId());
         }
         queryWrapper.eq("project_id", strategy.getProjectId());
+        Integer numberMin = 0;
+        Integer numberMax = 0;
+        if (strategy.getNumberValue().contains("-")) {
+            String[] split = strategy.getNumberValue().split("-");
+            numberMin = Integer.valueOf(split[0]);
+            numberMax = Integer.valueOf(split[1]);
+            strategy.setNumberMin(numberMin);
+            strategy.setNumberMax(numberMax);
+        }
         //查询是否已经创建过策略,若已创建则某些字段必须一致,比如是否循环、使用层级
         KuaishouChannelCreateStrategy one = channelCreateStrategyService.getOne(queryWrapper.last("limit 1"));
         if (!Check.isNull(one)) {
@@ -279,8 +281,6 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             if (!strategy.getNumberValue().contains("-")) {
                 return customizedCreate(strategy);
             }
-            Integer numberMin = strategy.getNumberMin();
-            Integer numberMax = strategy.getNumberMax();
             Integer usageRange = strategy.getUsageRange();
             if (usageRange == 2) {
                 /*==========================范围是 项目==========================*/
@@ -511,6 +511,18 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                     updateApp(strategy, app, token);
                 }
             }
+        }else{
+            KuaiShouAppList appInfo = kuaiShouAppListService.getAppInfo(strategy.getAccountId(), strategy.getAppId());
+            KuaishouChannelAppInfo channelAppInfo = new KuaishouChannelAppInfo();
+            BeanUtils.copyProperties(appInfo, channelAppInfo);
+            channelAppInfo.setState(1);
+            channelAppInfo.setUrl((String) appInfo.getUrl());
+            channelAppInfo.setUseSdk(0);
+            channelAppInfo.setAppIconUrl((String) appInfo.getAppIconUrl());
+            channelAppInfo.setId(null);
+            channelAppInfo.setType("check");
+            channelAppInfo.setRemark("选择原有App");
+            channelAppInfoService.save(channelAppInfo);
         }
     }
 
@@ -906,6 +918,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                 }
                 strategy.setCreateType(createType);
 
+                if (strategy.getNumberValue().contains("-")) {
+                    String[] split = strategy.getNumberValue().split("-");
+                    Integer numberMin = Integer.valueOf(split[0]);
+                    Integer numberMax = Integer.valueOf(split[1]);
+                    strategy.setNumberMin(numberMin);
+                    strategy.setNumberMax(numberMax);
+                }
+
                 QueryWrapper<KuaishouChannelCreateStrategy> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("product_id", strategy.getProductId());
                 if (!Check.isNull(strategy.getAccountId())) {
@@ -949,36 +969,81 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
 
     @Override
     public Result<Object> queryChannel(Long accountId, String level, String appName, String photoName) throws Exception {
-        //查询账户所有策略
-        List<Long> strategyIds = channelCreateStrategyService.queryAllIdByAccountId(accountId);
-        if (Check.isNull(strategyIds) || strategyIds.isEmpty()) {
-            return Result.error("渠道号获取失败,该账户没有创建过渠道号");
+        KuaishouChannel one = channelMapper.getChannelEntity(accountId);
+        if (Check.isNull(one)) {
+            return Result.error("未查询到渠道号");
         }
-        List<Integer> usageTimesTypes = channelMapper.queryUsedLevel(strategyIds);
-        if (Check.isNull(usageTimesTypes)) {
-            return Result.error("渠道号已无效");
-        }
-        for (Integer usageTimes : usageTimesTypes) {
-            //获取可用渠道号,筛查出一个返回给前端
-            List<KuaishouChannel> list = channelMapper.queryChannelByUsageTimes(usageTimes, level, strategyIds, appName);
-            if (Check.isNull(list)) {
-                continue;
+        //是否循环重复使用 0:否,1:是
+        Integer isCycle = one.getIsCycle();
+        if (isCycle == 0) {
+            if ("account".equals(level)) {
+                //账户层级   不可循环使用渠道号
+                List<KuaishouChannel> list = channelMapper.getAccountLevelNoRepeatChannel(accountId, appName);
+                KuaishouChannel channel = getValidChannel(list);
+                if (!Check.isNull(channel)) {
+                    return Result.ok(channel);
+                }
+            } else {
+                //获取可用渠道号,筛查出一个返回给前端
+                List<KuaishouChannel> list = channelMapper.queryNoAccountLevelNoRepeatChannel(level, accountId, appName);
+                KuaishouChannel channel = getValidChannel(list);
+                if (!Check.isNull(channel)) {
+                    return Result.ok(channel);
+                }
             }
-            for (KuaishouChannel channel : list) {
-                //1 关联单品,无单品则跳过
-                if (channel.getIsHaveItem() == 1) {
-                    List<KuaishouChannelItems> items = channelItemsRelService.queryItems(channel.getId());
-                    if (Check.isNull(items) || items.isEmpty()) {
-                        continue;
+        } else {
+            //循环使用逻辑
+            if ("account".equals(level)) {
+                //账户层级可循环使用渠道号
+                List<KuaishouChannel> list = channelMapper.getAccountLevelRepeatChannel(accountId,appName);
+                KuaishouChannel channel = getValidChannel(list);
+                if (!Check.isNull(channel)) {
+                    return Result.ok(channel);
+                }
+            } else {
+                //查询账户所有策略
+                List<Long> strategyIds = channelCreateStrategyService.queryAllIdByAccountId(accountId);
+                if (Check.isNull(strategyIds) || strategyIds.isEmpty()) {
+                    return Result.error("渠道号获取失败,该账户没有创建过渠道号");
+                }
+                List<Integer> usageTimesTypes = channelMapper.queryUsedLevel(strategyIds);
+                if (Check.isNull(usageTimesTypes)) {
+                    return Result.error("渠道号已无效");
+                }
+                for (Integer usageTimes : usageTimesTypes) {
+                    //获取可用渠道号,筛查出一个返回给前端
+                    List<KuaishouChannel> list = channelMapper.queryChannelByUsageTimes(usageTimes, level, strategyIds, appName);
+                    KuaishouChannel channel = getValidChannel(list);
+                    if (!Check.isNull(channel)) {
+                        return Result.ok(channel);
                     }
-                    channel.setItems(items);
                 }
-                return Result.ok(channel);
             }
         }
         return Result.error("查询失败");
     }
 
+    /**
+     * 筛选渠道号,给渠道号添加单品
+     */
+    private KuaishouChannel getValidChannel(List<KuaishouChannel> list) {
+        if (Check.isNull(list) || list.isEmpty()) {
+            return null;
+        }
+        for (KuaishouChannel channel : list) {
+            //1 关联单品,无单品则跳过
+            if (channel.getIsHaveItem() == 1) {
+                List<KuaishouChannelItems> items = channelItemsRelService.queryItems(channel.getId());
+                if (Check.isNull(items) || items.isEmpty()) {
+                    continue;
+                }
+                channel.setItems(items);
+            }
+            return channel;
+        }
+        return null;
+    }
+
     @Override
     public Result<Object> queryChannelLevel(JSONObject data) {
         Long accountId = data.getLong("accountId");
@@ -999,8 +1064,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     }
 
     @Override
-    public void callBackUpdateChannelRel(String level, String channelCode, Long accountId, Long planId, Long
-            groupId, Integer state) {
+    public void callBackUpdateChannelRel(String level, String channelCode, Long accountId, Long planId, Long groupId) {
         try {
             QueryWrapper<KuaishouChannel> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("account_id", accountId);
@@ -1008,34 +1072,27 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             KuaishouChannel one = this.getOne(queryWrapper);
             if (!Check.isNull(one)) {
                 one.setUpdateTime(new Date());
-                if (0 == state) {
-                    this.saveOrUpdate(one);
-                } else {
-                    QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
-                    relqueryWrapper.eq("account_id", accountId);
-                    relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
-                    KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
-                    if (!Check.isNull(rel)) {
-                        if (!Check.isNull(rel.getCampaignId())) {
-                            rel.setId(null);
-                        }
-                        rel.setCampaignId(planId);
-                        rel.setUnitId(groupId);
-                        rel.setUpdateTime(new Date());
-                        channelRelService.save(rel);
-                        if ("plan".equals(level)) {
-                            Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
-                            one.setUsageTimes(usageTimes);
-//                            if (usageTimes > one.getHaveCycleTimes()) {
-//                                one.setHaveCycleTimes(usageTimes);
-//                            }
-                            this.saveOrUpdate(one);
-                        } else if ("group".equals(level)) {
-                            Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
-                            one.setUsageTimes(usageTimes);
-                            this.saveOrUpdate(one);
-                        }
+                QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
+                relqueryWrapper.eq("account_id", accountId);
+                relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
+                KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
+                if (!Check.isNull(rel)) {
+                    if (!Check.isNull(rel.getCampaignId())) {
+                        rel.setId(null);
                     }
+                    rel.setCampaignId(planId);
+                    rel.setUnitId(groupId);
+                    rel.setUpdateTime(new Date());
+                    channelRelService.save(rel);
+//                    if ("plan".equals(level)) {
+//                        Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
+//                        one.setUsageTimes(usageTimes);
+//                        this.saveOrUpdate(one);
+//                    } else if ("group".equals(level)) {
+                    Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
+                    one.setUsageTimes(usageTimes);
+                    this.saveOrUpdate(one);
+//                    }
                 }
             }
         } catch (Exception e) {

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/DocumentLibraryMapper.java

@@ -23,7 +23,8 @@ public interface DocumentLibraryMapper {
 
     List<String> getDataByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
 
-    List<Map<String,String>> getDocumentByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
+    List<Map<String, String>> getDocumentByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
 
     void insertBatch(@Param("list") List<DocumentLibraryInfo> list);
+
 }

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/xml/DocumentLibraryMapper.xml

@@ -4,12 +4,12 @@
 
 
     <insert id="saveDocumentLibrary" parameterType="cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo">
-        insert into ctop_document_library (copy_writer_id,copy_writer,account_id,status,create_time) values
+        replace into ctop_document_library (copy_writer_id,copy_writer,account_id,status,create_time) values
         (#{copyWriterId},#{copyWriter},#{accountId},#{status},#{createTime})
     </insert>
 
     <insert id="insertBatch" parameterType="cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo">
-        insert into ctop_document_library
+        replace into ctop_document_library
         (copy_writer_id,copy_writer,account_id,status,create_time)
         values
         <foreach collection="list" item="video" separator=",">

+ 18 - 12
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/impl/DocumentLibraryServiceImpl.java

@@ -17,6 +17,7 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.MD5Util;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -61,20 +62,25 @@ public class DocumentLibraryServiceImpl implements DocumentLibraryService {
             return result;
         }
         try {
-            if (accountIds != null && !documentList.isEmpty() && !accountIds.isEmpty()) {
+            if (accountIds != null && !documentList.isEmpty() && accountIds != null && !accountIds.isEmpty()) {
 
+                List<DocumentLibraryInfo> list = new ArrayList<>();
                 for (String docu : documentList) {
-                    DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
-                    documentLibraryInfo.setCopyWriter(docu);
-                    documentLibraryInfo.setCopyWriterId(UUID.randomUUID().toString());
-                    documentLibraryInfo.setCreateTime(formatter.format(new Date()));
-                    documentLibraryInfo.setStatus(0);
                     if (docu != null && docu != "" && docu.length() <= 30) {
                         for (String accountId : accountIds) {
+                            DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
+                            documentLibraryInfo.setCopyWriter(docu);
+                            documentLibraryInfo.setCreateTime(formatter.format(new Date()));
+                            documentLibraryInfo.setStatus(0);
                             documentLibraryInfo.setAccountId(accountId);
-                            documentLibraryMapper.saveDocumentLibrary(documentLibraryInfo);
+                            documentLibraryInfo.setCopyWriterId(MD5Util.getMd5(accountId + docu));
+                            list.add(documentLibraryInfo);
                         }
                     }
+
+                    if (list.size() > 0) {
+                        documentLibraryMapper.insertBatch(list);
+                    }
                 }
             }
             result.success("添加成功");
@@ -238,7 +244,7 @@ public class DocumentLibraryServiceImpl implements DocumentLibraryService {
         }
         ExportExcelUtils eeu = new ExportExcelUtils();
         JSONArray array = new JSONArray();
-        for (int i = 1; i <= rows + 1; i++) {
+        for (int i = 0; i <= rows + 1; i++) {
             Row row = sheet.getRow(i);
             if (row != null) {
                 String value = eeu.getCellValue(row.getCell(0));
@@ -252,20 +258,20 @@ public class DocumentLibraryServiceImpl implements DocumentLibraryService {
     }
 
     @Override
-    public void insertBatch(String description,Long accountId) {
+    public void insertBatch(String description, Long accountId) {
         JSONArray array = JSONArray.parseArray(description);
         List<DocumentLibraryInfo> list = new ArrayList<>();
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         for (int i = 0; i < array.size(); i++) {
             DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
-            documentLibraryInfo.setCopyWriter(array.getString(i).trim());
-            documentLibraryInfo.setCopyWriterId(UUID.randomUUID().toString());
+            String copyWriter = array.getString(i).trim();
+            documentLibraryInfo.setCopyWriter(copyWriter);
+            documentLibraryInfo.setCopyWriterId(MD5Util.getMd5(accountId + copyWriter));
             documentLibraryInfo.setCreateTime(formatter.format(new Date()));
             documentLibraryInfo.setStatus(0);
             documentLibraryInfo.setAccountId(accountId.toString());
             list.add(documentLibraryInfo);
         }
-
         documentLibraryMapper.insertBatch(list);
     }
 }

+ 6 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/controller/KuaishouHostingTemplateController.java

@@ -125,7 +125,13 @@ public class KuaishouHostingTemplateController {
         if ("admin".equals(roleCode)) {
             kuaishouHostingTemplate.setUserId(null);
         }
+        String name = kuaishouHostingTemplate.getName();
+        kuaishouHostingTemplate.setName(null);
+
         QueryWrapper<KuaishouHostingTemplate> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouHostingTemplate, req.getParameterMap());
+        if (!Check.isNull(name)) {
+            queryWrapper.like("name", name);
+        }
         queryWrapper.orderByDesc("create_time");
         Page<KuaishouHostingTemplate> page = new Page<KuaishouHostingTemplate>(pageNo, pageSize);
         IPage<KuaishouHostingTemplate> pageList = kuaishouHostingTemplateService.page(page, queryWrapper);

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTask.java

@@ -355,6 +355,7 @@ public class KuaishouHostingTask {
     @Excel(name = "备注", width = 15)
     @ApiModelProperty(value = "备注")
     private String remarks;
+    private String SceneIds;
     /**
      * 创建时间
      */
@@ -371,4 +372,5 @@ public class KuaishouHostingTask {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "修改时间")
     private Date updateTime;
+
 }

+ 6 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/entity/KuaishouHostingTemplate.java

@@ -347,6 +347,12 @@ public class KuaishouHostingTemplate {
     @Excel(name = "每个智能托管匹配视频数量", width = 15)
     @ApiModelProperty(value = "每个智能托管匹配视频数量")
     private Integer videoCount;
+
+    /**
+     * 投放场景
+     */
+    private String sceneIds;
+
     /**
      * 创建时间
      */

+ 4 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/mapper/xml/KuaishouHostingTaskMapper.xml

@@ -58,7 +58,8 @@
         creative_name_rule,
         photo_infos,
         task_status,
-        remarks
+        remarks,
+        scene_ids
         )
         values
         <foreach collection="addList" item="add" separator=",">
@@ -117,7 +118,8 @@
             #{add.creativeNameRule},
             #{add.photoInfos},
             #{add.taskStatus},
-            #{add.remarks}
+            #{add.remarks},
+            #{add.sceneIds}
             )
         </foreach>
 

+ 13 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/hosting/service/impl/KuaishouHostingTaskServiceImpl.java

@@ -87,6 +87,10 @@ public class KuaishouHostingTaskServiceImpl extends ServiceImpl<KuaishouHostingT
             task.setPhotoInfos(videoInfo.toString());
             task.setName(getName(template.getName(), task.getAccountId()));
             task.setHostingScene(template.getHostingScene());
+            String sceneIds = template.getSceneIds();
+            if (!Check.isNull(sceneIds)) {
+                task.setSceneIds(sceneIds);
+            }
             task.setCampaignType(template.getCampaignType());
             if (!Check.isNull(template.getAppId())) {
                 task.setAppId(template.getAppId());
@@ -167,6 +171,7 @@ public class KuaishouHostingTaskServiceImpl extends ServiceImpl<KuaishouHostingT
         }
     }
 
+
     @Override
     public void createHosting(Long id) {
         try {
@@ -192,6 +197,14 @@ public class KuaishouHostingTaskServiceImpl extends ServiceImpl<KuaishouHostingT
             requestJson.put("advertiser_id", task.getAccountId());
             requestJson.put("name", task.getName());
             requestJson.put("hosting_scene", task.getHostingScene());
+
+            String sceneIds = task.getSceneIds();
+            if (!Check.isNull(sceneIds)) {
+                JSONArray scene_ids = JSONArray.parseArray(sceneIds);
+                if (!Check.isNull(scene_ids)) {
+                    requestJson.put("scene_ids", scene_ids);
+                }
+            }
             requestJson.put("campaign_type", task.getCampaignType());
             if (!Check.isNull(task.getAppId())) {
                 requestJson.put("app_id", task.getAppId());

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

@@ -6,12 +6,16 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoStrategy;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountAutoStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
+import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -55,6 +59,9 @@ public class AiKuaishouAdvertiserStrategyController {
     @Autowired
     private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
+    @Autowired
+    private IAiKuaishouAccountAutoStrategyService aiKuaishouAccountAutoStrategyService;
+
     /**
      * 分页列表查询
      *
@@ -66,9 +73,9 @@ public class AiKuaishouAdvertiserStrategyController {
      */
     @GetMapping(value = "/list")
     public Result<PageInfo<AiKuaishouAdvertiserStrategy>> queryPageList(AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy,
-                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                      HttpServletRequest req) {
+                                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                        HttpServletRequest req) {
         Result<PageInfo<AiKuaishouAdvertiserStrategy>> result = new Result<>();
         String roleCode = sysRoleService.getRoleCodeByUserId(aiKuaishouAdvertiserStrategy.getUserId());
         if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
@@ -188,6 +195,13 @@ public class AiKuaishouAdvertiserStrategyController {
         if (status != 0) {
             status = 1;
         }
+        QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", aiKuaishouAdvertiserStrategyEntity.getAccountId()).last("limit 1");
+        AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
+        if (null != one && one.getStatus() == status && status == 1) {
+            ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_AUTO_STRATEGY_UPDATE);
+            return result;
+        }
         aiKuaishouAdvertiserStrategyEntity.setStatus(status);
         aiKuaishouAdvertiserStrategyService.updateById(aiKuaishouAdvertiserStrategyEntity);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);

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

@@ -684,6 +684,38 @@ public class MaterialInfoController {
 
     }
 
+
+    // 批量修改状态
+    @PostMapping(value = "/batchEditStatus")
+    public Result<MaterialInfo> batchEditStatus(@RequestBody JSONObject requestJson) {
+        Result<MaterialInfo> result = new Result<>();
+        Integer status = requestJson.getInteger("status");
+        JSONArray ids = requestJson.getJSONArray("ids");
+        if (Check.isNull(ids)) {
+            result.setCode(-1);
+            result.setMessage("请选择素材");
+            return result;
+
+        }
+        int successNum = 0;
+        for (int i = 0; i < ids.size(); i++) {
+            String id = ids.getString(i);
+            MaterialInfo materialInfo = new MaterialInfo();
+            materialInfo.setId(id);
+            materialInfo.setStatus(status);
+            materialInfo.setConfirmTime(new Date());
+            boolean b = materialInfoService.updateById(materialInfo);
+            if (b) {
+                successNum++;
+            }
+
+        }
+        result.setCode(0);
+        result.setMessage("批量通过" + successNum + "个视频");
+        return result;
+
+    }
+
     /**
      * 通过id删除
      *

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

@@ -16,3 +16,4 @@ public class PerformanceAreaController {
         return result;
     }
 }
+

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

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.mapper.UserCompanyMapper;
 import cn.com.ctop.common.module.service.*;
 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.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -305,7 +306,8 @@ public class ProjectController {
 
     @ApiOperation(value = "项目-添加", notes = "项目-添加")
     @PostMapping(value = "/add")
-    public Result<Project> add(@RequestBody Project project) {
+    public Result<Project> add(@RequestBody JSONObject data) {
+        Project project = JSONObject.parseObject(data.toJSONString(), Project.class);
         Result<Project> result = new Result<>();
         try {
          /*   String advertiserId = project.getAdvertiserId();
@@ -372,7 +374,8 @@ public class ProjectController {
      */
     @ApiOperation(value = "项目-编辑", notes = "项目-编辑")
     @PutMapping(value = "/edit")
-    public Result<Project> edit(@RequestBody Project project) {
+    public Result<Project> edit(@RequestBody JSONObject data) {
+        Project project = JSONObject.parseObject(data.toJSONString(), Project.class);
         Result<Project> result = new Result<>();
         SysUser sysUser = sysUserService.getById(project.getResponsibleId());
         if (!Check.isNull(sysUser)) {

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

@@ -1,4 +1,4 @@
-/*
+
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.entity.*;
@@ -37,6 +37,8 @@ import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
@@ -58,11 +60,9 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-
-*/
 /**
  * @author jeecg-boot
- *//*
+ */
 
 @RestController
 @RequestMapping("/test")
@@ -993,22 +993,7 @@ public class TestController {
 
     }
 
-    @GetMapping("checkFile")
-    public Map<String, Object> checkFile() {
-        String nowDate = DateUtils.getDate("yyyy-MM-dd");
-        String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -1);
-        //  查询快手token
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取快手数据异常:未获取到可用的token");
-        }
-        for (CtopOauthToken token : tokens) {
-            dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate);
-        }
-        Map<String, Object> result = new HashMap<>();
-        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
-        return result;
-    }
+
 
 
     @GetMapping("loadBytedanceHistoryData")
@@ -1128,7 +1113,6 @@ public class TestController {
     }
 
 
-
     @GetMapping("/bytedance/effectVideo/get")
     public Map<String, Object> effectVideoGet(String date) {
         Map<String, Object> result = new HashMap<>();
@@ -1313,7 +1297,7 @@ public class TestController {
         return result;
     }
 
-    */
+
 /**
      * 勿动勿删,煜一人群报表数据拉取接口。
      *
@@ -1357,22 +1341,23 @@ public class TestController {
     static CountDownLatch countDownLatch = null;
     @Resource
     AiKuaishouUnitLevelOperationRecordMapper kuaishouUnitLevelOperationRecordMapper;
+
     @GetMapping(value = "/getAudienceDataNew")
-    public void getAudienceData(@RequestParam(required = false,defaultValue = "2019-01-01") String date) throws Exception {
+    public void getAudienceData(@RequestParam(required = false, defaultValue = "2019-01-01") String date) throws Exception {
         int page = 1;
         int pageSize = 2000;
-        if(date.equals("2019-01-01")){
+        if (date.equals("2019-01-01")) {
             date = DateUtils.formatDate(DateUtils.addDay(DateUtils.getNowDate(), -1), "yyyy-MM-dd");
         }
         List<CtopOauthToken> tokens = tokenService.getByProjectId(458L);    //淘特项目
         for (CtopOauthToken token : tokens) {
             Date startDate = DateUtils.addDay(DateUtils.getNowDate(), -1);
-            if(startDate.after(token.getAccessTokenExpiresIn())){   //过期跳过
+            if (startDate.after(token.getAccessTokenExpiresIn())) {   //过期跳过
                 continue;
             }
             Date enDate = DateUtils.addDay(startDate, -30);
             List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountIdAndDate(token.getAccountId(), enDate, startDate);
-            if(Check.isNull(planIdsAndUnitIds)){
+            if (Check.isNull(planIdsAndUnitIds)) {
                 continue;
             }
             countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
@@ -1493,5 +1478,13 @@ public class TestController {
             log.info("数据更新完成");
         }
     }
-}
 */
+    @GetMapping("checkUnitBid")
+    public Result checkUnitBid(Long accountId) throws Exception {
+        Date nowDate = new Date();
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        kuaishouInterfaceService.getGroupList(token, nowDate, nowDate);
+        return Result.ok("success");
+    }
+}
+

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

@@ -22,10 +22,8 @@ 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.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
@@ -486,11 +484,14 @@ public class UserAllocationController {
                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                        HttpServletRequest req) {
         Result<IPage<UserAllocation>> result = new Result<>();
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = userAllocation.getUserId();
+        userAllocation.setUserId(null);
+
+
         QueryWrapper<UserAllocation> queryWrapper = QueryGenerator.initQueryWrapper(userAllocation, req.getParameterMap());
-        String roleCode = sysRoleService.getRoleCodeByUserId(user.getId());
+        String roleCode = sysRoleService.getRoleCodeByUserId(userId);
         if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
-            queryWrapper.eq("user_id", user.getId());
+            queryWrapper.eq("user_id", userId);
             queryWrapper.orderByDesc("id");
         }
         Page<UserAllocation> page = new Page<>(pageNo, pageSize);

+ 10 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ProjectMember.java

@@ -69,6 +69,16 @@ public class ProjectMember implements Serializable {
 
 
     @TableField(exist = false)
+    private String bidType;  // 优化目标
+
+    @TableField(exist = false)
+    private String ocpxActionType; // 转化目标
+
+    @TableField(exist = false)
+    private String deepConversionType; // 深度转化目标
+
+
+    @TableField(exist = false)
     private String responsibleName;
 
 

+ 9 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java

@@ -3,7 +3,10 @@ package org.jeecg.modules.ctop.service.impl;
 import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
-import cn.com.ctop.common.module.service.*;
+import cn.com.ctop.common.module.service.IProductService;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.ISysRoleExtService;
+import cn.com.ctop.common.module.service.ISysUserService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import com.alibaba.fastjson.JSONArray;
@@ -96,7 +99,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
 
     //视频报表
     @Override
-    public List<ProjectMember> getProjects(List<Integer> mediaIds,String userId) {
+    public List<ProjectMember> getProjects(List<Integer> mediaIds, String userId) {
 //        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 //        String userId = sysUser.getId();
         String roleCode = memberMapper.getRoleCodeByUserId(userId);
@@ -153,6 +156,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
 
         return projectMemberList;
     }
+
     @Override
     public List<Map<String, Object>> getProjectAccountByUserId(String userId, String mediaType) {
         List<Map<String, Object>> result = new ArrayList<>();
@@ -410,6 +414,9 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
             }
             member.setMediaId(projectJson.getString("mediaId"));
             member.setMaxBid(projectJson.getLong("maxBid"));
+            member.setBidType(projectJson.getString("bidType"));
+            member.setOcpxActionType(projectJson.getString("ocpxActionType"));
+            member.setDeepConversionType(projectJson.getString("deepConversionType"));
             String advertiserId = projectJson.getString("advertiserId");
             member.setAdvertiserId(advertiserId);
             if (!Check.isNullMap(advertiserMap)) {

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.service.ISupplierListService;
 import cn.com.ctop.common.module.service.ISysUserService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.TransferAccount;
@@ -136,6 +137,12 @@ public class TransferAccountServiceImpl extends ServiceImpl<TransferAccountMappe
             if (!Check.isNullMap(supplierMap)) {
                 project.setSupplierCode_dictText(supplierMap.get(project.getSupplierCode()));
             }
+            if (!Check.isNull(project.getOcpxActionType())&&!project.getOcpxActionType().isEmpty()) {
+                project.setOcpxActionTypeArray(JSONArray.parseArray(project.getOcpxActionType()));
+            }
+            if (!Check.isNull(project.getDeepConversionType())&&!project.getDeepConversionType().isEmpty()) {
+                project.setDeepConversionTypeArray(JSONArray.parseArray(project.getDeepConversionType()));
+            }
         }
         return records;
     }