فهرست منبع

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

syh 4 سال پیش
والد
کامیت
749378449c
60فایلهای تغییر یافته به همراه1326 افزوده شده و 113 حذف شده
  1. 5 0
      jeecg-boot-module-system/pom.xml
  2. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/config/MybatisPlusConfig.java
  3. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  4. 31 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  5. 3 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml
  6. 7 0
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  7. 7 0
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  8. 7 0
      jeecg-boot-module-system/src/main/resources/application-prod2.yml
  9. 16 3
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  10. 27 16
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java
  11. 2 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/AlarmEventSend.java
  12. 40 9
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
  13. 5 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java
  14. 0 2
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java
  15. 45 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccountKuaishou.java
  16. 42 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java
  17. 27 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDatePlanKuaishou.java
  18. 50 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java
  19. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java
  20. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDataAccountKuaishouMapper.java
  21. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDataTargetKuaishouMapper.java
  22. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDatePlanKuaishouMapper.java
  23. 12 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDateUnitKuaishouMapper.java
  24. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  25. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataAccountKuaishouMapper.xml
  26. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataTargetKuaishouMapper.xml
  27. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDatePlanKuaishouMapper.xml
  28. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  29. 13 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataAccountKuaishouService.java
  30. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataTargetKuaishouService.java
  31. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataUnitKuaishouService.java
  32. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDatePlanKuaishouService.java
  33. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  34. 57 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataAccountKuaishouServiceImpl.java
  35. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataTargetKuaishouServiceImpl.java
  36. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataUnitKuaishouServiceImpl.java
  37. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDatePlanKuaishouServiceImpl.java
  38. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  39. 5 5
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/taobao/service/impl/TaobaoJhsbybtServiceImpl.java
  40. 53 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouDeleteCommentJob.java
  41. 32 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java
  42. 31 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java
  43. 34 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java
  44. 32 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java
  45. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CrossAccountBatchController.java
  46. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java
  47. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  48. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouUpdateService.java
  49. 139 55
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java
  50. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  51. 0 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/entity/KuaishouUserCookie.java
  52. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaiShouGetAccountFundService.java
  53. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouAccountService.java
  54. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouPlanService.java
  55. 62 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouGetAccountFundServiceImpl.java
  56. 6 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java
  57. 43 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouAccountServiceImpl.java
  58. 258 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  59. 5 13
      module-toutiao/src/main/resources/bytedance_config.properties
  60. 2 1
      pom.xml

+ 5 - 0
jeecg-boot-module-system/pom.xml

@@ -169,6 +169,11 @@
             <artifactId>pagehelper</artifactId>
             <version>5.1.11</version>
         </dependency>
+        <dependency>
+            <groupId>com.jimureport</groupId>
+            <artifactId>spring-boot-starter-jimureport</artifactId>
+            <version>1.1-beta</version>
+        </dependency>
     </dependencies>
 
     <dependencyManagement>

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

@@ -4,7 +4,6 @@ import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
 
 /**
  * 单数据源配置(jeecg.datasource.open = false时生效)

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

@@ -90,6 +90,9 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/bytedanceInterestCategory/**", "anon");
         filterChainDefinitionMap.put("/template/creative/words/get", "anon");
         filterChainDefinitionMap.put("template/bytedance/industry/list", "anon");
+        //报表设计器排除
+        filterChainDefinitionMap.put("/design/report/**", "anon");
+        filterChainDefinitionMap.put("/**/*.css.map", "anon");
 
         filterChainDefinitionMap.put("/bytedance/batch/creative/words/get", "anon");
         filterChainDefinitionMap.put("/bytedance/batch/action/text", "anon");

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

@@ -16,6 +16,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
@@ -476,4 +477,34 @@ public class UserAllocationController {
         return result;
     }
 
+    /**
+     *  账户绑定是否开启删评论开关
+     */
+    @PostMapping(value = "/onOrOffDeleteComment")
+    public Result<Object> onOrOffMonitoringLink(@RequestParam Long accountId, @RequestParam Integer switchType){
+        Result<Object> result=new Result<>();
+        UserAllocation userAllocation=new UserAllocation();
+        userAllocation.setAccountId(accountId);
+        UpdateWrapper<UserAllocation> wrapper=new UpdateWrapper<>();
+        //开启删评论
+        if(switchType==0){
+            wrapper.set("delete_comment",0);
+            wrapper.setEntity(userAllocation);
+            boolean update = userAllocationService.update(wrapper);
+            if(update){
+                result.success("删评论开启成功");
+            }
+        }else if(switchType==1){
+            wrapper.set("delete_comment",1);
+            wrapper.setEntity(userAllocation);
+            boolean update = userAllocationService.update(wrapper);
+            if(update){
+                result.success("删评论关闭成功");
+            }
+        }else {
+            result.error500("未知操作");
+        }
+        return result;
+    }
+
 }

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

@@ -155,7 +155,7 @@
                       FROM
                           ctop_material_info info
                       WHERE
-                          info.CODE = t2.signature
+                          info.CODE = t1.signature
                       ORDER BY
                           create_time DESC
                       LIMIT 1),'') AS url,
@@ -164,7 +164,7 @@
                       FROM
                           ctop_material_info info
                       WHERE
-                          info.CODE = t2.signature
+                          info.CODE = t1.signature
                       ORDER BY
                           create_time DESC
                       LIMIT 1),'') AS cover_url,
@@ -174,7 +174,7 @@
                          FROM
                              ctop_material_info info
                          WHERE
-                             info.CODE = t2.signature
+                             info.CODE = t1.signature
                          ORDER BY
                              create_time DESC
                          LIMIT 1

+ 7 - 0
jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -174,6 +174,13 @@ mybatis-plus:
     #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #jeecg专用配置
 jeecg:
+  #积木报表设置
+  jmreport:
+    mode: dev
+    #是否需要校验token
+    is_verify_token: false
+    #必须校验方法
+    verify_methods: remove,delete,save,add,update
   elasticsearch:
     cluster-nodes:
     check-enabled: false

+ 7 - 0
jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -144,6 +144,13 @@ mybatis-plus:
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #jeecg专用配置
 jeecg:
+  #积木报表设置
+  jmreport:
+    mode: dev
+    #是否需要校验token
+    is_verify_token: false
+    #必须校验方法
+    verify_methods: remove,delete,save,add,update
   elasticsearch:
     cluster-nodes:
     check-enabled: false

+ 7 - 0
jeecg-boot-module-system/src/main/resources/application-prod2.yml

@@ -136,6 +136,13 @@ mybatis-plus:
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #jeecg专用配置
 jeecg:
+  #积木报表设置
+  jmreport:
+    mode: dev
+    #是否需要校验token
+    is_verify_token: false
+    #必须校验方法
+    verify_methods: remove,delete,save,add,update
   elasticsearch:
     cluster-nodes:
     check-enabled: false

+ 16 - 3
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -14,6 +14,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouCostGroupService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
@@ -250,17 +251,17 @@ public class SampleTest {
     }
 
     @Test
-    public void loadKuaishouData(){
+    public void loadKuaishouData() {
         Date getDate = DateUtils.addDay(new Date(), -1);
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        for (CtopOauthToken token:tokens){
+        for (CtopOauthToken token : tokens) {
             kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
         }
     }
 
     @Test
-    public void loadKuaishouHourlyReportData(){
+    public void loadKuaishouHourlyReportData() {
         Date getDate = new Date();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
         String hour = simpleDateFormat.format(getDate);
@@ -272,6 +273,7 @@ public class SampleTest {
         Date finalGetDate = getDate;
         tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate));
     }
+
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
@@ -339,5 +341,16 @@ public class SampleTest {
         wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "1");
     }
 
+    @Autowired
+    IRuleKuaiShouPlanService kuaiShouPlanService;
+
+    @Test
+    public void kuaishouRuleData() {
+        //kuaiShouPlanService.cleanRuleDataPlan(3429620L,"2020-12-07","2020-12-07",1);
+        kuaiShouPlanService.cleanRuleDataUnit(3429620L, "2020-12-07", "2020-12-07", 1);
+        // kuaiShouPlanService.cleanRuleDataTarget(3429620L,"2020-12-07","2020-12-07",1);
+
+    }
+
 
 }

