Pārlūkot izejas kodu

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-boot

# Conflicts:
#	module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
yumeng 4 gadi atpakaļ
vecāks
revīzija
5e564f2d74
95 mainītis faili ar 7080 papildinājumiem un 1200 dzēšanām
  1. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  2. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  3. 9 3
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  4. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  5. 16 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  6. 57 32
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java
  7. 29 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouLandpagesJob.java
  8. 436 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouAppPackageController.java
  9. 0 403
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouCrowdPackController.java
  10. 493 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouDirectionalPackageController.java
  11. 337 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouLandpagePackageController.java
  12. 412 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouPopulationPackageController.java
  13. 71 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppGroup.java
  14. 126 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppPackage.java
  15. 79 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppPackageRel.java
  16. 232 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouDirectionalPackage.java
  17. 109 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouDirectionalaPckageRel.java
  18. 119 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouLandpagePackage.java
  19. 63 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouLandpagePackageRel.java
  20. 59 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationGroup.java
  21. 93 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationPackage.java
  22. 102 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationPackageRel.java
  23. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppGroupMapper.java
  24. 30 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageMapper.java
  25. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageRelMapper.java
  26. 0 41
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouCrowdPackMapper.java
  27. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPackageMapper.java
  28. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPckageRelMapper.java
  29. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageMapper.java
  30. 20 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageRelMapper.java
  31. 22 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationGroupMapper.java
  32. 30 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageMapper.java
  33. 40 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageRelMapper.java
  34. 22 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppGroupMapper.xml
  35. 117 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageMapper.xml
  36. 95 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageRelMapper.xml
  37. 0 344
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouCrowdPackMapper.xml
  38. 97 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPackageMapper.xml
  39. 94 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPckageRelMapper.xml
  40. 94 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageMapper.xml
  41. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageRelMapper.xml
  42. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationGroupMapper.xml
  43. 96 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageMapper.xml
  44. 194 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageRelMapper.xml
  45. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppGroupService.java
  46. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageRelService.java
  47. 37 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageService.java
  48. 0 31
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouCrowdPackService.java
  49. 48 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPackageService.java
  50. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPckageRelService.java
  51. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouLandpagePackageRelService.java
  52. 38 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouLandpagePackageService.java
  53. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationGroupService.java
  54. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageRelService.java
  55. 37 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageService.java
  56. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/KuaishouAppPackageRelMapper.java
  57. 24 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  58. 57 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java
  59. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppGroupServiceImpl.java
  60. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageRelServiceImpl.java
  61. 310 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageServiceImpl.java
  62. 0 277
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouCrowdPackServiceImpl.java
  63. 660 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java
  64. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalTemplateRelServiceImpl.java
  65. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageRelServiceImpl.java
  66. 172 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageServiceImpl.java
  67. 74 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationGroupServiceImpl.java
  68. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageRelServiceImpl.java
  69. 356 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageServiceImpl.java
  70. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/DingPanController.java
  71. 44 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  72. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTarget.java
  73. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplate.java
  74. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplateTarget.java
  75. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouPopulationMapper.java
  76. 5 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateMapper.java
  77. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateTargetMapper.java
  78. 16 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTargetMapper.xml
  79. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouPopulationMapper.xml
  80. 49 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateMapper.xml
  81. 95 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateTargetMapper.xml
  82. 8 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateService.java
  83. 139 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  84. 70 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java
  85. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  86. 36 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java
  87. 68 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  88. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchCampaignPreviewServiceImpl.java
  89. 38 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouCampaignCopyDataServiceImpl.java
  90. 119 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  91. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouPopulationServiceImpl.java
  92. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouProgramCreativeServiceImpl.java
  93. 37 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouStrategyServiceImpl.java
  94. 210 13
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java
  95. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouAccountMaterialReportDailyMapper.xml

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

@@ -44,4 +44,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<UserAllocation> listByMediaId(@Param("mediaId")String mediaId, @Param("accountStatus")Integer accountStatus);
 
     List<JSONObject> getAccountListByProjectList(@Param("list") List list);
+
+    List<Long> getValidProjectIds(@Param("mediaId")  Integer mediaId);
 }

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -12,6 +12,7 @@
         ctop_user_allocation a
         left join ctop_project b on a.project_id = b.id
         where b.id = #{projectId}
+        and account_status = 0
     </select>
 
     <select id="queryAdvertiserId" resultType="String">
@@ -71,6 +72,16 @@
     </select>
 
 
+    <select id="getValidProjectIds" resultType="java.lang.Long">
+        SELECT project_id FROM ctop_user_allocation t1
+        where account_status = 0
+        <if test="mediaId != null">
+              AND media_id = #{mediaId}
+        </if>
+        GROUP BY project_id
+    </select>
+
+
     <select id="getAccountIdListByUserId" resultType="com.alibaba.fastjson.JSONObject">
     SELECT
     t1.account_id as 'accountId',

+ 9 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.UserAllocation;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -18,7 +17,7 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     UserAllocation getByAccountId(Long accountId);
 
-    List<UserAllocation> getByParams(Long projectId, String systemType,Integer accountStatus);
+    List<UserAllocation> getByParams(Long projectId, String systemType, Integer accountStatus);
 
     Map<String, Object> getPangolinAccountListByParams(String userId, JSONObject data);
 
@@ -38,7 +37,7 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     List<JSONObject> getAccountIdsByUserId(String userId);
 
-    List<UserAllocation> getUserAllocations(String mediaId ,int switchType);
+    List<UserAllocation> getUserAllocations(String mediaId, int switchType);
 
     JSONObject getSwitchStatusByAccount(Long accountId);
 
@@ -46,5 +45,12 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
 
+    /**
+     * 获取有效的项目ID集合
+     *
+     * @param mediaId 平台类型 1 头条 2快手
+     * @throws
+     */
+    List<Long> getValidProjectIds(Integer mediaId);
 
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -175,4 +175,9 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         }
         return map;
     }
+
+    @Override
+    public List<Long> getValidProjectIds(Integer mediaId) {
+        return userAllocationMapper.getValidProjectIds(mediaId);
+    }
 }