+ 27 - 16
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -183,7 +183,9 @@ public class MatchLogic {
                 append("预警账户:").append(accountId).append(",授权名称:").append(accountName).append("<br/>");
         if ("plan".equals(type)) {
             buf.append("预警计划:").append(codes).append("<br/>");
-        } else if ("creative".equals(type)) {
+        } else if ("unit".equals(type)) {
+            buf.append("预警组:").append(codes).append("<br/>");
+        }else if ("creative".equals(type)) {
             buf.append("预警创意:").append(codes).append("<br/>");
         }
         if (isNull) {
@@ -279,29 +281,38 @@ public class MatchLogic {
      * @throws
      * @author ZHAOXA
      */
-    public static JSONArray getKuaiShouSendData(JSONArray accountDatas, JSONArray groupDatas, JSONArray planDatas, JSONArray creativeDatas, JSONArray targetDatas) {
+    public static JSONArray getKuaiShouSendData(JSONArray accountDatas, JSONArray planDatas, JSONArray groupDatas, JSONArray creativeDatas, JSONArray targetDatas) {
         JSONArray sendData = new JSONArray();
         if (!Check.isNull(accountDatas) && Check.isNull(groupDatas) && Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
             sendData = accountDatas;
         } else {
-            if (Check.isNull(groupDatas)) {
-                if (!Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
-                    sendData = planDatas;
-                } else if (Check.isNull(planDatas) && !Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+            if (Check.isNull(planDatas)) {
+                if (!Check.isNull(groupDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+                    sendData = groupDatas;
+                } else if (Check.isNull(groupDatas) && !Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
                     sendData = creativeDatas;
-                } else if (Check.isNull(planDatas) && Check.isNull(creativeDatas) && !Check.isNull(targetDatas)) {
+                } else if (Check.isNull(groupDatas) && Check.isNull(creativeDatas) && !Check.isNull(targetDatas)) {
                     sendData = targetDatas;
                 }
             } else {
-                if (Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
-                    sendData = groupDatas;
-                } else if (!Check.isNull(targetDatas)) {
-                    for (int i = 0; i < groupDatas.size(); i++) {
-                        Long gGroupId = groupDatas.getJSONObject(i).getLong("groupId");
-                        for (int k = 0; k < targetDatas.size(); k++) {
-                            Long tgGroupId = targetDatas.getJSONObject(k).getLong("groupId");
-                            if (tgGroupId == gGroupId) {
-                                sendData.add(creativeDatas.getJSONObject(k));
+                if (Check.isNull(groupDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+                    sendData = planDatas;
+                } else {
+                    for (int i = 0; i < planDatas.size(); i++) {
+                        Long planId = planDatas.getJSONObject(i).getLong("planId");
+                        if (!Check.isNull(targetDatas) && Check.isNull(groupDatas)) {
+                            for (int k = 0; k < targetDatas.size(); k++) {
+                                Long tgPlanId = targetDatas.getJSONObject(k).getLong("planId");
+                                if (tgPlanId == planId) {
+                                    sendData.add(creativeDatas.getJSONObject(k));
+                                }
+                            }
+                        } else if (Check.isNull(targetDatas) && !Check.isNull(groupDatas)) {
+                            for (int k = 0; k < groupDatas.size(); k++) {
+                                Long tgPlanId = groupDatas.getJSONObject(k).getLong("planId");
+                                if (tgPlanId == planId) {
+                                    sendData.add(creativeDatas.getJSONObject(k));
+                                }
                             }
                         }
                     }

+ 2 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/AlarmEventSend.java

@@ -62,6 +62,8 @@ public class AlarmEventSend {
     private String alarmStatus;
 
     private String ruleDimension;
+
+    private String mediaType;
     /**
      * createTime
      */

+ 40 - 9
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -22,6 +22,7 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.SysUserMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
 import cn.com.ctop.common.module.service.IRuleDataAccountService;
 import cn.com.ctop.common.module.service.ISendMessageService;
 import cn.com.ctop.common.module.utils.Check;
@@ -82,6 +83,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
     @Autowired
     private IRuleDataAccountService ruleDataAccountService;
     @Autowired
+    private IRuleDataAccountKuaishouService ruleDataAccountKuaishouService;
+    @Autowired
     private AlarmEventSendMapper alarmEventSendMapper;
     @Autowired
     private UserAllocationMapper userAllocationMapper;
@@ -94,6 +97,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 
     private JSONObject userObj = null;
     private final static String ACCOUNT = "account";
+    private final static String UNIT = "unit";
     private final static String PLAN = "plan";
     private final static String CREATIVE = "creative";
 
@@ -142,12 +146,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
         Integer type = (Integer) map.get("type");
         JSONObject matchData = null;
-        //媒体类型 1:头条2:快手
+        //媒体类型 1,3:头条2:快手
         if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
             //查询抖音匹配数据
-            matchData = getRuleData(templates.getAccountId());
+            matchData = getRuleData(templates.getAccountId(), "TT");
         } else {
-            //TODO 获取快手数据
+            matchData = getRuleData(templates.getAccountId(), "KS");
         }
         if (Check.isNull(matchData)) {
             log.warn("获取匹配数据失败");
@@ -398,9 +402,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     }
                     break;
                 }
-            } else if ("group".equals(ruleBase.getRuleDimension())) {
+            } else if (UNIT.equals(ruleBase.getRuleDimension())) {
                 groupDatas = getOKData(groupDatas, dimensionData, ruleBase, indicator, threshold);
-                if (Check.isNull(targetDatas)) {
+                if (Check.isNull(groupDatas)) {
                     if (!Check.isNull(accountDatas)) {
                         accountDatas = null;
                     }
@@ -471,6 +475,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         }
         JSONObject user = getUserByAccountId(accountId);
         StringJoiner creativeJoiner = new StringJoiner(",");
+        StringJoiner unitJoiner = new StringJoiner(",");
         StringJoiner planJoiner = new StringJoiner(",");
         StringJoiner isNullCreativeJoiner = new StringJoiner(",");
         StringJoiner isNullPlanJoiner = new StringJoiner(",");
@@ -512,6 +517,15 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                         creativeJoiner = new StringJoiner(",");
                         creativeJoiner.add(obj.getString("creativeId"));
                     }
+                } else if (!Check.isNull(obj.getLong("unitId"))) {
+                    if (unitJoiner.toString().getBytes().length <= 1800) {
+                        unitJoiner.add(obj.getString("unitId"));
+                    } else {
+                        String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), isNull);
+                        sendMsg(msg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType);
+                        unitJoiner = new StringJoiner(",");
+                        unitJoiner.add(obj.getString("unitId"));
+                    }
                 } else if (!Check.isNull(obj.getLong("planId"))) {
                     if (planJoiner.toString().getBytes().length <= 1800) {
                         planJoiner.add(obj.getString("planId"));
@@ -531,6 +545,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), false);
             sendMsg(creativeMsg, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId, mediaType);
         }
+        if (!Check.isNull(unitJoiner.toString())) {
+            String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), false);
+            sendMsg(creativeMsg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType);
+        }
         if (!Check.isNull(planJoiner.toString())) {
             String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), false);
             sendMsg(planMsg, ruleGroup, user, PLAN, planJoiner.toString(), accountId, mediaType);
@@ -595,11 +613,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 send.setAlarmDetail(msg.replace("<br/>", ","));
                 send.setAlarmStatus(NoEn.NO1.valueStr());
                 send.setGroupId(ruleGroup.getId());
+                send.setMediaType((NoEn.NO1.valueInt() == mediaType || NoEn.NO3.valueInt() == mediaType) ? "头条" : "快手");
                 send.setGroupName(ruleGroup.getGroupName());
                 if (CREATIVE.equals(type)) {
-                    send.setRuleDimension(CREATIVE);
+                    send.setRuleDimension(type);
                 } else if (PLAN.equals(type)) {
-                    send.setRuleDimension(PLAN);
+                    send.setRuleDimension(type);
+                } else if (UNIT.equals(type)) {
+                    send.setRuleDimension(type);
                 } else {
                     send.setRuleDimension(ACCOUNT);
                 }
@@ -648,6 +669,11 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     if (!(boolean) updateMap.get("success")) {
                         msg = msg.replace(id, id + "(F)");
                     }
+                } else if (UNIT.equals(type)) {
+                    updateMap = kuaiShouUpdateService.updateUnitStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
+                    if (!(boolean) updateMap.get("success")) {
+                        msg = msg.replace(id, id + "(F)");
+                    }
                 } else if (PLAN.equals(type)) {
                     updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
                     if (!(boolean) updateMap.get("success")) {
@@ -818,9 +844,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
      * @throws
      * @author ZHAOXA
      */
-    private JSONObject getRuleData(Long accountId) {
+    private JSONObject getRuleData(Long accountId, String type) {
         try {
-            return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            if ("TT".equals(type)) {
+                return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            }
+            if ("KS".equals(type)) {
+                return ruleDataAccountKuaishouService.getKuaiShouRuleDataByAccountId(accountId);
+            }
         } catch (Exception e) {
             log.error("获取匹配数据集异常", e);
         }

+ 5 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java

@@ -226,6 +226,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                 QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                 indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                 indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                indicatorQueryWrapper.eq("media_type", template.getMediaType());
                 indicatorQueryWrapper.last("limit 1");
                 RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
                 if (!Check.isNull(ruleIndicator)) {
@@ -334,6 +335,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                     indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                     indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                    indicatorQueryWrapper.eq("media_type", template.getMediaType());
                     indicatorQueryWrapper.last("limit 1");
                     RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);  // 查询指标的详情信息
                     if (!Check.isNull(ruleIndicator)) {
@@ -396,6 +398,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                          */
                         QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                         indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
+                        indicatorQueryWrapper.eq("media_type", template.getMediaType());
                         indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
                         indicatorQueryWrapper.last("limit 1");
                         RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper); // 查询基础规则的指标信息
@@ -478,6 +481,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                     indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                     indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                    indicatorQueryWrapper.eq("media_type", template.getMediaType());
                     indicatorQueryWrapper.last("limit 1");
                     RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
                     if (!Check.isNull(ruleIndicator)) {
@@ -515,6 +519,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                     indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                     indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                    indicatorQueryWrapper.eq("media_type", template.getMediaType());
                     indicatorQueryWrapper.last("limit 1");
                     RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
                     if (!Check.isNull(ruleIndicator)) {

+ 0 - 2
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java

@@ -1,7 +1,5 @@
 package cn.com.ctop.common.module.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;

+ 45 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccountKuaishou.java

@@ -0,0 +1,45 @@
+package cn.com.ctop.common.module.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * 快手预警数据账户维度
+ */
+@Data
+@TableName("ctop_rule_data_account_kuaishou")
+public class RuleDataAccountKuaishou {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户id*/
+	private Long accountId;
+	/**accountName*/
+	private String accountName;
+	/**消耗*/
+	private BigDecimal cost;
+	/**validBalance*/
+	private BigDecimal validBalance;
+	/**转化数*/
+	private Long convertNum;
+	/**转化成本*/
+	private BigDecimal convertCost;
+	/**次留数*/
+	private Long nextDayOpenNum;
+	/**nextDayOpenCost*/
+	private BigDecimal nextDayOpenCost;
+	/**次留率*/
+	private BigDecimal nextDayOpenRate;
+	/**status*/
+	private Integer status;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

+ 42 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java

@@ -0,0 +1,42 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * 快手预警指标数据
+ */
+@Data
+@TableName("ctop_rule_data_target_kuaishou")
+public class RuleDataTargetKuaishou {
+    
+	/**id*/
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+	/**planId*/
+	private Long planId;
+	/**unitId*/
+	private Long unitId;
+	/**广告位*/
+	private String sceneId;
+	/**地域定向*/
+	private String region;
+	/**gender*/
+	private Integer gender;
+	/**操作系统*/
+	private Integer platformOs;
+	/**手机品牌*/
+	private String deviceBrand;
+	/**手机价格*/
+	private String devicePrice;
+	/**智能扩量*/
+	private Integer isOpen;
+	/**过滤已转化人群*/
+	private Integer filterConvertedLevel;
+	/**投放时段*/
+	private String scheduleTime;
+
+	private Integer status;
+}

+ 27 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDatePlanKuaishou.java

@@ -0,0 +1,27 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * 预警快手计划数据清洗
+ */
+@Data
+@TableName("ctop_rule_date_plan_kuaishou")
+public class RuleDatePlanKuaishou {
+    
+	/**id*/
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+	/**accountName*/
+	private String accountName;
+	/**planId*/
+	private Long planId;
+	/**planName*/
+	private String planName;
+
+	private Integer status;
+
+}

+ 50 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java

@@ -0,0 +1,50 @@
+package cn.com.ctop.common.module.entity;
+
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 快手预警组数据
+ */
+@Data
+@TableName("ctop_rule_data_unit_kuaishou")
+public class RuleDateUnitKuaishou {
+    
+	/**id*/
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+    /**planId*/
+    private Long planId;
+	/**unitId*/
+	private Long unitId;
+	/**unitName*/
+	private String unitName;
+	/**消耗*/
+	private BigDecimal charge;
+
+	private Long convertNum;
+
+	private BigDecimal convertCost;
+
+	/**activation*/
+	private Long activation;
+	/**激活单价*/
+	private BigDecimal activationCost;
+	/**注册数*/
+	private Long eventRegister;
+	/**表单*/
+	private BigDecimal registerCost;
+	/**表单*/
+	private Long formCount;
+	/**表单提交单价*/
+	private BigDecimal formCost;
+	/**付费*/
+	private Long eventPay;
+	/**付费单价*/
+	private BigDecimal payCost;
+
+    private Integer status;
+
+}

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java

@@ -126,6 +126,13 @@ public class UserAllocation implements Serializable {
     private Integer landingPage;
 
     /**
+     * 是否开启删评论
+     * 0 启动
+     * 1 禁用
+     */
+    private Integer deleteComment;
+
+    /**
      * 修改时间
      */
     @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手预警数据账户维度
+ */
+public interface RuleDataAccountKuaishouMapper extends BaseMapper<RuleDataAccountKuaishou> {
+
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手预警指标数据
+ */
+public interface RuleDataTargetKuaishouMapper extends BaseMapper<RuleDataTargetKuaishou> {
+
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 预警快手计划数据清洗
+ */
+public interface RuleDatePlanKuaishouMapper extends BaseMapper<RuleDatePlanKuaishou> {
+
+}

+ 12 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDateUnitKuaishouMapper.java

@@ -0,0 +1,12 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 预警快手计划数据清洗
+ */
+public interface RuleDateUnitKuaishouMapper extends BaseMapper<RuleDateUnitKuaishou> {
+
+}

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

@@ -31,4 +31,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     UserAllocation getUserAllocation(@Param("accountId") Long accountId);
 
     JSONObject getSwitchStatusByAccount(@Param("accountId") Long accountId);
+
+    List<Long>  queryAccountsByDeleteComment();
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataAccountKuaishouMapper.xml

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

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataTargetKuaishouMapper.xml

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

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDatePlanKuaishouMapper.xml

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

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

@@ -85,5 +85,16 @@
             account_id = #{accountId}
     </select>
 
+    <select id="queryAccountsByDeleteComment" resultType="java.lang.Long">
+        SELECT
+            account_id
+        FROM
+            ctop_user_allocation
+        WHERE
+            media_id = 2
+          AND account_status = 0
+          AND delete_comment = 0
+    </select>
+
 
 </mapper>

+ 13 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataAccountKuaishouService.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *  快手预警数据账户维度
+ */
+public interface IRuleDataAccountKuaishouService extends IService<RuleDataAccountKuaishou> {
+
+    JSONObject getKuaiShouRuleDataByAccountId(Long accountId);
+}

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataTargetKuaishouService.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 快手预警指标数据
+ */
+public interface IRuleDataTargetKuaishouService extends IService<RuleDataTargetKuaishou> {
+
+}

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataUnitKuaishouService.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *  组维度数据清洗
+ */
+public interface IRuleDataUnitKuaishouService extends IService<RuleDateUnitKuaishou> {
+
+}

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDatePlanKuaishouService.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 预警快手计划数据清洗
+ */
+public interface IRuleDatePlanKuaishouService extends IService<RuleDatePlanKuaishou> {
+
+}

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -36,4 +36,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     List<UserAllocation> getUserAllocations(String mediaId ,int switchType);
 
     JSONObject getSwitchStatusByAccount(Long accountId);
+
+    List<Long> getAccountsByDeleteComment();
 }

+ 57 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataAccountKuaishouServiceImpl.java

@@ -0,0 +1,57 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDataAccountKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDataTargetKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDatePlanKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDateUnitKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手预警数据账户维度
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Service
+public class RuleDataAccountKuaishouServiceImpl extends ServiceImpl<RuleDataAccountKuaishouMapper, RuleDataAccountKuaishou> implements IRuleDataAccountKuaishouService {
+
+    @Autowired
+    private RuleDataAccountKuaishouMapper ruleDataAccountKuaishouMapper;
+    @Autowired
+    private RuleDataTargetKuaishouMapper ruleDataTargetKuaishouMapper;
+    @Autowired
+    private RuleDateUnitKuaishouMapper ruleDateUnitKuaishouMapper;
+    @Autowired
+    private RuleDatePlanKuaishouMapper ruleDatePlanKuaishouMapper;
+
+    @Override
+    public JSONObject getKuaiShouRuleDataByAccountId(Long accountId) {
+        JSONObject obj = new JSONObject();
+        Map<String, Object> map = new HashMap<>();
+        map.put("account_id", accountId);
+        map.put("status", NoEn.NO1.valueInt());
+        List<RuleDataAccountKuaishou> accountList = ruleDataAccountKuaishouMapper.selectByMap(map);
+        obj.put("account", accountList);
+        List<RuleDateUnitKuaishou> unitKuaishous = ruleDateUnitKuaishouMapper.selectByMap(map);
+        obj.put("unit", unitKuaishous);
+        List<RuleDataTargetKuaishou> targetKuaishous = ruleDataTargetKuaishouMapper.selectByMap(map);
+        obj.put("target", targetKuaishous);
+        List<RuleDatePlanKuaishou> planKuaishous = ruleDatePlanKuaishouMapper.selectByMap(map);
+        obj.put("plan", planKuaishous);
+        return obj;
+    }
+}

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataTargetKuaishouServiceImpl.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDataTargetKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDataTargetKuaishouService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手预警指标数据
+ */
+@Service
+public class RuleDataTargetKuaishouServiceImpl extends ServiceImpl<RuleDataTargetKuaishouMapper, RuleDataTargetKuaishou> implements IRuleDataTargetKuaishouService {
+
+}

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataUnitKuaishouServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDateUnitKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDataUnitKuaishouService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 组维度数据清洗
+ * @author jeecg-boot
+ * @date   2020-12-04
+ * @version V1.0
+ */
+@Service
+public class RuleDataUnitKuaishouServiceImpl extends ServiceImpl<RuleDateUnitKuaishouMapper, RuleDateUnitKuaishou> implements IRuleDataUnitKuaishouService {
+
+}

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDatePlanKuaishouServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDatePlanKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDatePlanKuaishouService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 预警快手计划数据清洗
+ * @author jeecg-boot
+ * @date   2020-12-04
+ * @version V1.0
+ */
+@Service
+public class RuleDatePlanKuaishouServiceImpl extends ServiceImpl<RuleDatePlanKuaishouMapper, RuleDatePlanKuaishou> implements IRuleDatePlanKuaishouService {
+
+}

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

@@ -134,4 +134,9 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public JSONObject getSwitchStatusByAccount(Long accountId) {
         return userAllocationMapper.getSwitchStatusByAccount(accountId);
     }
+
+    @Override
+    public List<Long> getAccountsByDeleteComment() {
+        return userAllocationMapper.queryAccountsByDeleteComment();
+    }
 }

+ 5 - 5
module-crawler/src/main/java/cn/com/ctop/crawler/modules/taobao/service/impl/TaobaoJhsbybtServiceImpl.java

@@ -138,19 +138,19 @@ public class TaobaoJhsbybtServiceImpl implements TaobaoJhsbybtService {
 
     public static void main(String[] args) {
         try {
-            PrintStream out = new PrintStream("D:/bybt1102.csv");
+            PrintStream out = new PrintStream("D:/bybt1208.csv");
             System.setOut(out);
         } catch (FileNotFoundException e) {
             e.printStackTrace();
         }
+
+        Boolean hasMore = true;
         System.out.println("商品id,商品名,销量,商品logo,设计图,商品图,商品链接,正常价,,,补贴价,补贴券");
 
         TaobaoJhsbybtServiceImpl tb = new TaobaoJhsbybtServiceImpl();
-        tb.taobaoLogin("流行之道","xzy19890417");
-//        tb.taobaoLogin("m228419161","cxq121119..");
+//        tb.taobaoLogin("流行之道","xzy19890417");
+        tb.taobaoLogin("m228419161","cxq121119..");
         int i = 1;
-
-        Boolean hasMore = true;
         while (hasMore) {
             try {
                 String result = tb.getGoodsList(i);

+ 53 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouDeleteCommentJob.java

@@ -0,0 +1,53 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCommentService;
+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.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class KuaiShouDeleteCommentJob {
+
+    @Autowired
+    private IUserAllocationService allocationService;
+
+    @Autowired
+    private IKuaiShouCommentService kuaiShouCommentService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    static CountDownLatch countDownLatch = null;
+
+    @XxlJob("kuaiShouDeleteCommentJob")
+    public void kuaiShouDeleteComment(){
+        Long start = System.currentTimeMillis();
+        //查询需要删除的账户
+        List<Long> accountIds = allocationService.getAccountsByDeleteComment();
+        if (!accountIds.isEmpty()) {
+            countDownLatch = new CountDownLatch(accountIds.size());
+            accountIds.forEach(accountId -> executorService.submit(() -> {
+                try {
+                    kuaiShouCommentService.shieldComment(accountId);
+                } catch (Exception e) {
+                    XxlJobHelper.log(e.getMessage(), e);
+                } finally {
+                    countDownLatch.countDown();
+                }
+            }));
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            Long end = System.currentTimeMillis();
+            XxlJobHelper.log("快手删评论所用时长:{}毫秒", end - start);
+        }
+    }
+}

+ 32 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java

@@ -0,0 +1,32 @@
+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.kuaishou.modules.report.service.IRuleKuaiShouAccountService;
+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 RuleKuaiShouDataAccountCleanJob {
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouAccountService ruleKuaiShouAccountService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataAccountCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警账户维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(()->ruleKuaiShouAccountService.cleanRuleDataAccount(token.getAccountId())));
+    }
+}

+ 31 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java

@@ -0,0 +1,31 @@
+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.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+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 RuleKuaiShouDataPlanCleanJob {
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataPlanCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警计划维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(()->ruleKuaiShouPlanService.cleanRuleDataPlan(token.getAccountId(),1)));
+    }
+}

+ 34 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java

@@ -0,0 +1,34 @@
+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.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+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.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class RuleKuaiShouDataTargetCleanJob {
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataTargetCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警定向维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() -> ruleKuaiShouPlanService.cleanRuleDataTarget(token.getAccountId(), 1)));
+    }
+
+}

+ 32 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java

@@ -0,0 +1,32 @@
+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.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+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 java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class RuleKuaiShouDataUnitCleanJob {
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataUnitCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警组维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() -> ruleKuaiShouPlanService.cleanRuleDataUnit(token.getAccountId(), DateUtils.date2Str(), DateUtils.date2Str(), 1)));
+    }
+
+}

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

@@ -243,6 +243,7 @@ public class CrossAccountBatchController {
                     createUnitArr = crossAccountBatchService.assembleUnitArray(oauthToken, createUnitArr, campaignList);
                 }
             }
+            System.err.println("组装数据:"+createUnitArr);
             JSONArray returnArray = crossAccountBatchService.createUnit(createUnitArr);
             System.err.println(returnArray);
             result.setSuccess(true);
@@ -275,6 +276,7 @@ public class CrossAccountBatchController {
                 JSONObject accountJson = accountArr.getJSONObject(i);
                 creativeArray = crossAccountBatchService.assembleCreativeJson(creativeArray, accountJson);
             }
+            System.err.println("组装数据:"+creativeArray);
             JSONArray returnArray = crossAccountBatchService.createCreative(creativeArray);
             System.err.println(returnArray);
             result.setSuccess(true);

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,4 +18,6 @@ public interface KuaiShouCampaignMapper extends BaseMapper<KuaiShouCampaign> {
     void replaceBatch(@Param(value = "campaigns") List<KuaiShouCampaign> campaigns);
 
     List<Long> queryIdsByPutStatus(Long accountId,String putStatus);
+
+    JSONArray queryCampaignIdByAccountId(Long accountId);
 }

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

@@ -41,4 +41,10 @@
         WHERE account_id = #{accountId}
         AND put_status = #{putStatus}
     </select>
+    <select id="queryCampaignIdByAccountId" resultType="java.lang.Long">
+        SELECT campaign_id
+        FROM
+        ctop_kuaishou_campaign
+        WHERE account_id = #{accountId}
+    </select>
 </mapper>

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

@@ -58,7 +58,7 @@ public interface IKuaiShouUpdateService {
      * @param token
      * @param advertiserId
      * @param unitId
-     * @param putStatus
+     * @param putStatus 1-投放、2-暂停、3-删除,传其他数字非法
      * @return
      */
     Map<String, Object> updateUnitStatus(String token, Long advertiserId, Long unitId, int putStatus, String loginId);

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

@@ -5,8 +5,10 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +69,8 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
             for (int j = 0; j < unitNames.size(); j++) {
                 String unitName = unitNames.getString(j);
                 if (!Check.isNull(unitName)) {
+                    String s = JSON.toJSONString(createUnitJson, SerializerFeature.DisableCircularReferenceDetect);
+                    createUnitJson = JSON.parseObject(s);
                     createUnitJson.remove("campaign_id");
                     createUnitJson.remove("unit_name");
                     createUnitJson.put("campaign_id", campaignId);
@@ -107,6 +111,9 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
 
                 JSONObject createUnitJson = this.getCreateUnitJson(unitIdenticalJson);// 通用参数组装
                 for (int j = 0; j < unitNames.size(); j++) {
+                    String s = JSON.toJSONString(createUnitJson, SerializerFeature.DisableCircularReferenceDetect);
+                    createUnitJson = JSON.parseObject(s);
+
                     String unitName = unitNames.getString(j);
                     createUnitJson.put("advertiser_id", oauthToken.getAccountId());
                     createUnitJson.put("access_token", oauthToken.getAccessToken());
@@ -192,6 +199,15 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
         }
 
 
+        String clickTrackUrl = accountJson.getString("clickTrackUrl");
+        String impressionUrl = accountJson.getString("impressionUrl");
+        String adPhotoPlayedT3sUrl = accountJson.getString("adPhotoPlayedT3sUrl");
+        Integer creativeCategory = accountJson.getInteger("creativeCategory");
+        JSONArray creativeTag = accountJson.getJSONArray("creativeTag");
+        String actionBarText = accountJson.getString("actionBarText");
+        String siteId = accountJson.getString("siteId");
+
+
         for (int i = 0; i < photoArr.size(); i++) {
             JSONObject photoJson = photoArr.getJSONObject(i);
             if (Check.isNull(photoJson)) {
@@ -201,89 +217,122 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
             creativeJson.put("advertiser_id", oauthToken.getAccountId());
             creativeJson.put("access_token", oauthToken.getAccessToken());
             creativeJson.put("unit_id", unitId);
-            if (!Check.isNull(photoJson.getString("clickTrackUrl"))) {
-                creativeJson.put("click_track_url", photoJson.getString("clickTrackUrl")); //第三方点击检测链接
+            creativeJson.put("unit_name", accountJson.getString("unitName"));
+            if (!Check.isNull(clickTrackUrl)) {
+                creativeJson.put("click_track_url", clickTrackUrl); //第三方点击检测链接
             }
-            if (!Check.isNull(photoJson.getString("impressionUrl"))) {
-                creativeJson.put("impression_url", photoJson.getString("impressionUrl")); //第三方开始播放监测链接
+            if (!Check.isNull(impressionUrl)) {
+                creativeJson.put("impression_url", impressionUrl); //第三方开始播放监测链接
             }
-            if (!Check.isNull(photoJson.getString("adPhotoPlayedT3sUrl"))) {
-                creativeJson.put("ad_photo_played_t3s_url", photoJson.getString("adPhotoPlayedT3sUrl")); //第三方有效播放监测链接
+            if (!Check.isNull(adPhotoPlayedT3sUrl)) {
+                creativeJson.put("ad_photo_played_t3s_url", adPhotoPlayedT3sUrl); //第三方有效播放监测链接
             }
             if (!Check.isNull(photoJson.getString("actionbarClickUrl"))) {
                 creativeJson.put("actionbar_click_url", photoJson.getString("actionbarClickUrl")); //第三方点击按钮监测链接
             }
-            if (!Check.isNull(photoJson.getInteger("creativeCategory"))) {
-                creativeJson.put("creative_category", photoJson.getInteger("creativeCategory")); // 创意分类
+            if (!Check.isNull(creativeCategory)) {
+                creativeJson.put("creative_category", creativeCategory); // 创意分类
             }
-            if (!Check.isNull(photoJson.getJSONArray("creativeTag"))) {
-                creativeJson.put("creative_tag", photoJson.getJSONArray("creativeTag")); //创意标签
+            if (!Check.isNull((creativeTag))) {
+                creativeJson.put("creative_tag", creativeTag); //创意标签
             }
 
             Long creativeMaterialType = photoJson.getLong("creativeMaterialType");
 
             JSONArray creatives = new JSONArray();
-            JSONObject createJson = new JSONObject();
-            if (!Check.isNull(photoJson.getString("creativeName"))) {
-                createJson.put("creative_name", photoJson.getString("creativeName")); // 创意名称
-            }
-            if (!Check.isNull(creativeMaterialType)) {
-                createJson.put("creative_material_type", creativeMaterialType); // 素材类型
-            }
-            if (!Check.isNull(photoJson.getString("actionBar_text"))) {
-                createJson.put("action_bar_text", photoJson.getString("actionBarText")); // 行动号召按钮文案
-            }
-            if (!Check.isNull(photoJson.getString("description"))) {
-                createJson.put("description", photoJson.getString("description")); // 广告语
-            }
-            if (!Check.isNull(photoJson.getString("stickerTitle"))) {
-                createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
-            }
-            if (!Check.isNull(photoJson.getString("overlayType"))) {
-                createJson.put("overlay_type", photoJson.getString("overlayType")); // 贴纸样式类型
-            }
-            if (!Check.isNull(photoJson.getString("exposeTag"))) {
-                createJson.put("expose_tag", photoJson.getString("exposeTag")); //广告标签
-            }
-            if (!Check.isNull(photoJson.getString("newExposeTag"))) {
-                createJson.put("new_expose_tag", photoJson.getString("newExposeTag")); // 广告标签2期
-            }
-            if (!Check.isNull(photoJson.getString("siteId"))) {
-                createJson.put("site_id", photoJson.getString("siteId")); //安卓下载中间页ID
-            }
-
             String creativeName = photoJson.getString("creativeName");// 创意名称
             if (4 == creativeMaterialType) { // 便利贴组装数据
-                if (!Check.isNull(photoJson.getString("shortSlogan"))) {
-                    createJson.put("short_slogan", photoJson.getString("shortSlogan")); // 便利贴创意短广告语
-                }
+
                 JSONArray imageTokens = photoJson.getJSONArray("imageTokens");
                 for (int j = 0; j < imageTokens.size(); j++) {
                     String imageToken = imageTokens.getString(j);
                     if (!Check.isNull(imageToken)) {
-                        createJson.put("image_tokens", imageToken); // 便利贴创意短广告语
+                        JSONObject createJson = new JSONObject();
+                        if (!Check.isNull(photoJson.getString("shortSlogan"))) {
+                            createJson.put("short_slogan", photoJson.getString("shortSlogan")); // 便利贴创意短广告语
+                        }
+                        if (!Check.isNull(creativeMaterialType)) {
+                            createJson.put("creative_material_type", creativeMaterialType); // 素材类型
+                        }
+                        if (!Check.isNull(actionBarText)) {
+                            createJson.put("action_bar_text", actionBarText); // 行动号召按钮文案
+                        }
+                        if (!Check.isNull(photoJson.getString("description"))) {
+                            createJson.put("description", photoJson.getString("description")); // 广告语
+                        }
+                        if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                            createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                        }
+                        if (!Check.isNull(photoJson.getString("overlayType"))) {
+                            createJson.put("overlay_type", photoJson.getString("overlayType")); // 贴纸样式类型
+                        }
+                        if (!Check.isNull(photoJson.getString("exposeTag"))) {
+                            createJson.put("expose_tag", photoJson.getString("exposeTag")); //广告标签
+                        }
+                        if (!Check.isNull(photoJson.getString("newExposeTag"))) {
+                            createJson.put("new_expose_tag", photoJson.getString("newExposeTag")); // 广告标签2期
+                        }
+                        if (!Check.isNull(siteId)) {
+                            createJson.put("site_id", siteId); //安卓下载中间页ID
+                        }
+                        JSONArray imageTokenArr = new JSONArray();
+                        imageTokenArr.add(imageToken);
+                        createJson.put("image_tokens", imageTokenArr); // 便利贴创意短广告语
                         if (!Check.isNull(creativeName)) {
                             createJson.put("creative_name", creativeName + "_" + RandomUtil.verifyCodeV2()); // 便利贴创意短广告语
                         }
                         creatives.add(createJson);
                     }
                 }
-
+                creativeJson.put("creatives", creatives);
             } else { //  非便利贴组装数据
-                if (!Check.isNull(photoJson.getLong("photoId"))) {
-                    createJson.put("photo_id", photoJson.getLong("photoId")); // 视频id
-                }
-                JSONArray imageTokenArr = photoJson.getJSONArray("imageToken");
+                JSONArray imageTokenArr = photoJson.getJSONArray("imageTokenArr");
                 if (Check.isNull(imageTokenArr)) { // 如果图片为空 说明是首帧创建
+                    JSONObject createJson = new JSONObject();
+                    if (!Check.isNull(photoJson.getLong("photoId"))) {
+                        createJson.put("photo_id", photoJson.getLong("photoId")); // 视频id
+                    }
                     createJson.put("creative_name", creativeName); // 创意名称
+                    if (!Check.isNull(creativeMaterialType)) {
+                        createJson.put("creative_material_type", creativeMaterialType); // 素材类型
+                    }
+                    if (!Check.isNull(actionBarText)) {
+                        createJson.put("action_bar_text", actionBarText); // 行动号召按钮文案
+                    }
+                    if (!Check.isNull(photoJson.getString("description"))) {
+                        createJson.put("description", photoJson.getString("description")); // 广告语
+                    }
+                    if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                        createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                    }
+                    if (!Check.isNull(photoJson.getString("overlayType"))) {
+                        createJson.put("overlay_type", photoJson.getString("overlayType")); // 贴纸样式类型
+                    }
+                    if (!Check.isNull(photoJson.getString("exposeTag"))) {
+                        createJson.put("expose_tag", photoJson.getString("exposeTag")); //广告标签
+                    }
+                    if (!Check.isNull(photoJson.getString("newExposeTag"))) {
+                        createJson.put("new_expose_tag", photoJson.getString("newExposeTag")); // 广告标签2期
+                    }
+                    if (!Check.isNull(siteId)) {
+                        createJson.put("site_id", siteId); //安卓下载中间页ID
+                    }
+
+                    if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                        createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                    }
+
                     creatives.add(createJson);
                 } else { // 选择多张图片进行创建
                     for (int j = 0; j < imageTokenArr.size(); j++) {
                         String signature = imageTokenArr.getString(j);
-
                         if (Check.isNull(signature)) {
                             continue;
                         }
+                        JSONObject createJson = new JSONObject();
+                        if (!Check.isNull(photoJson.getLong("photoId"))) {
+                            createJson.put("photo_id", photoJson.getLong("photoId")); // 视频id
+                        }
                         QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
                         queryWrapper.eq("account_id", accountId);
                         queryWrapper.eq("signature", signature);
@@ -301,6 +350,31 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         }
                         String name = creativeName + "_" + RandomUtil.verifyCodeV2();
                         createJson.put("creative_name", name); // 创意名称
+                        if (!Check.isNull(creativeMaterialType)) {
+                            createJson.put("creative_material_type", creativeMaterialType); // 素材类型
+                        }
+                        if (!Check.isNull(actionBarText)) {
+                            createJson.put("action_bar_text", actionBarText); // 行动号召按钮文案
+                        }
+                        if (!Check.isNull(photoJson.getString("description"))) {
+                            createJson.put("description", photoJson.getString("description")); // 广告语
+                        }
+
+                        if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                            createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                        }
+                        if (!Check.isNull(photoJson.getString("overlayType"))) {
+                            createJson.put("overlay_type", photoJson.getString("overlayType")); // 贴纸样式类型
+                        }
+                        if (!Check.isNull(photoJson.getString("exposeTag"))) {
+                            createJson.put("expose_tag", photoJson.getString("exposeTag")); //广告标签
+                        }
+                        if (!Check.isNull(photoJson.getString("newExposeTag"))) {
+                            createJson.put("new_expose_tag", photoJson.getString("newExposeTag")); // 广告标签2期
+                        }
+                        if (!Check.isNull(siteId)) {
+                            createJson.put("site_id", siteId); //安卓下载中间页ID
+                        }
                         creatives.add(createJson);
                     }
 
@@ -308,8 +382,8 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
 
 
             }
-            createJson.put("creatives", creatives);
-            creativeArray.add(createJson);
+            creativeJson.put("creatives", creatives);
+            creativeArray.add(creativeJson);
         }
 
         return creativeArray;
@@ -375,11 +449,13 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         thread.start();
                         returnJson.put("code", 0);
                         returnJson.put("accountId", requestJson.getLong("advertiser_id"));
+                        returnJson.put("campaignId", requestJson.getLong("campaign_id"));
                         returnJson.put("unitId", unitId);
                         returnJson.put("accountName", requestJson.getString("account_name"));
                         returnJson.put("unitName", requestJson.getString("unit_name"));
                         returnJson.put("sceneId", requestJson.getJSONArray("scene_id").toJSONString());
                         returnJson.put("ocpxActionType", requestJson.getLong("ocpx_action_type"));
+                        returnJson.put("bidType", requestJson.getLong("bid_type"));
                         returnJson.put("unitType", requestJson.getInteger("unit_type"));
                     }
 
@@ -465,7 +541,9 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         };
                         thread.start();
                         retuenJson.put("code", 0);
-                        retuenJson.put("unit_id", requestJson.getString("unit_id"));
+                        retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+                        retuenJson.put("unitId", requestJson.getString("unit_id"));
+                        retuenJson.put("unitName", requestJson.getString("unit_name"));
                     }
                 } else {
                     if (code == 500000 && count <= 4) {
@@ -477,7 +555,9 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                     log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson, count + 1);
                     retuenJson.put("code", -1);
                     retuenJson.put("message", resultJson.getString("message"));
-                    retuenJson.put("unit_id", requestJson.getString("unit_id"));
+                    retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+                    retuenJson.put("unitId", requestJson.getString("unit_id"));
+                    retuenJson.put("unitName", requestJson.getString("unit_name"));
                 }
             } else {
                 if (count <= 4) {
@@ -486,14 +566,18 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                 log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 retuenJson.put("code", -1);
                 retuenJson.put("message", "创建创意失败,返回信息为空");
-                retuenJson.put("unit_id", requestJson.getString("unit_id"));
+                retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+                retuenJson.put("unitId", requestJson.getString("unit_id"));
+                retuenJson.put("unitName", requestJson.getString("unit_name"));
             }
 
         } catch (Exception e) {
             log.error("创建广告创意失败,advertiser_id:{}", requestJson.getLong("advertiser_id"));
             retuenJson.put("code", -1);
             retuenJson.put("message", e.getMessage());
-            retuenJson.put("unit_id", requestJson.getString("unit_id"));
+            retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+            retuenJson.put("unitId", requestJson.getString("unit_id"));
+            retuenJson.put("unitName", requestJson.getString("unit_name"));
             e.printStackTrace();
         }
         return retuenJson;

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

@@ -893,6 +893,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             Date getStartDate = DateUtils.addDay(endDate, -i);
             //1: 获取广告主信息数据
             getAdvertiserReportHourly(token, getStartDate, getStartDate);
+            getAdvertiserReportDaily(token, getStartDate, getStartDate);
             //2:获取广告计划信息数据
             // getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
             //3:获取广告组信息数据

+ 0 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/entity/KuaishouUserCookie.java

@@ -7,9 +7,7 @@ import lombok.Data;
 @Data
 @TableName("ctop_kuaishou_user_cookie")
 public class KuaishouUserCookie {
-    @TableId
     private String userId;
-    @TableId
     private String ksid;
     private String eid;
     private String cookie;

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaiShouGetAccountFundService.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONObject;
+
+/**
+ *  Created by JQ.bi on 2020.11.15
+ *
+ *  拉取账户余额
+ */
+public interface IKuaiShouGetAccountFundService {
+
+    /**
+     * 获取账号余额信息
+     */
+    JSONObject getAccountFundBy(CtopOauthToken token, Long advertiserId);
+
+    /**
+     * 获取账号余额信息
+     */
+    JSONObject getAccountReportBy(CtopOauthToken token, Long advertiserId);
+
+}

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouAccountService.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+public interface IRuleKuaiShouAccountService {
+
+    void cleanRuleDataAccount(Long accountId);
+
+}

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouPlanService.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+/**
+ *  快手规则引擎数据清洗;计划、组、定向
+ */
+public interface IRuleKuaiShouPlanService {
+
+    /**
+     *  计划
+     */
+    void cleanRuleDataPlan(Long accountId,int page);
+
+    /**
+     *  组
+     */
+    void cleanRuleDataUnit(Long accountId,String startDate, String endDate,int page);
+
+    /**
+     *  定向
+     */
+    void cleanRuleDataTarget(Long accountId,int page);
+
+}

+ 62 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouGetAccountFundServiceImpl.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouGetAccountFundService;
+
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.context.XxlJobHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.constant.SystemDateConstant;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class KuaiShouGetAccountFundServiceImpl implements IKuaiShouGetAccountFundService {
+
+    @Override
+    public JSONObject getAccountFundBy(CtopOauthToken token, Long advertiserId) {
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+
+        JSONObject params=new JSONObject();
+        params.put("advertiser_id",advertiserId);
+
+        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpGetRequest("https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/fund/get", headers,params));
+        if(jsonObject.getInteger("code")!=0){
+            XxlJobHelper.log("查询账户余额失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
+            return null;
+        }
+        return jsonObject.getJSONObject("data");
+    }
+
+    @Override
+    public JSONObject getAccountReportBy(CtopOauthToken token, Long advertiserId) {
+
+        JSONObject result= new JSONObject();
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+
+        String now = DateUtils.getNowDate(SystemDateConstant.yyyy_MM_dd);
+        JSONObject params=new JSONObject();
+        params.put("advertiser_id",advertiserId);
+        params.put("start_date",now);
+        params.put("end_date",now);
+        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/report/account_report", params, headers));
+        if(jsonObject.getInteger("code")!=0){
+            XxlJobHelper.log("账户{}获取实时数据失败---{}",advertiserId,jsonObject.getString("message"));
+        }else {
+            if(!jsonObject.getJSONObject("data").getJSONArray("details").isEmpty()){
+                result= (JSONObject) jsonObject.getJSONObject("data").getJSONArray("details").get(0);
+            }
+        }
+        return result;
+    }
+}

+ 6 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.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.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
@@ -43,6 +44,8 @@ import java.util.Map;
 public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyMapper, KuaishouAudienceReportDaily> implements IKuaishouAudienceReportDailyService {
 
     @Autowired
+    private KuaiShouCampaignMapper kuaiShouCampaignMapper;
+    @Autowired
     private KuaishouAudienceReportDailyProvinceMapper provinceMapper;
     @Autowired
     private KuaishouAudienceReportDailyAgeMapper ageMapper;
@@ -70,6 +73,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
     public void crowdAnalysisReport(CtopOauthToken token, String date, String type, Integer page, Integer pageSize) {
         long start = System.currentTimeMillis();
         try {
+            JSONArray campaignIdList = kuaiShouCampaignMapper.queryCampaignIdByAccountId(token.getAccountId());
             String url = urlPath + KuaishouInterfaceConstant.AUDIENCE_REPORT;
             JSONArray reportDims = new JSONArray();
             reportDims.add(type);
@@ -78,6 +82,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
             headers.put("Content-Type", "application/json");
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", token.getAccountId());
+            requestJson.put("campaign_ids", campaignIdList);
             requestJson.put("start_date", date);
             requestJson.put("end_date", date);
             requestJson.put("report_dims", reportDims);
@@ -91,7 +96,6 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                     JSONObject datas = resultJson.getJSONObject("data");
                     JSONArray details = datas.getJSONArray("details");
                     if (!Check.isNull(details)) {
-                        System.out.println(type + ",size:" + details.size());
                         for (int i = 0; i < details.size(); i++) {
                             JSONObject obj = details.getJSONObject(i);
                             if ("province".equals(type)) {
@@ -145,7 +149,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                             }
                         }
                     }
-                }else{
+                } else {
                     log.error("查询人群分析报表数据返回信息错误:accountId:{},返回信息:{}", token.getAccountId(), resultJson);
                 }
             }

+ 43 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouAccountServiceImpl.java

@@ -0,0 +1,43 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouGetAccountFundService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouAccountService;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RuleKuaiShouAccountServiceImpl implements IRuleKuaiShouAccountService {
+
+    @Autowired
+    IKuaiShouGetAccountFundService kuaiShouGetAccountFundService;
+    @Autowired
+    ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    IRuleDataAccountKuaishouService ruleDataAccountKuaishouService;
+    @Autowired
+    IUserAllocationService userAllocationService;
+
+    @Override
+    public void cleanRuleDataAccount(Long accountId) {
+        CtopOauthToken oauthToken=oauthTokenService.getTokenByAccountId(accountId);
+        //查询账户实时数据
+        JSONObject dataAccount=kuaiShouGetAccountFundService.getAccountReportBy(oauthToken,accountId);
+        if(!dataAccount.isEmpty()){
+            JSONObject fundData=kuaiShouGetAccountFundService.getAccountFundBy(oauthToken,accountId);
+            RuleDataAccountKuaishou ruleDataAccount=new RuleDataAccountKuaishou();
+            ruleDataAccount.setId(accountId);
+            ruleDataAccount.setAccountName(userAllocationService.getByAccountId(accountId).getAuthName());
+            ruleDataAccount.setAccountId(accountId);
+            ruleDataAccount.setCost(dataAccount.getBigDecimal("charge"));
+            ruleDataAccount.setValidBalance(fundData.getBigDecimal("balance"));
+
+            ruleDataAccountKuaishouService.saveOrUpdate(ruleDataAccount);
+        }
+    }
+}

+ 258 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java

@@ -0,0 +1,258 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataTargetKuaishouService;
+import cn.com.ctop.common.module.service.IRuleDataUnitKuaishouService;
+import cn.com.ctop.common.module.service.IRuleDatePlanKuaishouService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.context.XxlJobHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
+
+    @Autowired
+    ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    IRuleDataTargetKuaishouService targetKuaishouService;
+
+    @Autowired
+    IRuleDatePlanKuaishouService planKuaishouService;
+
+    @Autowired
+    IRuleDataUnitKuaishouService unitKuaishouService;
+
+    @Autowired
+    IKuaiShouGroupService kuaiShouGroupService;
+
+    @Override
+    public void cleanRuleDataPlan(Long accountId, int page) {
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", oauthTokenService.getTokenByAccountId(accountId).getAccessToken());
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/campaign/list", param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            XxlJobHelper.log("获取广告计划接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            XxlJobHelper.log("获取广告计划返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        this.insertPlan(accountId, details);
+        cleanRuleDataPlan(accountId, page + 1);
+    }
+
+    @Override
+    public void cleanRuleDataUnit(Long accountId, String startDate, String endDate, int page) {
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+        param.put("start_date",startDate);
+        param.put("end_date",endDate);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", oauthTokenService.getTokenByAccountId(accountId).getAccessToken());
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/report/unit_report", param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            XxlJobHelper.log("获取广告组报表接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            XxlJobHelper.log("获取广告组报表返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        this.insertUnit(accountId, details);
+        cleanRuleDataUnit(accountId, startDate, endDate, page + 1);
+    }
+
+    @Override
+    public void cleanRuleDataTarget(Long accountId, int page) {
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", oauthTokenService.getTokenByAccountId(accountId).getAccessToken());
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/ad_unit/list", param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            XxlJobHelper.log("获取广告组接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            XxlJobHelper.log("获取广告组返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        this.insertTarget(accountId, details);
+        cleanRuleDataTarget(accountId, page + 1);
+    }
+
+    private void insertPlan(Long accountId, JSONArray details) {
+        List<RuleDatePlanKuaishou> batch = new ArrayList<>();
+        details.forEach(detail -> {
+            JSONObject planDetail = (JSONObject) detail;
+            RuleDatePlanKuaishou plan = new RuleDatePlanKuaishou();
+            if (planDetail.getInteger("status") == 4 && planDetail.getInteger("put_status") == 1) {
+                plan.setId(planDetail.getLong("campaign_id"));
+                plan.setAccountId(accountId);
+                plan.setPlanId(planDetail.getLong("campaign_id"));
+                plan.setPlanName(planDetail.getString("campaign_name"));
+                batch.add(plan);
+            }
+        });
+        if(!batch.isEmpty()) {
+            planKuaishouService.saveOrUpdateBatch(batch);
+        }
+    }
+
+    private void insertUnit(Long accountId, JSONArray details) {
+        List<RuleDateUnitKuaishou> batch = new ArrayList<>();
+        details.forEach(detail -> {
+            JSONObject unitDetail = (JSONObject) detail;
+            RuleDateUnitKuaishou unit = new RuleDateUnitKuaishou();
+            QueryWrapper<KuaiShouGroup> wrapper=new QueryWrapper<>();
+            wrapper.eq("unit_id",unitDetail.getLong("unit_id"));
+            KuaiShouGroup group = kuaiShouGroupService.getOne(wrapper);
+            if(group!=null){
+                unit.setId(unitDetail.getLong("unit_id"));
+                unit.setAccountId(accountId);
+                unit.setPlanId(unitDetail.getLong("campaign_id"));
+                unit.setUnitId(unitDetail.getLong("unit_id"));
+                unit.setUnitName(unitDetail.getString("unit_name"));
+                unit.setCharge(unitDetail.getBigDecimal("charge"));
+                //未知优化目标数据存空
+                if(group.getOcpxActionType()!=0){
+                    unit.setConvertNum(handleConvertNum(group.getOcpxActionType(),unitDetail));
+                    if(unit.getConvertNum()!=0){
+                        unit.setConvertCost(unitDetail.getBigDecimal("charge").divide(BigDecimal.valueOf(unit.getConvertNum()), 2, RoundingMode.HALF_UP));
+                    }
+                }
+                batch.add(unit);
+            }
+
+        });
+        if(!batch.isEmpty()){
+            unitKuaishouService.saveOrUpdateBatch(batch);
+        }
+    }
+
+    private void insertTarget(Long accountId, JSONArray details) {
+        List<RuleDataTargetKuaishou> batch = new ArrayList<>();
+        details.forEach(detail -> {
+            JSONObject unitDetail = (JSONObject) detail;
+            RuleDataTargetKuaishou target = new RuleDataTargetKuaishou();
+            if ((unitDetail.getInteger("status") == 20 || unitDetail.getInteger("status") == 19) &&
+                    unitDetail.getInteger("put_status") == 1) {
+                target.setId(unitDetail.getLong("unit_id"));
+                target.setAccountId(accountId);
+                target.setPlanId(unitDetail.getLong("campaign_id"));
+                target.setUnitId(unitDetail.getLong("unit_id"));
+                target.setSceneId(unitDetail.getJSONArray("scene_id")==null?"":unitDetail.getJSONArray("scene_id").toString());
+                target.setRegion(unitDetail.getJSONArray("region")==null?"":unitDetail.getJSONArray("region").toString());
+                target.setGender(unitDetail.getInteger("gender")==null?0:unitDetail.getInteger("gender"));
+                target.setPlatformOs(unitDetail.getInteger("platform_os")==null?0:unitDetail.getInteger("platform_os"));
+                target.setDeviceBrand(unitDetail.getJSONArray("device_brand")==null?"":unitDetail.getJSONArray("device_brand").toString());
+                target.setDevicePrice(unitDetail.getJSONArray("device_price")==null?"":unitDetail.getJSONArray("device_price").toString());
+                target.setFilterConvertedLevel(unitDetail.getInteger("filter_converted_level")==null?0:unitDetail.getInteger("filter_converted_level"));
+                target.setIsOpen(unitDetail.getInteger("is_open")==null?0:unitDetail.getInteger("is_open"));
+                target.setScheduleTime(unitDetail.getString("schedule_time")==null?"":unitDetail.getString("schedule_time"));
+                batch.add(target);
+            }
+        });
+        if (!batch.isEmpty()) {
+            targetKuaishouService.saveOrUpdateBatch(batch);
+        }
+    }
+
+    private Long handleConvertNum(int ocpxActionType,JSONObject detail){
+        Long convertNum=null;
+        switch (ocpxActionType){
+            case 2:
+                convertNum=detail.getLong("submit");
+                break;
+            case 10:
+                convertNum=detail.getLong("show");
+                break;
+            case 11:
+                convertNum=detail.getLong("photo_click");
+                break;
+            case 31:
+                convertNum=detail.getLong("download_completed");
+                break;
+            case 53:
+                convertNum=detail.getLong("event_valid_clues");
+                break;
+            case 180:
+                convertNum=detail.getLong("activation");
+                break;
+            case 190:
+                convertNum=detail.getLong("event_pay");
+                break;
+            case 191:
+                convertNum=detail.getDouble("event_pay_first_day_roi").longValue();
+                break;
+            case 348:
+                convertNum=detail.getLong("event_valid_clues");
+                break;
+            case 383:
+                convertNum=detail.getLong("event_credit_grant_landing_page");
+                break;
+            case 384:
+                convertNum=detail.getLong("event_jin_jian_landing_page");
+                break;
+            case 715:
+                convertNum=detail.getLong("event_add_wechat");
+                break;
+        }
+        return convertNum;
+    }
+}

+ 5 - 13
module-toutiao/src/main/resources/bytedance_config.properties

@@ -1,26 +1,22 @@
 #release
-#bytedance_appid=1635316529903624
+bytedance_appid=1635316529903624
 # bytedance_appid=1634953881401358
-#bytedance_secret=0c51523e90d6166418fc8421a4896808e90e26f4
+bytedance_secret=0c51523e90d6166418fc8421a4896808e90e26f4
 # bytedance_secret=34bc59f53955c66871ce111a1f15a6051cfa3f12
 #release
-#bytedance_api_url=https://ad.oceanengine.com/open_api
-#bytedance_auth_url=https://ad.oceanengine.com/openapi
-
+bytedance_api_url=https://ad.oceanengine.com/open_api
+bytedance_auth_url=https://ad.oceanengine.com/openapi
 #sandbox
 #bytedance_api_url=https://test-ad.toutiao.com/open_api
 #bytedance_auth_url=https://test-ad.toutiao.com/open_api
 #bytedance_callback_url=http://callback.c-top.com.cn/bytedance
-#bytedance_callback_url=http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
+bytedance_callback_url=http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
 bytedance_v2_advertiser_info=/2/advertiser/public_info/
 bytedance_v2_ad_get=/2/ad/get/
-bytedance_v2_advertiser_fund_daily_stat=/2/advertiser/fund/daily_stat/
 bytedance_v2_ad_create=/2/ad/create/
-bytedance_v2_ad_update=/2/ad/update/
 bytedance_v2_ad_update_status=/2/ad/update/status/
 bytedance_v2_ad_update_bid=/2/ad/update/bid/
 bytedance_v2_ad_update_budget=/2/ad/update/budget/
-bytedance_v2_ad_update_reject_reason=2/ad/reject_reason/
 bytedance_v2_campaign_get=/2/campaign/get/
 bytedance_v2_campaign_create=/2/campaign/create/
 bytedance_v2_campaign_update_status=/2/campaign/update/status/
@@ -32,10 +28,6 @@ bytedance_v2_creative_update_status=/2/creative/update/status/
 bytedance_v2_creative_material_get=/2/creative/material/read/
 bytedance_v2_creative_create_v2=/2/creative/create_v2/
 bytedance_v2_creative_get=/2/creative/get/
-bytedance_v2_creative_read=/2/creative/read_v2/
-bytedance_v2_creative_update=/2/creative/update_v2/
-bytedance_v2_creative_reject_reason=/2/creative/reject_reason/
-
 bytedance_v2_advertiser_report_get=/2/report/advertiser/get/
 bytedance_v2_campaign_report_get=/2/report/campaign/get/
 bytedance_v2_ad_report_get=/2/report/ad/get/

+ 2 - 1
pom.xml

@@ -91,7 +91,7 @@
         <java.version>1.8</java.version>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <mybatis-plus.version>3.1.2</mybatis-plus.version>
+        <mybatis-plus.version>3.3.2</mybatis-plus.version>
         <druid.version>1.1.10</druid.version>
         <commons.version>2.6</commons.version>
         <aliyun-java-sdk-core.version>3.5.0</aliyun-java-sdk-core.version>
@@ -476,6 +476,7 @@
             <artifactId>tencentcloud-sdk-java</artifactId>
             <version>3.1.62</version><!-- 注:这里只是示例版本号,请获取并替换为 最新的版本号 -->
         </dependency>
+
     </dependencies>
 
     <dependencyManagement>