+ 16 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -83,7 +83,23 @@ public class KuaishouInterfaceConstant {
      * 创建定向模板
      */
     public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
+
     public static final String TEMPLATE_UPDATE = "/rest/openapi/v1/target/template/update";
+
+    /**
+     * 删除定向模板
+     */
+    public static final String TEMPLATE_DELETE = "/rest/openapi/v1/target/template/delete";
+    /**
+     * 获取行为与兴趣"类目"
+     */
+    public static final String BEHAVIOR_INTEREST = "/rest/openapi/v1/tool/label/behavior_interest";
+
+    /**
+     * 获取行为兴趣"关键词"
+     */
+    public static final String KEYWORD_QUERY = "/rest/openapi/v1/tool/keyword/query";
+
     /**
      * 获取地域信息
      */

+ 57 - 32
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java

@@ -3,18 +3,22 @@ package cn.com.ctop.job.kuaishou.handler;
 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.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.Date;
+import java.util.Hashtable;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -24,13 +28,14 @@ public class CrowdListQueryJob {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
-    private KuaishouCrowdPackMapper crowdPackMapper;
-    @Autowired
     private IKuaishouPopulationService iKuaishouPopulationService;
     @Autowired
-    private IKuaishouCrowdPackService crowdPackService;
-
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    private KuaishouPopulationPackageMapper kuaishouPopulationPackageMapper;
+    @Autowired
+    private KuaishouPopulationPackageRelMapper relMapper;
+    @Autowired
+    private IKuaishouPopulationPackageRelService relService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
 
     @XxlJob("crowdListQueryJob")
     public void execute() {
@@ -40,36 +45,56 @@ public class CrowdListQueryJob {
                 list.add(i);
             }
         }
-        list.forEach(status -> executorService.submit(() -> {
-            List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
-            for (KuaishouCrowdPack crowdPack : crowdList) {
-                CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
-                JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), status);
-                if (jsonObject.getInteger("code") == 0) {
-                    JSONObject data = jsonObject.getJSONObject("data");
-                    if (!Check.isNull(data)) {
-                        JSONArray details = data.getJSONArray("details");
-                        if (details.size() > 0) {
-                            for (int j = 0; j < details.size(); j++) {
-                                JSONObject obj = details.getJSONObject(j);
-                                if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
-                                    KuaishouCrowdPack oldPack = crowdPackMapper.queryByAccountId(null, obj.getLong("orientation_id"));
-                                    KuaishouCrowdPack crowdPackEntity = JSONObject.toJavaObject(obj, KuaishouCrowdPack.class);
-                                    if (!Check.isNull(oldPack)) {
-                                        crowdPackEntity.setStatDate(oldPack.getStatDate());
-                                        crowdPackEntity.setUrl(oldPack.getUrl());
-                                        crowdPackEntity.setSignature(oldPack.getSignature());
+        List<JSONObject> objs = kuaishouPopulationPackageMapper.queryListByStatus();
+        objs.forEach(o -> executorService.submit(() -> {
+            Long accountId = o.getLong("account_id");
+            Long projectId = o.getLong("project_id");
+            Hashtable newIds = new Hashtable();
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (!Check.isNull(token)) {
+                for (Integer status : list) {
+                    JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), status);
+                    if (jsonObject.getInteger("code") == 0) {
+                        JSONObject data = jsonObject.getJSONObject("data");
+                        if (!Check.isNull(data)) {
+                            JSONArray details = data.getJSONArray("details");
+                            if (details.size() > 0) {
+                                List<KuaishouPopulationPackageRel> rellist = new ArrayList<>();
+                                for (int j = 0; j < details.size(); j++) {
+                                    JSONObject obj = details.getJSONObject(j);
+                                    KuaishouPopulationPackageRel rel = JSONObject.parseObject(obj.toJSONString(), KuaishouPopulationPackageRel.class);
+                                    newIds.put(rel.getOrientationId(), rel.getOrientationId());
+                                    if (Check.isNull(relMapper.queryByOrientationId(rel.getOrientationId(), rel.getAccountId()))) {
+                                        rel.setProjectId(projectId);
+                                        rel.setDataStatus(1);
+                                        rel.setStatDate(DateUtils.formatDate(new Date()));
+                                        rellist.add(rel);
+                                    } else {
+                                        rel.setDataStatus(1);
+                                        relMapper.updateStatus(rel);
                                     }
-                                    crowdPackEntity.setMessage("PUSH OK");
-                                    crowdPackEntity.setDataStatus(1);
-                                    crowdPackService.save(crowdPackEntity);
-                                } else {
-                                    crowdPackMapper.update(obj);
+                                }
+                                if (!Check.isNull(rellist)) {
+                                    relMapper.replaceBatch(rellist);
                                 }
                             }
                         }
                     }
                 }
+                //查询现有的人群包ID集
+                List<Long> oldOrientationIds = relMapper.queryByOrientationId(null, accountId);
+                if (oldOrientationIds.size() != newIds.size()) {
+                    for (Long id : oldOrientationIds) {
+                        if (!newIds.contains(id)) {
+                            KuaishouPopulationPackageRel rel = new KuaishouPopulationPackageRel();
+                            rel.setDataStatus(0);
+                            rel.setOrientationId(id);
+                            rel.setAccountId(accountId);
+                            rel.setMessage("人群包已从媒体后台删除");
+                            relMapper.updateStatus(rel);
+                        }
+                    }
+                }
             }
         }));
         XxlJobHelper.log("快手人群报表更新成功");

+ 29 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouLandpagesJob.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class KuaishouLandpagesJob {
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
+    @XxlJob("kuaishouLandpagesJob")
+    public void execute() {
+        //获取快手有效的账户
+        List<Long> list = userAllocationService.getValidProjectIds(2);
+        list.forEach(projectId -> executorService.submit(() -> landpagePackageService.synchronousData(projectId)));
+        XxlJobHelper.log("快手落地页数据更新");
+    }
+}

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

@@ -0,0 +1,436 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-12
+ */
+@Slf4j
+@Api(tags = "项目绑定的应用")
+@RestController
+@RequestMapping("/kuaishouAppPackage")
+public class KuaishouAppPackageController {
+    @Autowired
+    private IKuaishouAppPackageService kuaishouAppPackageService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouAppPackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(KuaishouAppPackage kuaishouAppPackage, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouAppPackageService.queryPageList(kuaishouAppPackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询应用列表异常", e);
+        }
+        return Result.error("查询应用列表失败");
+    }
+
+    /**
+     * 查询相关账户
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccounts")
+    public Result<Object> getRelatedAccounts(Long id, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.getRelatedAccounts(id);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 查询相关组
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedGroups")
+    public Result<Object> getRelatedGroups(Long id, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.getRelatedGroups(id, accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getAccountByProjectId")
+    public Result<Object> getAccountByProjectId(Long projectId, String id,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.getAccountByProjectId(projectId, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 推送应用
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/pushAppPackage")
+    public Result<Object> pushAppPackage(@RequestBody JSONObject requestJson) {
+        try {
+            Long id = requestJson.getLong("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            if (Check.isNull(accountIds)) {
+                return Result.error("请选择推送账户");
+            }
+            return kuaishouAppPackageService.pushAppPackage(id, accountIds);
+        } catch (Exception e) {
+            log.error("推送应用异常", e);
+        }
+        return Result.error("推送失败");
+    }
+
+    /**
+     * 查询推送结果
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushResults")
+    public Result<Object> queryPushResults(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.queryPushResults(id, accountIds, null);
+        } catch (Exception e) {
+            log.error("查询推送结果异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询推送历史
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushHistory")
+    public Result<Object> queryPushHistory(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.queryPushResults(id, accountIds, requestJson.getString("status"));
+        } catch (Exception e) {
+            log.error("查询推送历史异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 添加——填写链接
+     *
+     * @param kuaishouAppPackage
+     * @return
+     */
+    @PostMapping(value = "/fillInLink")
+    public Result<Object> fillInLink(@RequestBody KuaishouAppPackage kuaishouAppPackage) {
+        try {
+            if (Check.isNull(kuaishouAppPackage.getProjectId())) {
+                return Result.error("请选择项目");
+            } else if (Check.isNull(kuaishouAppPackage.getAppVersion())) {
+                return Result.error("请填写应用标记");
+            } else if (Check.isNull(kuaishouAppPackage.getAppName())) {
+                return Result.error("请填写应用名称");
+            } else if (Check.isNull(kuaishouAppPackage.getPlatform())) {
+                return Result.error("请选择应用类型");
+            } else {
+                Integer platform = kuaishouAppPackage.getPlatform();
+                if ((platform == 1 || platform == 3) && Check.isNull(kuaishouAppPackage.getImageToken())) {
+                    return Result.error("请上传图标");
+                }
+                if ((platform == 1 || platform == 2) && Check.isNull(kuaishouAppPackage.getAppPrivacyUrl())) {
+                    return Result.error("安卓类应用隐私政策url不为空");
+                }
+                if (platform == 1 && Check.isNull(kuaishouAppPackage.getPackageName())) {
+                    return Result.error("请填写应用包名");
+                }
+            }
+            kuaishouAppPackage.setDataStatus(1);//有效
+            kuaishouAppPackageService.saveOrUpdate(kuaishouAppPackage);
+            return Result.ok("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return Result.error("操作失败");
+    }
+
+    /**
+     * 校验应用标记
+     *
+     * @param kuaishouAppPackage
+     * @return
+     */
+    @GetMapping(value = "/checkAppVersion")
+    public Result<Object> checkAppVersion(Long projectId, String appVersion, Long id) {
+        try {
+            if (Check.isNull(projectId) || Check.isNull(appVersion)) {
+                return Result.error("缺失参数");
+            }
+            List<Long> list = kuaishouAppPackageService.queryByAppVersion(projectId, appVersion);
+            if (Check.isNull(list)) {
+                return Result.ok("success");
+            } else {
+                //修改校验
+                if (!Check.isNull(id) && (list.size() == 1 && list.get(0) - id == 0)) {
+                    return Result.ok("success");
+                }
+                return Result.error("重复的应用标记");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return Result.error("操作失败");
+    }
+
+    /**
+     * 逻辑删除,修改模板状态
+     *
+     * @param kuaishouAppPackage
+     * @return
+     */
+    @PostMapping(value = "/delete")
+    public Result<KuaishouAppPackage> delete(@RequestBody KuaishouAppPackage kuaishouAppPackage) {
+        Result<KuaishouAppPackage> result = new Result<KuaishouAppPackage>();
+        KuaishouAppPackage kuaishouAppPackageEntity = kuaishouAppPackageService.getById(kuaishouAppPackage.getId());
+        if (kuaishouAppPackageEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            kuaishouAppPackage.setDataStatus(0);
+            boolean ok = kuaishouAppPackageService.updateById(kuaishouAppPackage);
+            if (ok) {
+                result.success("刪除成功!");
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "项目绑定的应用-通过id删除")
+    @ApiOperation(value = "项目绑定的应用-通过id删除", notes = "项目绑定的应用-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouAppPackageService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "项目绑定的应用-批量删除")
+    @ApiOperation(value = "项目绑定的应用-批量删除", notes = "项目绑定的应用-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouAppPackage> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouAppPackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouAppPackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "项目绑定的应用-通过id查询")
+    @ApiOperation(value = "项目绑定的应用-通过id查询", notes = "项目绑定的应用-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouAppPackage> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouAppPackage> result = new Result<>();
+        KuaishouAppPackage kuaishouAppPackage = kuaishouAppPackageService.getById(id);
+        if (kuaishouAppPackage == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouAppPackage);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出应用模板
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportAppTemplate")
+    public void exportXls(HttpServletRequest request, HttpServletResponse response) {
+        Map<String, Object> paramsMap = new HashMap<>();
+        try {
+            List<List<Object>> excelList = new ArrayList<>();
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            String[] titles = {"应用名称", "应用包名", "应用标记", "隐私政策链接", "下载链接", "监测链接", "广告监测SDK"};
+            eeu.exportExcelForAttendance(workbook, 0, "Sheet1", titles, excelList);
+            HttpUtils.setResponseHeader(response, "AppTemplate.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    /**
+     * 导入应用程序excel
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/importAppExcel")
+    @ResponseBody
+    public Result<Object> importExcel(HttpServletResponse response,
+                                      @RequestParam("file") MultipartFile file,
+                                      @RequestParam("projectId") Long projectId,
+                                      @RequestParam("platform") Integer platform,
+                                      @RequestParam("imageToken") String imageToken,
+                                      @RequestParam("imageUrl") String imageUrl) {
+        response.setHeader("Access-Control-Allow-Origin", "*");
+        try {
+            if (Check.isNull(file)) {
+                return Result.error("执行失败,请上传应用Excel文件");
+            } else if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            } else if (Check.isNull(imageToken) || Check.isNull(imageUrl)) {
+                return Result.error("请上传图标");
+            } else if (Check.isNull(platform)) {
+                return Result.error("请选择应用类型");
+            }
+            return kuaishouAppPackageService.importExcel(file, projectId, platform, imageToken, imageUrl);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("解析应用Excel文档异常", e);
+            return Result.error("解析应用Excel文档失败," + e.getMessage());
+        }
+    }
+
+}

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

@@ -1,403 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.controller;
-
-import cn.com.ctop.common.module.annotation.AutoLog;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.QueryGenerator;
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
-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;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 人群报表
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2021-03-26
- */
-@Slf4j
-@Api(tags = "人群报表")
-@RestController
-@RequestMapping("/kuaishouCrowdPack")
-public class KuaishouCrowdPackController {
-    @Autowired
-    private IKuaishouCrowdPackService kuaishouCrowdPackService;
-
-    /**
-     * 分页列表查询
-     *
-     * @param kuaishouCrowdPack
-     * @param pageNo
-     * @param pageSize
-     * @param req
-     * @return
-     */
-    @AutoLog(value = "人群报表-分页列表查询")
-    @ApiOperation(value = "人群报表-分页列表查询", notes = "人群报表-分页列表查询")
-    @GetMapping(value = "/list")
-    public Result<IPage<KuaishouCrowdPack>> list(KuaishouCrowdPack kuaishouCrowdPack,
-                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                 HttpServletRequest req) {
-        Result<IPage<KuaishouCrowdPack>> result = new Result<>();
-        QueryWrapper<KuaishouCrowdPack> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCrowdPack, req.getParameterMap());
-        Page<KuaishouCrowdPack> page = new Page<KuaishouCrowdPack>(pageNo, pageSize);
-        IPage<KuaishouCrowdPack> pageList = kuaishouCrowdPackService.page(page, queryWrapper);
-        result.setSuccess(true);
-        result.setResult(pageList);
-        return result;
-    }
-
-    /**
-     * 人群包列表
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/queryPageList")
-    public Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack,
-                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-        try {
-            return kuaishouCrowdPackService.queryPageList(kuaishouCrowdPack, pageNo, pageSize);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 相关账户查询
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/queryRel")
-    public Result<Object> queryRel(String type, String signature,
-                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-        try {
-            if (Check.isNull(type) || Check.isNull(signature)) {
-                return Result.error("缺失参数");
-            }
-            return kuaishouCrowdPackService.queryRel(type, signature, pageNo, pageSize);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 查询原因
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/queryFailReason")
-    public Result<Object> queryFailReason(String signature,
-                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-        try {
-            return kuaishouCrowdPackService.queryFailReason(signature, pageNo, pageSize);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 上传前的人群包校验
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/checkCrowdPackage")
-    public Result<Object> checkCrowdPackage(String signature) {
-        try {
-            return kuaishouCrowdPackService.checkCrowdPackage(signature);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 上传人群包
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-
-    @PostMapping(value = "/uploadCrowdPack")
-    public Result<Object> uploadCrowdPack(@RequestBody JSONObject request) {
-        Integer type = request.getInteger("type");
-        String orientationName = request.getString("orientationName");
-        Long accountId = request.getLong("accountId");
-        String url = request.getString("url");
-        try {
-            if (Check.isNull(type) || Check.isNull(orientationName) || Check.isNull(url) || Check.isNull(accountId)) {
-                return Result.error("缺少参数");
-            }
-            return kuaishouCrowdPackService.uploadCrowdPack(type, orientationName, accountId, url);
-        } catch (Exception e) {
-            log.error("上传异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("上传失败");
-    }
-
-    /**
-     * 账户推送
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-    @AutoLog(value = "账户推送")
-    @ApiOperation(value = "账户推送", notes = "账户推送")
-    @PostMapping(value = "/accountPush")
-    public Result<Object> accountPush(@RequestBody JSONObject request) {
-        try {
-            JSONArray accountIds = request.getJSONArray("accountIds");
-            String signature = request.getString("signature");
-            if (Check.isNull(accountIds) || Check.isNull(signature)) {
-                return Result.error("缺少参数");
-            }
-            return kuaishouCrowdPackService.accountPush(request);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    @RequestMapping(value = "/crowdListQuery")
-    public Result<Object> crowdListQuery() {
-        try {
-            kuaishouCrowdPackService.crowdListQuery();
-            return Result.ok("success");
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 添加
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-    @AutoLog(value = "人群报表-添加")
-    @ApiOperation(value = "人群报表-添加", notes = "人群报表-添加")
-    @PostMapping(value = "/add")
-    public Result<KuaishouCrowdPack> add(@RequestBody KuaishouCrowdPack kuaishouCrowdPack) {
-        Result<KuaishouCrowdPack> result = new Result<>();
-        try {
-            kuaishouCrowdPackService.save(kuaishouCrowdPack);
-            result.success("添加成功!");
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            result.error500("操作失败");
-        }
-        return result;
-    }
-
-    /**
-     * 编辑
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-    @AutoLog(value = "人群报表-编辑")
-    @ApiOperation(value = "人群报表-编辑", notes = "人群报表-编辑")
-    @PostMapping(value = "/edit")
-    public Result<KuaishouCrowdPack> edit(@RequestBody KuaishouCrowdPack kuaishouCrowdPack) {
-        Result<KuaishouCrowdPack> result = new Result<KuaishouCrowdPack>();
-        KuaishouCrowdPack kuaishouCrowdPackEntity = kuaishouCrowdPackService.getById(kuaishouCrowdPack.getId());
-        if (kuaishouCrowdPackEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = kuaishouCrowdPackService.updateById(kuaishouCrowdPack);
-            if (ok) {
-                result.success("修改成功!");
-            }
-        }
-        return result;
-    }
-
-    /**
-     * 通过id删除
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "人群报表-通过id删除")
-    @ApiOperation(value = "人群报表-通过id删除", notes = "人群报表-通过id删除")
-    @GetMapping(value = "/delete")
-    public Result<Object> delete(KuaishouCrowdPack kuaishouCrowdPack) {
-        KuaishouCrowdPack kuaishouCrowdPackEntity = kuaishouCrowdPackService.getById(kuaishouCrowdPack.getId());
-        if (kuaishouCrowdPackEntity == null) {
-            return Result.error("未找到对应实体");
-        } else {
-            kuaishouCrowdPackEntity.setDataStatus(0);
-            return kuaishouCrowdPackService.updateDataStatus(kuaishouCrowdPackEntity);
-        }
-    }
-
-    /**
-     * 批量删除
-     *
-     * @param ids
-     * @return
-     */
-    @AutoLog(value = "人群报表-批量删除")
-    @ApiOperation(value = "人群报表-批量删除", notes = "人群报表-批量删除")
-    @DeleteMapping(value = "/deleteBatch")
-    public Result<KuaishouCrowdPack> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        Result<KuaishouCrowdPack> result = new Result<>();
-        if (ids == null || "".equals(ids.trim())) {
-            result.error500("参数不识别!");
-        } else {
-            this.kuaishouCrowdPackService.removeByIds(Arrays.asList(ids.split(",")));
-            result.success("删除成功!");
-        }
-        return result;
-    }
-
-    /**
-     * 通过id查询
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "人群报表-通过id查询")
-    @ApiOperation(value = "人群报表-通过id查询", notes = "人群报表-通过id查询")
-    @GetMapping(value = "/queryById")
-    public Result<KuaishouCrowdPack> queryById(@RequestParam(name = "id", required = true) String id) {
-        Result<KuaishouCrowdPack> result = new Result<>();
-        KuaishouCrowdPack kuaishouCrowdPack = kuaishouCrowdPackService.getById(id);
-        if (kuaishouCrowdPack == null) {
-            result.error500("未找到对应实体");
-        } else {
-            result.setResult(kuaishouCrowdPack);
-            result.setSuccess(true);
-        }
-        return result;
-    }
-
-    /**
-     * 导出excel
-     *
-     * @param request
-     * @param response
-     */
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
-        // Step.1 组装查询条件
-        QueryWrapper<KuaishouCrowdPack> queryWrapper = null;
-        try {
-            String paramsStr = request.getParameter("paramsStr");
-            if (oConvertUtils.isNotEmpty(paramsStr)) {
-                String deString = URLDecoder.decode(paramsStr, "UTF-8");
-                KuaishouCrowdPack kuaishouCrowdPack = JSON.parseObject(deString, KuaishouCrowdPack.class);
-                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCrowdPack, request.getParameterMap());
-            }
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-
-        //Step.2 AutoPoi 导出Excel
-        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-        List<KuaishouCrowdPack> pageList = kuaishouCrowdPackService.list(queryWrapper);
-        //导出文件名称
-        mv.addObject(NormalExcelConstants.FILE_NAME, "人群报表列表");
-        mv.addObject(NormalExcelConstants.CLASS, KuaishouCrowdPack.class);
-        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("人群报表列表数据", "导出人:Jeecg", "导出信息"));
-        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
-        return mv;
-    }
-
-    /**
-     * 通过excel导入数据
-     *
-     * @param request
-     * @param response
-     * @return
-     */
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
-        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
-            MultipartFile file = entity.getValue();
-            ImportParams params = new ImportParams();
-            params.setTitleRows(2);
-            params.setHeadRows(1);
-            params.setNeedSave(true);
-            try {
-                List<KuaishouCrowdPack> listKuaishouCrowdPacks = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouCrowdPack.class, params);
-                kuaishouCrowdPackService.saveBatch(listKuaishouCrowdPacks);
-                return Result.ok("文件导入成功!数据行数:" + listKuaishouCrowdPacks.size());
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return Result.error("文件导入失败:" + e.getMessage());
-            } finally {
-                try {
-                    file.getInputStream().close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return Result.ok("文件导入失败!");
-    }
-
-}

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

@@ -0,0 +1,493 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+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;
+import com.github.pagehelper.PageHelper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Slf4j
+@Api(tags = "自动投放-定向包详情")
+@RestController
+@RequestMapping("/kuaishouDirectionalPackage")
+public class KuaishouDirectionalPackageController {
+    @Autowired
+    private IKuaishouDirectionalPackageService kuaishouDirectionalPackageService;
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouDirectionalPackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-分页列表查询")
+    @ApiOperation(value = "自动投放-定向包详情-分页列表查询", notes = "自动投放-定向包详情-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouDirectionalPackage>> queryPageList(KuaishouDirectionalPackage kuaishouDirectionalPackage,
+                                                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                   HttpServletRequest req) {
+        Result<IPage<KuaishouDirectionalPackage>> result = new Result<>();
+        QueryWrapper<KuaishouDirectionalPackage> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouDirectionalPackage, req.getParameterMap());
+        Page<KuaishouDirectionalPackage> page = new Page<KuaishouDirectionalPackage>(pageNo, pageSize);
+        IPage<KuaishouDirectionalPackage> pageList = kuaishouDirectionalPackageService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 查询定向包列表
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/queryList")
+    public Result<Object> queryList(KuaishouDirectionalPackage directionalPackage,
+                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouDirectionalPackageService.queryList(directionalPackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e);
+            return Result.error("查询失败," + e.getMessage());
+        }
+
+    }
+
+    /**
+     * 相关账户/组
+     *
+     * @param projectId 账户ID
+     * @param type      1是账户,2是组维度
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccountGroup")
+    public Result<Object> getRelatedAccountGroup(String id, Integer type, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(type)) {
+                return Result.error("请选择查询类型");
+            }
+            return kuaishouDirectionalPackageService.getRelatedAccountGroup(id, type, accountId, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e);
+            return Result.error("查询失败");
+        }
+
+    }
+
+    /**
+     * 编辑定向包
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/editPopulation")
+    public Result<Object> editPopulation(@RequestBody JSONObject requestJson) {
+        try {
+            if (Check.isNull(requestJson.getString("id"))) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(requestJson.getLong("accountId"))) {
+                return Result.error("请选择账户");
+            }
+            if (Check.isNull(requestJson.getLong("templateId"))) {
+                return Result.error("未获取到定向包ID");
+            }
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                return Result.error("未获取到定向包名称");
+            }
+            return kuaishouDirectionalPackageService.editPopulation(requestJson);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getAccountByProjectId")
+    public Result<Object> getAccountByProjectId(Long projectId, String id,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouDirectionalPackageService.getAccountByProjectId(projectId, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 创建定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/createDirectionalPackage")
+    public Result<Object> createDirectionalPackage(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                return Result.error("定向模板名称为必传项");
+            }
+            Long accountId = requestJson.getLong("projectId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择账户id");
+            }
+            return kuaishouDirectionalPackageService.createDirectionalPackage(requestJson);
+        } catch (Exception e) {
+            log.error("创建定向包失败", e);
+            return Result.error("创建失败" + e.getMessage());
+        }
+    }
+
+    /**
+     * 修改定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/updateDirectionalPackage")
+    public Result<Object> updateDirectionalPackage(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson.getString("id"))) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(requestJson.getString("projectId"))) {
+                return Result.error("请选择项目");
+            }
+            return kuaishouDirectionalPackageService.updateDirectionalPackage(requestJson);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return Result.error("上传失败");
+    }
+
+    /**
+     * 推送定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/pushDirectionalPackage")
+    public Result<Object> pushDirectionalPackage(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray datas = requestJson.getJSONArray("datas");
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(datas)) {
+                return Result.error("请选择推送账户");
+            }
+            return kuaishouDirectionalPackageService.pushDirectionalPackage(id, datas);
+        } catch (Exception e) {
+            log.error("推送定向包异常", e);
+        }
+        return Result.error("推送失败");
+    }
+
+    /**
+     * 查询推送结果
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushResults")
+    public Result<Object> queryPushResults(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouDirectionalPackageService.queryPushResults(id, accountIds, requestJson.getString("status"));
+        } catch (Exception e) {
+            log.error("查询推送结果异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 删除定向模板
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<?>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/delete")
+    public Result<Object> delete(String id) {
+        try {
+            boolean b = kuaishouDirectionalPackageService.removeById(id);
+            if (b) {
+                return Result.ok("删除成功");
+            }
+        } catch (Exception e) {
+            log.error("删除异常", e);
+        }
+        return Result.error("删除失败!");
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouDirectionalPackage
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-添加")
+    @ApiOperation(value = "自动投放-定向包详情-添加", notes = "自动投放-定向包详情-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouDirectionalPackage> add(@RequestBody KuaishouDirectionalPackage kuaishouDirectionalPackage) {
+        Result<KuaishouDirectionalPackage> result = new Result<>();
+        try {
+            kuaishouDirectionalPackageService.save(kuaishouDirectionalPackage);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouDirectionalPackage
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-编辑")
+    @ApiOperation(value = "自动投放-定向包详情-编辑", notes = "自动投放-定向包详情-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouDirectionalPackage> edit(@RequestBody KuaishouDirectionalPackage kuaishouDirectionalPackage) {
+        Result<KuaishouDirectionalPackage> result = new Result<KuaishouDirectionalPackage>();
+        KuaishouDirectionalPackage kuaishouDirectionalPackageEntity = kuaishouDirectionalPackageService.getById(kuaishouDirectionalPackage.getId());
+        if (kuaishouDirectionalPackageEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouDirectionalPackageService.updateById(kuaishouDirectionalPackage);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-批量删除")
+    @ApiOperation(value = "自动投放-定向包详情-批量删除", notes = "自动投放-定向包详情-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouDirectionalPackage> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouDirectionalPackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouDirectionalPackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 查询待修改的定向包
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/queryById")
+    public Result<Object> queryById(@RequestParam(name = "id", required = true) String id) {
+        KuaishouDirectionalPackage kuaishouDirectionalPackage = kuaishouDirectionalPackageService.getById(id);
+        if (kuaishouDirectionalPackage == null) {
+            return Result.error("未找到对应实体");
+        } else {
+            JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(kuaishouDirectionalPackage)).toJavaObject(JSONObject.class);
+            if (!Check.isNull(data.getString("keyword"))) {
+                data.put("keyword", data.getJSONArray("keyword"));
+            }
+            return Result.ok(data);
+        }
+    }
+
+    /**
+     * 查询待修改的定向包
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/queryPopulationById")
+    public Result<Object> queryPopulationById(Long templateId, Long accountId) {
+        try {
+            if (Check.isNull(templateId) || Check.isNull(accountId)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouDirectionalPackageService.queryPopulationById(templateId, accountId);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouDirectionalPackage> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouDirectionalPackage kuaishouDirectionalPackage = JSON.parseObject(deString, KuaishouDirectionalPackage.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouDirectionalPackage, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouDirectionalPackage> pageList = kuaishouDirectionalPackageService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "自动投放-定向包详情列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouDirectionalPackage.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("自动投放-定向包详情列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouDirectionalPackage> listKuaishouDirectionalPackages = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouDirectionalPackage.class, params);
+                kuaishouDirectionalPackageService.saveBatch(listKuaishouDirectionalPackages);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouDirectionalPackages.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,337 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.pagehelper.PageHelper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 落地页账户项目关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-11
+ */
+@Slf4j
+@Api(tags = "落地页账户项目关联表")
+@RestController
+@RequestMapping("/kuaishouLandpagePackage")
+public class KuaishouLandpagePackageController {
+    @Autowired
+    private IKuaishouLandpagePackageService kuaishouLandpagePackageService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouLandpagePackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-分页列表查询")
+    @ApiOperation(value = "落地页账户项目关联表-分页列表查询", notes = "落地页账户项目关联表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(KuaishouLandpagePackage kuaishouLandpagePackage, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouLandpagePackageService.queryPageList(kuaishouLandpagePackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询落地页列表异常", e);
+        }
+        return Result.error("查询落地页列表失败");
+    }
+
+    /**
+     * 同步项目下落地页和账户关联数据
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/synchronousData")
+    public Result<Object> synchronousData(KuaishouLandpagePackage kuaishouLandpagePackage) {
+        try {
+            if (Check.isNull(kuaishouLandpagePackage.getProjectId())) {
+                return Result.error("请选择项目");
+            }
+            return kuaishouLandpagePackageService.synchronousData(kuaishouLandpagePackage.getProjectId());
+        } catch (Exception e) {
+            log.error("同步落地页数据异常", e);
+        }
+        return Result.error("同步落地页数据失败");
+    }
+
+    /**
+     * 查询相关账户
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccounts")
+    public Result<Object> getRelatedAccounts(Long siteId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(siteId)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouLandpagePackageService.getRelatedAccounts(siteId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 查询相关组
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedGroups")
+    public Result<Object> getRelatedGroups(Long siteId, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(siteId)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouLandpagePackageService.getRelatedGroups(siteId, accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/createLandPageAndUnit")
+    public Result<Object> createLandPageAndUnit(Long siteId, Long creativeId, Long unitId, Long accountId) {
+        try {
+            kuaishouLandpagePackageService.createLandPageAndUnit(siteId, creativeId, unitId, accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.ok("ok");
+
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouLandpagePackage
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-添加")
+    @ApiOperation(value = "落地页账户项目关联表-添加", notes = "落地页账户项目关联表-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouLandpagePackage> add(@RequestBody KuaishouLandpagePackage kuaishouLandpagePackage) {
+        Result<KuaishouLandpagePackage> result = new Result<>();
+        try {
+            kuaishouLandpagePackageService.save(kuaishouLandpagePackage);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouLandpagePackage
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-编辑")
+    @ApiOperation(value = "落地页账户项目关联表-编辑", notes = "落地页账户项目关联表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouLandpagePackage> edit(@RequestBody KuaishouLandpagePackage kuaishouLandpagePackage) {
+        Result<KuaishouLandpagePackage> result = new Result<KuaishouLandpagePackage>();
+        KuaishouLandpagePackage kuaishouLandpagePackageEntity = kuaishouLandpagePackageService.getById(kuaishouLandpagePackage.getId());
+        if (kuaishouLandpagePackageEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouLandpagePackageService.updateById(kuaishouLandpagePackage);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-通过id删除")
+    @ApiOperation(value = "落地页账户项目关联表-通过id删除", notes = "落地页账户项目关联表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouLandpagePackageService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-批量删除")
+    @ApiOperation(value = "落地页账户项目关联表-批量删除", notes = "落地页账户项目关联表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouLandpagePackage> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouLandpagePackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouLandpagePackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-通过id查询")
+    @ApiOperation(value = "落地页账户项目关联表-通过id查询", notes = "落地页账户项目关联表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouLandpagePackage> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouLandpagePackage> result = new Result<>();
+        KuaishouLandpagePackage kuaishouLandpagePackage = kuaishouLandpagePackageService.getById(id);
+        if (kuaishouLandpagePackage == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouLandpagePackage);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouLandpagePackage> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouLandpagePackage kuaishouLandpagePackage = JSON.parseObject(deString, KuaishouLandpagePackage.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouLandpagePackage, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouLandpagePackage> pageList = kuaishouLandpagePackageService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "落地页账户项目关联表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouLandpagePackage.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("落地页账户项目关联表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouLandpagePackage> listKuaishouLandpagePackages = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouLandpagePackage.class, params);
+                kuaishouLandpagePackageService.saveBatch(listKuaishouLandpagePackages);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouLandpagePackages.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,412 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageService;
+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.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-06
+ */
+@Slf4j
+@Api(tags = "项目绑定的人群包模板")
+@RestController
+@RequestMapping("/kuaishouPopulationPackage")
+public class KuaishouPopulationPackageController {
+    @Autowired
+    private IKuaishouPopulationPackageService kuaishouPopulationPackageService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouPopulationPackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-分页列表查询", notes = "项目绑定的人群包模板-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(KuaishouPopulationPackage kuaishouPopulationPackage,
+                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouPopulationPackageService.queryPageList(kuaishouPopulationPackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询人群包列表异常", e);
+        }
+        return Result.error("查询人群包列表失败");
+    }
+
+    /**
+     * 查询推送结果
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushResults")
+    public Result<Object> queryPushResults(@RequestBody JSONObject requestJson) {
+        try {
+            Long id = requestJson.getLong("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(accountIds) || Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.queryPushResults(id, accountIds);
+        } catch (Exception e) {
+            log.error("查询推送结果异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询推送历史
+     *
+     * @param
+     * @return
+     */
+    @GetMapping(value = "/queryPushHistory")
+    public Result<Object> queryPushHistory(Long id, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.queryPushHistory(id);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询相关账户
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccounts")
+    public Result<Object> getRelatedAccounts(Long id, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.getRelatedAccounts(id);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 查询相关组
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedGroups")
+    public Result<Object> getRelatedGroups(Long id,Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.getRelatedGroups(id,accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getAccountByProjectId")
+    public Result<Object> getAccountByProjectId(Long projectId, String id,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.getAccountByProjectId(projectId, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @RequestMapping(value = "/crowdListQuery")
+    public Result<Object> crowdListQuery() {
+        try {
+            kuaishouPopulationPackageService.crowdListQuery();
+            return Result.ok("success");
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @RequestMapping(value = "/checkPopulationPackage")
+    public Result<Object> checkPopulationPackage(String signature) {
+        try {
+           return kuaishouPopulationPackageService.checkPopulationPackage(signature);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 添加
+     *
+     * @param kuaishouPopulationPackage
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-添加", notes = "项目绑定的人群包模板-添加")
+    @PostMapping(value = "/add")
+    public Result<Object> add(@RequestBody KuaishouPopulationPackage kuaishouPopulationPackage) {
+        Result<KuaishouPopulationPackage> result = new Result<>();
+        try {
+            if (Check.isNull(kuaishouPopulationPackage.getType())) {
+                return Result.error("请选择匹配类型");
+            }
+            if (Check.isNull(kuaishouPopulationPackage.getOrientationName())) {
+                return Result.error("请填写人群包名称");
+            }
+            if (Check.isNull(kuaishouPopulationPackage.getUrl())) {
+                return Result.error("请填写文件路径");
+            }
+            if (Check.isNull(kuaishouPopulationPackage.getProjectId())) {
+                return Result.error("请选择项目");
+            }
+            return kuaishouPopulationPackageService.createEntity(kuaishouPopulationPackage);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("上传异常");
+        }
+        return Result.error("上传失败");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouPopulationPackage
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-编辑", notes = "项目绑定的人群包模板-编辑")
+    @PostMapping(value = "/push")
+    public Result<Object> push(@RequestBody JSONObject request) {
+        try {
+            JSONArray accountIds = request.getJSONArray("accountIds");
+            Long id = request.getLong("id");
+            if (Check.isNull(accountIds) || Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouPopulationPackageService.push(accountIds, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("推送失败");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-通过id删除", notes = "项目绑定的人群包模板-通过id删除")
+    @GetMapping(value = "/delete")
+    public Result<Object> delete(Long id) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("参数为空");
+            }
+            KuaishouPopulationPackage populationPackage = new KuaishouPopulationPackage();
+            populationPackage.setId(id);
+            populationPackage.setDataStatus(0);//逻辑删除
+            boolean b = kuaishouPopulationPackageService.updateById(populationPackage);
+            if (b) {
+                return Result.ok("删除成功!");
+            }
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+        }
+        return Result.error("删除失败!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-批量删除", notes = "项目绑定的人群包模板-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouPopulationPackage> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaishouPopulationPackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouPopulationPackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-通过id查询", notes = "项目绑定的人群包模板-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouPopulationPackage> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouPopulationPackage> result = new Result<>();
+        KuaishouPopulationPackage kuaishouPopulationPackage = kuaishouPopulationPackageService.getById(id);
+        if (kuaishouPopulationPackage == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouPopulationPackage);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouPopulationPackage> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouPopulationPackage kuaishouPopulationPackage = JSON.parseObject(deString, KuaishouPopulationPackage.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouPopulationPackage, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouPopulationPackage> pageList = kuaishouPopulationPackageService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "项目绑定的人群包模板列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouPopulationPackage.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("项目绑定的人群包模板列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouPopulationPackage> listKuaishouPopulationPackages = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouPopulationPackage.class, params);
+                kuaishouPopulationPackageService.saveBatch(listKuaishouPopulationPackages);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouPopulationPackages.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,71 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 应用-广告组关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-14
+ */
+@Data
+@TableName("ctop_kuaishou_app_group")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_app_group对象", description = "应用-广告组关联表")
+public class KuaishouAppGroup {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 广告组ID
+     */
+    @Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+    private Long unitId;
+    /**
+     * 应用id
+     */
+    @Excel(name = "应用id", width = 15)
+    @ApiModelProperty(value = "应用id")
+    private Long appId;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 126 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppPackage.java

@@ -0,0 +1,126 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-12
+ */
+@Data
+@TableName("ctop_kuaishou_app_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_app_package对象", description = "项目绑定的应用")
+public class KuaishouAppPackage {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 应用唯一标识
+     */
+    @Excel(name = "应用唯一标识", width = 15)
+    @ApiModelProperty(value = "应用唯一标识")
+    private String appMd5;
+    /**
+     * 应用地址
+     */
+    @Excel(name = "应用地址", width = 15)
+    @ApiModelProperty(value = "应用地址")
+    private String url;
+    /**
+     * 应用标记
+     */
+    @Excel(name = "应用标记", width = 15)
+    @ApiModelProperty(value = "应用标记")
+    private String appVersion;
+    /**
+     * 应用名称
+     */
+    @Excel(name = "应用名称", width = 15)
+    @ApiModelProperty(value = "应用名称")
+    private String appName;
+    /**
+     * 应用图标链接地址
+     */
+    @Excel(name = "应用图标链接地址", width = 15)
+    @ApiModelProperty(value = "应用图标链接地址")
+    private String appIconUrl;
+    /**
+     * 安卓类应用必填 隐私政策链接
+     */
+    private String appPrivacyUrl;
+    /**
+     * 图片token
+     */
+    @Excel(name = "图片token", width = 15)
+    @ApiModelProperty(value = "图片token")
+    private String imageToken;
+    /**
+     * 应用包名
+     */
+    @Excel(name = "应用包名", width = 15)
+    @ApiModelProperty(value = "应用包名")
+    private String packageName;
+
+    /**
+     * 监测链接
+     */
+    private String trackUrl;
+    /**
+     * 应用类型 1: Android 应用下载,2: Android 网页游戏,3: iOS 应用下载, 4:iOS 网页游戏
+     */
+    @Excel(name = "应用类型 1: Android 应用下载,2: Android 网页游戏,3: iOS 应用下载, 4:iOS 网页游戏", width = 15)
+    @ApiModelProperty(value = "应用类型 1: Android 应用下载,2: Android 网页游戏,3: iOS 应用下载, 4:iOS 网页游戏")
+    private Integer platform;
+    /**
+     * 是否接入快手广告监测SDK	0:未接入,1:已接入
+     */
+    @Excel(name = "是否接入快手广告监测SDK	0:未接入,1:已接入", width = 15)
+    @ApiModelProperty(value = "是否接入快手广告监测SDK	0:未接入,1:已接入")
+    private Integer useSdk;
+    /**
+     * 0无效,1有效
+     */
+    private Integer dataStatus;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 79 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppPackageRel.java

@@ -0,0 +1,79 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 应用和账户关联表
+ * @author jeecg-boot
+ * @date   2021-05-13
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_app_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_app_package_rel对象", description="应用和账户关联表")
+public class KuaishouAppPackageRel {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	@ApiModelProperty(value = "id")
+	private Long id;
+	/**应用模板ID*/
+	@Excel(name = "应用模板ID", width = 15)
+	@ApiModelProperty(value = "应用模板ID")
+	private Long apptemId;
+	/**项目ID*/
+	@Excel(name = "项目ID", width = 15)
+	@ApiModelProperty(value = "项目ID")
+	private Long projectId;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+	@ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+	@ApiModelProperty(value = "账户ID")
+	private Long appId;
+	/**快手方-应用地址*/
+	@Excel(name = "快手方-应用地址", width = 15)
+	@ApiModelProperty(value = "快手方-应用地址")
+	private String returnUrl;
+
+	private Integer dataStatus;
+
+	private String appVersion;
+	/**返回信息*/
+	@Excel(name = "返回信息", width = 15)
+	@ApiModelProperty(value = "返回信息")
+	private String message;
+	/**更新时间*/
+	@Excel(name = "更新时间", width = 15)
+	@ApiModelProperty(value = "更新时间")
+	private String returnUpdateTime;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	@ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	@ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+}

+ 232 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouDirectionalPackage.java

@@ -0,0 +1,232 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Data
+@TableName("ctop_kuaishou_directional_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_directional_package对象", description = "自动投放-定向包详情")
+public class KuaishouDirectionalPackage {
+
+    /**
+     * id
+     */
+    private String id;
+    /**
+     * 定向模板id
+     */
+    private Long projectId;
+    /**
+     * 0无效,1有效
+     */
+    private Integer dataStatus;
+
+    private String templateName;
+    /**
+     * 地域
+     */
+    @Excel(name = "地域", width = 15)
+    @ApiModelProperty(value = "地域")
+    private String region;
+    /**
+     * 商圈定向
+     */
+    @Excel(name = "商圈定向", width = 15)
+    @ApiModelProperty(value = "商圈定向")
+    private String districtIds;
+    /**
+     * 用户类型 0:实时1:常驻 2:不限
+     */
+    @Excel(name = "用户类型 0:实时1:常驻 2:不限 ", width = 15)
+    @ApiModelProperty(value = "用户类型 0:实时1:常驻 2:不限 ")
+    private Integer userType;
+    /**
+     * 可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁
+     */
+    @Excel(name = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ", width = 15)
+    @ApiModelProperty(value = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ")
+    private String agesRange;
+    /**
+     * 年龄最小值
+     */
+    @Excel(name = "年龄最小值", width = 15)
+    @ApiModelProperty(value = "年龄最小值")
+    private Integer min;
+    /**
+     * 年龄最大值
+     */
+    @Excel(name = "年龄最大值", width = 15)
+    @ApiModelProperty(value = "年龄最大值")
+    private Integer max;
+    /**
+     * 性别 1:女性, 2:男性,0 表示不限
+     */
+    @Excel(name = "性别 1:女性, 2:男性,0 表示不限", width = 15)
+    @ApiModelProperty(value = "性别 1:女性, 2:男性,0 表示不限")
+    private Integer gender;
+    /**
+     * 定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限
+     */
+    @Excel(name = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限", width = 15)
+    @ApiModelProperty(value = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限")
+    private Integer platformOs;
+    /**
+     * Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+
+     */
+    @Excel(name = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+", width = 15)
+    @ApiModelProperty(value = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+")
+    private Integer androidOsv;
+    /**
+     * iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+
+     */
+    @Excel(name = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+", width = 15)
+    @ApiModelProperty(value = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+")
+    private Integer iosOsv;
+    /**
+     * 网络环境 1:WI-FI,2:移动网络,0:表示不限
+     */
+    @Excel(name = "网络环境 1:WI-FI,2:移动网络,0:表示不限", width = 15)
+    @ApiModelProperty(value = "网络环境 1:WI-FI,2:移动网络,0:表示不限")
+    private Integer network;
+    /**
+     * 过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP
+     */
+    @Excel(name = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP", width = 15)
+    @ApiModelProperty(value = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP")
+    private Integer filterConvertedLevel;
+    /**
+     * 设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向
+     */
+    @Excel(name = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向", width = 15)
+    @ApiModelProperty(value = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向")
+    private String deviceBrand;
+    /**
+     * 设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限
+     */
+    @Excel(name = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限", width = 15)
+    @ApiModelProperty(value = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限")
+    private String devicePrice;
+    /**
+     * 商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签
+     */
+    @Excel(name = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签", width = 15)
+    @ApiModelProperty(value = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签")
+    private Integer businessInterestType;
+    /**
+     * 商业兴趣
+     */
+    @Excel(name = "商业兴趣", width = 15)
+    @ApiModelProperty(value = "商业兴趣")
+    private String businessInterest;
+    /**
+     * 网红类别
+     */
+    @Excel(name = "网红类别", width = 15)
+    @ApiModelProperty(value = "网红类别")
+    private String fansStar;
+    /**
+     * 兴趣视频
+     */
+    @Excel(name = "兴趣视频", width = 15)
+    @ApiModelProperty(value = "兴趣视频")
+    private String interestVideo;
+    /**
+     * APP行为-按分类
+     */
+    @Excel(name = "APP行为-按分类", width = 15)
+    @ApiModelProperty(value = "APP行为-按分类")
+    private String appInterest;
+    /**
+     * APP行为-按APP名称
+     */
+    @Excel(name = "APP行为-按APP名称", width = 15)
+    @ApiModelProperty(value = "APP行为-按APP名称")
+    private String appIds;
+    /**
+     * 开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0
+     */
+    @Excel(name = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0", width = 15)
+    @ApiModelProperty(value = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0")
+    private Integer isOpen;
+    /**
+     * 不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)")
+    private Integer noAgeBreak;
+    /**
+     * 不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破
+     */
+    @Excel(name = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破", width = 15)
+    @ApiModelProperty(value = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破")
+    private Integer noGenderBreak;
+    /**
+     * 不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)")
+    private Integer noAreaBreak;
+    /**
+     * 行为定向关键词
+     */
+    @Excel(name = "行为定向关键词", width = 15)
+    @ApiModelProperty(value = "行为定向关键词")
+    private String keyword;
+    /**
+     * 行为定向 类目词
+     */
+    @Excel(name = "行为定向 类目词", width = 15)
+    @ApiModelProperty(value = "行为定向 类目词")
+    private String label;
+    /**
+     * 兴趣定向类目词
+     */
+    @Excel(name = "兴趣定向类目词", width = 15)
+    @ApiModelProperty(value = "兴趣定向类目词")
+    private String interestLabel;
+    /**
+     * 在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天
+     */
+    @Excel(name = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天", width = 15)
+    @ApiModelProperty(value = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天")
+    private Integer timeType;
+    /**
+     * 行为强度	0:不限 1:高强度
+     */
+    @Excel(name = "行为强度	0:不限 1:高强度", width = 15)
+    @ApiModelProperty(value = "行为强度	0:不限 1:高强度")
+    private Integer strengthType;
+    /**
+     * 行为场景	1:社区 2:APP 4:推广
+     */
+    @Excel(name = "行为场景	1:社区 2:APP 4:推广", width = 15)
+    @ApiModelProperty(value = "行为场景	1:社区 2:APP 4:推广")
+    private String sceneType;
+    /**
+     * 定向模板创建时间
+     */
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

+ 109 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouDirectionalaPckageRel.java

@@ -0,0 +1,109 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 自动投放-定向包详情关系表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-25
+ */
+@Data
+@TableName("ctop_kuaishou_directional_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_directional_template_rel对象", description = "自动投放-定向包详情关系表")
+public class KuaishouDirectionalaPckageRel {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 本地定向模板ID
+     */
+    @Excel(name = "本地定向模板ID", width = 15)
+    @ApiModelProperty(value = "本地定向模板ID")
+    private String dirId;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 0无效,1有效
+     */
+    private Integer dataStatus;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+    /**
+     * 人群包名
+     */
+    @Excel(name = "人群包名", width = 15)
+    @ApiModelProperty(value = "人群包名")
+    private String templateName;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long relId;
+    /**
+     * 绑定类型,account 账户,unit 组
+     */
+    @Excel(name = "绑定类型,account 账户,unit 组", width = 15)
+    @ApiModelProperty(value = "绑定类型,account 账户,unit 组")
+    private String relType;
+    /**
+     * 排除人群包
+     */
+    @Excel(name = "排除人群包", width = 15)
+    @ApiModelProperty(value = "排除人群包")
+    private String excludePopulation;
+    /**
+     * 付费人群包
+     */
+    @Excel(name = "付费人群包", width = 15)
+    @ApiModelProperty(value = "付费人群包")
+    private String paidAudience;
+    /**
+     * 定向人群包
+     */
+    @Excel(name = "定向人群包", width = 15)
+    @ApiModelProperty(value = "定向人群包")
+    private String population;
+    /**
+     * 结果说明
+     */
+    @Excel(name = "结果说明", width = 15)
+    @ApiModelProperty(value = "结果说明")
+    private String message;
+    /**
+     * 定向模板创建时间
+     */
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

+ 119 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouLandpagePackage.java

@@ -0,0 +1,119 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 落地页账户项目关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-11
+ */
+@Data
+@TableName("ctop_kuaishou_landpage_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_landpage_package对象", description = "落地页账户项目关联表")
+public class KuaishouLandpagePackage {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 落地页名称
+     */
+    @Excel(name = "落地页名称", width = 15)
+    @ApiModelProperty(value = "落地页名称")
+    private String landpageName;
+    /**
+     * 落地页ID
+     */
+    @Excel(name = "落地页ID", width = 15)
+    @ApiModelProperty(value = "落地页ID")
+    private Long siteId;
+    /**
+     * 落地页URL
+     */
+    @Excel(name = "落地页URL", width = 15)
+    @ApiModelProperty(value = "落地页URL")
+    private String url;
+    /**
+     * 落地页类型	0:站内;1:联盟
+     */
+    @Excel(name = "落地页类型	0:站内;1:联盟", width = 15)
+    @ApiModelProperty(value = "落地页类型	0:站内;1:联盟")
+    private Integer bizType;
+    /**
+     * 应用ID
+     */
+    @Excel(name = "应用ID", width = 15)
+    @ApiModelProperty(value = "应用ID")
+    private Long appId;
+    /**
+     * 组件数据
+     */
+    @Excel(name = "组件数据", width = 15)
+    @ApiModelProperty(value = "组件数据")
+    private String comps;
+    /**
+     * 落地页创建时间
+     */
+    @Excel(name = "落地页创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "落地页创建时间")
+    private Date landpageCreateTime;
+    /**
+     * 落地页修改时间
+     */
+    @Excel(name = "落地页修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "落地页修改时间")
+    private Date landpageUpdateTime;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 63 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouLandpagePackageRel.java

@@ -0,0 +1,63 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 落地页-广告组关联表
+ * @author jeecg-boot
+ * @date   2021-05-11
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_landpage_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_landpage_package_rel对象", description="落地页-广告组关联表")
+public class KuaishouLandpagePackageRel {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**广告组ID*/
+	@Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+	private Long unitId;
+	/**落地页id*/
+	@Excel(name = "落地页id", width = 15)
+    @ApiModelProperty(value = "落地页id")
+	private Long siteId;
+	/**创意ID集*/
+	@Excel(name = "创意ID集", width = 15)
+    @ApiModelProperty(value = "创意ID集")
+	private String creativeArr;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+}

+ 59 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationGroup.java

@@ -0,0 +1,59 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 人群包-广告组关联表
+ * @author jeecg-boot
+ * @date   2021-05-08
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_population_group")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_population_group对象", description="人群包-广告组关联表")
+public class KuaishouPopulationGroup {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**广告组ID*/
+	@Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+	private Long unitId;
+	/**人群包id*/
+	@Excel(name = "人群包id", width = 15)
+    @ApiModelProperty(value = "人群包id")
+	private Long orientationId;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+}

+ 93 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationPackage.java

@@ -0,0 +1,93 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-06
+ */
+@Data
+@TableName("ctop_kuaishou_population_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_population_package对象", description = "项目绑定的人群包模板")
+public class KuaishouPopulationPackage {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 人群包名称
+     */
+    @Excel(name = "人群包名称", width = 15)
+    @ApiModelProperty(value = "人群包名称")
+    private String orientationName;
+    /**
+     * 链接
+     */
+    @Excel(name = "链接", width = 15)
+    @ApiModelProperty(value = "链接")
+    private String url;
+
+    private String statDate;
+    /**
+     * 0 删除,1 有效
+     */
+    @Excel(name = "0 删除,1 有效", width = 15)
+    @ApiModelProperty(value = "0 删除,1 有效")
+    private Integer dataStatus;
+    /**
+     * 匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5
+     */
+    @Excel(name = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5", width = 15)
+    @ApiModelProperty(value = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5")
+    private Integer type;
+    /**
+     * signature
+     */
+    @Excel(name = "signature", width = 15)
+    @ApiModelProperty(value = "signature")
+    private String signature;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 102 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationPackageRel.java

@@ -0,0 +1,102 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 人群包模板和账户绑定关系表
+ * @author jeecg-boot
+ * @date   2021-05-07
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_population_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_population_package_rel对象", description="人群包模板和账户绑定关系表")
+public class KuaishouPopulationPackageRel {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**本地人群模板ID*/
+	@Excel(name = "本地人群模板ID", width = 15)
+    @ApiModelProperty(value = "本地人群模板ID")
+	private Long popId;
+	/**项目ID*/
+	@Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+	private Long projectId;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**上传日期*/
+	@Excel(name = "上传日期", width = 15)
+    @ApiModelProperty(value = "上传日期")
+	private String statDate;
+	/**人群包ID*/
+	@Excel(name = "人群包ID", width = 15)
+    @ApiModelProperty(value = "人群包ID")
+	private Long orientationId;
+	/**人群包名称*/
+	@Excel(name = "人群包名称", width = 15)
+    @ApiModelProperty(value = "人群包名称")
+	private String orientationName;
+	/**人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...*/
+	@Excel(name = "人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...", width = 15)
+    @ApiModelProperty(value = "人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...")
+	private String populationType;
+	/**匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5*/
+	@Excel(name = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5", width = 15)
+    @ApiModelProperty(value = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5")
+	private Integer type;
+	/**状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效*/
+	@Excel(name = "状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效", width = 15)
+    @ApiModelProperty(value = "状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效")
+	private Integer status;
+	/**0成功,1失败*/
+	private Integer dataStatus;
+	/**覆盖人群*/
+	@Excel(name = "覆盖人群", width = 15)
+    @ApiModelProperty(value = "覆盖人群")
+	private Long coverNum;
+	/**上传数量*/
+	@Excel(name = "上传数量", width = 15)
+    @ApiModelProperty(value = "上传数量")
+	private Long recordSize;
+	/**匹配数量*/
+	@Excel(name = "匹配数量", width = 15)
+    @ApiModelProperty(value = "匹配数量")
+	private Long matchSize;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+	/**执行结果反馈*/
+	@Excel(name = "执行结果反馈", width = 15)
+    @ApiModelProperty(value = "执行结果反馈")
+	private String message;
+	private String signature;
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppGroupMapper.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppGroup;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 应用-广告组关联表
+ * @author: jeecg-boot
+ * @date:   2021-05-14
+ * @cersion: V1.0
+ */
+public interface KuaishouAppGroupMapper extends BaseMapper<KuaishouAppGroup> {
+
+    void replaceBatch(@Param("request") JSONObject request);
+}

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageMapper.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author: jeecg-boot
+ * @date: 2021-05-12
+ * @cersion: V1.0
+ */
+public interface KuaishouAppPackageMapper extends BaseMapper<KuaishouAppPackage> {
+
+    void replaceBatch(@Param("appList") List<KuaishouAppPackage> appList);
+
+    List<String> queryAppVersions(@Param("projectId") Long projectId);
+
+    List<Long> queryByAppVersion(@Param("projectId") Long projectId,@Param("appVersion") String appVersion);
+
+    List<JSONObject> queryPageList(@Param("appVersion") String appVersion, @Param("projectId") Long projectId, @Param("platform") Integer platform);
+
+    Long queryUnitCount(@Param("id") Long id);
+
+    List<JSONObject> getRelatedGroups(@Param("id") Long id, @Param("accountId") Long accountId);
+}

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageRelMapper.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 应用和账户关联表
+ *
+ * @author: jeecg-boot
+ * @date: 2021-05-13
+ * @cersion: V1.0
+ */
+public interface KuaishouAppPackageRelMapper extends BaseMapper<KuaishouAppPackageRel> {
+
+    void replaceBatch(@Param("relList") List<KuaishouAppPackageRel> relList);
+
+    KuaishouAppPackageRel queryEntityByAccountId(@Param("accountId") Long accountId, @Param("appVersion") String appVersion);
+
+    List<JSONObject> queryPushResults(@Param("id") String id, @Param("accountIds") JSONArray accountIds, @Param("status") String status);
+
+    List<JSONObject> getRelatedAccounts(@Param("id") Long id);
+
+    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
+}

+ 0 - 41
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouCrowdPackMapper.java

@@ -1,41 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.mapper;
-
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * 人群报表
- *
- * @author: jeecg-boot
- * @date: 2021-03-26
- * @cersion: V1.0
- */
-public interface KuaishouCrowdPackMapper extends BaseMapper<KuaishouCrowdPack> {
-
-    Long getTotal(@Param(value = "status") Integer status, @Param(value = "accountId") Long accountId, @Param(value = "orientationName") String orientationName);
-
-    List<JSONObject> queryPageList(@Param(value = "status") Integer status, @Param(value = "accountId") Long accountId, @Param(value = "orientationName") String orientationName);
-
-    List<KuaishouCrowdPack> queryListByStatus();
-
-    List<JSONObject> queryFailReason(@Param(value = "signature") String signature);
-
-    List<JSONObject> queryRelAccounts(@Param(value = "signature") String signature);
-
-    List<JSONObject> queryRelProject(@Param(value = "signature") String signature);
-
-    void replaceBatch(@Param(value = "list") List<KuaishouCrowdPack> list);
-
-    Integer queryProjectCount(@Param(value = "signature") String signature);
-
-    KuaishouCrowdPack queryByAccountId(@Param(value = "accountId") Long accountId, @Param(value = "orientationId") Long orientationId);
-
-    Integer queryAccountCount(@Param(value = "signature") String signature);
-
-    void update(JSONObject obj);
-}

+ 28 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPackageMapper.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-20
+ * @cersion: V1.0
+ */
+public interface KuaishouDirectionalPackageMapper extends BaseMapper<KuaishouDirectionalPackage> {
+
+    KuaishouDirectionalPackage queryEntity(JSONObject requestJson);
+
+    List<JSONObject> queryList(KuaishouDirectionalPackage directionalPackage);
+
+    Long queryListTotal(KuaishouDirectionalPackage directionalPackage);
+
+    List<JSONObject> getRelatedAccount(@Param("id") String id);
+
+    List getRelatedGroup(@Param("id") String id, @Param("accountId") Long accountId);
+}

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPckageRelMapper.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 自动投放-定向包详情关系表
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-25
+ * @cersion: V1.0
+ */
+public interface KuaishouDirectionalPckageRelMapper extends BaseMapper<KuaishouDirectionalaPckageRel> {
+
+    void replace(KuaishouDirectionalaPckageRel rel);
+
+    List<JSONObject> queryPushResults(@Param("id") String id, @Param("accountIds") JSONArray accountIds,@Param("status") String status);
+
+    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
+
+    List<JSONObject> queryRelId(@Param("projectId") Long projectId, @Param("id") String id, @Param("type") String type);
+
+    List<JSONObject> queryUnitIdByAccountId(@Param("id") String id,@Param("accountId")  Long accountId);
+}

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageMapper.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 落地页账户项目关联表
+ *
+ * @author: jeecg-boot
+ * @date: 2021-05-11
+ * @cersion: V1.0
+ */
+public interface KuaishouLandpagePackageMapper extends BaseMapper<KuaishouLandpagePackage> {
+
+    void replaceBatch(@Param("landpagePackageList") List<KuaishouLandpagePackage> landpagePackageList);
+
+    void deleteByAccountId(@Param("accountId") Long accountId);
+
+    List<JSONObject> queryPageList(@Param("accountId") Long accountId,@Param("projectId") Long projectId);
+
+    List<JSONObject> getRelatedAccounts(@Param("siteId") Long siteId);
+
+    List<JSONObject> getRelatedGroups(@Param("siteId") Long siteId, @Param("accountId") Long accountId);
+
+}

+ 20 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageRelMapper.java

@@ -0,0 +1,20 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 落地页-广告组关联表
+ * @author: jeecg-boot
+ * @date:   2021-05-11
+ * @cersion: V1.0
+ */
+public interface KuaishouLandpagePackageRelMapper extends BaseMapper<KuaishouLandpagePackageRel> {
+
+    JSONObject queryByUnitId(@Param("siteId") Long siteId,@Param("unitId") Long unitId,@Param("accountId") Long accountId);
+
+}

+ 22 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationGroupMapper.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationGroup;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 人群包-广告组关联表
+ *
+ * @author jeecg-boot
+ * 2021-05-08
+ * @version V1.0
+ */
+public interface KuaishouPopulationGroupMapper extends BaseMapper<KuaishouPopulationGroup> {
+
+    void deleteByUnitId(@Param("unitId") Long unitId);
+
+    void replaceBatch(@Param(value = "list") List<KuaishouPopulationGroup> list);
+}

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageMapper.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * 2021-05-06
+ * @version V1.0
+ */
+public interface KuaishouPopulationPackageMapper extends BaseMapper<KuaishouPopulationPackage> {
+
+    Long queryPageListTotal(@Param("projectId") Long projectId, @Param("orientationName") String orientationName);
+
+    List<JSONObject> queryPageList(@Param("projectId") Long projectId, @Param("orientationName") String orientationName);
+
+    Long queryUnitCount(@Param("id") Long id);
+
+    List<JSONObject> getRelatedGroups(@Param("id") Long id, @Param("accountId") Long accountId);
+
+    List<JSONObject> queryListByStatus();
+
+    KuaishouPopulationPackage checkPopulationPackage(@Param("signature") String signature);
+}

+ 40 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageRelMapper.java

@@ -0,0 +1,40 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 人群包模板和账户绑定关系表
+ *
+ * @author jeecg-boot
+ * 2021-05-07
+ * @version V1.0
+ */
+public interface KuaishouPopulationPackageRelMapper extends BaseMapper<KuaishouPopulationPackageRel> {
+
+    /**
+     * 查询账户同一主题下可推送的该人群包ID
+     */
+    KuaishouPopulationPackageRel queryPushableCrowdPackage(@Param("accountId") Long accountId, @Param("id") Long id);
+
+    KuaishouPopulationPackageRel queryByAccountId(@Param("accountId") Long accountId, @Param("orientationId") Long orientationId);
+
+    void replaceBatch(@Param("packageRels") List<KuaishouPopulationPackageRel> packageRels);
+
+    List<JSONObject> queryPushResults(@Param("id") Long id, @Param("accountIds") JSONArray accountIds);
+
+    List<JSONObject> getRelatedAccounts(@Param("id") Long id);
+
+    KuaishouPopulationPackageRel queryEntity(@Param("accountId") Long accountId, @Param("id") Long id);
+
+    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
+
+    void updateStatus(@Param("rel") KuaishouPopulationPackageRel rel);
+
+    List<Long> queryByOrientationId(@Param("orientationId") Long orientationId, @Param("accountId") Long accountId);
+}

+ 22 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppGroupMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppGroupMapper">
+
+    <insert id="replaceBatch">
+        replace
+        into ctop_kuaishou_app_group(
+        id,
+        account_id,
+        unit_id,
+        app_id
+        )
+        values
+            (
+        #{request.id},
+        #{request.accountId},
+        #{request.unitId},
+        #{request.appId}
+        )
+    </insert>
+
+</mapper>

+ 117 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageMapper.xml

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageMapper">
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_app_package(
+        id,
+        project_id,
+        app_md5,
+        url,
+        app_version,
+        app_name,
+        app_icon_url,
+        image_token,
+        package_name,
+        platform,
+        app_privacy_url,
+        use_sdk,
+        track_url,
+        data_status
+        )
+        values
+        <foreach collection="appList" item="app" separator=",">
+            (
+            #{app.id},
+            #{app.projectId},
+            #{app.appMd5},
+            #{app.url},
+            #{app.appVersion},
+            #{app.appName},
+            #{app.appIconUrl},
+            #{app.imageToken},
+            #{app.packageName},
+            #{app.platform},
+            #{app.appPrivacyUrl},
+            #{app.useSdk},
+            #{app.trackUrl},
+            #{app.dataStatus}
+            )
+        </foreach>
+    </insert>
+    <select id="queryAppVersions" resultType="java.lang.String">
+        SELECT app_version
+        FROM ctop_kuaishou_app_package
+        where project_id = #{projectId}
+    </select>
+
+    <select id="queryByAppVersion" resultType="java.lang.Long">
+        SELECT id
+        FROM ctop_kuaishou_app_package
+        where project_id = #{projectId}
+          and app_version = #{appVersion}
+    </select>
+
+    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.id,
+        t1.project_id 'projectId',
+        t1.app_name 'appName',
+        t1.app_version 'appVersion',
+        t1.platform,
+        CASE t1.platform
+        WHEN 1 THEN 'Android应用下载'
+        WHEN 2 THEN 'Android网页游戏'
+        WHEN 3 THEN 'iOS应用下载'
+        WHEN 4 THEN 'iOS网页游戏'
+        END 'platformStr',
+        t1.package_name 'packageName',
+        DATE_FORMAT(t1.create_time,'%Y-%m-%d') 'createTime',
+        t2.project_name 'projectName',
+        (SELECT COUNT(1) FROM ctop_kuaishou_app_package_rel WHERE apptem_id = t1.id AND data_status = 1)'accountCount'
+        FROM ctop_kuaishou_app_package t1
+        LEFT JOIN ctop_project = t2 on t1.project_id =t2.id
+        WHERE t1.data_status =1
+        <if test="appVersion!=null">
+            AND t1.app_version Like concat('%',#{appVersion},'%')
+        </if>
+        <if test="projectId!=null">
+            AND t1.project_id=#{projectId}
+        </if>
+        <if test="platform!=null">
+            AND t1.platform=#{platform}
+        </if>
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryUnitCount" resultType="java.lang.Long">
+        SELECT IFNULL(COUNT(1), 0)
+        FROM ctop_kuaishou_app_group
+        where app_id IN
+              (SELECT app_id
+               FROM ctop_kuaishou_app_package_rel
+               WHERE data_status = 1
+                 AND apptem_id = #{id}
+              )
+    </select>
+
+    <select id="getRelatedGroups" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.account_id as 'accountId',
+        t2.auth_name as 'authName',
+        t3.unit_name as 'unitName'
+        FROM ctop_kuaishou_app_group t1
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where t1.app_id IN
+        (SELECT DISTINCT app_id
+        FROM ctop_kuaishou_app_package_rel
+        WHERE data_status = 1
+        AND apptem_id =#{id}
+        <if test="accountId !=null">
+            AND account_id = #{accountId}
+        </if>
+        )
+        order by t1.create_time desc
+    </select>
+
+</mapper>

+ 95 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageRelMapper.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageRelMapper">
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_app_package_rel(
+        id,
+        apptem_id,
+        project_id,
+        account_id,
+        app_id,
+        app_version,
+        data_status,
+        return_url,
+        message,
+        return_update_time
+        )
+        values
+        <foreach collection="relList" item="rel" separator=",">
+            (
+            #{rel.id},
+            #{rel.apptemId},
+            #{rel.projectId},
+            #{rel.accountId},
+            #{rel.appId},
+            #{rel.appVersion},
+            #{rel.dataStatus},
+            #{rel.returnUrl},
+            #{rel.message},
+            #{rel.returnUpdateTime}
+            )
+        </foreach>
+    </insert>
+
+    <select id="queryEntityByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel">
+        SELECT apptem_id, app_id, project_id
+        FROM ctop_kuaishou_app_package_rel
+        where account_id = #{accountId}
+          and app_version = #{appVersion}
+          and data_status = 1
+    </select>
+
+    <select id="queryPushResults" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        apptem_id 'id',
+        IFNULL(t2.auth_name,'') as 'authName',
+        IFNULL(t2.account_id,'') as 'accountId',
+        IFNULL(t1.message,'-') as 'message',
+        CASE WHEN t1.data_status =1 THEN '推送成功' ELSE '推送失败' end as 'result'
+        FROM ctop_kuaishou_app_package_rel t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where apptem_id = #{id}
+        <if test=" status!=null">
+            AND  t1.data_status = #{status}
+        </if>
+        <if test="accountIds!=null">
+            AND t1.account_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        order by t1.create_time desc
+    </select>
+
+    <select id="getRelatedAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT apptem_id as 'id',
+               IFNULL(t2.auth_name, '') as 'authName',
+               IFNULL(t2.account_id, '') as 'accountId',
+               (SELECT COUNT(1)
+                FROM ctop_kuaishou_app_list
+                where account_id = t1.account_id) as 'appCount'
+        FROM ctop_kuaishou_app_package_rel t1
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.apptem_id =#{id}
+          AND t1.data_status = 1
+        order by t1.create_time desc
+    </select>
+
+    <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.account_id as 'accountId',
+            CONCAT(t1.auth_name,'(',t1.account_id,')') as 'authName',
+            IFNULL(t2.data_status,0) as 'state'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN (
+            SELECT account_id,data_status FROM ctop_kuaishou_app_package_rel
+            WHERE  project_id = #{projectId}
+              AND apptem_id = #{id}
+        ) t2 ON t1.account_id = t2.account_id
+        where t1.account_status = 0
+          AND t1.project_id = #{projectId}
+    </select>
+
+</mapper>

+ 0 - 344
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouCrowdPackMapper.xml

@@ -1,344 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper">
-
-    <select id="getTotal" resultType="java.lang.Long">
-        SELECT  IFNULL(COUNT(1),0) FROM(
-        SELECT 1
-        FROM ctop_kuaishou_crowd_package t1
-        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        WHERE t1.`status` is not null
-        AND t1.`status`!=2
-        and t1.data_status = 1
-        AND t1.signature is not null
-        <if test="orientationName !=null">
-            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
-        </if>
-        <if test="accountId !=null">
-            AND t2.account_id = #{accountId}
-        </if>
-        <if test="status !=null">
-            AND t1.`status` =#{status}
-        </if>
-        GROUP BY t1.signature
-        ) t
-    </select>
-
-    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.id,
-        t1.account_id as 'accountId',
-        t2.auth_name as 'accountName',
-        IFNULL(stat_date,'') as 'statDate',
-        IFNULL(t1.orientation_id,'') as 'orientationId',
-        IFNULL(orientation_name,'') as 'orientationName',
-        IFNULL(url,'') as 'url',
-        IFNULL(population_type,'') as 'populationType',
-        IFNULL(t1.type,'') as 'type',
-        CASE t1.type
-        WHEN 1 THEN 'IMEI'
-        WHEN 2 THEN 'IDFA'
-        WHEN 3 THEN 'IMEI_MD5'
-        WHEN 4 THEN 'IDFA_MD5'
-        WHEN 5 THEN '手机号-MD5'
-        WHEN 7 THEN 'OAID'
-        WHEN 8 THEN 'OAID_MD5'
-        ELSE ''
-        END as 'typeStr',
-        <if test="status ==null">
-            t4.statusStr,
-            t4.`status`,
-        </if>
-        <if test="status !=null">
-            t1.`status`,
-            CASE t1.`status`
-            WHEN 0 THEN '计算中'
-            WHEN 1 THEN '已生效'
-            WHEN 3 THEN '推送中'
-            WHEN 4 THEN '已推送'
-            WHEN 5 THEN '计算失败'
-            WHEN 6 THEN '推送失败'
-            WHEN 7 THEN '已失效'
-            ELSE ''
-            END as 'statusStr',
-        </if>
-        IFNULL(t1.signature,'') as 'signature',
-        IFNULL(cover_num,0) as 'coverNum'
-        FROM ctop_kuaishou_crowd_package t1
-        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        LEFT JOIN (
-        SELECT t.signature ,COUNT(1) as 'num' FROM (SELECT DISTINCT signature, t2.project_id FROM
-        ctop_kuaishou_crowd_package t1
-        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        where orientation_id is not null
-        GROUP BY project_id) t
-        ) t3 ON t1.signature = t3.signature
-        left join
-        (
-        SELECT signature,
-        CASE maxlevel
-        WHEN 66 THEN '计算中'
-        WHEN 77 THEN '已生效'
-        WHEN 88 THEN '推送中'
-        WHEN 99 THEN '已推送'
-        WHEN 33 THEN '计算失败'
-        WHEN 44 THEN '推送失败'
-        WHEN 55 THEN '已失效'
-        ELSE ''
-        END as 'statusStr',
-        CASE maxlevel
-        WHEN 66 THEN 0
-        WHEN 77 THEN 1
-        WHEN 88 THEN 3
-        WHEN 99 THEN 4
-        WHEN 33 THEN 5
-        WHEN 44 THEN 6
-        WHEN 55 THEN 7
-        ELSE -1
-        END as 'status'
-        FROM (
-        SELECT signature,max(level) as 'maxlevel' FROM (
-        SELECT signature,
-        CASE t1.`status`
-        WHEN 0 THEN 66
-        WHEN 1 THEN 77
-        WHEN 3 THEN 88
-        WHEN 4 THEN 99
-        WHEN 5 THEN 33
-        WHEN 6 THEN 44
-        WHEN 7 THEN 55
-        ELSE ''
-        END as 'level'
-        FROM ctop_kuaishou_crowd_package t1
-        where signature IN(
-        SELECT signature
-        FROM ctop_kuaishou_crowd_package t1
-        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        WHERE t1.`status` is not null
-        AND t1.`status`!=2
-        and t1.data_status = 1
-        AND t1.signature is not null
-        <if test="orientationName !=null">
-            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
-        </if>
-        <if test="accountId !=null">
-            AND t2.account_id =#{accountId}
-        </if>
-        GROUP BY t1.signature
-        )
-        GROUP BY t1.signature,`status`
-        )t1
-        GROUP BY signature
-        ) t2
-        ) t4 ON t1.signature = t4.signature
-        WHERE t1.`status` is not null
-        AND t1.`status`!=2
-        and t1.data_status = 1
-        AND t1.signature is not null
-        <if test="orientationName !=null">
-            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
-        </if>
-        <if test="accountId !=null">
-            AND t2.account_id =#{accountId}
-        </if>
-        <if test="status !=null">
-            AND t1.`status` =#{status}
-        </if>
-        GROUP BY t1.signature
-        order by t1.update_time desc
-    </select>
-
-    <select id="queryListByStatus" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
-        SELECT account_id
-        FROM ctop_kuaishou_crowd_package
-        WHERE `status` !=2
-        GROUP BY account_id
-    </select>
-
-    <select id="queryFailReason" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT DISTINCT IFNULL(t3.project_name, null) as 'projectName', IFNULL(t2.auth_name, null)as 'accountName', IFNULL(t1.message, null) as 'message'
-        FROM ctop_kuaishou_crowd_package t1
-                 INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                 INNER JOIN ctop_project t3 ON t2.project_id = t3.id
-        WHERE t1.signature = #{signature}
-          AND t1.data_status = 0
-    </select>
-
-    <select id="queryRelAccounts" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT IFNULL(t1.project_name, '') AS 'projectName' ,
-               IFNULL(t1.auth_name, '') AS 'accountName',
-               t2.count,
-               t1.`status`,
-               CASE t1.`status`
-                   WHEN 0 THEN '计算中'
-                   WHEN 1 THEN '已生效'
-                   WHEN 2 THEN '已删除'
-                   WHEN 3 THEN '推送中'
-                   WHEN 4 THEN '已推送'
-                   WHEN 5 THEN '计算失败'
-                   WHEN 6 THEN '推送失败'
-                   WHEN 7 THEN '已失效'
-                   ELSE ''
-                   END as 'statusStr'
-        FROM (
-                 SELECT t2.auth_name, t2.account_id, t3.project_name, t1.status
-                 FROM ctop_kuaishou_crowd_package t1
-                          INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                          INNER JOIN ctop_project t3 ON t3.id = t2.project_id
-                 where signature = #{signature}
-                   and data_status = 1
-                   AND `status` !=2
-                 GROUP BY t1.account_id
-             ) t1
-                 LEFT JOIN(
-            SELECT t.account_id, COUNT(1) as 'count'
-            FROM (
-                     SELECT t1.account_id, signature
-                     FROM ctop_kuaishou_crowd_package t1
-                              INNER JOIN (
-                         SELECT t1.account_id
-                         FROM ctop_kuaishou_crowd_package t1
-                                  INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                         where signature = #{signature}
-                           and data_status = 1
-                           AND `status` !=2
-                         GROUP BY account_id
-                     ) t2 ON t1.account_id = t2.account_id
-                     where signature is not NULL
-                       AND data_status = 1
-                       AND `status` != 2
-                     GROUP BY signature, t1.account_id
-                 ) t
-            GROUP BY t.account_id
-        ) t2 ON t1.account_id = t2.account_id
-    </select>
-
-    <select id="queryRelProject" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT IFNULL(CONCAT(tt3.project_name, '(', tt.project_id, ')'), '') as 'projectName' ,
-               tt.accountCount,
-               tt2.count
-        FROM (
-                 SELECT t.project_id, COUNT(1) as  'accountCount'
-                 FROM (
-                          SELECT t1.project_id, t1.account_id
-                          FROM ctop_user_allocation t1
-                                   INNER JOIN(
-                              SELECT t1.account_id
-                              FROM ctop_kuaishou_crowd_package t1
-                                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                              where signature = #{signature}
-                                AND data_status = 1
-                                AND `status` !=2
-                              GROUP BY t1.account_id
-                          ) t2 ON t2.account_id = t1.account_id
-                      ) t
-                 GROUP BY t.project_id
-             ) tt
-                 LEFT JOIN
-             (
-                 SELECT t.project_id, t.account_id, COUNT(1) as 'count'
-                 FROM (
-                          SELECT t3.project_id, t1.account_id, signature
-                          FROM ctop_kuaishou_crowd_package t1
-                                   INNER JOIN (
-                              SELECT t1.account_id
-                              FROM ctop_kuaishou_crowd_package t1
-                                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                              where signature = #{signature}
-                                AND data_status = 1
-                                AND `status` !=2
-                              GROUP BY t1.account_id
-                          ) t2 ON t1.account_id = t2.account_id
-                                   INNER JOIN ctop_user_allocation t3 ON t3.account_id = t2.account_id
-                          where signature is not NULL
-                            AND data_status = 1
-                            AND `status` != 2
-                          GROUP BY signature, t1.account_id, t3.project_id
-                      ) t
-                 GROUP BY t.account_id, t.project_id
-             ) tt2 ON tt2.project_id = tt.project_id
-                 LEFT JOIN ctop_project tt3 ON tt2.project_id = tt3.id
-        GROUP BY tt.project_id
-    </select>
-
-    <select id="queryProjectCount" resultType="java.lang.Integer">
-        SELECT IFNULL(COUNT(1),0)
-        FROM (SELECT t2.project_id
-              FROM ctop_kuaishou_crowd_package t1
-                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-              where orientation_id is not null
-                AND signature = #{signature}
-                AND data_status = 1
-                AND `status` !=2
-              GROUP BY project_id) t
-    </select>
-    <select id="queryAccountCount" resultType="java.lang.Integer">
-        SELECT IFNULL(COUNT(1),0)
-        FROM (
-                 SELECT account_id
-                 FROM ctop_kuaishou_crowd_package
-                 WHERE signature = #{signature}
-                   AND `status` !=2
-                 AND data_status = 1
-                 GROUP BY account_id) t
-    </select>
-
-    <select id="queryByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
-        SELECT *
-        FROM ctop_kuaishou_crowd_package
-        where data_status = 1
-        AND `status` !=2
-        <if test="accountId!=null">
-            AND account_id = #{accountId}
-        </if>
-        <if test="orientationId!=null">
-            AND orientation_id = #{orientationId}
-        </if>
-        limit 1
-    </select>
-
-    <update id="update">
-        update ctop_kuaishou_crowd_package
-        set status = #{status}
-        where account_id = #{account_id}
-        and orientation_id = #{orientation_id}
-    </update>
-
-    <insert id="replaceBatch">
-        replace into ctop_kuaishou_crowd_package(
-        account_id,
-        stat_date,
-        orientation_id,
-        orientation_name,
-        url,
-        population_type,
-        data_status,
-        type,
-        status,
-        signature,
-        cover_num,
-        record_size,
-        match_size,
-        message
-        )
-        values
-        <foreach collection="list" item="li" separator=",">
-            (
-            #{li.accountId},
-            #{li.statDate},
-            #{li.orientationId},
-            #{li.orientationName},
-            #{li.url},
-            #{li.populationType},
-            #{li.dataStatus},
-            #{li.type},
-            #{li.status},
-            #{li.signature},
-            #{li.coverNum},
-            #{li.recordSize},
-            #{li.matchSize},
-            #{li.message}
-            )
-        </foreach>
-    </insert>
-
-</mapper>

+ 97 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPackageMapper.xml

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper">
+
+    <select id="queryEntity" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage">
+        SELECT project_id,template_name from ctop_kuaishou_directional_package
+        WHERE data_status = 1
+        <if test="projectId != null">
+            and project_id = #{projectId}
+        </if>
+        <if test="templateName != null">
+            and template_name = #{templateName}
+        </if>
+        limit 1
+    </select>
+    <select id="queryList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.id,
+        t1.template_name 'templateName',
+        t2.project_name 'projectName',
+        t1.project_id 'projectId',
+        CASE WHEN t1.platform_os =1 THEN 'Android' WHEN t1.platform_os =2 THEN 'IOS' ELSE '不限' END 'platformOs',
+        t1.update_time 'updateTime',
+        IFNULL(t4.count,0) as 'accountCount',
+        IFNULL(t5.count,0) as 'unitCount'
+        FROM ctop_kuaishou_directional_package t1
+        LEFT JOIN ctop_project t2 ON t2.id = t1.project_id
+        LEFT JOIN (
+        SELECT dir_id,COUNT(1) 'count' FROM
+        ctop_kuaishou_directional_package_rel
+        WHERE rel_type = 'account'
+        AND data_status=1
+        GROUP BY dir_id
+        ) t4 ON t4.dir_id = t1.id
+        LEFT JOIN (
+        SELECT dir_id,COUNT(1) 'count' FROM
+        ctop_kuaishou_directional_package_rel t
+        INNER JOIN ctop_kuaishou_group tt ON t.rel_id = tt.unit_id
+        WHERE t.rel_type = 'unit'
+        AND t.data_status=1
+        GROUP BY dir_id
+        ) t5 ON t5.dir_id = t1.id
+        where t1.data_status = 1
+        <if test="templateName !=null">
+            AND t1.template_name like concat('%',#{templateName},'%')
+        </if>
+        <if test="platformOs !=null">
+            AND t1.platform_os = #{platformOs}
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id = #{projectId}
+        </if>
+        order by t1.update_time desc
+    </select>
+    <select id="queryListTotal" resultType="java.lang.Long">
+        SELECT
+        IFNULL(count(1),0)
+        FROM ctop_kuaishou_directional_package t1
+        where t1.data_status = 1
+        <if test="templateName !=null">
+            AND t1.template_name like concat('%',#{templateName},'%')
+        </if>
+        <if test="platformOs !=null">
+            AND t1.platform_os = #{platformOs}
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id = #{projectId}
+        </if>
+    </select>
+
+
+    <select id="getRelatedAccount" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.dir_id as 'id', IFNULL(t2.auth_name, '') as 'authName', IFNULL(t2.account_id, '') as 'accountId', IFNULL(t1.template_id, '') as 'templateId', IFNULL(t1.template_name, '') as 'templateName'
+        FROM ctop_kuaishou_directional_package_rel t1
+                 INNER JOIN ctop_user_allocation t2 ON t1.rel_id = t2.account_id
+        WHERE t1.data_status = 1
+          AND t1.dir_id = #{id}
+    </select>
+
+    <select id="getRelatedGroup" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.dir_id as 'id',
+        IFNULL(t3.auth_name,'') as 'authName',
+        IFNULL(t1.account_id,'') as 'accountId',
+        IFNULL(t2.template_id,'') as 'templateId',
+        t1.unit_name as 'unitName'
+        FROM ctop_kuaishou_directional_package_rel t2
+        INNER JOIN ( SELECT account_id,unit_id,unit_name FROM ctop_kuaishou_group
+        where 1=1
+        <if test="accountId!=null">
+           and account_id = #{accountId}
+        </if>
+        ) t1 ON t1.unit_id = t2.rel_id
+        LEFT JOIN ctop_user_allocation t3 ON t1.account_id = t3.account_id
+        WHERE t2.rel_type = 'unit' AND t2.dir_id =#{id}
+    </select>
+</mapper>

+ 94 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPckageRelMapper.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPckageRelMapper">
+
+    <insert id="replace">
+        replace
+        into ctop_kuaishou_directional_package_rel(
+        id ,
+        dir_id ,
+        project_id ,
+        template_id ,
+        template_name ,
+        data_status,
+        rel_id ,
+        rel_type ,
+        exclude_population ,
+        paid_audience ,
+        population ,
+        message
+        )
+        values
+            (
+        #{id} ,
+        #{dirId} ,
+        #{projectId} ,
+        #{templateId} ,
+        #{templateName} ,
+        #{dataStatus} ,
+        #{relId} ,
+        #{relType} ,
+        #{excludePopulation} ,
+        #{paidAudience} ,
+        #{population} ,
+        #{message}
+        )
+
+    </insert>
+
+    <select id="queryPushResults" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        dir_id 'id',
+        IFNULL(t2.auth_name,'') as 'authName',
+        IFNULL(t2.account_id,'') as 'accountId',
+        IFNULL(t1.template_id,'') as 'templateId',
+        IFNULL(t1.message,'-') as 'message',
+        CASE WHEN t1.data_status =1 THEN '推送成功' ELSE '推送失败' end as 'result'
+        FROM ctop_kuaishou_directional_package_rel t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.rel_id = t2.account_id
+        where dir_id = #{id}
+        AND rel_type = 'account'
+        <if test=" status!=null">
+        AND  t1.data_status = #{status}
+        </if>
+        <if test="accountIds!=null">
+            AND rel_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.account_id as 'accountId',
+            CONCAT(t1.auth_name,'(',t1.account_id,')') as 'authName',
+            IFNULL(t2.data_status,0) as 'state'
+            FROM ctop_user_allocation t1
+                LEFT JOIN (
+                SELECT rel_id,data_status FROM ctop_kuaishou_directional_package_rel
+                WHERE  project_id = #{projectId}
+                  AND rel_type = 'account'
+                  AND dir_id = #{id}
+            ) t2 ON t1.account_id = t2.rel_id
+        where t1.account_status = 0
+          AND t1.project_id = #{projectId}
+    </select>
+
+    <select id="queryRelId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel_id,template_id FROM ctop_kuaishou_directional_package_rel
+        WHERE  project_id = #{projectId}
+          AND rel_type = #{type}
+          AND dir_id = #{id}
+    </select>
+
+    <select id="queryUnitIdByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel_id,template_id FROM(
+       SELECT DISTINCT unit_id FROM ctop_kuaishou_group
+       where account_id = #{accountId} ) t1
+       INNER JOIN ctop_kuaishou_directional_package_rel t2 ON t1.unit_id = t2.rel_id
+        WHERE t2.rel_type = 'unit' AND t2.dir_id = #{id}
+    </select>
+
+</mapper>

+ 94 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageMapper.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageMapper">
+
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_landpage_package(
+        id,
+        project_id,
+        account_id,
+        landpage_name,
+        site_id,
+        url,
+        biz_type,
+        app_id,
+        comps,
+        landpage_create_time,
+        landpage_update_time
+        )
+        values
+        <foreach collection="landpagePackageList" item="landpage" separator=",">
+            (
+            #{landpage.id},
+            #{landpage.projectId},
+            #{landpage.accountId},
+            #{landpage.landpageName},
+            #{landpage.siteId},
+            #{landpage.url},
+            #{landpage.bizType},
+            #{landpage.appId},
+            #{landpage.comps},
+            #{landpage.landpageCreateTime},
+            #{landpage.landpageUpdateTime}
+            )
+        </foreach>
+    </insert>
+
+    <delete id="deleteByAccountId">
+        delete
+        from ctop_kuaishou_landpage_package
+        where account_id = #{accountId}
+    </delete>
+
+    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.project_id 'projectId',
+        t1.account_id 'accountId',
+        CONCAT(t1.site_id,'') 'siteId',
+        t1.landpage_name 'landpageName',
+        t2.project_name 'projectName',
+        t3.auth_name 'authName',
+        t1.landpage_update_time 'landpageUpdateTime',
+        (SELECT COUNT(1) FROM ctop_kuaishou_landpage_package WHERE site_id = t1.site_id) as 'accountCount',
+        (SELECT COUNT(1) FROM ctop_kuaishou_landpage_package_rel WHERE site_id = t1.site_id) as 'unitCount'
+        FROM ctop_kuaishou_landpage_package t1
+        LEFT JOIN ctop_project t2 ON t1.project_id = t2.id
+        LEFT JOIN ctop_user_allocation t3 ON t1.account_id = t3.account_id
+        WHERE 1=1
+        <if test="projectId!=null">
+            AND t1.project_id =#{projectId}
+        </if>
+        <if test="accountId!=null">
+            AND t1.account_id =#{accountId}
+        </if>
+        ORDER BY t1.landpage_update_time desc
+    </select>
+
+    <select id="getRelatedAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.auth_name 'authName', (SELECT COUNT(1)
+                                         FROM ctop_kuaishou_landpage_package
+                                         WHERE account_id = t1.account_id) 'count'
+        FROM ctop_kuaishou_landpage_package t1
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.account_id IN (
+            SELECT DISTINCT account_id
+            FROM ctop_kuaishou_landpage_package
+            WHERE site_id = #{siteId}
+        )
+        GROUP BY t1.account_id
+        order by t1.create_time desc
+    </select>
+
+    <select id="getRelatedGroups" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.auth_name 'authName', t3.unit_name 'unitName'
+        FROM ctop_kuaishou_landpage_package_rel t1
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where t1.site_id = #{siteId}
+        <if test="accountId!=null">
+            AND t1.account_id = #{accountId}
+        </if>
+        order by t1.create_time desc
+    </select>
+</mapper>

+ 12 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageRelMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageRelMapper">
+
+    <select id="queryByUnitId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT id,creative_arr
+        FROM ctop_kuaishou_landpage_package_rel
+        WHERE unit_id = #{unitId}
+          AND site_id = #{siteId}
+          AND account_id = #{accountId}
+    </select>
+</mapper>

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationGroupMapper.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationGroupMapper">
+
+    <delete id="deleteByUnitId">
+        DELETE
+        FROM ctop_kuaishou_population_group
+        WHERE unit_id = #{unitId}
+    </delete>
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_population_group(
+        id,
+        account_id,
+        unit_id,
+        orientation_id
+        )
+        values
+        <foreach collection="list" item="pop" separator=",">
+            (
+            #{pop.id},
+            #{pop.accountId},
+            #{pop.unitId},
+            #{pop.orientationId}
+            )
+        </foreach>
+    </insert>
+
+</mapper>

+ 96 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageMapper.xml

@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper">
+
+    <select id="queryPageListTotal" resultType="java.lang.Long">
+        SELECT IFNULL(COUNT(1), 0)
+        FROM ctop_kuaishou_population_package t1
+        WHERE data_status = 1
+        <if test="orientationName !=null">
+            AND orientation_name LIKE CONCAT('%', #{orientationName}, '%')
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id =#{projectId}
+        </if>
+    </select>
+
+    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.orientation_name 'orientationName',
+        IFNULL(t1.type,'') as 'type',
+        CASE t1.type
+        WHEN 1 THEN 'IMEI'
+        WHEN 2 THEN 'IDFA'
+        WHEN 3 THEN 'IMEI_MD5'
+        WHEN 4 THEN 'IDFA_MD5'
+        WHEN 5 THEN '手机号-MD5'
+        WHEN 7 THEN 'OAID'
+        WHEN 8 THEN 'OAID_MD5'
+        ELSE ''
+        END as 'typeStr',
+        t1.id,
+        t1.stat_date 'statDate',
+        t2.project_name 'projectName',
+        t1.project_id 'projectId',
+        (SELECT COUNT(1) FROM ctop_kuaishou_population_package_rel
+        WHERE pop_id = t1.id
+        AND data_status = 1)as 'accountCount'
+        FROM
+        ctop_kuaishou_population_package t1
+        LEFT JOIN ctop_project t2 ON t1.project_id = t2.id
+        WHERE data_status = 1
+        <if test="orientationName !=null">
+            AND orientation_name LIKE CONCAT(CONCAT('%', #{orientationName}), '%')
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id =#{projectId}
+        </if>
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryUnitCount" resultType="java.lang.Long">
+        SELECT IFNULL(COUNT(1), 0)
+        FROM ctop_kuaishou_population_group t1
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where orientation_id IN
+              (SELECT orientation_id
+               FROM ctop_kuaishou_population_package_rel
+               WHERE data_status = 1
+                 AND pop_id = #{id}
+              )
+    </select>
+
+    <select id="queryListByStatus" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT account_id,project_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE data_status =1
+        GROUP BY account_id
+    </select>
+
+    <select id="getRelatedGroups" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.account_id as 'accountId',
+        t2.auth_name as 'authName',
+        t3.unit_name as 'unitName'
+        FROM ctop_kuaishou_population_group t1
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where orientation_id IN
+        (SELECT DISTINCT orientation_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE data_status = 1
+        AND pop_id = #{id}
+        <if test="accountId !=null">
+            AND account_id = #{accountId}
+        </if>
+        )
+        order by t1.create_time desc
+    </select>
+
+    <select id="checkPopulationPackage" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage">
+        select orientation_name
+        from ctop_kuaishou_population_package
+        where signature = #{signature}
+        AND data_status = 1
+</select>
+
+</mapper>

+ 194 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageRelMapper.xml

@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper">
+
+    <select id="queryPushableCrowdPackage"
+            resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel">
+        SELECT t1.*
+        FROM ctop_kuaishou_population_package_rel t1
+        WHERE `status` = 4
+          AND pop_id = #{id}
+          AND orientation_id is not null
+          AND data_status = 1
+          AND account_id IN (
+            SELECT account_id
+            FROM ctop_kuaishou_advertiser_base_info
+            WHERE user_id = (SELECT user_id FROM ctop_kuaishou_advertiser_base_info WHERE account_id = #{accountId})
+        )
+            limit 1
+    </select>
+
+    <select id="queryByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
+        SELECT *
+        FROM ctop_kuaishou_population_package_rel
+        where data_status = 1
+        <if test="accountId!=null">
+            AND account_id = #{accountId}
+        </if>
+        <if test="orientationId!=null">
+            AND orientation_id = #{orientationId}
+        </if>
+        limit 1
+    </select>
+
+    <select id="queryPushResults" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        pop_id as 'id',
+        IFNULL(t2.auth_name,'') as 'authName',
+        IFNULL(t2.account_id,'') as 'accountId',
+        IFNULL(t1.message,'-') as 'message',
+        CASE WHEN t1.data_status =1 THEN '推送成功' ELSE '推送失败' end as 'result'
+        FROM ctop_kuaishou_population_package_rel t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.pop_id = #{id}
+        <if test="accountIds!=null">
+            AND t1.account_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getRelatedAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT pop_id as 'id',
+               IFNULL(t2.auth_name, '') as 'authName',
+               IFNULL(t2.account_id, '') as 'accountId',
+               t1.`status`,
+               CASE t1.`status`
+                   WHEN 0 THEN '计算中'
+                   WHEN 1 THEN '已生效'
+                   WHEN 3 THEN '推送中'
+                   WHEN 4 THEN '已推送'
+                   WHEN 5 THEN '计算失败'
+                   WHEN 6 THEN '推送失败'
+                   WHEN 7 THEN '已失效'
+                   ELSE ''
+                   END as 'statusStr',
+               cover_num 'coverNum',
+               (SELECT COUNT(1)
+                FROM ctop_kuaishou_population_package_rel t
+                where t.account_id = t1.account_id
+                  AND t.data_status = 1
+                  AND (t.`status` = 0 OR t.`status` = 1 or t.`status` = 3 or t.`status` = 4)) as 'populationCount'
+        FROM ctop_kuaishou_population_package_rel t1
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.pop_id = #{id}
+          AND t1.data_status = 1
+    </select>
+
+    <select id="queryEntity" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel">
+        SELECT pop_id,
+               account_id,
+               orientation_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE pop_id = #{id}
+          AND data_status = 1
+          AND account_id = #{accountId}
+    </select>
+
+    <select id="queryByOrientationId" resultType="java.lang.Long">
+        SELECT orientation_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE data_status = 1
+        AND account_id = #{accountId}
+        <if test="orientationId!=null">
+            AND orientation_id = #{orientationId}
+        </if>
+    </select>
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_population_package_rel(
+        id,
+        pop_id,
+        project_id,
+        account_id,
+        stat_date,
+        orientation_id,
+        signature,
+        orientation_name,
+        population_type,
+        `type`,
+        status,
+        cover_num,
+        record_size,
+        match_size,
+        message,
+        data_status
+        )
+        values
+        <foreach collection="packageRels" item="package" separator=",">
+            (
+            #{package.id},
+            #{package.popId},
+            #{package.projectId},
+            #{package.accountId},
+            #{package.statDate},
+            #{package.orientationId},
+            #{package.signature},
+            #{package.orientationName},
+            #{package.populationType},
+            #{package.type},
+            #{package.status},
+            #{package.coverNum},
+            #{package.recordSize},
+            #{package.matchSize},
+            #{package.message},
+            #{package.dataStatus}
+            )
+        </foreach>
+    </insert>
+
+    <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.account_id as 'accountId', CONCAT(t1.auth_name, '(', t1.account_id, ')') as 'authName', CASE
+                                                                                                              WHEN
+                                                                                                                      t2.status = 0
+                                                                                                                      OR
+                                                                                                                      t2.status = 1
+                                                                                                                      OR
+                                                                                                                      t2.status = 3
+                                                                                                                      OR
+                                                                                                                      t2.status = 4
+                                                                                                                  THEN 1
+                                                                                                              ELSE 0 END
+            as 'state'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN (
+            SELECT account_id, status
+            FROM ctop_kuaishou_population_package_rel
+            WHERE project_id = #{projectId}
+              AND pop_id = #{id}
+              AND data_status = 1
+        ) t2 ON t1.account_id = t2.account_id
+        where t1.account_status = 0
+          AND t1.project_id = #{projectId}
+    </select>
+
+    <update id="updateStatus">
+        update
+        ctop_kuaishou_population_package_rel
+        <set>
+            <if test="rel.status != null">
+                status = #{rel.status},
+            </if>
+            <if test="rel.coverNum != null">
+                cover_num = #{rel.coverNum},
+            </if>
+            <if test="rel.recordSize != null">
+                record_size = #{rel.recordSize},
+            </if>
+            <if test="rel.dataStatus != null">
+                data_status = #{rel.dataStatus},
+            </if>
+            <if test="rel.matchSize != null">
+                match_size = #{rel.matchSize},
+            </if>
+            <if test="rel.message != null">
+                message = #{rel.message},
+            </if>
+        </set>
+        where orientation_id = #{rel.orientationId}
+        and account_id = #{rel.accountId}
+    </update>
+
+</mapper>

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppGroup;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 应用-广告组关联表
+ * @Author: jeecg-boot
+ * @Date: 2021-05-14
+ * @Version: V1.0
+ */
+public interface IKuaishouAppGroupService extends IService<KuaishouAppGroup> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 应用和账户关联表
+ * @Author: jeecg-boot
+ * @Date:   2021-05-13
+ * @Version: V1.0
+ */
+public interface IKuaishouAppPackageRelService extends IService<KuaishouAppPackageRel> {
+
+}

+ 37 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageService.java

@@ -0,0 +1,37 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * @Description: 项目绑定的应用
+ * @Author: jeecg-boot
+ * @Date: 2021-05-12
+ * @Version: V1.0
+ */
+public interface IKuaishouAppPackageService extends IService<KuaishouAppPackage> {
+
+    Result<Object> importExcel(MultipartFile file, Long projectId, Integer platform, String imageToken, String imageUrl) throws Exception;
+
+    Result<Object> pushAppPackage(Long id, JSONArray accountIds);
+
+    Result<Object> queryPushResults(String id, JSONArray accountIds, String status);
+
+    List<Long> queryByAppVersion(Long projectId,String appVersion);
+
+    void createAppAndGroupRel(JSONObject request);
+
+    Result<Object> queryPageList(KuaishouAppPackage kuaishouAppPackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> getRelatedAccounts(Long id);
+
+    Result<Object> getRelatedGroups(Long id, Long accountId);
+
+    Result<Object> getAccountByProjectId(Long projectId, String id);
+}

+ 0 - 31
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouCrowdPackService.java

@@ -1,31 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.service;
-
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.common.api.vo.Result;
-
-/**
- * @Description: 人群报表
- * @Author: jeecg-boot
- * @Date: 2021-03-26
- * @Version: V1.0
- */
-public interface IKuaishouCrowdPackService extends IService<KuaishouCrowdPack> {
-
-    Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack, Integer pageNo, Integer pageSize);
-
-    Result<Object> uploadCrowdPack(Integer type, String orientationName, Long accountId, String url);
-
-    Result<Object> accountPush(JSONObject request);
-
-    void crowdListQuery();
-
-    Result<Object> queryRel(String type, String signature, Integer pageNo, Integer pageSize);
-
-    Result<Object> queryFailReason(String signature, Integer pageNo, Integer pageSize);
-
-    Result<Object> updateDataStatus(KuaishouCrowdPack kuaishouCrowdPack);
-
-    Result<Object> checkCrowdPackage(String signature);
-}

+ 48 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPackageService.java

@@ -0,0 +1,48 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 自动投放-定向包详情
+ * @Author: jeecg-boot
+ * @Date: 2021-04-20
+ * @Version: V1.0
+ */
+public interface IKuaishouDirectionalPackageService extends IService<KuaishouDirectionalPackage> {
+
+    Result<Object> createDirectionalPackage(JSONObject requestJson);
+
+    Result<Object> updateDirectionalPackage(JSONObject requestJson) throws InterruptedException;
+
+    Result<Object> queryList(KuaishouDirectionalPackage directionalPackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> getRelatedAccountGroup(String id, Integer type,Long accountId, Integer pageNo, Integer pageSize);
+
+    Result<Object> pushDirectionalPackage(String id, JSONArray datas);
+
+    Result<Object> queryPushResults(String id, JSONArray accountIds,String status);
+
+    Result<Object> editPopulation(JSONObject requestJson);
+
+    Result<Object> getAccountByProjectId(Long projectId, String id);
+
+    /**
+     * 添加广告组和定向模板绑定关系
+     *
+     * @param unitId            广告组Id
+     * @param templateId        模板Id
+     * @param population        定向人群包
+     * @param paidAudience      付费人群包
+     * @param excludePopulation 排除人群包
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void createUnitAndTemplate(JSONObject request) throws Exception;
+
+    Result<Object> queryPopulationById(Long templateId, Long accountId);
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 自动投放-定向包详情关系表
+ * @Author: jeecg-boot
+ * @Date:   2021-04-25
+ * @Version: V1.0
+ */
+public interface IKuaishouDirectionalPckageRelService extends IService<KuaishouDirectionalaPckageRel> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 落地页-广告组关联表
+ * @Author: jeecg-boot
+ * @Date:   2021-05-11
+ * @Version: V1.0
+ */
+public interface IKuaishouLandpagePackageRelService extends IService<KuaishouLandpagePackageRel> {
+
+}

+ 38 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouLandpagePackageService.java

@@ -0,0 +1,38 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.List;
+
+/**
+ * @Description: 落地页账户项目关联表
+ * @Author: jeecg-boot
+ * @Date: 2021-05-11
+ * @Version: V1.0
+ */
+public interface IKuaishouLandpagePackageService extends IService<KuaishouLandpagePackage> {
+
+    Result<Object> queryPageList(KuaishouLandpagePackage kuaishouLandpagePackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> synchronousData(Long projectId);
+
+    Result<Object> getRelatedAccounts(Long siteId);
+
+    Result<Object> getRelatedGroups(Long siteId, Long accountId);
+
+    /**
+     * 绑定落地页与广告组的关系
+     *
+     * @param siteId     落地页Id
+     * @param creativeId 创意ID
+     * @param unitId     广告组ID
+     * @param accountId  账户ID
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void createLandPageAndUnit(Long siteId, Long creativeId, Long unitId, Long accountId);
+
+}

+ 28 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationGroupService.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationGroup;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 人群包-广告组关联表
+ *
+ * @author jeecg-boot
+ * 2021-05-08
+ * @version V1.0
+ */
+public interface IKuaishouPopulationGroupService extends IService<KuaishouPopulationGroup> {
+
+    /* 添加广告组和人群包绑定关系
+     *
+     * @param unitId            广告组Id
+     * @param accountId         账户Id
+     * @param population        定向人群包
+     * @param paidAudience      付费人群包
+     * @param excludePopulation 排除人群包
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void createPopulationAndGroupRel(JSONObject request) throws Exception;
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 人群包模板和账户绑定关系表
+ *
+ * @author jeecg-boot
+ * 2021-05-07
+ * @version V1.0
+ */
+public interface IKuaishouPopulationPackageRelService extends IService<KuaishouPopulationPackageRel> {
+
+}

+ 37 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageService.java

@@ -0,0 +1,37 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * 2021-05-06
+ * @version V1.0
+ */
+public interface IKuaishouPopulationPackageService extends IService<KuaishouPopulationPackage> {
+
+    Result<Object> createEntity(KuaishouPopulationPackage kuaishouPopulationPackage);
+
+    Result<Object> push(JSONArray accountIds, Long id);
+
+    Result<Object> queryPageList(KuaishouPopulationPackage kuaishouPopulationPackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> queryPushResults(Long id, JSONArray accountIds);
+
+    Result<Object> queryPushHistory(Long  id);
+
+    Result<Object> getRelatedAccounts(Long id);
+
+    Result<Object> getRelatedGroups(Long id,Long accountId);
+
+    void crowdListQuery();
+
+    Result<Object> getAccountByProjectId(Long projectId, String id);
+
+    Result<Object> checkPopulationPackage(String signature);
+}

+ 17 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/KuaishouAppPackageRelMapper.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 应用和账户关联表
+ * @author: jeecg-boot
+ * @date:   2021-05-13
+ * @cersion: V1.0
+ */
+public interface KuaishouAppPackageRelMapper extends BaseMapper<KuaishouAppPackageRel> {
+
+}

+ 24 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -61,6 +61,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     @Autowired
     private IAiKuaishouCreativeLevelOperationRecordService creativeLevelOperationRecordService;
     @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
     private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
 
@@ -326,10 +328,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
                 timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
             } else if (strategy.getMultipleBids() == 1) {
-                timeStart = -1 * 60 * 24L;
-                timeEnd = -5L;
+                if (createType == 1) {
+                    timeStart = -1 * 60 * 24L;
+                    timeEnd = -5L;
+                } else {
+                    timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+                    timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+                }
             }
-
         }
         Long now = System.currentTimeMillis();
         String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
@@ -601,6 +607,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
         Long unitId = creativeParams.getLong("unit_id");
         if (code == 0) {
+            createLandPageAndUnit(creativeParams, resultJson.getJSONObject("data"));
+
             log.info("创建程序化创意成功,accountId:{},unit:{}", token.getAccountId(), unitId);
 
         } else {
@@ -617,6 +625,19 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
     }
 
+    //绑定落地页与广告组、创意的关系
+    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 JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt, String appVersion) {
         JSONObject programJson = new JSONObject();
         programJson.put("advertiser_id", token.getAccountId());
@@ -1307,7 +1328,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         creativeParams.put("photo_id", videoItem.getPhotoId());
         creativeParams.put("creative_material_type", videoItem.getMaterialType());
         creativeParams.put("action_bar_text", strategy.getActionBarText());
-
         JSONArray descArr = JSONArray.parseArray(strategy.getDescription());
         int index = new Random().nextInt(descArr.size());
         String description = descArr.getString(index);

+ 57 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java

@@ -3,12 +3,22 @@ package cn.com.ctop.kuaishou.modules.ai.service.impl;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 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.KuaiShouVideoGet;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+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.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -37,6 +47,8 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
     private IKuaiShouVideoGetService videoGetService;
     @Autowired
     private IKuaiShouGroupTemplateService groupTemplateService;
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
     @Value("${ai.callback.callback-unit-url}")
     private String unitUrl;
@@ -446,6 +458,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 if (resultJson.getInteger("code") == 0) {
                     returnJson.put("code", 0);
                     returnJson.put("message", "程序化创意创建成功");
+                    createLandPageAndUnit(programJson, resultJson.getJSONObject("data"));
                 } else {
                     log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", oauthToken.getAccountId(), resultJson.getString("message"), programCreativeJson);
                     returnJson.put("code", -1);
@@ -466,6 +479,18 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
         callback(creativeUrl, returnArray, "program_create");
     }
 
+    //绑定落地页与广告组、创意的关系
+    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();
+        }
+    }
 
     /**
      * 回调
@@ -614,9 +639,36 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 target.put("intelli_extend", intelli_extend); // 智能扩量
             }
         }
-        if (Check.isNull(unitJson.getJSONObject("behavior_interest"))) {
-            // TODO 只是单独结构体 后续需要优化
-            target.put("behavior_interest", unitJson.getJSONObject("behavior_interest")); // 智能扩量
+        //-------------兴趣行为定向
+        JSONObject behaviorInterest = new JSONObject();
+        JSONObject behavior = new JSONObject();
+        JSONObject interest = new JSONObject();
+        if (!Check.isNull(unitJson.getJSONArray("keyword"))) {
+            behavior.put("keyword", unitJson.getJSONArray("keyword"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("label"))) {
+            behavior.put("label", unitJson.getJSONArray("label"));
+        }
+        if (!Check.isNull(unitJson.getInteger("strengthType"))) {
+            behavior.put("strength_type", unitJson.getInteger("strengthType"));
+        }
+        if (!Check.isNull(unitJson.getInteger("timeType"))) {
+            behavior.put("time_type", unitJson.getInteger("timeType"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("sceneType"))) {
+            behavior.put("scene_type", unitJson.getJSONArray("sceneType"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("interestLabel"))) {
+            interest.put("label", unitJson.getJSONArray("interestLabel"));
+        }
+        if (!Check.isNull(behavior)) {
+            behaviorInterest.put("behavior", behavior);
+        }
+        if (!Check.isNull(interest)) {
+            behaviorInterest.put("interest", interest);
+        }
+        if (!Check.isNull(behaviorInterest)) {
+            target.put("behavior_interest", behaviorInterest);
         }
         return target;
     }

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppGroup;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppGroupMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppGroupService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 应用-广告组关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-14
+ */
+@Service
+public class KuaishouAppGroupServiceImpl extends ServiceImpl<KuaishouAppGroupMapper, KuaishouAppGroup> implements IKuaishouAppGroupService {
+
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 应用和账户关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-13
+ */
+@Service
+public class KuaishouAppPackageRelServiceImpl extends ServiceImpl<KuaishouAppPackageRelMapper, KuaishouAppPackageRel> implements IKuaishouAppPackageRelService {
+
+}

+ 310 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageServiceImpl.java

@@ -0,0 +1,310 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppGroupMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+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.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-12
+ */
+@Service
+public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackageMapper, KuaishouAppPackage> implements IKuaishouAppPackageService {
+
+    @Autowired
+    private KuaishouAppPackageMapper appPackageMapper;
+
+    @Autowired
+    private KuaishouAppPackageRelMapper relMapper;
+
+    @Autowired
+    private KuaishouAppGroupMapper appGroupMapper;
+
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaiShouMaterialUploadService materialUploadService;
+
+    @Override
+    public Result<Object> importExcel(MultipartFile file, Long projectId, Integer platform, String imageToken, String imageUrl) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        Workbook workbook = null;
+        String fileName = file.getOriginalFilename();
+        String substring = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase();
+        if (substring.equals("XLS")) {
+            workbook = new HSSFWorkbook(file.getInputStream());
+        } else if (substring.equals("XLSX")) {
+            workbook = new XSSFWorkbook(file.getInputStream());
+        } else {
+            throw new Exception("文件不是Excel文件");
+        }
+        Sheet sheet = workbook.getSheet("Sheet1");
+        if (Check.isNull(sheet)) {
+            throw new Exception("Sheet标题不是默认的Sheet1");
+        }
+        int rows = sheet.getLastRowNum();// 指的行数,一共有多少行+
+        if (rows == 0) {
+            throw new Exception("请填写数据");
+        }
+        //查询项目下的应用标记(同一账户下应用标记不能重复),在此视为同一项目不可重复
+        List<String> appVersions = appPackageMapper.queryAppVersions(projectId);
+        StringBuffer errAppVersions = new StringBuffer();
+        List<KuaishouAppPackage> appList = new ArrayList<>();
+        for (int i = 1; i <= rows + 1; i++) {
+            Row row = sheet.getRow(i);
+            if (row != null) {
+                KuaishouAppPackage appPackage = new KuaishouAppPackage();
+                String appName = getCellValue(row.getCell(0));
+                String packageName = getCellValue(row.getCell(1));
+                String appVersion = getCellValue(row.getCell(2));
+                String appPrivacyUrl = getCellValue(row.getCell(3));
+                String url = getCellValue(row.getCell(4));
+                String trackUrl = getCellValue(row.getCell(5));
+                String useSdk = getCellValue(row.getCell(6));
+                if ((platform == 1 || platform == 2) && Check.isNull(appPrivacyUrl)) {
+                    return Result.error("执行失败,您选择的是安卓类应用,请填写隐私政策链接");
+                } else if (Check.isNull(appVersion)) {
+                    return Result.error("解析失败,文档中应用标记列缺失数据");
+                } else if (platform == 1 && Check.isNull(packageName)) {
+                    return Result.error("解析失败,选择Android应用下载时,文档中应用包名列缺失数据");
+                } else if (Check.isNull(appName)) {
+                    return Result.error("解析失败,文档中应用名称列缺失数据");
+                } else if (Check.isNull(url)) {
+                    return Result.error("解析失败,文档中下载链接列缺失数据");
+                } else if (Check.isNull(trackUrl)) {
+                    return Result.error("解析失败,文档中监测链接列缺失数据");
+                }
+                if (appVersions.contains(appVersion)) {
+                    errAppVersions.append(appVersion).append("、");
+                }
+                appPackage.setProjectId(projectId);
+                appPackage.setAppName(appName);
+                appPackage.setAppVersion(appVersion);
+                appPackage.setAppIconUrl(imageUrl);
+                appPackage.setPackageName(packageName);
+                appPackage.setPlatform(platform);
+                appPackage.setImageToken(imageToken);
+                appPackage.setTrackUrl(trackUrl);
+                appPackage.setAppPrivacyUrl(appPrivacyUrl);
+                appPackage.setDataStatus(1);//有效
+                appPackage.setUrl(url);
+                String md5 = MD5Util.getMd5(url);
+                if (!Check.isNull(md5)) {
+                    appPackage.setAppMd5(md5);
+                }
+                if (!Check.isNull(useSdk)) {
+                    appPackage.setUseSdk(Integer.valueOf(useSdk));
+                }
+                appList.add(appPackage);
+            }
+        }
+        String errVersion = errAppVersions.toString();
+        if (!Check.isNull(errVersion)) {
+            return Result.error("数据异常,重复的应用标记:" + errVersion.substring(0, errVersion.length() - 1));
+        }
+        appPackageMapper.replaceBatch(appList);
+        return Result.ok("文件导入成功");
+    }
+
+    private String getCellValue(Cell cell) {
+        String value = "";
+        if (cell != null) {
+            // 以下是判断数据的类型
+            switch (cell.getCellType()) {
+                case HSSFCell.CELL_TYPE_NUMERIC: // 数字
+                    value = cell.getNumericCellValue() + "";
+                    if (HSSFDateUtil.isCellDateFormatted(cell)) {
+                        Date date = cell.getDateCellValue();
+                        if (date != null) {
+                            value = new SimpleDateFormat("yyyy-MM-dd").format(date);
+                        } else {
+                            value = "";
+                        }
+                    } else {
+                        value = new DecimalFormat("0").format(cell.getNumericCellValue());
+                    }
+                    break;
+                case HSSFCell.CELL_TYPE_STRING: // 字符串
+                    value = cell.getStringCellValue();
+                    break;
+                case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
+                    value = cell.getBooleanCellValue() + "";
+                    break;
+                case HSSFCell.CELL_TYPE_FORMULA: // 公式
+                    value = cell.getCellFormula() + "";
+                    break;
+                case HSSFCell.CELL_TYPE_BLANK: // 空值
+                    value = "";
+                    break;
+                case HSSFCell.CELL_TYPE_ERROR: // 故障
+                    value = "非法字符";
+                    break;
+                default:
+                    value = "未知类型";
+                    break;
+            }
+        }
+        return value.trim();
+    }
+
+    @Override
+    public Result<Object> pushAppPackage(Long id, JSONArray accountIds) {
+        KuaishouAppPackage appPackage = appPackageMapper.selectById(id);
+        if (Check.isNull(appPackage)) {
+            return Result.error("为获取到应用信息");
+        }
+        KuaishouAppPackageRel rel = new KuaishouAppPackageRel();
+        rel.setApptemId(appPackage.getId());
+        rel.setProjectId(appPackage.getProjectId());
+        rel.setAppVersion(appPackage.getAppVersion());
+        List<KuaishouAppPackageRel> list = new ArrayList<>();
+        for (Object account : accountIds) {
+            try {
+                Long accountId = Long.valueOf(String.valueOf(account));
+                KuaishouAppPackageRel entity = relMapper.queryEntityByAccountId(accountId, appPackage.getAppVersion());
+                if (!Check.isNull(entity)) {
+                    continue;
+                }
+                CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+                JSONObject requestJson = new JSONObject();
+                requestJson.put("advertiser_id", accountId);
+                requestJson.put("app_version", appPackage.getAppVersion());
+                requestJson.put("app_name", appPackage.getAppName());
+                requestJson.put("image_token", appPackage.getImageToken());
+                requestJson.put("package_name", appPackage.getPackageName());
+                requestJson.put("platform", appPackage.getPlatform());
+                requestJson.put("url", appPackage.getUrl());
+                requestJson.put("use_sdk", appPackage.getUseSdk());
+                requestJson.put("app_privacy_url", appPackage.getAppPrivacyUrl());
+                String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_CREATE;
+                Map<String, String> headerMap = new HashMap<>();
+                headerMap.put("Content-Type", "multipart/form-data");
+                headerMap.put("Access-Token", oauthToken.getAccessToken());
+                String result = materialUploadService.exceptInfoForRestTemplate(url, requestJson, headerMap);
+                JSONObject resultJson = JSONObject.parseObject(result);
+                rel.setAccountId(accountId);
+                if (!Check.isNull(resultJson)) {
+                    Integer code = resultJson.getInteger("code");
+                    if (code == 0) {
+                        JSONObject data = resultJson.getJSONObject("data");
+                        rel.setAppId(data.getLong("app_id"));
+                        rel.setReturnUrl(data.getString("url"));
+                        rel.setMessage(resultJson.getString("message"));
+                        rel.setDataStatus(1);
+                    } else {
+                        rel.setDataStatus(0);
+                        rel.setMessage(resultJson.getString("message"));
+                    }
+                } else {
+                    rel.setDataStatus(0);
+                    rel.setMessage("上传应用返回结果为空");
+                }
+            } catch (Exception e) {
+                rel.setDataStatus(0);
+                rel.setMessage("上传应用异常");
+                log.error("上传应用异常,accountId=" + account, e);
+            }
+            list.add(rel);
+        }
+        if (!list.isEmpty()) {
+            relMapper.replaceBatch(list);
+        }
+        return Result.ok("推送完成");
+    }
+    @Override
+    public Result<Object> queryPushResults(String id, JSONArray accountIds, String status) {
+        List<JSONObject> lsit = relMapper.queryPushResults(id, accountIds, status);
+        return Result.ok(new PageInfo<JSONObject>(lsit));
+    }
+
+    @Override
+    public List<Long> queryByAppVersion(Long projectId,String appVersion) {
+        return appPackageMapper.queryByAppVersion(projectId,appVersion);
+    }
+
+    @Override
+    public void createAppAndGroupRel(JSONObject request) {
+        try {
+            appGroupMapper.replaceBatch(request);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("添加广告组和应用绑定关系异常");
+        }
+    }
+
+    @Override
+    public Result<Object> queryPageList(KuaishouAppPackage kuaishouAppPackage, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = appPackageMapper.queryPageList(kuaishouAppPackage.getAppVersion(), kuaishouAppPackage.getProjectId(), kuaishouAppPackage.getPlatform());
+        for (JSONObject object : list) {
+            object.put("unitCount", appPackageMapper.queryUnitCount(object.getLong("id")));
+        }
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedAccounts(Long id) {
+        JSONObject result = new JSONObject();
+        KuaishouAppPackage appPackage = appPackageMapper.selectById(id);
+        List<JSONObject> list = relMapper.getRelatedAccounts(id);
+        result.put("app", appPackage);
+        result.put("page", new PageInfo<>(list));
+        return Result.ok(result);
+    }
+
+    @Override
+    public Result<Object> getRelatedGroups(Long id, Long accountId) {
+        JSONObject result = new JSONObject();
+        KuaishouAppPackage appPackage = appPackageMapper.selectById(id);
+        List<JSONObject> list = appPackageMapper.getRelatedGroups(id, accountId);
+        result.put("app", appPackage);
+        result.put("page", new PageInfo<>(list));
+        return Result.ok(result);
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, String id) {
+        List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+
+}

+ 0 - 277
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouCrowdPackServiceImpl.java

@@ -1,277 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.service.impl;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.mapper.UserAllocationMapper;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.LoadFileUtil;
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
-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.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.util.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * 人群报表
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2021-03-26
- */
-@Slf4j
-@Service
-public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackMapper, KuaishouCrowdPack> implements IKuaishouCrowdPackService {
-
-    @Autowired
-    private KuaishouCrowdPackMapper crowdPackMapper;
-
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-
-    @Autowired
-    private IKuaishouPopulationService iKuaishouPopulationService;
-
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
-    @Autowired
-    UserAllocationMapper userAllocationMapper;
-
-    @Value("${zip.local.download-path}")
-    private String downloadPath;
-
-
-    @Override
-    public Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack, Integer pageNo, Integer pageSize) {
-        Long total = crowdPackMapper.getTotal(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationName());
-        PageHelper.startPage(pageNo, pageSize, false);
-        List<JSONObject> list = crowdPackMapper.queryPageList(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationName());
-        for (JSONObject object : list) {
-            int count = crowdPackMapper.queryProjectCount(object.getString("signature"));
-            object.put("projectCount", count);
-            int accountCount = crowdPackMapper.queryAccountCount(object.getString("signature"));
-            object.put("accountCount", accountCount);
-        }
-        PageInfo pageInfo = new PageInfo(list);
-        pageInfo.setTotal(total);
-        return Result.ok(pageInfo);
-    }
-
-    @Override
-    public Result<Object> uploadCrowdPack(Integer type, String orientationName, Long accountId, String url) {
-        StringBuffer path = new StringBuffer();
-        path.append(downloadPath).append(DateUtils.getNowDate(DateUtils.WEB_FORMAT)).append("/").append(UUID.randomUUID().toString()).append("/");
-        if (!url.contains("http")) {
-            url = "https:".concat(url);
-        }
-        String newFileUrl = LoadFileUtil.downLoadFromUrl(url, path.toString());
-        if (Check.isNull(newFileUrl)) {
-            return Result.error("文件下载失败,路径:" + url);
-        }
-        String md5 = null;
-        try {
-            md5 = LoadFileUtil.getMD5(newFileUrl);
-        } catch (IOException e) {
-            log.error("获取MD5签名失败", e);
-        }
-        QueryWrapper<KuaishouCrowdPack> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("account_id", accountId);
-        queryWrapper.eq("signature", md5);
-        queryWrapper.eq("data_status", 1);
-        queryWrapper.last("limit 1");
-        KuaishouCrowdPack one = crowdPackMapper.selectOne(queryWrapper);
-        if (!Check.isNull(one)) {
-            return Result.error("本账户已上传过该人群包,人群包名为:" + one.getOrientationName());
-        }
-        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        JSONObject jsonObject = iKuaishouPopulationService.updatePopulation(token, type, orientationName, newFileUrl);
-        LoadFileUtil.delFile(newFileUrl);
-        if (!Check.isNull(jsonObject)) {
-            if (jsonObject.getInteger("code") == 0) {
-                KuaishouCrowdPack crowdPack = JSONObject.toJavaObject(jsonObject.getJSONObject("data"), KuaishouCrowdPack.class);
-                crowdPack.setSignature(md5);
-                crowdPack.setUrl(url);
-                crowdPack.setMessage(jsonObject.getString("message"));
-                crowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                crowdPack.setDataStatus(1);
-                this.save(crowdPack);
-            } else {
-                KuaishouCrowdPack crowdPack = new KuaishouCrowdPack();
-                crowdPack.setAccountId(accountId);
-                crowdPack.setOrientationName(orientationName);
-                crowdPack.setSignature(md5);
-                crowdPack.setUrl(url);
-                crowdPack.setMessage(jsonObject.getString("message"));
-                crowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                crowdPack.setDataStatus(0);
-                this.save(crowdPack);
-                return Result.error(jsonObject.getString("message"));
-            }
-        }
-        return Result.ok("success");
-    }
-
-    @Override
-    public Result<Object> accountPush(JSONObject request) {
-        JSONArray accountIds = request.getJSONArray("accountIds");
-        String signature = request.getString("signature");
-        Long accountId = request.getLong("accountId");
-        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        QueryWrapper<KuaishouCrowdPack> wrapper = new QueryWrapper<>();
-        wrapper.eq("account_id", accountId);
-        wrapper.eq("signature", signature);
-        wrapper.eq("status", 4);
-        wrapper.last("limit 1");
-        KuaishouCrowdPack kuaishouCrowdPack = crowdPackMapper.selectOne(wrapper);
-        if (Check.isNull(kuaishouCrowdPack)) {
-            return Result.error("该账户下没有可推送人群包");
-        }
-        JSONObject jsonObject = iKuaishouPopulationService.pushAccountsPopulation(token, kuaishouCrowdPack.getOrientationId(), accountIds);
-        if (jsonObject.getInteger("code") == 0) {
-            List<KuaishouCrowdPack> list = new ArrayList<>();
-            JSONObject data = jsonObject.getJSONObject("data");
-            if (!Check.isNull(data)) {
-                JSONArray success = data.getJSONArray("success");
-                for (Object account : success) {
-                    kuaishouCrowdPack.setAccountId(Long.valueOf(String.valueOf(account)));
-                    kuaishouCrowdPack.setMessage("PUSH OK");
-                    kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                    list.add(kuaishouCrowdPack);
-                }
-                JSONArray fail = data.getJSONArray("fail");
-                for (Object account : fail) {
-                    Long aaccount = Long.valueOf(String.valueOf(account));
-                    KuaishouCrowdPack crowdPack = crowdPackMapper.queryByAccountId(aaccount, kuaishouCrowdPack.getOrientationId());
-                    if (Check.isNull(crowdPack)) {
-                        kuaishouCrowdPack.setDataStatus(0);
-                        kuaishouCrowdPack.setAccountId(aaccount);
-                        kuaishouCrowdPack.setMessage("推送失败");
-                        kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                        kuaishouCrowdPack.setStatus(null);
-                        kuaishouCrowdPack.setType(null);
-                        kuaishouCrowdPack.setCoverNum(null);
-                        kuaishouCrowdPack.setRecordSize(null);
-                        kuaishouCrowdPack.setMatchSize(null);
-                        list.add(kuaishouCrowdPack);
-                    }
-                }
-                if (list.size() > 0) {
-                    crowdPackMapper.replaceBatch(list);
-                }
-            }
-        } else {
-            return Result.error(jsonObject.getString("message"));
-        }
-        return Result.ok("success");
-    }
-
-    @Override
-    public void crowdListQuery() {
-        List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
-        for (int i = 0; i <= 7; i++) {
-            if (i != 2) {
-                for (KuaishouCrowdPack crowdPack : crowdList) {
-                    CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
-                    JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), i);
-                    if (jsonObject.getInteger("code") == 0) {
-                        JSONObject data = jsonObject.getJSONObject("data");
-                        if (!Check.isNull(data)) {
-                            JSONArray details = data.getJSONArray("details");
-                            if (details.size() > 0) {
-                                for (int j = 0; j < details.size(); j++) {
-                                    JSONObject obj = details.getJSONObject(j);
-                                    if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
-                                        KuaishouCrowdPack oldPack = crowdPackMapper.queryByAccountId(null, obj.getLong("orientation_id"));
-                                        KuaishouCrowdPack crowdPackEntity = JSONObject.toJavaObject(obj, KuaishouCrowdPack.class);
-                                        if (!Check.isNull(oldPack)) {
-                                            crowdPackEntity.setStatDate(oldPack.getStatDate());
-                                            crowdPackEntity.setUrl(oldPack.getUrl());
-                                            crowdPackEntity.setSignature(oldPack.getSignature());
-                                        }
-                                        crowdPackEntity.setMessage("PUSH OK");
-                                        crowdPackEntity.setDataStatus(1);
-                                        this.save(crowdPackEntity);
-                                    } else {
-                                        crowdPackMapper.update(obj);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    @Override
-    public Result<Object> queryRel(String type, String signature, Integer pageNo, Integer pageSize) {
-        PageHelper.startPage(pageNo, pageSize);
-        List<JSONObject> list = null;
-        if ("1".equals(type)) {
-            list = crowdPackMapper.queryRelProject(signature);
-        } else {
-            list = crowdPackMapper.queryRelAccounts(signature);
-        }
-        PageInfo pageInfo = new PageInfo(list);
-        return Result.ok(pageInfo);
-    }
-
-    @Override
-    public Result<Object> queryFailReason(String signature, Integer pageNo, Integer pageSize) {
-        PageHelper.startPage(pageNo, pageSize);
-        List<JSONObject> list = crowdPackMapper.queryFailReason(signature);
-        PageInfo pageInfo = new PageInfo(list);
-        return Result.ok(pageInfo);
-    }
-
-    @Override
-    public Result<Object> updateDataStatus(KuaishouCrowdPack kuaishouCrowdPack) {
-        CtopOauthToken token = tokenService.getTokenByAccountId(kuaishouCrowdPack.getAccountId());
-        JSONObject object = iKuaishouPopulationService.deletePopulation(kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationId(), token.getAccessToken());
-        if (!Check.isNull(object)) {
-            if (object.getInteger("code") == 0) {
-                if (this.removeById(kuaishouCrowdPack.getId())) {
-                    return Result.ok("删除成功");
-                }
-            }
-            return Result.error("删除失败,".concat(object.getString("message")));
-        }
-        return Result.error("删除失败");
-    }
-
-    @Override
-    public Result<Object> checkCrowdPackage(String signature) {
-        QueryWrapper<KuaishouCrowdPack> wrapper = new QueryWrapper<>();
-        wrapper.eq("signature", signature);
-        wrapper.eq("data_status", 1);
-        wrapper.last("limit 1");
-        KuaishouCrowdPack kuaishouCrowdPack = crowdPackMapper.selectOne(wrapper);
-        Result result = new Result();
-        if (Check.isNull(kuaishouCrowdPack)) {
-            return Result.ok("success");
-        }
-        result.setSuccess(true);
-        result.setCode(201);
-        result.setMessage("后台保存过该人群包,名称为:" + kuaishouCrowdPack.getOrientationName());
-        result.setResult(kuaishouCrowdPack);
-        return result;
-    }
-}

+ 660 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java

@@ -0,0 +1,660 @@
+package cn.com.ctop.kuaishou.modules.ai.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.entity.KuaishouDirectionalPackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPckageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPckageRelService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateTargetMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
+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.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 java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Slf4j
+@Service
+public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouDirectionalPackageMapper, KuaishouDirectionalPackage> implements IKuaishouDirectionalPackageService {
+
+    @Autowired
+    private IKuaishouTemplateService kuaishouTemplateService;
+    @Autowired
+    private KuaishouDirectionalPackageMapper packageMapper;
+    @Autowired
+    private KuaishouDirectionalPckageRelMapper relMapper;
+    @Autowired
+    private IKuaishouDirectionalPckageRelService relService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private KuaishouTemplateMapper templateMapper;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+    @Autowired
+    private KuaishouTemplateTargetMapper templateTargetMapper;
+
+    @Autowired
+    private IKuaiShouGroupTemplateService groupTemplateService;
+    static ExecutorService executorService = null;
+
+    @Override
+    public Result<Object> createDirectionalPackage(JSONObject requestJson) {
+        KuaishouDirectionalPackage entity = packageMapper.queryEntity(requestJson);
+        if (!Check.isNull(entity)) {
+            return Result.error("该账户下定向包名已存在");
+        }
+        KuaishouDirectionalPackage kuaishouDirectionalPackage = JSONObject.toJavaObject(requestJson, KuaishouDirectionalPackage.class);
+        if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+            kuaishouDirectionalPackage.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
+        }
+        kuaishouDirectionalPackage.setDataStatus(1);
+        boolean save = this.save(kuaishouDirectionalPackage);
+        if (save) {
+            return Result.ok("创建成功");
+        }
+        return Result.error("创建失败,定向包存储失败");
+    }
+
+
+    @Override
+    public Result<Object> updateDirectionalPackage(JSONObject requestJson) throws InterruptedException {
+        KuaishouDirectionalPackage entity = packageMapper.selectById(requestJson.getString("id"));
+        if (Check.isNull(entity)) {
+            return Result.error("未获取到定向包");
+        }
+        KuaishouDirectionalPackage kuaishouDirectionalPackage = JSONObject.toJavaObject(requestJson, KuaishouDirectionalPackage.class);
+        if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+            kuaishouDirectionalPackage.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
+        }
+        this.saveOrUpdate(kuaishouDirectionalPackage);
+        //获取本项目绑定该定向的账户
+        List<JSONObject> accounts = relMapper.queryRelId(requestJson.getLong("projectId"), requestJson.getString("id"), "account");
+        if (!Check.isNull(accounts)) {
+            for (JSONObject account : accounts) {
+                updateAccountsDirectionalPackage(requestJson, account);
+            }
+        }
+        Thread.sleep(300);
+        //获取本项目绑定该定向的广告组
+        List<JSONObject> units = relMapper.queryRelId(requestJson.getLong("projectId"), requestJson.getString("id"), "unit");
+        if (!Check.isNull(units)) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    executorService = Executors.newFixedThreadPool(3);
+                    units.forEach(unit -> {
+                        executorService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    updateUnitsDirectionalPackage(requestJson, unit);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        });
+                    });
+                    log.info("修改广告组定向完成");
+                }
+            };
+            thread.start();
+        }
+        return Result.ok("该项目下定向包已做同步修改");
+    }
+
+    private void updateUnitsDirectionalPackage(JSONObject requestJson, JSONObject unit) {
+        try {
+            Long unitId = unit.getLong("rel_id");
+            QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper();
+            queryWrapper.eq("unit_id", unitId);
+            queryWrapper.last("limit 1");
+            KuaiShouGroup kuaiShouGroup = groupMapper.selectOne(queryWrapper);
+            if (Check.isNull(kuaiShouGroup)) {
+                throw new Exception("未获取到组信息");
+            }
+            CtopOauthToken token = oauthTokenService.getTokenByAccountId(kuaiShouGroup.getAccountId());
+            String sceneIdStr = kuaiShouGroup.getSceneId();
+            if (Check.isNull(sceneIdStr)) {
+                throw new Exception("未获取资源位置");
+            }
+            Integer sceneId = (Integer) JSONArray.parseArray(sceneIdStr).get(0);
+            JSONObject unitJson = new JSONObject();
+            unitJson.put("advertiser_id", kuaiShouGroup.getAccountId());
+            unitJson.put("unit_id", unitId);
+            if (sceneId != 5) {
+                unitJson.put("template_id", unit.getLong("template_id"));
+            } else {
+                JSONObject unionJson = groupTemplateService.getUnionJson(unit.getLong("template_id"));
+                if (Check.isNullMap(unionJson)) {
+                    throw new Exception("根据定向模板未获取到相关信息");
+                }
+                unitJson.put("target", unionJson.getJSONObject("target"));
+            }
+            updateService.updateUnit(token.getAccessToken(), unitJson);
+        } catch (Exception e) {
+            log.error("修改广告组定向异常", e);
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 更新帐户定向包
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void updateAccountsDirectionalPackage(JSONObject requestJson, JSONObject accounEntity) {
+        Long accountId = accounEntity.getLong("rel_id");
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        try {
+            JSONObject param = new JSONObject();
+            param.put("template_id", accounEntity.getLong("template_id"));
+            param.put("advertiser_id", accountId);
+            if (!Check.isNull(requestJson.getString("templateName"))) {
+                param.put("template_name", requestJson.getString("templateName"));
+            }
+            JSONObject targetJson = new JSONObject();
+            if (requestJson.getJSONArray("region") != null) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", requestJson.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(requestJson.getInteger("userType"))) {
+                targetJson.put("user_type", requestJson.getInteger("userType"));
+            }
+            JSONArray agesRange = requestJson.getJSONArray("agesRange");
+            if (!Check.isNull(agesRange)) {
+                targetJson.put("ages_range", agesRange);
+            }
+            Integer min = requestJson.getInteger("min");
+            Integer max = requestJson.getInteger("max");
+            if (!Check.isNull(min) && !Check.isNull(max) && max != -1 && min != -1) {
+                JSONObject ageJson = new JSONObject();
+                ageJson.put("min", requestJson.getInteger("min"));
+                ageJson.put("max", requestJson.getInteger("max"));
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(requestJson.getInteger("gender"))) {
+                targetJson.put("gender", requestJson.getInteger("gender"));
+            }
+            if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+                targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+            }
+            if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("network"))) {
+                targetJson.put("network", requestJson.getInteger("network"));
+            }
+            if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
+            }
+            if (requestJson.getJSONArray("deviceBrand") != null) {
+                targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+            }
+            if (requestJson.getJSONArray("devicePrice") != null) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("population"))) {
+                targetJson.put("population", requestJson.getJSONArray("population"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            }
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                JSONObject intelliExtendJson = new JSONObject();
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+
+                if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
+            }
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                behavior.put("keyword", requestJson.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("label"))) {
+                behavior.put("label", requestJson.getJSONArray("label"));
+            }
+            if (!Check.isNull(requestJson.getInteger("strengthType"))) {
+                behavior.put("strength_type", requestJson.getInteger("strengthType"));
+            }
+            if (!Check.isNull(requestJson.getInteger("timeType"))) {
+                behavior.put("time_type", requestJson.getInteger("timeType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", requestJson.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestLabel"))) {
+                interest.put("label", requestJson.getJSONArray("interestLabel"));
+            }
+            if (!behavior.isEmpty()) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!interest.isEmpty()) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!behaviorInterest.isEmpty()) {
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
+                } else {
+                    log.error("修改账户定向失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("修改账户定向包异常,账户Id:{}", accountId, e);
+        }
+    }
+
+    @Override
+    public Result<Object> queryList(KuaishouDirectionalPackage directionalPackage, Integer pageNo, Integer pageSize) {
+        Long total = packageMapper.queryListTotal(directionalPackage);
+        PageHelper.startPage(pageNo, pageSize, false);
+        List<JSONObject> list = packageMapper.queryList(directionalPackage);
+        PageInfo pageInfo = new PageInfo(list);
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> getRelatedAccountGroup(String id, Integer type, Long accountId, Integer pageNo, Integer pageSize) {
+        PageInfo pageInfo = null;
+        if (1 == type) {
+            PageHelper.startPage(pageNo, pageSize);
+            pageInfo = new PageInfo(packageMapper.getRelatedAccount(id));
+        } else {
+            PageHelper.startPage(pageNo, pageSize);
+            pageInfo = new PageInfo(packageMapper.getRelatedGroup(id, accountId));
+        }
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> pushDirectionalPackage(String id, JSONArray datas) {
+        KuaishouDirectionalPackage directionalPackage = packageMapper.selectById(id);
+        JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(directionalPackage)).toJavaObject(JSONObject.class);
+        if (Check.isNull(data)) {
+            return Result.error("未找到定向包");
+        }
+        for (int i = 0; i < datas.size(); i++) {
+            JSONObject request = datas.getJSONObject(i);
+            createDirectionalPackage(data, request);
+        }
+        return Result.ok("推送完成");
+    }
+
+    private void createDirectionalPackage(JSONObject data, JSONObject request) {
+        Long accountId = request.getLong("accountId");
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        String message = "";
+        KuaishouDirectionalaPckageRel rel = new KuaishouDirectionalaPckageRel();
+        rel.setDirId(data.getString("id"));
+        rel.setRelId(accountId);
+        rel.setRelType("account");
+        rel.setProjectId(data.getLong("projectId"));
+        rel.setTemplateName(data.getString("templateName"));
+        rel.setDataStatus(0);
+        try {
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", accountId);
+            param.put("template_name", data.getString("templateName"));
+            JSONObject targetJson = new JSONObject();
+            if (data.getJSONArray("region") != null) {
+                targetJson.put("region", data.getJSONArray("region"));
+            }
+            if (!Check.isNull(data.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", data.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(data.getInteger("userType"))) {
+                targetJson.put("user_type", data.getInteger("userType"));
+            }
+            if (!Check.isNull(data.getJSONArray("agesRange"))) {
+                targetJson.put("ages_range", data.getJSONArray("agesRange"));
+            }
+
+            Integer min = data.getInteger("min");
+            Integer max = data.getInteger("max");
+            if (!Check.isNull(min) && !Check.isNull(max) && max != -1 && min != -1) {
+                JSONObject ageJson = new JSONObject();
+                ageJson.put("min", data.getInteger("min"));
+                ageJson.put("max", data.getInteger("max"));
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(data.getInteger("gender"))) {
+                targetJson.put("gender", data.getInteger("gender"));
+            }
+            if (!Check.isNull(data.getInteger("platformOs"))) {
+                targetJson.put("platform_os", data.getInteger("platformOs"));
+            }
+            if (!Check.isNull(data.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", data.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(data.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", data.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(data.getInteger("network"))) {
+                targetJson.put("network", data.getInteger("network"));
+            }
+            if (!Check.isNull(data.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", data.getInteger("filterConvertedLevel"));
+            }
+            if (data.getJSONArray("deviceBrand") != null) {
+                targetJson.put("device_brand", data.getJSONArray("deviceBrand"));
+            }
+            if (data.getJSONArray("devicePrice") != null) {
+                targetJson.put("device_price", data.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(data.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", data.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(data.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", data.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(data.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", data.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(data.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", data.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(data.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", data.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(data.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", data.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(request.getJSONArray("population"))) {
+                targetJson.put("population", request.getJSONArray("population"));
+                rel.setPopulation(request.getString("population"));
+            }
+            if (!Check.isNull(request.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", request.getJSONArray("paidAudience"));
+                rel.setPaidAudience(request.getString("paidAudience"));
+            }
+            if (!Check.isNull(request.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", request.getJSONArray("excludePopulation"));
+                rel.setExcludePopulation(request.getString("excludePopulation"));
+            }
+            if (!Check.isNull(data.getInteger("isOpen"))) {
+                JSONObject intelliExtendJson = new JSONObject();
+                intelliExtendJson.put("is_open", data.getInteger("isOpen"));
+
+                if (!Check.isNull(data.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", data.getInteger("noAgeBreak"));
+                }
+                if (!Check.isNull(data.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", data.getInteger("noGenderBreak"));
+                }
+                if (!Check.isNull(data.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", data.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
+            }
+            //-------------兴趣行为定向
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(data.getJSONArray("keyword"))) {
+                behavior.put("keyword", data.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(data.getJSONArray("label"))) {
+                behavior.put("label", data.getJSONArray("label"));
+            }
+            if (!Check.isNull(data.getInteger("strengthType"))) {
+                behavior.put("strength_type", data.getInteger("strengthType"));
+            }
+            if (!Check.isNull(data.getInteger("timeType"))) {
+                behavior.put("time_type", data.getInteger("timeType"));
+            }
+            if (!Check.isNull(data.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", data.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(data.getJSONArray("interestLabel"))) {
+                interest.put("label", data.getJSONArray("interestLabel"));
+            }
+            if (!behavior.isEmpty()) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!interest.isEmpty()) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!behaviorInterest.isEmpty()) {
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                message = resultJson.getString("message");
+                if (code == 0) {
+                    kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
+                    JSONObject results = resultJson.getJSONObject("data");
+                    rel.setTemplateId(results.getLong("template_id"));
+                    rel.setDataStatus(1);
+                } else {
+                    message = "推送定向包失败," + message;
+                    log.error(message);
+                }
+            } else {
+                message = "推送定向包失败,返回结果为空";
+            }
+        } catch (Exception e) {
+            message = "推送定向包出现异常";
+            log.error(message, e);
+        }
+        rel.setMessage(message);
+        relMapper.replace(rel);
+    }
+
+    @Override
+    public Result<Object> queryPushResults(String id, JSONArray accountIds, String status) {
+        List<JSONObject> list = relMapper.queryPushResults(id, accountIds, status);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+
+    @Override
+    public Result<Object> editPopulation(JSONObject requestJson) {
+        Long accountId = requestJson.getLong("accountId");
+        String message = "";
+        KuaishouDirectionalaPckageRel rel = new KuaishouDirectionalaPckageRel();
+        try {
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            QueryWrapper<KuaishouDirectionalaPckageRel> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("dir_id", requestJson.getString("id"));
+            queryWrapper.eq("rel_id", accountId);
+            queryWrapper.eq("rel_type", "account");
+            queryWrapper.eq("template_id", requestJson.getLong("templateId"));
+            JSONObject param = new JSONObject();
+            param.put("template_id", requestJson.getLong("templateId"));
+            param.put("advertiser_id", accountId);
+            param.put("template_name", requestJson.getString("templateName"));
+            JSONObject targetJson = new JSONObject();
+            targetJson.put("population", requestJson.getJSONArray("population"));
+            rel.setPopulation(requestJson.getString("population"));
+            targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            rel.setPaidAudience(requestJson.getString("paidAudience"));
+            targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            rel.setExcludePopulation(requestJson.getString("excludePopulation"));
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                message = resultJson.getString("message");
+                if (code == 0) {
+                    kuaishouTemplateService.getTemplateByAccountId(requestJson.getLong("accountId"), oauthToken.getAccessToken(), 1);
+                    JSONObject data = resultJson.getJSONObject("data");
+                    relService.update(rel, queryWrapper);
+                    List<JSONObject> units = relMapper.queryUnitIdByAccountId(requestJson.getString("id"), requestJson.getLong("accountId"));
+                    for (JSONObject unit : units) {
+                        updateUnitsDirectionalPackage(requestJson, unit);
+                    }
+                    return Result.ok("修改成功");
+                } else {
+                    return Result.error("修改失败," + message);
+                }
+            } else {
+                return Result.error("修改失败,返回结果为空");
+            }
+        } catch (Exception e) {
+            log.error("修改定向模板人群包信息异常,账户:{}", accountId, e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("修改失败");
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, String id) {
+        List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public void createUnitAndTemplate(JSONObject request) throws Exception {
+        try {
+            JSONObject target = templateMapper.queryByTemplateId(request.getLong("templateId"));
+            if (Check.isNull(target)) {
+                throw new Exception("添加广告组和定向模板绑定关系失败");
+            }
+            KuaishouDirectionalaPckageRel relEntity = new KuaishouDirectionalaPckageRel();
+            relEntity.setDirId(target.getString("dir_id"));
+            relEntity.setProjectId(target.getLong("project_id"));
+            relEntity.setTemplateId(request.getLong("templateId"));
+            relEntity.setTemplateName(target.getString("template_name"));
+            relEntity.setDataStatus(1);
+            relEntity.setRelId(request.getLong("unitId"));
+            relEntity.setRelType("unit");
+            relEntity.setExcludePopulation(request.getString("excludePopulation"));
+            relEntity.setPopulation(request.getString("population"));
+            relEntity.setPaidAudience(request.getString("paidAudience"));
+            relMapper.replace(relEntity);
+        } catch (Exception e) {
+            log.error("添加广告组和定向模板绑定关系异常", e);
+        }
+    }
+
+    @Override
+    public Result<Object> queryPopulationById(Long templateId, Long accountId) {
+        KuaishouTemplateTarget target = templateTargetMapper.queryTemplateTarget(templateId, accountId);
+        if (Check.isNull(target)) {
+            return Result.error("为查询到人群包");
+        }
+        JSONObject data = new JSONObject();
+        String excludePopulation = target.getExcludePopulation();
+        if (!Check.isNull(excludePopulation)) {
+            data.put("excludePopulation", JSONArray.parseArray(excludePopulation));
+        }
+        String population = target.getPopulation();
+        if (!Check.isNull(population)) {
+            data.put("population", JSONArray.parseArray(population));
+        }
+        String paidAudience = target.getPaidAudience();
+        if (!Check.isNull(paidAudience)) {
+            data.put("paidAudience", JSONArray.parseArray(paidAudience));
+        }
+        return Result.ok(data);
+    }
+
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPckageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPckageRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 自动投放-定向包详情关系表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-25
+ */
+@Service
+public class KuaishouDirectionalTemplateRelServiceImpl extends ServiceImpl<KuaishouDirectionalPckageRelMapper, KuaishouDirectionalaPckageRel> implements IKuaishouDirectionalPckageRelService {
+
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageRelService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 落地页-广告组关联表
+ * @author jeecg-boot
+ * @date   2021-05-11
+ * @version V1.0
+ */
+@Service
+public class KuaishouLandpagePackageRelServiceImpl extends ServiceImpl<KuaishouLandpagePackageRelMapper, KuaishouLandpagePackageRel> implements IKuaishouLandpagePackageRelService {
+
+}

+ 172 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageServiceImpl.java

@@ -0,0 +1,172 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.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.KuaishouLandpagePackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 落地页账户项目关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-11
+ */
+@Service
+public class KuaishouLandpagePackageServiceImpl extends ServiceImpl<KuaishouLandpagePackageMapper, KuaishouLandpagePackage> implements IKuaishouLandpagePackageService {
+
+    @Autowired
+    private KuaishouLandpagePackageMapper landpagePackageMapper;
+    @Autowired
+    private KuaishouLandpagePackageRelMapper landpagePackageRelMapper;
+    @Autowired
+    private KuaishouLandpagePackageRelServiceImpl landpagePackageRelService;
+
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Override
+    public Result<Object> queryPageList(KuaishouLandpagePackage kuaishouLandpagePackage, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = landpagePackageMapper.queryPageList(kuaishouLandpagePackage.getAccountId(), kuaishouLandpagePackage.getProjectId());
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public Result<Object> synchronousData(Long projectId) {
+        try {
+            List<UserAllocation> userAllocations = userAllocationMapper.selectAccountListByProjectId(projectId);
+            for (UserAllocation userAllocation : userAllocations) {
+                Long accountId = userAllocation.getAccountId();
+                CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+                String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PAGE_LIST;
+                Map<String, String> headers = new HashMap<>();
+                headers.put("Content-Type", "application/json");
+                headers.put("Access-Token", oauthToken.getAccessToken());
+                Map<String, Object> param = new HashMap<>();
+                param.put("advertiser_id", accountId);
+                param.put("page_size", 500);
+                String result = HttpUtils.httpPostRequest(url, param, headers);
+                JSONObject resultJson = JSON.parseObject(result);
+                if (!Check.isNull(resultJson)) {
+                    if (resultJson.getInteger("code") == 0) {
+                        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+                        if (!Check.isNull(details)) {
+                            List<KuaishouLandpagePackage> landpagePackageList = new ArrayList<>();
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject jsonObject = details.getJSONObject(i);
+                                KuaishouLandpagePackage landpagePackage = getEntity(jsonObject);
+                                landpagePackage.setAccountId(accountId);
+                                landpagePackage.setProjectId(projectId);
+                                landpagePackageList.add(landpagePackage);
+                            }
+                            if (!Check.isNull(landpagePackageList)) {
+                                landpagePackageMapper.deleteByAccountId(accountId);
+                                landpagePackageMapper.replaceBatch(landpagePackageList);
+                            }
+
+                        }
+                    } else {
+                        log.error(resultJson.getString("message")+",accountId:"+accountId);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("同步项目下落地页和账户关联数据异常", e);
+            return Result.error("同步项目下落地页和账户关联数据异常");
+        }
+        return Result.ok("同步成功");
+    }
+
+    /**
+     * 处理对象参数
+     */
+    private KuaishouLandpagePackage getEntity(JSONObject jsonObject) {
+        KuaishouLandpagePackage landpagePackage = new KuaishouLandpagePackage();
+        landpagePackage.setLandpageName(jsonObject.getString("name"));
+        landpagePackage.setSiteId(jsonObject.getLong("id"));
+        landpagePackage.setUrl(jsonObject.getString("url"));
+        landpagePackage.setBizType(jsonObject.getInteger("biz_type"));
+        landpagePackage.setLandpageCreateTime(jsonObject.getSqlDate("create_time"));
+        landpagePackage.setLandpageUpdateTime(jsonObject.getSqlDate("update_time"));
+        JSONArray compsArr = jsonObject.getJSONArray("comps");
+        if (!Check.isNull(compsArr)) {
+            landpagePackage.setComps(JSONObject.toJSONString(compsArr));
+            for (int j = 0; j < compsArr.size(); j++) {
+                JSONObject compJson = compsArr.getJSONObject(j);
+                JSONObject props = compJson.getJSONObject("props");
+                if (!Check.isNull(props)) {
+                    landpagePackage.setAppId(props.getLong("appId"));
+                }
+            }
+        }
+        return landpagePackage;
+    }
+
+    @Override
+    public Result<Object> getRelatedAccounts(Long siteId) {
+        List<JSONObject> list = landpagePackageMapper.getRelatedAccounts(siteId);
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedGroups(Long siteId, Long accountId) {
+        List<JSONObject> list = landpagePackageMapper.getRelatedGroups(siteId,accountId);
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public void createLandPageAndUnit(Long siteId, Long creativeId, Long unitId, Long accountId) {
+        try {
+            JSONObject entity = landpagePackageRelMapper.queryByUnitId(siteId, unitId, accountId);
+            if (Check.isNull(entity)) {
+                KuaishouLandpagePackageRel rel = new KuaishouLandpagePackageRel();
+                rel.setUnitId(unitId);
+                rel.setAccountId(accountId);
+                rel.setSiteId(siteId);
+                JSONArray creativeArr = new JSONArray();
+                creativeArr.add(creativeId);
+                rel.setCreativeArr(JSONObject.toJSONString(creativeArr));
+                landpagePackageRelService.save(rel);
+            } else {
+                //不为空,落地页已经绑定过广告组,判断是否是新的创意
+                JSONArray creative_arr = entity.getJSONArray("creative_arr");
+                if (!creative_arr.contains(creativeId)) {
+                    //不包含创意,则添加并更新进数据表中
+                    KuaishouLandpagePackageRel rel = new KuaishouLandpagePackageRel();
+                    creative_arr.add(creativeId);
+                    rel.setCreativeArr(JSONObject.toJSONString(creative_arr));
+                    rel.setId(entity.getLong("id"));
+                    landpagePackageRelMapper.updateById(rel);
+                }
+            }
+        } catch (Exception e) {
+            log.error("绑定落地页与广告组异常", e);
+        }
+    }
+}

+ 74 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationGroupServiceImpl.java

@@ -0,0 +1,74 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationGroup;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationGroupMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 人群包-广告组关联表
+ *
+ * @author jeecg-boot
+ * 2021-05-08
+ * @version V1.0
+ */
+@Service
+public class KuaishouPopulationGroupServiceImpl extends ServiceImpl<KuaishouPopulationGroupMapper, KuaishouPopulationGroup> implements IKuaishouPopulationGroupService {
+
+    @Autowired
+    private KuaishouPopulationGroupMapper populationGroupMapper;
+
+    @Override
+    public void createPopulationAndGroupRel(JSONObject request) throws Exception {
+        try {
+            List<KuaishouPopulationGroup> list = new ArrayList<>();
+            Long accountId = request.getLong("accountId");
+            Long unitId = request.getLong("unitId");
+            KuaishouPopulationGroup populationGroup = null;
+            JSONArray population = request.getJSONArray("population");
+            if (!Check.isNull(population)) {
+                for (Object id : population) {
+                    populationGroup = new KuaishouPopulationGroup();
+                    populationGroup.setAccountId(accountId);
+                    populationGroup.setUnitId(unitId);
+                    populationGroup.setOrientationId(Long.valueOf(String.valueOf(id)));
+                    list.add(populationGroup);
+                }
+            }
+            JSONArray excludePopulation = request.getJSONArray("excludePopulation");
+            if (!Check.isNull(excludePopulation)) {
+                for (Object id : excludePopulation) {
+                    populationGroup = new KuaishouPopulationGroup();
+                    populationGroup.setAccountId(accountId);
+                    populationGroup.setUnitId(unitId);
+                    populationGroup.setOrientationId(Long.valueOf(String.valueOf(id)));
+                    list.add(populationGroup);
+                }
+            }
+            JSONArray paidAudience = request.getJSONArray("paidAudience");
+            if (!Check.isNull(paidAudience)) {
+                for (Object id : paidAudience) {
+                    populationGroup = new KuaishouPopulationGroup();
+                    populationGroup.setAccountId(accountId);
+                    populationGroup.setUnitId(unitId);
+                    populationGroup.setOrientationId(Long.valueOf(String.valueOf(id)));
+                    list.add(populationGroup);
+                }
+            }
+            if (list.size() > 0) {
+                populationGroupMapper.deleteByUnitId(request.getLong("unitId"));
+                populationGroupMapper.replaceBatch(list);
+            }
+        } catch (NumberFormatException e) {
+            log.error("添加广告组和人群包绑定关系异常", e);
+        }
+    }
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群包模板和账户绑定关系表
+ *
+ * @author jeecg-boot
+ * 2021-05-07
+ * @version V1.0
+ */
+@Service
+public class KuaishouPopulationPackageRelServiceImpl extends ServiceImpl<KuaishouPopulationPackageRelMapper, KuaishouPopulationPackageRel> implements IKuaishouPopulationPackageRelService {
+
+}

+ 356 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageServiceImpl.java

@@ -0,0 +1,356 @@
+package cn.com.ctop.kuaishou.modules.ai.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.LoadFileUtil;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+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.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * 2021-05-06
+ * @version V1.0
+ */
+@Service
+public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPopulationPackageMapper, KuaishouPopulationPackage> implements IKuaishouPopulationPackageService {
+
+    @Autowired
+    private KuaishouPopulationPackageMapper kuaishouPopulationPackageMapper;
+    @Autowired
+    private KuaishouPopulationPackageRelMapper relMapper;
+    @Autowired
+    private IKuaishouPopulationPackageRelService relService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouPopulationService kuaishouPopulationService;
+    @Autowired
+    private IKuaishouPopulationService iKuaishouPopulationService;
+    @Autowired
+    private IKuaishouPopulationGroupService populationGroupService;
+    @Value("${zip.local.download-path}")
+    private String downloadPath;
+
+    @Override
+    public Result<Object> createEntity(KuaishouPopulationPackage kuaishouPopulationPackage) {
+        QueryWrapper<KuaishouPopulationPackage> wrapper = new QueryWrapper<>();
+        wrapper.eq("project_id", kuaishouPopulationPackage.getProjectId());
+        wrapper.eq("orientation_name", kuaishouPopulationPackage.getOrientationName());
+        wrapper.eq("data_status", 1);
+        wrapper.last("limit 1");
+        KuaishouPopulationPackage checkName = kuaishouPopulationPackageMapper.selectOne(wrapper);
+        if (!Check.isNull(checkName)) {
+            return Result.error("该项目下已存在人群包名,请重新输入!");
+        }
+
+        String url = kuaishouPopulationPackage.getUrl();
+        String newFileUrl = getDownloadPath(url);
+        if (Check.isNull(newFileUrl)) {
+            return Result.error("本地下载文件失败,路径:" + url);
+        }
+        String md5 = null;
+        try {
+            md5 = LoadFileUtil.getMD5(newFileUrl);
+        } catch (IOException e) {
+            log.error("获取MD5签名失败", e);
+        }
+
+        QueryWrapper<KuaishouPopulationPackage> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", kuaishouPopulationPackage.getProjectId());
+        queryWrapper.eq("signature", md5);
+        queryWrapper.eq("data_status", 1);
+        queryWrapper.last("limit 1");
+        KuaishouPopulationPackage one = kuaishouPopulationPackageMapper.selectOne(queryWrapper);
+        if (!Check.isNull(one)) {
+            return Result.error("该项目已上传过此人群包,人群包名为:" + one.getOrientationName());
+        }
+        kuaishouPopulationPackage.setSignature(md5);
+        kuaishouPopulationPackage.setDataStatus(1);
+        kuaishouPopulationPackage.setStatDate(DateUtils.formatDate(new Date()));
+        this.save(kuaishouPopulationPackage);
+        LoadFileUtil.delFile(newFileUrl);
+        return Result.ok("上传成功");
+    }
+
+    /**
+     * 文件下载到本地的路径
+     */
+    private String getDownloadPath(String url) {
+        StringBuffer path = new StringBuffer();
+        path.append(downloadPath).append(DateUtils.getNowDate(DateUtils.WEB_FORMAT)).append("/").append(UUID.randomUUID().toString()).append("/");
+        if (!url.contains("http")) {
+            url = "https:".concat(url);
+        }
+        return LoadFileUtil.downLoadFromUrl(url, path.toString());
+    }
+
+    @Override
+    public Result<Object> push(JSONArray accountIds, Long id) {
+        KuaishouPopulationPackage pPackage = kuaishouPopulationPackageMapper.selectById(id);
+        if (Check.isNull(pPackage)) {
+            return Result.error("没有获取到人群包");
+        }
+        String newFileUrl = getDownloadPath(pPackage.getUrl());
+        if (Check.isNull(newFileUrl)) {
+            return Result.error("本地下载文件失败,路径:" + pPackage.getUrl());
+        }
+        for (Object account : accountIds) {
+            Long accountId = Long.valueOf(String.valueOf(account));
+            KuaishouPopulationPackageRel relEntity = relMapper.queryEntity(accountId, pPackage.getId());
+            //查询该定向模板下是否存在有效的账户数据,不存在执行推送或者上传。
+            if (Check.isNull(relEntity)) {
+                //查询账户同一主题下可推送的该人群包ID
+                KuaishouPopulationPackageRel populationPackageRel = relMapper.queryPushableCrowdPackage(accountId, pPackage.getId());
+                if (Check.isNull(populationPackageRel)) {
+                    //执行上传操作
+                    uploadAccount(pPackage, accountId, newFileUrl);
+                } else {
+                    //执行跨账户推送操作
+                    pushAccount(populationPackageRel, pPackage, accountId);
+                }
+            }
+        }
+        LoadFileUtil.delFile(newFileUrl);
+        return Result.ok("推送结束");
+    }
+
+
+    /**
+     * 执行推送操作
+     */
+    private void pushAccount(KuaishouPopulationPackageRel populationPackageRel, KuaishouPopulationPackage pPackage, Long accountId) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        JSONArray array = new JSONArray();
+        array.add(accountId);
+        JSONObject jsonObject = kuaishouPopulationService.pushAccountsPopulation(token, populationPackageRel.getOrientationId(), array);
+        if (jsonObject.getInteger("code") == 0) {
+            List<KuaishouCrowdPack> list = new ArrayList<>();
+            JSONObject data = jsonObject.getJSONObject("data");
+            if (!Check.isNull(data)) {
+                JSONArray success = data.getJSONArray("success");
+                if (!Check.isNull(success)) {
+                    populationPackageRel.setProjectId(pPackage.getProjectId());
+                    populationPackageRel.setPopId(pPackage.getId());
+                    populationPackageRel.setAccountId(Long.valueOf(String.valueOf(accountId)));
+                    populationPackageRel.setMessage("OK");
+                    populationPackageRel.setStatDate(DateUtils.formatDate(new Date()));
+                }
+                JSONArray fail = data.getJSONArray("fail");
+                if (!Check.isNull(fail)) {
+                    KuaishouPopulationPackageRel fRel = relMapper.queryByAccountId(accountId, populationPackageRel.getOrientationId());
+                    if (Check.isNull(fRel)) {
+                        populationPackageRel = new KuaishouPopulationPackageRel();
+                        populationPackageRel.setProjectId(pPackage.getProjectId());
+                        populationPackageRel.setPopId(pPackage.getId());
+                        populationPackageRel.setSignature(pPackage.getSignature());
+                        populationPackageRel.setDataStatus(0);
+                        populationPackageRel.setOrientationName(pPackage.getOrientationName());
+                        populationPackageRel.setAccountId(accountId);
+                        populationPackageRel.setMessage("推送失败");
+                        populationPackageRel.setStatDate(DateUtils.formatDate(new Date()));
+                    }
+                }
+            }
+        } else {
+            populationPackageRel = new KuaishouPopulationPackageRel();
+            populationPackageRel.setProjectId(pPackage.getProjectId());
+            populationPackageRel.setPopId(pPackage.getId());
+            populationPackageRel.setDataStatus(0);
+            populationPackageRel.setSignature(pPackage.getSignature());
+            populationPackageRel.setAccountId(accountId);
+            populationPackageRel.setOrientationName(pPackage.getOrientationName());
+            populationPackageRel.setMessage(jsonObject.getString("message"));
+            populationPackageRel.setStatDate(DateUtils.formatDate(new Date()));
+        }
+        List<KuaishouPopulationPackageRel> packageRels = new ArrayList(1);
+        packageRels.add(populationPackageRel);
+        relMapper.replaceBatch(packageRels);
+    }
+
+    //**执行上传操作*/
+    private void uploadAccount(KuaishouPopulationPackage pPackage, Long accountId, String newFileUrl) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        KuaishouPopulationPackageRel packageRel = null;
+        JSONObject jsonObject = kuaishouPopulationService.updatePopulation(token, pPackage.getType(), pPackage.getOrientationName(), newFileUrl);
+        if (!Check.isNull(jsonObject)) {
+            if (jsonObject.getInteger("code") == 0) {
+                packageRel = JSONObject.toJavaObject(jsonObject.getJSONObject("data"), KuaishouPopulationPackageRel.class);
+                packageRel.setSignature(pPackage.getSignature());
+                packageRel.setMessage(jsonObject.getString("message"));
+                packageRel.setStatDate(DateUtils.formatDate(new Date()));
+                packageRel.setProjectId(pPackage.getProjectId());
+                packageRel.setPopId(pPackage.getId());
+                packageRel.setDataStatus(1);//成功
+            } else {
+                packageRel = new KuaishouPopulationPackageRel();
+                packageRel.setAccountId(accountId);
+                packageRel.setOrientationName(pPackage.getOrientationName());
+                packageRel.setSignature(pPackage.getSignature());
+                packageRel.setMessage(jsonObject.getString("message"));
+                packageRel.setStatDate(DateUtils.formatDate(new Date()));
+                packageRel.setProjectId(pPackage.getProjectId());
+                packageRel.setPopId(pPackage.getId());
+                packageRel.setDataStatus(0);
+            }
+        } else {
+            packageRel = new KuaishouPopulationPackageRel();
+            packageRel.setAccountId(accountId);
+            packageRel.setOrientationName(pPackage.getOrientationName());
+            packageRel.setSignature(pPackage.getSignature());
+            packageRel.setMessage("上传失败,返回结果为空");
+            packageRel.setStatDate(DateUtils.formatDate(new Date()));
+            packageRel.setProjectId(pPackage.getProjectId());
+            packageRel.setPopId(pPackage.getId());
+            packageRel.setDataStatus(0);
+        }
+        List<KuaishouPopulationPackageRel> packageRels = new ArrayList(1);
+        packageRels.add(packageRel);
+        relMapper.replaceBatch(packageRels);
+    }
+
+    @Override
+    public Result<Object> queryPageList(KuaishouPopulationPackage kuaishouPopulationPackage, Integer pageNo, Integer pageSize) {
+        Long total = kuaishouPopulationPackageMapper.queryPageListTotal(kuaishouPopulationPackage.getProjectId(), kuaishouPopulationPackage.getOrientationName());
+        PageHelper.startPage(pageNo, pageSize, false);
+        List<JSONObject> list = kuaishouPopulationPackageMapper.queryPageList(kuaishouPopulationPackage.getProjectId(), kuaishouPopulationPackage.getOrientationName());
+        if (!Check.isNull(list)) {
+            for (JSONObject object : list) {
+                object.put("unitCount", kuaishouPopulationPackageMapper.queryUnitCount(object.getLong("id")));
+            }
+        }
+        PageInfo pageInfo = new PageInfo(list);
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> queryPushResults(Long id, JSONArray accountIds) {
+        List<JSONObject> list = relMapper.queryPushResults(id, accountIds);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> queryPushHistory(Long id) {
+        List<JSONObject> list = relMapper.queryPushResults(id, null);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedAccounts(Long id) {
+        List<JSONObject> list = relMapper.getRelatedAccounts(id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedGroups(Long id, Long accountId) {
+        List<JSONObject> list = kuaishouPopulationPackageMapper.getRelatedGroups(id, accountId);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public void crowdListQuery() {
+        List<JSONObject> objs = kuaishouPopulationPackageMapper.queryListByStatus();
+        for (JSONObject o : objs) {
+            Long accountId = o.getLong("account_id");
+            Long projectId = o.getLong("project_id");
+            Hashtable newIds = new Hashtable();
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (!Check.isNull(token)) {
+                for (int i = 0; i <= 7; i++) {
+                    if (i != 2) {
+                        JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), i);
+                        if (jsonObject.getInteger("code") == 0) {
+                            JSONObject data = jsonObject.getJSONObject("data");
+                            if (!Check.isNull(data)) {
+                                JSONArray details = data.getJSONArray("details");
+                                if (details.size() > 0) {
+                                    List<KuaishouPopulationPackageRel> list = new ArrayList<>();
+                                    for (int j = 0; j < details.size(); j++) {
+                                        JSONObject obj = details.getJSONObject(j);
+                                        KuaishouPopulationPackageRel rel = JSONObject.parseObject(obj.toJSONString(), KuaishouPopulationPackageRel.class);
+                                        newIds.put(rel.getOrientationId(), rel.getOrientationId());
+                                        if (Check.isNull(relMapper.queryByOrientationId(rel.getOrientationId(), rel.getAccountId()))) {
+                                            rel.setProjectId(projectId);
+                                            rel.setDataStatus(1);
+                                            rel.setStatDate(DateUtils.formatDate(new Date()));
+                                            list.add(rel);
+                                        } else {
+                                            rel.setDataStatus(1);
+                                            relMapper.updateStatus(rel);
+                                        }
+                                    }
+                                    if (!Check.isNull(list)) {
+                                        relMapper.replaceBatch(list);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                //查询现有的人群包ID集
+                List<Long> oldOrientationIds = relMapper.queryByOrientationId(null, accountId);
+                if (oldOrientationIds.size() != newIds.size()) {
+                    for (Long id : oldOrientationIds) {
+                        if (!newIds.contains(id)) {
+                            KuaishouPopulationPackageRel rel = new KuaishouPopulationPackageRel();
+                            rel.setDataStatus(0);
+                            rel.setOrientationId(id);
+                            rel.setAccountId(accountId);
+                            rel.setMessage("人群包已从媒体后台删除");
+                            relMapper.updateStatus(rel);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, String id) {
+        List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> checkPopulationPackage(String signature) {
+        KuaishouPopulationPackage ksPackage = kuaishouPopulationPackageMapper.checkPopulationPackage(signature);
+        if (Check.isNull(ksPackage)) {
+            return Result.ok("success");
+        } else {
+            Result<Object> r = new Result<>();
+            r.setCode(201);
+            r.setMessage("项目已保存过该人群包,名称为:" + ksPackage.getOrientationName());
+            r.setSuccess(true);
+            return r;
+        }
+    }
+
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/DingPanController.java

@@ -157,7 +157,7 @@ public class DingPanController {
                 if (Check.isNullMap(unionJson)) {
                     throw new Exception("根据定向模板未获取到相关信息");
                 }
-                unitJson.put("target", unionJson);
+                unitJson.put("target", unionJson.getJSONObject("target"));
             }
             JSONObject jsonObject = updateService.updateUnit(token.getAccessToken(), unitJson);
             Integer code = jsonObject.getInteger("code");

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

@@ -21,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;
@@ -57,9 +65,9 @@ public class KuaishouTemplateController {
     @AutoLog(value = "快手-定向模板-分页列表查询")
     @ApiOperation(value = "快手-定向模板-分页列表查询", notes = "快手-定向模板-分页列表查询")
     @GetMapping(value = "/list")
-    public Result<List<JSONObject>> list(Long accountId, Integer platformOs) {
+    public Result<List<JSONObject>> list(Long accountId, Integer platformOs, Boolean autoTarget) {
         Result<List<JSONObject>> result = new Result<>();
-        List<JSONObject> list = kuaishouTemplateService.getJsonArrByAccountId(accountId, platformOs);
+        List<JSONObject> list = kuaishouTemplateService.getJsonArrByAccountId(accountId, platformOs, autoTarget);
         result.setSuccess(true);
         result.setResult(list);
         return result;
@@ -67,6 +75,39 @@ public class KuaishouTemplateController {
 
 
     /**
+     * 获取行为与兴趣"类目词"
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getbehaviorInterest")
+    public Result<Object> getbehaviorInterest(Long accountId) {
+        Result<List<JSONObject>> result = new Result<>();
+        if (Check.isNull(accountId)) {
+            //各账户类目词一致
+            accountId = 23212L;
+        }
+        return kuaishouTemplateService.getBehaviorInterest(accountId);
+    }
+
+    /**
+     * 获取行为兴趣"关键词"
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/getKeywordQuery")
+    public Result<Object> getKeywordQuery(@RequestBody JSONObject data) {
+        Result<List<JSONObject>> result = new Result<>();
+        return kuaishouTemplateService.getKeywordQuery(data);
+    }
+
+
+    /**
      * 分页列表查询
      *
      * @param kuaishouTemplate

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

@@ -188,6 +188,42 @@ public class KuaiShouGroupTarget {
     @ApiModelProperty(value = "不可突破地域 0:可突破/无需控制,1:不可突破")
     private Integer noAreaBreak;
     /**
+     * 行为定向关键词
+     */
+    @Excel(name = "行为定向关键词", width = 15)
+    @ApiModelProperty(value = "行为定向关键词")
+    private String keyword;
+    /**
+     * 行为定向 类目词
+     */
+    @Excel(name = "行为定向 类目词", width = 15)
+    @ApiModelProperty(value = "行为定向 类目词")
+    private String label;
+    /**
+     * 兴趣定向类目词
+     */
+    @Excel(name = "兴趣定向类目词", width = 15)
+    @ApiModelProperty(value = "兴趣定向类目词")
+    private String interestLabel;
+    /**
+     * 在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天
+     */
+    @Excel(name = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天", width = 15)
+    @ApiModelProperty(value = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天")
+    private Integer timeType;
+    /**
+     * 行为强度	0:不限 1:高强度
+     */
+    @Excel(name = "行为强度	0:不限 1:高强度", width = 15)
+    @ApiModelProperty(value = "行为强度	0:不限 1:高强度")
+    private Integer strengthType;
+    /**
+     * 行为场景	1:社区 2:APP 4:推广
+     */
+    @Excel(name = "行为场景	1:社区 2:APP 4:推广", width = 15)
+    @ApiModelProperty(value = "行为场景	1:社区 2:APP 4:推广")
+    private String sceneType;
+    /**
      * 创建时间
      */
     @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")

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

@@ -53,6 +53,7 @@ public class KuaishouTemplate {
     @Excel(name = "绑定组个数", width = 15)
     @ApiModelProperty(value = "绑定组个数")
     private Integer unitCount;
+    private Boolean autoTarget;
     /**
      * 定向模板创建时间
      */

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

@@ -198,6 +198,42 @@ public class KuaishouTemplateTarget {
     @ApiModelProperty(value = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)")
     private Integer noAreaBreak;
     /**
+     * 行为定向关键词
+     */
+    @Excel(name = "行为定向关键词", width = 15)
+    @ApiModelProperty(value = "行为定向关键词")
+    private String keyword;
+    /**
+     * 行为定向 类目词
+     */
+    @Excel(name = "行为定向 类目词", width = 15)
+    @ApiModelProperty(value = "行为定向 类目词")
+    private String label;
+    /**
+     * 兴趣定向类目词
+     */
+    @Excel(name = "兴趣定向类目词", width = 15)
+    @ApiModelProperty(value = "兴趣定向类目词")
+    private String interestLabel;
+    /**
+     * 在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天
+     */
+    @Excel(name = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天", width = 15)
+    @ApiModelProperty(value = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天")
+    private Integer timeType;
+    /**
+     * 行为强度	0:不限 1:高强度
+     */
+    @Excel(name = "行为强度	0:不限 1:高强度", width = 15)
+    @ApiModelProperty(value = "行为强度	0:不限 1:高强度")
+    private Integer strengthType;
+    /**
+     * 行为场景	1:社区 2:APP 4:推广
+     */
+    @Excel(name = "行为场景	1:社区 2:APP 4:推广", width = 15)
+    @ApiModelProperty(value = "行为场景	1:社区 2:APP 4:推广")
+    private String sceneType;
+    /**
      * 定向模板创建时间
      */
     @Excel(name = "定向模板创建时间", width = 15)

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

@@ -16,4 +16,6 @@ import java.util.List;
 public interface KuaishouPopulationMapper extends BaseMapper<KuaishouPopulation> {
 
     void replaceBatch(@Param("addList") List<KuaishouPopulation> addList);
+
+    void deleteByAccountId(@Param("accountId") Long accountId);
 }

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

@@ -15,5 +15,9 @@ import java.util.List;
  * @cersion: V1.0
  */
 public interface KuaishouTemplateMapper extends BaseMapper<KuaishouTemplate> {
-    List<JSONObject> getJsonArrByAccountId(@Param("accountId") Long accountId,@Param("platformOs") Integer platformOs);
+    List<JSONObject> getJsonArrByAccountId(@Param("accountId") Long accountId, @Param("platformOs") Integer platformOs, @Param("autoTarget") Boolean autoTarget);
+
+    void replaceBatch(@Param("templateList") List<KuaishouTemplate> templateList);
+
+    JSONObject queryByTemplateId(@Param("templateId") Long templateId);
 }

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

@@ -2,6 +2,9 @@ package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 快手-定向模板-详情
@@ -12,4 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaishouTemplateTargetMapper extends BaseMapper<KuaishouTemplateTarget> {
 
+    void templateTargetList(@Param("templateTargetList") List<KuaishouTemplateTarget> templateTargetList);
+
+    KuaishouTemplateTarget queryTemplateTarget(@Param("templateId") Long templateId, @Param("accountId")Long accountId);
 }

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

@@ -31,7 +31,13 @@
         is_open,
         no_age_break,
         no_gender_break,
-        no_area_break
+        no_area_break,
+        keyword,
+        label,
+        interest_label,
+        time_type,
+        strength_type,
+        scene_type
         )
         values
         <foreach collection="targets" item="targets" separator=",">
@@ -62,7 +68,13 @@
             #{targets.isOpen},
             #{targets.noAgeBreak},
             #{targets.noGenderBreak},
-            #{targets.noAreaBreak}
+            #{targets.noAreaBreak},
+            #{targets.keyword},
+            #{targets.label},
+            #{targets.interestLabel},
+            #{targets.timeType},
+            #{targets.strengthType},
+            #{targets.sceneType}
             )
         </foreach>
     </insert>
@@ -77,10 +89,9 @@
 
 
     <select id="queryTargetInfoByunitId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget">
-        SELECT
-        *
+        SELECT *
         FROM ctop_kuaishou_group_target
         WHERE account_id = #{accountId}
-         AND unit_id = #{unitId}
+          AND unit_id = #{unitId}
     </select>
 </mapper>

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

@@ -32,4 +32,10 @@
             )
         </foreach>
     </insert>
+
+    <delete id="deleteByAccountId">
+        delete
+        from ctop_kuaishou_population
+        where account_id = #{accountId}
+    </delete>
 </mapper>

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

@@ -1,22 +1,62 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper">
+    <insert id="replaceBatch">
+
+        replace into ctop_kuaishou_template(
+        id,
+        account_id,
+        template_id,
+        template_name,
+        unit_count,
+        auto_target,
+        create_time,
+        update_time)
+        values
+        <foreach collection="templateList" item="template" separator=",">
+            (
+            #{template.id},
+            #{template.accountId},
+            #{template.templateId},
+            #{template.templateName},
+            #{template.unitCount},
+            #{template.autoTarget},
+            #{template.createTime},
+            #{template.updateTime}
+            )
+        </foreach>
+
+    </insert>
 
     <select id="getJsonArrByAccountId" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            t1.account_id AS 'accountId',
-            t1.template_id AS 'templateId',
-            t1.template_name AS 'templateName',
-            t1.unit_count AS 'unitCount',
-            t2.platform_os AS 'platformOs'
+        t1.account_id AS 'accountId',
+        t1.template_id AS 'templateId',
+        t1.template_name AS 'templateName',
+        t1.unit_count AS 'unitCount',
+        t2.platform_os AS 'platformOs'
         FROM
-            ctop_kuaishou_template t1
-                LEFT JOIN ctop_kuaishou_template_target t2 ON t1.template_id = t2.template_id
+        ctop_kuaishou_template t1
+        LEFT JOIN ctop_kuaishou_template_target t2 ON t1.template_id = t2.template_id
         WHERE
-            t1.account_id = #{accountId}
-        <if test="platformOs != null">
+        t1.account_id = #{accountId}
+        <if test="platformOs != null and platformOs!= '' ">
             AND t2.platform_os = #{platformOs}
         </if>
+        <if test="autoTarget != null and autoTarget != '' ">
+            AND t1.auto_target = #{autoTarget}
+        </if>
     </select>
 
+
+    <select id="queryByTemplateId" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.account_id,t1.template_id,t1.template_name,t3.dir_id,t3.project_id
+        from ctop_kuaishou_template t1
+                 INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                 left JOIN ctop_kuaishou_directional_package_rel t3 ON t1.template_id = t3.template_id AND t2.project_id = t3.project_id
+        where t1.template_id = #{templateId}
+        limit 1
+    </select>
+
+
 </mapper>

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

@@ -2,4 +2,99 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateTargetMapper">
 
+    <insert id="templateTargetList">
+        replace into ctop_kuaishou_template_target(
+        id,
+        template_id,
+        region,
+        district_ids,
+        user_type,
+        ages_range,
+        min,
+        max,
+        gender,
+        platform_os,
+        android_osv,
+        ios_osv,
+        network,
+        filter_converted_level,
+        device_brand,
+        device_price,
+        business_interest_type,
+        business_interest,
+        fans_star,
+        interest_video,
+        app_interest,
+        app_ids,
+        population,
+        paid_audience,
+        exclude_population,
+        is_open,
+        no_age_break,
+        no_gender_break,
+        no_area_break,
+        keyword,
+        label,
+        interest_label,
+        time_type,
+        strength_type,
+        scene_type,
+        create_time,
+        update_time)
+        values
+        <foreach collection="templateTargetList" item="templateTarget" separator=",">
+            (
+            #{templateTarget.id},
+            #{templateTarget.templateId},
+            #{templateTarget.region},
+            #{templateTarget.districtIds},
+            #{templateTarget.userType},
+            #{templateTarget.agesRange},
+            #{templateTarget.min},
+            #{templateTarget.max},
+            #{templateTarget.gender},
+            #{templateTarget.platformOs},
+            #{templateTarget.androidOsv},
+            #{templateTarget.iosOsv},
+            #{templateTarget.network},
+            #{templateTarget.filterConvertedLevel},
+            #{templateTarget.deviceBrand},
+            #{templateTarget.devicePrice},
+            #{templateTarget.businessInterestType},
+            #{templateTarget.businessInterest},
+            #{templateTarget.fansStar},
+            #{templateTarget.interestVideo},
+            #{templateTarget.appInterest},
+            #{templateTarget.appIds},
+            #{templateTarget.population},
+            #{templateTarget.paidAudience},
+            #{templateTarget.excludePopulation},
+            #{templateTarget.isOpen},
+            #{templateTarget.noAgeBreak},
+            #{templateTarget.noGenderBreak},
+            #{templateTarget.noAreaBreak},
+            #{templateTarget.keyword},
+            #{templateTarget.label},
+            #{templateTarget.interestLabel},
+            #{templateTarget.timeType},
+            #{templateTarget.strengthType},
+            #{templateTarget.sceneType},
+            #{templateTarget.createTime},
+            #{templateTarget.updateTime}
+            )
+        </foreach>
+    </insert>
+
+    <select id="queryTemplateTarget" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget">
+        SELECT t1.template_id,
+               population,
+               paid_audience,
+               exclude_population
+        FROM ctop_kuaishou_template_target t1
+                 LEFT JOIN ctop_kuaishou_template t2 ON t1.template_id = t2.template_id
+        WHERE t1.template_id = #{templateId}
+          AND t2.account_id = #{accountId}
+    </select>
+
+
 </mapper>

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

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
 
@@ -20,5 +21,11 @@ public interface IKuaishouTemplateService extends IService<KuaishouTemplate> {
 
     JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson);
 
-    List<JSONObject> getJsonArrByAccountId(Long accountId,Integer platformOs);
+    List<JSONObject> getJsonArrByAccountId(Long accountId, Integer platformOs, Boolean autoTarget);
+
+    Result<Object> getBehaviorInterest(Long accountId);
+
+    Result<Object> getKeywordQuery(JSONObject data);
+
+    Result<Object> templateDelete(Long accountId, Long templateId);
 }

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

@@ -6,9 +6,21 @@ import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.mapper.BatchMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTargetMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
+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.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -359,6 +371,37 @@ public class BatchServiceImpl implements IBatchService {
             if (!Check.isNull(intelliExtendJson)) {
                 targetJson.put("intelli_extend", intelliExtendJson);
             }
+            //-------------兴趣行为定向
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                behavior.put("keyword", requestJson.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("label"))) {
+                behavior.put("label", requestJson.getJSONArray("label"));
+            }
+            if (!Check.isNull(requestJson.getInteger("strengthType"))) {
+                behavior.put("strength_type", requestJson.getInteger("strengthType"));
+            }
+            if (!Check.isNull(requestJson.getInteger("timeType"))) {
+                behavior.put("time_type", requestJson.getInteger("timeType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", requestJson.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestLabel"))) {
+                interest.put("label", requestJson.getJSONArray("interestLabel"));
+            }
+            if (!behavior.isEmpty()) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!interest.isEmpty()) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!behaviorInterest.isEmpty()) {
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
         }
 
         unitJson.put("target", targetJson);
@@ -665,6 +708,37 @@ public class BatchServiceImpl implements IBatchService {
                 if (!Check.isNull(intelliExtendJson)) {
                     targetJson.put("intelli_extend", intelliExtendJson);
                 }
+                //-------------兴趣行为定向
+                JSONObject behaviorInterest = new JSONObject();
+                JSONObject behavior = new JSONObject();
+                JSONObject interest = new JSONObject();
+                if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                    behavior.put("keyword", requestJson.getJSONArray("keyword"));
+                }
+                if (!Check.isNull(requestJson.getJSONArray("label"))) {
+                    behavior.put("label", requestJson.getJSONArray("label"));
+                }
+                if (!Check.isNull(requestJson.getInteger("strengthType"))) {
+                    behavior.put("strength_type", requestJson.getInteger("strengthType"));
+                }
+                if (!Check.isNull(requestJson.getInteger("timeType"))) {
+                    behavior.put("time_type", requestJson.getInteger("timeType"));
+                }
+                if (!Check.isNull(requestJson.getJSONArray("sceneType"))) {
+                    behavior.put("scene_type", requestJson.getJSONArray("sceneType"));
+                }
+                if (!Check.isNull(requestJson.getJSONArray("interestLabel"))) {
+                    interest.put("label", requestJson.getJSONArray("interestLabel"));
+                }
+                if (!behavior.isEmpty()) {
+                    behaviorInterest.put("behavior", behavior);
+                }
+                if (!interest.isEmpty()) {
+                    behaviorInterest.put("interest", interest);
+                }
+                if (!behaviorInterest.isEmpty()) {
+                    targetJson.put("behavior_interest", behaviorInterest);
+                }
             }
             unitJson.put("target", targetJson);
             JSONObject groupJson = requestJson.getJSONObject("groupArr");
@@ -960,8 +1034,38 @@ public class BatchServiceImpl implements IBatchService {
                         if (!Check.isNull(intelliExtendJson)) {
                             targetJson.put("intelli_extend", intelliExtendJson);
                         }
+                        //-------------兴趣行为定向
+                        JSONObject behaviorInterest = new JSONObject();
+                        JSONObject behavior = new JSONObject();
+                        JSONObject interest = new JSONObject();
+                        if (!Check.isNull(groupTarget.getKeyword())) {
+                            behavior.put("keyword", JSONArray.parseArray(groupTarget.getKeyword()));
+                        }
+                        if (!Check.isNull(groupTarget.getLabel())) {
+                            behavior.put("label", JSONArray.parseArray(groupTarget.getLabel()));
+                        }
+                        if (!Check.isNull(groupTarget.getStrengthType())) {
+                            behavior.put("strength_type", groupTarget.getStrengthType());
+                        }
+                        if (!Check.isNull(groupTarget.getTimeType())) {
+                            behavior.put("time_type", groupTarget.getTimeType());
+                        }
+                        if (!Check.isNull(groupTarget.getSceneType())) {
+                            behavior.put("scene_type", JSONArray.parseArray(groupTarget.getSceneType()));
+                        }
+                        if (!Check.isNull(groupTarget.getInterestLabel())) {
+                            interest.put("label", JSONArray.parseArray(groupTarget.getInterestLabel()));
+                        }
+                        if (!behavior.isEmpty()) {
+                            behaviorInterest.put("behavior", behavior);
+                        }
+                        if (!interest.isEmpty()) {
+                            behaviorInterest.put("interest", interest);
+                        }
+                        if (!behaviorInterest.isEmpty()) {
+                            targetJson.put("behavior_interest", behaviorInterest);
+                        }
                     }
-
                     unitJson.put("target", targetJson);
                 }
                 // 出价
@@ -1837,10 +1941,38 @@ public class BatchServiceImpl implements IBatchService {
                     targetJson.put("intelli_extend", intelliExtendJson);
                 }
             }
-
-
+            //-------------兴趣行为定向
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                behavior.put("keyword", requestJson.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("label"))) {
+                behavior.put("label", requestJson.getJSONArray("label"));
+            }
+            if (!Check.isNull(requestJson.getInteger("strengthType"))) {
+                behavior.put("strength_type", requestJson.getInteger("strengthType"));
+            }
+            if (!Check.isNull(requestJson.getInteger("timeType"))) {
+                behavior.put("time_type", requestJson.getInteger("timeType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", requestJson.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestLabel"))) {
+                interest.put("label", requestJson.getJSONArray("interestLabel"));
+            }
+            if (!behavior.isEmpty()) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!interest.isEmpty()) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!behaviorInterest.isEmpty()) {
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
             unitJson.put("target", targetJson);
-
             returnJson = updateService.updateUnit(token.getAccessToken(), unitJson);
         } catch (Exception e) {
             e.printStackTrace();

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

@@ -2,9 +2,22 @@ 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.*;
+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.common.module.utils.RandomUtil;
+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.KuaiShouImageGet;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.ICrossAccountBatchService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+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.IKuaiShouOverRunSendMessageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -35,6 +48,14 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
+    @Autowired
+    private IKuaishouDirectionalPackageService directionalPackageService;
+    @Autowired
+    private IKuaishouPopulationGroupService populationGroupService;
+    @Autowired
+    private IKuaishouAppPackageService appPackageService;
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
     /**
      * 组装数据  jason
@@ -457,6 +478,36 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         returnJson.put("ocpxActionType", requestJson.getLong("ocpx_action_type"));
                         returnJson.put("bidType", requestJson.getLong("bid_type"));
                         returnJson.put("unitType", requestJson.getInteger("unit_type"));
+                        //添加广告组和定向模板、人群包绑定关系
+                        Thread thread2 = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    JSONObject request = new JSONObject();
+                                    request.put("accountId", requestJson.getLong("advertiser_id"));
+                                    request.put("unitId", unitId);
+                                    JSONObject target = requestJson.getJSONObject("target");
+                                    if (!Check.isNull(target)) {
+                                        request.put("excludePopulation", target.getJSONArray("exclude_population"));
+                                        request.put("population", target.getJSONArray("population"));
+                                        request.put("paidAudience", target.getJSONArray("paid_audience"));
+                                        populationGroupService.createPopulationAndGroupRel(request);
+                                    }
+                                    if (!Check.isNull(requestJson.getLong("template_id"))) {
+                                        request.put("templateId", requestJson.getLong("template_id"));
+                                        directionalPackageService.createUnitAndTemplate(request);
+                                    }
+                                    if (!Check.isNull(requestJson.getLong("app_id"))) {
+                                        request.put("appId", requestJson.getLong("app_id"));
+                                        appPackageService.createAppAndGroupRel(request);
+                                    }
+
+                                } catch (Exception e) {
+                                    log.error("添加广告组和定向模板、人群包绑定关系异常,", e);
+                                }
+                            }
+                        };
+                        thread2.start();
                     }
 
                 } else {
@@ -533,7 +584,7 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                                 try {
                                     Thread.sleep(100);
                                     kuaishouInterfaceService.getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
-
+                                    createLandPageAndUnit(requestJson, add_creative_ids);
                                 } catch (InterruptedException e) {
                                     e.printStackTrace();
                                 }
@@ -584,6 +635,22 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
 
     }
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONArray add_creative_ids) {
+        JSONArray creatives = programJson.getJSONArray("creatives");
+        if (creatives != null && !creatives.isEmpty()) {
+            JSONObject jsonObject = creatives.getJSONObject(0);
+            Long siteId = jsonObject.getLong("site_id");
+            if (!Check.isNull(siteId)) {
+                if (!Check.isNull(jsonObject)) {
+                    for (Object creativeId : add_creative_ids) {
+                        landpagePackageService.createLandPageAndUnit(siteId, Long.valueOf(String.valueOf(creativeId)), jsonObject.getLong("unit_id"), jsonObject.getLong("advertiser_id"));
+                    }
+                }
+            }
+        }
+    }
+
     /**
      * 通用组创建数据组装
      *

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

@@ -548,6 +548,34 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                             groupTarget.setNoAreaBreak(intelliExtend.getInteger("no_area_break"));
 
                         }
+                        //行为兴趣定向
+                        JSONObject behaviorInterest = targetJson.getJSONObject("behavior_interest");
+                        if (!Check.isNull(behaviorInterest)) {
+                            JSONObject behavior = behaviorInterest.getJSONObject("behavior");
+                            if (!Check.isNull(behavior)) {
+                                if (!Check.isNull(behavior.getJSONArray("keyword"))) {
+                                    groupTarget.setKeyword(JSONObject.toJSONString(behavior.getJSONArray("keyword")));
+                                }
+                                if (!Check.isNull(behavior.getString("label"))) {
+                                    groupTarget.setLabel(behavior.getString("label"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("time_type"))) {
+                                    groupTarget.setTimeType(behavior.getInteger("time_type"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("strength_type"))) {
+                                    groupTarget.setStrengthType(behavior.getInteger("strength_type"));
+                                }
+                                if (!Check.isNull(behavior.getString("scene_type"))) {
+                                    groupTarget.setSceneType(behavior.getString("scene_type"));
+                                }
+                            }
+                            JSONObject interest = behaviorInterest.getJSONObject("interest");
+                            if (!Check.isNull(interest)) {
+                                if (!Check.isNull(interest.getString("label"))) {
+                                    groupTarget.setInterestLabel(interest.getString("label"));
+                                }
+                            }
+                        }
                         targets.add(groupTarget);
                     }
                 }

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

@@ -7,7 +7,11 @@ 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.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.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -498,6 +502,37 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         if (!Check.isNull(templateTarget.getPaidAudience())) {
             target.put("paid_audience", JSONArray.parseArray(templateTarget.getPaidAudience()));
         }
+        //-------------兴趣行为定向
+        JSONObject behaviorInterest = new JSONObject();
+        JSONObject behavior = new JSONObject();
+        JSONObject interest = new JSONObject();
+        if (!Check.isNull(templateTarget.getKeyword())) {
+            behavior.put("keyword", JSONArray.parseArray(templateTarget.getKeyword()));
+        }
+        if (!Check.isNull(templateTarget.getLabel())) {
+            behavior.put("label", JSONArray.parseArray(templateTarget.getLabel()));
+        }
+        if (!Check.isNull(templateTarget.getStrengthType())) {
+            behavior.put("strength_type", templateTarget.getStrengthType());
+        }
+        if (!Check.isNull(templateTarget.getTimeType())) {
+            behavior.put("time_type", templateTarget.getTimeType());
+        }
+        if (!Check.isNull(templateTarget.getSceneType())) {
+            behavior.put("scene_type", JSONArray.parseArray(templateTarget.getSceneType()));
+        }
+        if (!Check.isNull(templateTarget.getInterestLabel())) {
+            interest.put("label", JSONArray.parseArray(templateTarget.getInterestLabel()));
+        }
+        if (!Check.isNull(behavior)) {
+            behaviorInterest.put("behavior", behavior);
+        }
+        if (!Check.isNull(interest)) {
+            behaviorInterest.put("interest", interest);
+        }
+        if (!Check.isNull(behaviorInterest)) {
+            target.put("behavior_interest", behaviorInterest);
+        }
         returnJson.put("target", target);
         returnJson.put("code", 0);
         return returnJson;

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

@@ -4,8 +4,23 @@ 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.batch.entity.*;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
+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.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignDayBudget;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignStatus;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupBid;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupDayBudget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignDayBudgetMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignStatusMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupBidMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupDayBudgetMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
@@ -46,8 +61,14 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
     private KuaiShouCampaignMapper kuaiShouCampaignMapper;
     @Resource
     private KuaiShouCreativeMapper creativeMapper;
-
-
+    @Autowired
+    private IKuaishouDirectionalPackageService directionalPackageService;
+    @Autowired
+    private IKuaishouPopulationGroupService populationGroupService;
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
+    private IKuaishouAppPackageService appPackageService;
     @Override
     public Map<String, Object> updateCampaign(String token, Long advertiserId, Long campaignId, Long dayBudget, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -606,6 +627,35 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 if (code == 0) {
                     JSONObject data = resultJson.getJSONObject("data");
                     if (!Check.isNull(data)) {
+                        //添加广告组和定向模板、人群包绑定关系
+                        Thread thread2 = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    JSONObject request = new JSONObject();
+                                    request.put("accountId", unitJson.getLong("advertiser_id"));
+                                    request.put("unitId", data.getLong("unit_id"));
+                                    JSONObject target = unitJson.getJSONObject("target");
+                                    if (!Check.isNull(target)) {
+                                        request.put("excludePopulation", target.getJSONArray("exclude_population"));
+                                        request.put("population", target.getJSONArray("population"));
+                                        request.put("paidAudience", target.getJSONArray("paid_audience"));
+                                        populationGroupService.createPopulationAndGroupRel(request);
+                                    }
+                                    if (!Check.isNull(unitJson.getLong("template_id"))) {
+                                        request.put("templateId", unitJson.getLong("template_id"));
+                                        directionalPackageService.createUnitAndTemplate(request);
+                                    }
+                                    if (!Check.isNull(unitJson.getLong("app_id"))) {
+                                        request.put("appId", unitJson.getLong("app_id"));
+                                        appPackageService.createAppAndGroupRel(request);
+                                    }
+                                } catch (Exception e) {
+                                    log.error("添加广告组和定向模板、人群包绑定关系异常,", e);
+                                }
+                            }
+                        };
+                        thread2.start();
                         try {
                             Thread.sleep(500);
                             groupService.getGroupByUnitId(accessToken, unitJson.getLong("advertiser_id"), data.getLong("unit_id"));
@@ -660,6 +710,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         try {
                             Thread.sleep(200);
                             interfaceService.getCreativeByCreativeId(accessToken, creativeJson.getLong("advertiser_id"), data.getLong("creative_id"));
+                            createLandPageAndUnit(creativeJson, resultJson.getJSONObject("data"));
                         } catch (InterruptedException e) {
                             e.printStackTrace();
                         }
@@ -686,6 +737,19 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
         return returnJson;
     }
 
+    //绑定落地页与广告组、创意的关系
+    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();
+        }
+    }
+
     @Override
     public Map<String, Object> updateUnitDeepConversionBid(String accessToken, Long accountId, Long unitId, Long deepConversionBid, String userId) {
 

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

@@ -315,7 +315,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                 }
                 if (Check.isNull(campaignId)) {
                     campaignPreview.setId(null);
-                    campaignPreview.setCampaignName(getName(campaignPreview.getCampaignNameFormat(), null, null, appId, null) + i);
+                    campaignPreview.setCampaignName(getName(campaignPreview.getCampaignNameFormat(), targetIds.getLong(i), null, appId, null) + i);
                     campaignPreviewMapper.insert(campaignPreview);
                 }
                 for (int j = 0; j < materialList.size(); j++) {

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

@@ -8,7 +8,13 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouCampaignCopyDataMapper;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTargetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouCampaignCopyDataService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -370,6 +376,37 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
                             targetJson.put("intelli_extend", intelliExtendJson);
                         }
                     }
+                    //-------------兴趣行为定向
+                    JSONObject behaviorInterest = new JSONObject();
+                    JSONObject behavior = new JSONObject();
+                    JSONObject interest = new JSONObject();
+                    if (!Check.isNull(target.getJSONArray("keyword"))) {
+                        behavior.put("keyword", target.getJSONArray("keyword"));
+                    }
+                    if (!Check.isNull(target.getJSONArray("label"))) {
+                        behavior.put("label", target.getJSONArray("label"));
+                    }
+                    if (!Check.isNull(target.getInteger("strengthType"))) {
+                        behavior.put("strength_type", target.getInteger("strengthType"));
+                    }
+                    if (!Check.isNull(target.getInteger("timeType"))) {
+                        behavior.put("time_type", target.getInteger("timeType"));
+                    }
+                    if (!Check.isNull(target.getJSONArray("sceneType"))) {
+                        behavior.put("scene_type", target.getJSONArray("sceneType"));
+                    }
+                    if (!Check.isNull(target.getJSONArray("interestLabel"))) {
+                        interest.put("label", target.getJSONArray("interestLabel"));
+                    }
+                    if (!behavior.isEmpty()) {
+                        behaviorInterest.put("behavior", behavior);
+                    }
+                    if (!interest.isEmpty()) {
+                        behaviorInterest.put("interest", interest);
+                    }
+                    if (!behaviorInterest.isEmpty()) {
+                        targetJson.put("behavior_interest", behaviorInterest);
+                    }
                     unitJson.put("target", targetJson);
                 }
                 // 出价

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

@@ -7,19 +7,67 @@ import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.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.batch.entity.*;
+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 com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -53,7 +101,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;
 
@@ -67,6 +119,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     KuaishouReportDailyCampaignMapper dailyCampaignMapper;
     @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
     private KuaiShouGroupMapper groupMapper;
     @Autowired
     private IKuaiShouCreativeService creativeService;
@@ -119,6 +173,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private IWarningOperationService warningOperationService;
 
+    @Autowired
+    private IKuaishouDirectionalPackageService directionalPackageService;
+    @Autowired
+    private IKuaishouPopulationGroupService populationGroupService;
+    @Autowired
+    private IKuaishouAppPackageService appPackageService;
 
     @Override
     public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
@@ -912,6 +972,35 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("message", "success");
                         returnMap.put("unitId", unitId);
                         returnMap.put("success", true);
+                        //添加广告组和定向模板、人群包绑定关系
+                        Thread thread2 = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    JSONObject request = new JSONObject();
+                                    request.put("accountId", requestJson.getLong("advertiser_id"));
+                                    request.put("unitId", unitId);
+                                    JSONObject target = requestJson.getJSONObject("target");
+                                    if (!Check.isNull(target)) {
+                                        request.put("excludePopulation", target.getJSONArray("exclude_population"));
+                                        request.put("population", target.getJSONArray("population"));
+                                        request.put("paidAudience", target.getJSONArray("paid_audience"));
+                                        populationGroupService.createPopulationAndGroupRel(request);
+                                    }
+                                    if (!Check.isNull(requestJson.getLong("template_id"))) {
+                                        request.put("templateId", requestJson.getLong("template_id"));
+                                        directionalPackageService.createUnitAndTemplate(request);
+                                    }
+                                    if (!Check.isNull(requestJson.getLong("app_id"))) {
+                                        request.put("appId", requestJson.getLong("app_id"));
+                                        appPackageService.createAppAndGroupRel(request);
+                                    }
+                                } catch (Exception e) {
+                                    log.error("添加广告组和定向模板、人群包绑定关系异常,", e);
+                                }
+                            }
+                        };
+                        thread2.start();
                     }
 
                 } else {
@@ -1920,6 +2009,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                 try {
                                     Thread.sleep(100);
                                     getCreativeByCreativeId(accessToken, advertiserId, creativeId);
+                                    //绑定落地页与广告组、创意的关系
+                                    if (!Check.isNull(requestJson.getLong("site_id"))) {
+                                        landpagePackageService.createLandPageAndUnit(requestJson.getLong("site_id"), creativeId, requestJson.getLong("unit_id"), advertiserId);
+                                    }
                                 } catch (InterruptedException e) {
                                     e.printStackTrace();
                                 }
@@ -2004,6 +2097,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     try {
                                         Thread.sleep(100);
                                         getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
+                                        createLandPageAndUnit(requestJson, add_creative_ids);
                                     } catch (InterruptedException e) {
                                         e.printStackTrace();
                                     }
@@ -2056,6 +2150,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONArray add_creative_ids) {
+        JSONArray creatives = programJson.getJSONArray("creatives");
+        if (creatives != null && !creatives.isEmpty()) {
+            JSONObject jsonObject = creatives.getJSONObject(0);
+            Long siteId = jsonObject.getLong("site_id");
+            if (!Check.isNull(siteId)) {
+                if (!Check.isNull(jsonObject)) {
+                    for (Object creativeId : add_creative_ids) {
+                        landpagePackageService.createLandPageAndUnit(siteId, Long.valueOf(String.valueOf(creativeId)), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                    }
+                }
+            }
+        }
+    }
 
     /**
      * 获取视频信息
@@ -2636,7 +2745,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
                         }
                     }
-                    populationService.replaceBatch(addList);
+                    if (!Check.isNull(addList)) {
+                        populationService.replaceBatch(addList);
+                    }
                     getPopulationList(accountId, accessToken, page + 1);
                 } else {
                     log.error("获取人群包管理返回数据为空,accountId:{}", accountId);

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

@@ -355,6 +355,7 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
 
     @Override
     public void replaceBatch(List<KuaishouPopulation> addList) {
+        populationMapper.deleteByAccountId(addList.get(0).getAccountId());
         populationMapper.replaceBatch(addList);
     }
 }

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

@@ -6,6 +6,7 @@ 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.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouProgramCreativeMapper;
@@ -45,6 +46,8 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
     @Autowired
     private IMaterialCutFrameService materialCutFrameService;
 
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
     @Override
     public void getProgramCreative(Long accountId, Long unitId, String accessToken, String startDate, String endDate, Integer page) {
@@ -194,6 +197,7 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
                 if (code == 0) {
                     returnJson.put("isTrueOrFalse", true);
                     returnJson.put("message", "创建成功");
+                    createLandPageAndUnit(pramsJson,jsonObject.getJSONObject("data"));
                 } else {
                     log.error("创建失败:入参:{}", pramsJson);
                     returnJson.put("isTrueOrFalse", false);
@@ -212,6 +216,19 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
         return returnJson;
     }
 
+    //绑定落地页与广告组、创意的关系
+    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();
+        }
+    }
+
     @Override
     public JSONArray getProgramCreativeCover(JSONArray md5Arr) {
 

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

@@ -7,7 +7,11 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
 import cn.com.ctop.kuaishou.modules.batch.entity.kuaishoustrategycampaignRel;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouStrategyMapper;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+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.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -464,6 +468,38 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
         if (!Check.isNull(groupJson.getJSONArray("thirdPlatformCode"))) {
             targetJson.put("third_platform_code", groupJson.getJSONArray("thirdPlatformCode"));
         }
+
+        //-------------兴趣行为定向
+        JSONObject behaviorInterest = new JSONObject();
+        JSONObject behavior = new JSONObject();
+        JSONObject interest = new JSONObject();
+        if (!Check.isNull(groupJson.getJSONArray("keyword"))) {
+            behavior.put("keyword", groupJson.getJSONArray("keyword"));
+        }
+        if (!Check.isNull(groupJson.getJSONArray("label"))) {
+            behavior.put("label", groupJson.getJSONArray("label"));
+        }
+        if (!Check.isNull(groupJson.getInteger("strengthType"))) {
+            behavior.put("strength_type", groupJson.getInteger("strengthType"));
+        }
+        if (!Check.isNull(groupJson.getInteger("timeType"))) {
+            behavior.put("time_type", groupJson.getInteger("timeType"));
+        }
+        if (!Check.isNull(groupJson.getJSONArray("sceneType"))) {
+            behavior.put("scene_type", groupJson.getJSONArray("sceneType"));
+        }
+        if (!Check.isNull(groupJson.getJSONArray("interestLabel"))) {
+            interest.put("label", groupJson.getJSONArray("interestLabel"));
+        }
+        if (!behavior.isEmpty()) {
+            behaviorInterest.put("behavior", behavior);
+        }
+        if (!interest.isEmpty()) {
+            behaviorInterest.put("interest", interest);
+        }
+        if (!behaviorInterest.isEmpty()) {
+            targetJson.put("behavior_interest", behaviorInterest);
+        }
         unitJson.put("target", targetJson);
         return kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
     }

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

@@ -1,5 +1,7 @@
 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;
@@ -7,15 +9,17 @@ import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateTargetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -30,15 +34,21 @@ import java.util.Map;
 @Slf4j
 @Service
 public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMapper, KuaishouTemplate> implements IKuaishouTemplateService {
+
+    @Autowired
+    private KuaishouTemplateTargetMapper templateTargetMapper;
+
     @Autowired
-    private IKuaishouTemplateTargetService templateTargetService;
- @Autowired
     private KuaishouTemplateMapper templateMapper;
 
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
     @Override
-    public List<JSONObject> getJsonArrByAccountId(Long accountId,Integer platformOs) {
-        return templateMapper.getJsonArrByAccountId(accountId,platformOs);
+    public List<JSONObject> getJsonArrByAccountId(Long accountId, Integer platformOs, Boolean autoTarget) {
+        return templateMapper.getJsonArrByAccountId(accountId, platformOs, autoTarget);
     }
+
     @Override
     public void getTemplateByAccountId(Long accountId, String accessToken, Integer page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_LIST;
@@ -46,6 +56,7 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
         param.put("advertiser_id", accountId);
         param.put("page", page);
         param.put("page_size", 500);
+
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Access-Token", accessToken);
         headers.put("Content-Type", " application/json");
@@ -53,9 +64,6 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
         JSONObject resultJson = JSONObject.parseObject(result);
         if (!Check.isNull(resultJson)) {
             Integer code = resultJson.getInteger("code");
-         /*   Map<String, Object> deleteMap = new HashMap<>();
-            deleteMap.put("account_id", accountId);
-            this.removeByMap(deleteMap);*/
             if (code == 0) {
                 JSONObject dataJson = resultJson.getJSONObject("data");
                 if (Check.isNull(dataJson)) {
@@ -65,6 +73,9 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
                 if (Check.isNull(details)) {
                     return;
                 }
+
+                List<KuaishouTemplate> templateList = new ArrayList<>();
+                List<KuaishouTemplateTarget> templateTargetList = new ArrayList<>();
                 for (int i = 0; i < details.size(); i++) {
                     JSONObject jsonObject = details.getJSONObject(i);
                     Long templateId = jsonObject.getLong("template_id");
@@ -74,9 +85,10 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
                     template.setTemplateId(templateId);
                     template.setTemplateName(jsonObject.getString("template_name"));
                     template.setUnitCount(jsonObject.getInteger("unit_count"));
+                    template.setAutoTarget(jsonObject.getBoolean("auto_target"));
                     template.setCreateTime(jsonObject.getDate("create_time"));
                     template.setUpdateTime(jsonObject.getDate("updateTime"));
-                    this.saveOrUpdate(template);
+                    templateList.add(template);
                     JSONObject targetJson = jsonObject.getJSONObject("target");
                     if (!Check.isNull(targetJson)) {
                         KuaishouTemplateTarget templateTarget = new KuaishouTemplateTarget();
@@ -165,10 +177,45 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
                                 templateTarget.setNoAreaBreak(intelliExtendJson.getInteger("no_area_break"));
                             }
                         }
-                        templateTargetService.saveOrUpdate(templateTarget);
+                        //行为兴趣定向
+                        JSONObject behaviorInterest = targetJson.getJSONObject("behavior_interest");
+                        if (!Check.isNull(behaviorInterest)) {
+                            JSONObject behavior = behaviorInterest.getJSONObject("behavior");
+                            if (!Check.isNull(behavior)) {
+                                if (!Check.isNull(behavior.getJSONArray("keyword"))) {
+                                    templateTarget.setKeyword(JSONObject.toJSONString(behavior.getJSONArray("keyword")));
+                                }
+                                if (!Check.isNull(behavior.getString("label"))) {
+                                    templateTarget.setLabel(behavior.getString("label"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("time_type"))) {
+                                    templateTarget.setTimeType(behavior.getInteger("time_type"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("strength_type"))) {
+                                    templateTarget.setStrengthType(behavior.getInteger("strength_type"));
+                                }
+                                if (!Check.isNull(behavior.getString("scene_type"))) {
+                                    templateTarget.setSceneType(behavior.getString("scene_type"));
+                                }
+                            }
+                            JSONObject interest = behaviorInterest.getJSONObject("interest");
+                            if (!Check.isNull(interest)) {
+                                if (!Check.isNull(interest.getString("label"))) {
+                                    templateTarget.setInterestLabel(interest.getString("label"));
+                                }
+                            }
+                        }
+
+                        templateTarget.setCreateTime(jsonObject.getDate("create_time"));
+                        templateTarget.setUpdateTime(jsonObject.getDate("updateTime"));
+                        templateTargetList.add(templateTarget);
                     }
 
                 }
+                if (!Check.isNull(templateList)) {
+                    templateMapper.replaceBatch(templateList);
+                    templateTargetMapper.templateTargetList(templateTargetList);
+                }
 
                 getTemplateByAccountId(accountId, accessToken, page + 1);
             } else {
@@ -202,10 +249,12 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             if (Check.isNull(requestJson.getString("templateName"))) {
                 throw new Exception("定向模板名称为必传项");
             }
-
             JSONObject param = new JSONObject();
             param.put("advertiser_id", accountId);
             param.put("template_name", requestJson.getString("templateName"));
+            if (!Check.isNull(requestJson.getBoolean("autoTarget"))) {
+                param.put("auto_target", requestJson.getBoolean("autoTarget"));
+            }
             JSONObject targetJson = new JSONObject();
             if (!Check.isNull(requestJson.getJSONArray("region"))) {
                 targetJson.put("region", requestJson.getJSONArray("region"));
@@ -349,7 +398,6 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
      */
     @Override
     public JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson) {
-        System.err.println(requestJson);
         JSONObject returnJson = new JSONObject();
         try {
             if (Check.isNull(requestJson.getString("templateName"))) {
@@ -466,7 +514,6 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
-            System.err.println("入参:" + param);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
@@ -494,4 +541,154 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
         }
         return returnJson;
     }
+
+
+    /**
+     * 获得行为兴趣类目词
+     *
+     * @param
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> getBehaviorInterest(Long accountId) {
+        try {
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.BEHAVIOR_INTEREST;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data").getJSONObject("behavior_interest");
+                    JSONArray interest = data.getJSONArray("interest");
+                    splicingId(interest);
+                    JSONArray behavior = data.getJSONArray("behavior");
+                    splicingId(behavior);
+                    data.put("interest", interest);
+                    data.put("behavior", behavior);
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info(" 获取行为与兴趣类目失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("获取行为与兴趣类目失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("获取行为与兴趣类目失败", e);
+        }
+        return Result.error("获取行为与兴趣类目失败");
+    }
+
+    private void splicingId(JSONArray interest) {
+        for (int i = 0; i < interest.size(); i++) {
+            JSONObject level1 = interest.getJSONObject(i);
+            JSONArray children1 = level1.getJSONArray("children");
+            if (!Check.isNull(children1)) {
+                for (int j = 0; j < children1.size(); j++) {
+                    JSONObject level2 = children1.getJSONObject(j);
+                    JSONArray children2 = level2.getJSONArray("children");
+                    if (!Check.isNull(children2)) {
+                        for (int k = 0; k < children2.size(); k++) {
+                            JSONObject level3 = children2.getJSONObject(k);
+                            level3.put("id", level1.getString("id").concat("-").concat(level2.getString("id")).concat("-").concat(level3.getString("id")));
+                        }
+                    }
+                    level2.put("id", level1.getString("id").concat("-").concat(level2.getString("id")));
+                }
+            }
+        }
+    }
+
+    /**
+     * 获取行为兴趣关键词
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> getKeywordQuery(JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            String query_str = data.getString("query_str");
+            Integer type = data.getInteger("type");
+            JSONArray ids = data.getJSONArray("ids");
+            if (Check.isNull(accountId) || Check.isNull(type)) {
+                return Result.error("缺失参数");
+            }
+            if (Check.isNull(query_str) && Check.isNull(ids)) {
+                return Result.error("缺失参数");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.KEYWORD_QUERY;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("type", type);
+            if (!Check.isNull(query_str)) {
+                params.put("query_str", query_str);
+            }
+            if (!Check.isNull(ids)) {
+                params.put("ids", ids);
+            }
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info("获取行为兴趣关键词失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("获取行为兴趣关键词失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("获取行为兴趣关键词失败", e);
+        }
+        return Result.error("获取行为兴趣关键词失败");
+    }
+
+    /**
+     * 删除定向模板
+     *
+     * @param
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> templateDelete(Long accountId, Long templateId) {
+        try {
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_DELETE;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("template_id", templateId);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok("删除成功");
+                } else {
+                    log.info("删除定向模板失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("删除定向模板失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("删除定向模板失败", e);
+        }
+        return Result.error("删除定向模板失败");
+    }
+
 }

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

@@ -157,7 +157,7 @@
     sum(m.download_completed)as download_completed,
     sum(m.activation)as activation ,
     sum(m.submit)as submit,
-    stat_date,
+    date_format(m.stat_date,'%Y-%m-%d') as stat_date,
     sum(m.photo_click)as photo_click,
     sum(m.event_pay_first_day)as event_pay_first_day,
     sum(m.event_pay_purchase_amount_first_day)as event_pay_purchase_amount_first_day,