Selaa lähdekoodia

Merge remote-tracking branch 'ctop/master'

hcst_sunzhen 5 vuotta sitten
vanhempi
commit
89954b0ef7
100 muutettua tiedostoa jossa 2948 lisäystä ja 565 poistoa
  1. 9 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 3 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  3. 5 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  4. 58 62
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  5. 142 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MediaReportCtrl.java
  6. 22 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  7. 2 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  8. 50 63
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  9. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TransferAccountController.java
  10. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  11. 69 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/BytedanceAreaInfo.java
  12. 81 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/KuaishouMatcostAccountMay.java
  13. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountCpaBidJob.java
  14. 5 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java
  15. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/KuaishouMatcostAccountMayMapper.java
  16. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MediaReportMapper.java
  17. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/KuaishouMatcostAccountMayMapper.xml
  18. 43 76
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml
  19. 412 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml
  20. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ICpaBidWarningService.java
  21. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IKuaishouMatcostAccountMayService.java
  22. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMediaReportService.java
  23. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  24. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  25. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java
  26. 3 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaiShouUploadServiceImpl.java
  27. 43 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaishouMatcostAccountMayServiceImpl.java
  28. 117 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MediaReportServiceImpl.java
  29. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  30. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/MaterialTopVO.java
  31. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileServiceImpl.java
  32. 1 1
      jeecg-boot-module-system/src/main/resources/application-test.yml
  33. 56 19
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  34. 30 0
      module-common/src/main/java/cn/com/ctop/common/module/annotation/AutoLog.java
  35. 42 0
      module-common/src/main/java/cn/com/ctop/common/module/annotation/Dict.java
  36. 25 0
      module-common/src/main/java/cn/com/ctop/common/module/annotation/PermissionData.java
  37. 6 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java
  38. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java
  39. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMapper.java
  40. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/BindAccountLoginMapper.xml
  41. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMapper.xml
  42. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectService.java
  43. 13 11
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountLoginServiceImpl.java
  44. 0 2
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  45. 4 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectServiceImpl.java
  46. 0 7
      module-common/src/main/java/cn/com/ctop/common/module/utils/CosUtils.java
  47. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/ResultMapUtils.java
  48. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java
  49. 2 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinApp.java
  50. 1 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportAppHour.java
  51. 2 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportBillMonth.java
  52. 1 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportChannelDaily.java
  53. 13 13
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinAppMapper.xml
  54. 19 19
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportAppHourMapper.xml
  55. 4 4
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportBillMonthMapper.xml
  56. 10 12
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportChannelDailyMapper.xml
  57. 2 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinAppService.java
  58. 16 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinAppServiceImpl.java
  59. 24 13
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java
  60. 0 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java
  61. 5 6
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java
  62. 22 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceAccountBidJob.java
  63. 55 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceCampaignDailyReportLoadJob.java
  64. 54 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceCampaignHourlyReportLoadJob.java
  65. 22 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountBidJob.java
  66. 7 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSuZaoLoadJob.java
  67. 29 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  68. 0 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  69. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  70. 0 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoTimeService.java
  71. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  72. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouMaterialUploadServiceImpl.java
  73. 49 67
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  74. 0 64
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoTimeServiceImpl.java
  75. 45 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  76. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/IKuaishouBidWarningService.java
  77. 161 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/KuaishouBidWarningServiceImpl.java
  78. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml
  79. 259 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/BytedanceAreaInfoController.java
  80. 171 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/BytedanceInterestCategoryController.java
  81. 72 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/entity/BytedanceAreaInfo.java
  82. 73 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/entity/BytedanceInterestCategory.java
  83. 15 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/mapper/BytedanceAreaInfoMapper.java
  84. 7 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/mapper/BytedanceInterestCategoryMapper.java
  85. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/mapper/xml/BytedanceAreaInfoMapper.xml
  86. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/mapper/xml/BytedanceInterestCategoryMapper.xml
  87. 16 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/IBytedanceAreaInfoService.java
  88. 14 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/IBytedanceGroupApiService.java
  89. 7 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/IBytedanceInterestCategoryService.java
  90. 33 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/impl/BytedanceAreaInfoServiceImpl.java
  91. 142 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/impl/BytedanceGroupApiServiceImpl.java
  92. 11 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/impl/BytedanceInterestCategoryServiceImpl.java
  93. 4 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceCampaign.java
  94. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java
  95. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceBidWarningService.java
  96. 4 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  97. 168 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceBidWarningServiceImpl.java
  98. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/ByteDanceVideoReportDaily.java
  99. 3 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java
  100. 0 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml

+ 9 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -32,6 +32,15 @@ public class DateUtils extends PropertyEditorSupport {
     private static final long SECOND_IN_MILLIS = 1000L;
 
 
+    public static Date getNowDate() throws ParseException {
+        SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
+        String nowDate = getNowDate("yyyy-MM-dd");
+        Date parse = dsdf.parse(nowDate);
+        return parse;
+
+    }
+
+
     public static boolean compare(String beginDate, String nowDate) throws ParseException {
         //如果想比较日期则写成"yyyy-MM-dd"就可以了
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

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

@@ -1,7 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.*;
@@ -20,11 +23,8 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.entity.Advertiser;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.vo.SheetInfoVo;
 import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
 import org.jeecg.modules.system.entity.SysCategory;

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

@@ -314,11 +314,11 @@ public class CallbackController {
                             CtopOauthToken token = new CtopOauthToken(advertiserId, data);
                             ctopOauthTokenService.saveOrUpdate(token);
                             //获取广告主信息
-                            Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
+                            Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(advertiser_id1 + "", data.getString("access_token"));
                             Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
                             if (null == getSuccess || !getSuccess) {
                                 log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
-                                text.append("账户id:" + advertiser_id + "暂未获取数据权限,请检查账户")
+                                text.append("账户id:" + advertiser_id + "暂未获取数据权限,请检查账户")
                                         .append("<br/>");
                                 continue;
                             }
@@ -335,7 +335,7 @@ public class CallbackController {
                                         .append("<br/>");
                                 continue;
                             }
-                            text.append("accountId:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
+                            text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
                             String systemType = json.getString("systemType");
                             UserAllocation userAllocation = new UserAllocation();
                             userAllocation.setUserId(userId);
@@ -368,11 +368,11 @@ public class CallbackController {
                     CtopOauthToken token = new CtopOauthToken(advertiserId, data);
                     ctopOauthTokenService.saveOrUpdate(token);
                     //获取广告主信息
-                    Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
+                    Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(advertiser_id + "", data.getString("access_token"));
                     Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
                     if (null == getSuccess || !getSuccess) {
                         log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
-                        text.append("accountId:" + advertiser_id + "暂未获取数据权限,请检查账户")
+                        text.append("账户id:" + advertiser_id + ",暂未获取数据权限,请检查账户")
                                 .append("<br/>");
                         continue;
                     }

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

@@ -25,10 +25,8 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -342,77 +340,75 @@ public class MaterialInfoController {
         Result<MaterialInfo> result = new Result<>();
         MaterialInfo materialInfoEntity = materialInfoService.getById(materialInfo.getId());
         if (materialInfoEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            String url = materialInfo.getUrl();
-            if (!Check.isNull(url)) {
-                if (!url.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
-                    url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
-                }
-                materialInfo.setUrl(url);
+            return result.error500("未找到对应实体");
+        }
+        String url = materialInfo.getUrl();
+        if (!Check.isNull(url)) {
+            if (!url.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
+                url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
             }
+            materialInfo.setUrl(url);
+        }
 
-            //  修改素材库 相关联code
-            if (!Check.isNull(materialInfo.getCode())) {
-                String code = materialInfoEntity.getCode();
-                if (!Check.isNull(code)) {
-                    MaterialTag updateMaterialTag = new MaterialTag();
-                    updateMaterialTag.setMaterialId(materialInfo.getCode());
-                    QueryWrapper<MaterialTag> tagQueryWrapper = new QueryWrapper<>();
-                    tagQueryWrapper.eq("material_id", code);
-                    materialTagService.update(updateMaterialTag, tagQueryWrapper);
-                    MaterialParameter updateParameter = new MaterialParameter();
-                    updateParameter.setMaterialId(materialInfo.getCode());
-                    QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
-                    parameterQueryWrapper.eq("material_id", code);
-                    materialParameterService.update(updateParameter, parameterQueryWrapper);
-                    MaterialAscription updateMaterialAscription = new MaterialAscription();
-                    updateMaterialAscription.setMaterialId(materialInfo.getCode());
-                    QueryWrapper<MaterialAscription> ascriptionQueryWrapper = new QueryWrapper<>();
-                    ascriptionQueryWrapper.eq("material_id", code);
-                    materialAscriptionService.update(updateMaterialAscription, ascriptionQueryWrapper);
-                }
+        //  修改素材库 相关联code
+        if (!Check.isNull(materialInfo.getCode())) {
+            String code = materialInfoEntity.getCode();
+            if (!Check.isNull(code)) {
+                MaterialTag updateMaterialTag = new MaterialTag();
+                updateMaterialTag.setMaterialId(materialInfo.getCode());
+                QueryWrapper<MaterialTag> tagQueryWrapper = new QueryWrapper<>();
+                tagQueryWrapper.eq("material_id", code);
+                materialTagService.update(updateMaterialTag, tagQueryWrapper);
+                MaterialParameter updateParameter = new MaterialParameter();
+                updateParameter.setMaterialId(materialInfo.getCode());
+                QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
+                parameterQueryWrapper.eq("material_id", code);
+                materialParameterService.update(updateParameter, parameterQueryWrapper);
+                MaterialAscription updateMaterialAscription = new MaterialAscription();
+                updateMaterialAscription.setMaterialId(materialInfo.getCode());
+                QueryWrapper<MaterialAscription> ascriptionQueryWrapper = new QueryWrapper<>();
+                ascriptionQueryWrapper.eq("material_id", code);
+                materialAscriptionService.update(updateMaterialAscription, ascriptionQueryWrapper);
             }
+        }
 
-            //  审核通过自动同步到到媒体后台
-           /* Long projectId = materialInfoEntity.getProjectId();
-            Project project = projectService.getById(projectId);
-            if (!Check.isNull(projectId)) {
-                if ("2".equals(project.getMediaId())) {
-                    if (!Check.isNull(materialInfo.getStatus())) {
-                        Integer status = materialInfo.getStatus();
-                        if (status == 1) {
-                            Thread thread = new Thread() {
-                                @Override
-                                public void run() {
-                                    log.info("开始自动同步素材,code:{}", materialInfoEntity.getCode());
-                                    uploadService.upload(materialInfoEntity);
-                                }
-                            };
-                            thread.start();
-                        }
+        //  审核通过自动同步到到媒体后台
+       /* Long projectId = materialInfoEntity.getProjectId();
+        Project project = projectService.getById(projectId);
+        if (!Check.isNull(projectId)) {
+            if ("2".equals(project.getMediaId())) {
+                if (!Check.isNull(materialInfo.getStatus())) {
+                    Integer status = materialInfo.getStatus();
+                    if (status == 1) {
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                log.info("开始自动同步素材,code:{}", materialInfoEntity.getCode());
+                                uploadService.upload(materialInfoEntity);
+                            }
+                        };
+                        thread.start();
                     }
                 }
-
-            }*/
-
-            boolean ok = materialInfoService.updateById(materialInfo);
-            if (ok) {
-                result.success("修改成功!");
             }
 
-            Integer status = materialInfo.getStatus();
-            // 如果状态为2 审核拒绝 给上传人发送消息
-            if (status == 2) {
-                Project project = projectService.getById(materialInfoEntity.getProjectId());
-                String text = messageTemplate.getMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
-                sendMessageService.sendMessage(materialInfoEntity.getUserId(), text);
+        }*/
 
-                String feishuText = messageTemplate.getFeishuMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
-                sendMessageService.sendFeishuMessage(materialInfoEntity.getUserId(), feishuText);
-            }
+        boolean ok = materialInfoService.updateById(materialInfo);
+        if (ok) {
+            result.success("修改成功!");
         }
 
+        Integer status = materialInfo.getStatus();
+        // 如果状态为2 审核拒绝 给上传人发送消息
+        if (status == 2) {
+            Project project = projectService.getById(materialInfoEntity.getProjectId());
+            String text = messageTemplate.getMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
+            sendMessageService.sendMessage(materialInfoEntity.getUserId(), text);
+
+            String feishuText = messageTemplate.getFeishuMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
+            sendMessageService.sendFeishuMessage(materialInfoEntity.getUserId(), feishuText);
+        }
         return result;
 
     }

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

@@ -0,0 +1,142 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import cn.com.ctop.common.module.service.ISysCompanyService;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.ctop.service.IMediaReportService;
+ import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  Created by JQ.bi on 2020.6.30
+ */
+@Slf4j
+@RestController
+@RequestMapping("ctop/media/report")
+public class MediaReportCtrl {
+
+    @Autowired
+    ISysCompanyService sysCompanyService;
+
+    @Autowired
+    IMediaReportService mediaReportService;
+
+    @GetMapping("/getCompany")
+    public Result<List<SysCompany>> getCompany(){
+
+        Result<List<SysCompany>> result=new Result<>();
+        //TODO 没有维护渠道的信息暂时不能再库里加,会影响到绩效等其他接口查询公司的接口
+        List<SysCompany> list=sysCompanyService.list();
+        SysCompany sysCompany = new SysCompany();
+        sysCompany.setId(4L);
+        sysCompany.setCompanyId("6weq589875c040119adst08751712368");
+        sysCompany.setCompanyCode("A04");
+        sysCompany.setCompanyName("渠道");
+        sysCompany.setArea("渠道");
+        list.add(sysCompany);
+        result.setSuccess(true);
+        result.setResult(list);
+        return result;
+
+    }
+
+    @GetMapping("/getAdvertiser")
+    public Result<List<JSONObject>> getAdvertiser(String companyId){
+        Result<List<JSONObject>> result=new Result<>();
+        result.setSuccess(true);
+        result.setResult(mediaReportService.queryAdvertiserNameByCompanyId(companyId));
+        return result;
+    }
+
+    @GetMapping("/getProject")
+    public Result<List<JSONObject>> getProject(String advertiserId){
+        Result<List<JSONObject>> result=new Result<>();
+        result.setSuccess(true);
+        result.setResult(mediaReportService.queryProjectNameByAdvertiserId(advertiserId));
+        return result;
+    }
+
+    @PostMapping("/{pageNo}/{pageSize}")
+    public Result<PageInfo<JSONObject>> getReport(@PathVariable int pageNo,
+                                                  @PathVariable int pageSize,
+                                                  @RequestBody JSONObject requestBody){ Result<PageInfo<JSONObject>> result = new Result<>();
+        if(requestBody.isEmpty()){
+            log.error("requestBody is null");
+            result.setSuccess(false);
+            return result;
+        }
+        PageInfo<JSONObject> pageInfo;
+        if(requestBody.getString("companyId").isEmpty()){
+            pageInfo =mediaReportService.queryAllReportByCondition(pageNo,pageSize,requestBody);
+        }else {
+            pageInfo =mediaReportService.queryReportByCondition(pageNo,pageSize,requestBody);
+        }
+        result.setResult(pageInfo);
+        result.setSuccess(true);
+        return result;
+    }
+    /**
+     *  导出数据
+     * @param requestBody
+     * @param request
+     * @param response
+     */
+    @PostMapping("/excel")
+    public void getExcelReport(@RequestBody JSONObject requestBody,
+                               HttpServletRequest request,
+                               HttpServletResponse response) {
+        List<JSONObject> excelData;
+        if(requestBody.getString("companyId").isEmpty()){
+            excelData = mediaReportService.queryAllByCondition(requestBody);
+        }else {
+            excelData =mediaReportService.queryReportByCondition(requestBody);
+        }
+        if(excelData.isEmpty()){
+            return;
+        }
+        List<List<Object>> excelList= new ArrayList<>();
+        excelData.forEach(data->{
+            List<Object> temp= new ArrayList<>();
+            temp.add(data.get("mediaType")==null?"-":data.get("mediaType"));
+            temp.add(data.get("advertiserId")==null?"-":data.get("advertiserId"));
+            temp.add(data.get("advertiserName")==null?"-":data.get("advertiserName"));
+            temp.add(data.get("projectName")==null?"-":data.get("projectName"));
+            temp.add(data.get("operatorManger")==null?"-":data.get("operatorManger"));
+            temp.add(data.get("operator")==null?"-":data.get("operator"));
+            temp.add(data.get("sale")==null?"-":data.get("sale"));
+            temp.add(data.get("plan")==null?"-":data.get("plan"));
+            temp.add(data.get("shot")==null?"-":data.get("shot"));
+            temp.add(data.get("clip")==null?"-":data.get("clip"));
+            temp.add(data.get("todayCost"));
+            temp.add(data.get("yesterdayCost"));
+            temp.add(data.get("diffCost"));
+            excelList.add(temp);
+        });
+        try{
+            String[] headers = {"媒体类型","广告主Id","广告主","项目","运营负责人","运营","销售","策划","拍摄","剪辑",requestBody.getString("todayDate"),requestBody.getString("yesterdayDate"),"消耗差"};
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            eeu.exportExcel(workbook, 0, "媒介报表", headers, excelList);
+            HttpUtils.setResponseHeader(response, "媒介报表.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        }catch (IOException e){
+            log.error(e.getMessage());
+        }
+    }
+}

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

@@ -1,7 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
@@ -17,14 +20,11 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ctop.entity.Advertiser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.entity.TransferAccount;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
 import org.jeecg.modules.system.entity.SysCategory;
 import org.jeecg.modules.system.entity.SysUser;
@@ -173,6 +173,12 @@ public class ProjectController {
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                 HttpServletRequest req) {
         Result<IPage<Project>> result = new Result<>();
+        String advertiserName = project.getAdvertiserName();
+        project.setAdvertiserName(null);
+        String projectName = project.getProjectName();
+        project.setProjectName(null);
+
+
         String industryId = project.getIndustryId();
         project.setIndustryId(null);
         QueryWrapper<Project> queryWrapper = QueryGenerator.initQueryWrapper(project, req.getParameterMap());
@@ -183,12 +189,19 @@ public class ProjectController {
             queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
         }
-        if(null!=industryId&&!"".equals(industryId.trim())){
+        if (null != industryId && !"".equals(industryId.trim())) {
             SysCategory category = sysCategoryService.getById(industryId);
-            if(null!=category){
-                queryWrapper.likeRight("industry_code",category.getCode());
+            if (null != category) {
+                queryWrapper.likeRight("industry_code", category.getCode());
             }
         }
+        if (!Check.isNull(advertiserName)) {
+            queryWrapper.like("advertiser_name", advertiserName);
+
+        }
+        if (!Check.isNull(projectName)) {
+            queryWrapper.like("project_name", projectName);
+        }
         IPage<Project> pageList = projectService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
@@ -217,7 +230,7 @@ public class ProjectController {
                 project.setCompanyId(advertiser.getCompanyId());
             }
             SysCategory category = sysCategoryService.getById(project.getIndustryId());
-            if(null!=category){
+            if (null != category) {
                 project.setIndustryCode(category.getCode());
                 project.setIndustryId(category.getId());
             }
@@ -283,7 +296,7 @@ public class ProjectController {
         }
 
         SysCategory category = sysCategoryService.getById(project.getIndustryId());
-        if(null!=category){
+        if (null != category) {
             project.setIndustryCode(category.getCode());
             project.setIndustryId(category.getId());
         }
@@ -308,7 +321,7 @@ public class ProjectController {
             userAllocationQueryWrapper.eq("project_id", project.getId());
             UserAllocation updateUserAllocation = new UserAllocation();
             updateUserAllocation.setProjectName(project.getProjectName());
-           // updateUserAllocation.setMediaId(project.getMediaId());
+            // updateUserAllocation.setMediaId(project.getMediaId());
             userAllocationService.update(updateUserAllocation, userAllocationQueryWrapper);
 
             if (ok) {

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

@@ -1,8 +1,9 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -16,15 +17,12 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;

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

@@ -7,7 +7,6 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
@@ -97,72 +96,38 @@ public class TestController {
     private IMaterialCutFrameService cutFrameService;
     @Autowired
     IKuaiShouVideoGetService videoGetService;
-    @Autowired
-    private IKuaiShouVideoTimeService timeService;
-
 
-    @GetMapping(value = "/getVideoTime")
-    public void getVideoTime() throws InterruptedException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("channel_type", 0);
-                List<KuaiShouVideoGet> list = videoGetService.list(queryWrapper);
-                for (KuaiShouVideoGet video : list) {
-                    videoService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            Date date = timeService.getVideoTime(video.getPhotoId(), video.getAccountId());
-                            if (!Check.isNull(date)) {
-                                video.setUploadDate(date);
-                                videoGetService.updateById(video);
-                            }
 
-                            try {
-                                Thread.sleep(1000);
-                            } catch (InterruptedException e) {
-                                e.printStackTrace();
-                            }
-                        }
-                    });
-                }
-            }
-        };
-        thread.start();
+    @GetMapping(value = "/getSuZhao")
+    public void getSuZhao() throws JobExecutionException {
 
-    }
+        try {
 
+            //1:查询当日数据
+            QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("media_id", 2);
+            queryWrapper.orderByDesc("create_time");
+            List<CtopOauthToken> tokens = tokenService.list(queryWrapper);
+            if (null == tokens || tokens.size() <= 0) {
+                log.info("定时获取快手数据异常:未获取到可用的token");
+                return;
+            }
 
-    @GetMapping(value = "/getSuZhao")
-    public void getSuZhao() throws InterruptedException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("channel_type", 1);
-                List<KuaiShouVideoGet> list = videoGetService.list(queryWrapper);
-                for (KuaiShouVideoGet video : list) {
-                    suzhaoService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            Date date = timeService.getVideoTime(video.getPhotoId(), video.getAccountId());
-                            if (!Check.isNull(date)) {
-                                video.setUploadDate(date);
-                                videoGetService.updateById(video);
-                            }
+            executorService = Executors.newFixedThreadPool(8);
+            tokens.forEach(token -> {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        //1: 获取广告主信息数据
+                        log.info("获取素造素材:accountId:{}", token.getAccountId());
+                        kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
+                    }
+                });
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
-                            try {
-                                Thread.sleep(1000);
-                            } catch (InterruptedException e) {
-                                e.printStackTrace();
-                            }
-                        }
-                    });
-                }
-            }
-        };
-        thread.start();
 
     }
 
@@ -223,7 +188,7 @@ public class TestController {
                             @Override
                             public void run() {
                                 try {
-                                    kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1);
+                                    kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
                                     String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                                     String videoEndDate = DateUtils.addDay(nowDate, -180);
                                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -268,7 +233,7 @@ public class TestController {
                     tokenQueryWrapper.eq("account_id", accountId);
                     CtopOauthToken one = tokenService.getOne(tokenQueryWrapper);
                     try {
-                        kuaishouInterfaceService.getSuZaoList(one.getAccessToken(), one.getAccountId(), 1);
+                        kuaishouInterfaceService.getSuZaoList(one.getAccessToken(), one.getAccountId(), 1, null, null);
                         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                         String videoEndDate = DateUtils.addDay(nowDate, -180);
                         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -474,6 +439,28 @@ public class TestController {
     }
 
 
+    @GetMapping(value = "/getHistoryDataByAccountId")
+    public String getHistoryDataByAccountId(Long accountId) {
+        Result<String> result = new Result<>();
+        try {
+            String endDateStr = DateUtils.getDate("yyyy-MM-dd");
+            String startDate = DateUtils.addMonth(endDateStr, -6);
+            QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+            tokenQueryWrapper.eq("media_id", 2);
+            tokenQueryWrapper.eq("account_id", accountId);
+            CtopOauthToken ctopOauthTokens = oauthTokenMapper.selectOne(tokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                historyReportTaskService.createTask(ctopOauthTokens.getAccountId(), ctopOauthTokens.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return "success";
+    }
+
+
     @GetMapping(value = "/getTaskList")
     public String getTaskList() {
         Result<String> result = new Result<>();

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

@@ -1,8 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.service.IMailLogService;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
@@ -13,11 +15,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;

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

@@ -1,8 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
@@ -18,11 +20,9 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 

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

@@ -0,0 +1,69 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 省市县信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-09-17
+ */
+@Data
+@TableName("ctop_bytedance_area_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_bytedance_area_info对象", description = "省市县信息")
+public class BytedanceAreaInfo {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * name
+     */
+    @Excel(name = "name", width = 15)
+    @ApiModelProperty(value = "name")
+    private String name;
+    /**
+     * code
+     */
+    @Excel(name = "code", width = 15)
+    @ApiModelProperty(value = "code")
+    private String code;
+    /**
+     * parentCode
+     */
+    @Excel(name = "parentCode", width = 15)
+    @ApiModelProperty(value = "parentCode")
+    private String parentCode;
+    /**
+     * level
+     */
+    @Excel(name = "level", width = 15)
+    @ApiModelProperty(value = "level")
+    private Integer level;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

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

@@ -0,0 +1,81 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.math.BigDecimal;
+
+@TableName("kuaishou_matcost_account_jun_12_18")
+public class KuaishouMatcostAccountMay {
+    private BigDecimal cost;
+    private Long accountId;
+    private String videoCode;
+    private String channelType;
+    private String url;
+    private String userName;
+    private String minDate;
+    private String endDate;
+
+    public BigDecimal getCost() {
+        return cost;
+    }
+
+    public void setCost(BigDecimal cost) {
+        this.cost = cost;
+    }
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public String getVideoCode() {
+        return videoCode;
+    }
+
+    public void setVideoCode(String videoCode) {
+        this.videoCode = videoCode;
+    }
+
+    public String getChannelType() {
+        return channelType;
+    }
+
+    public void setChannelType(String channelType) {
+        this.channelType = channelType;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getMinDate() {
+        return minDate;
+    }
+
+    public void setMinDate(String minDate) {
+        this.minDate = minDate;
+    }
+
+    public String getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(String endDate) {
+        this.endDate = endDate;
+    }
+}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountCpaBidJob.java

@@ -1,11 +1,11 @@
 package org.jeecg.modules.ctop.job;
 
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.utils.BigDecimalUtil;
 import cn.com.ctop.common.module.utils.Check;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.ICpaBidWarningService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;

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

@@ -2,9 +2,9 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -35,7 +35,10 @@ public class KuaishouSuZaoLoadJob implements Job {
                         @Override
                         public void run() {
                             try {
-                                kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1);
+                                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+                                String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
+                                kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate);
                             } catch (Exception e) {
                                 e.printStackTrace();
                             } finally {

+ 17 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/KuaishouMatcostAccountMayMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+
+import java.math.BigDecimal;
+
+public interface KuaishouMatcostAccountMayMapper extends BaseMapper<KuaishouMatcostAccountMay> {
+    String getMinDateByCode(@Param(value = "code") String code);
+
+    void updateByCode(@Param(value = "code")String code, @Param(value = "minDate")String minDate);
+
+    void updateCostByCode(@Param(value = "code")String code, @Param(value = "cost")BigDecimal cost);
+
+    BigDecimal getCostByParams(@Param(value = "code")String videoCode, @Param(value = "startDate")String minDate, @Param(value = "endDate")String endDate);
+}

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

@@ -0,0 +1,20 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface MediaReportMapper {
+
+    List<JSONObject> queryAdvertiserNameByCompanyId(@Param("companyId") String companyId);
+
+    List<JSONObject> queryProjectNameByAdvertiserId(@Param("advertiserId") String advertiserId);
+
+    List<JSONObject> queryAllBy(@Param("todayDate") String todayDate ,@Param("yesterdayDate") String yesterdayDate);
+
+    List<JSONObject> queryMediaReportBy(@Param("todayDate") String todayDate ,@Param("yesterdayDate") String yesterdayDate,@Param("condition") String condition);
+
+    List<JSONObject> queryAgentReportBy(@Param("todayDate") String todayDate ,@Param("yesterdayDate") String yesterdayDate);
+
+}

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/KuaishouMatcostAccountMayMapper.xml

@@ -0,0 +1,25 @@
+<?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="org.jeecg.modules.ctop.mapper.KuaishouMatcostAccountMayMapper">
+    <update id="updateByCode">
+        update kuaishou_matcost_account_jun_12_18 set min_date = #{minDate}
+        where video_code = #{code}
+    </update>
+    <update id="updateCostByCode">
+        update kuaishou_matcost_account_jun_12_18 set twcost = #{cost}
+        where video_code = #{code}
+    </update>
+    <select id="getMinDateByCode" resultType="java.lang.String">
+    select substr(min(tmp.stat_date),1,10) from kuaishou_video_new_v2 video
+        left join tmp_kuaishou_creative_statdate2 tmp on tmp.photo_id = video.photo_id
+        where video.video_code = #{code}
+    </select>
+    <select id="getCostByParams" resultType="java.math.BigDecimal">
+        SELECT
+            sum(report.charge)
+        FROM
+        tmp_kuaishou_creative_report report
+        WHERE
+        report.video_code =#{code} and report.state_date &gt;= #{startDate} and report.state_date &lt; #{endDate};
+    </select>
+</mapper>

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

@@ -4,6 +4,7 @@
     <select id="selectMapsPage" resultType="org.jeecg.modules.ctop.vo.MaterialTopVO">
        SELECT
           url,
+          cover_url,
           name,
           stat_date ,
           sum(cost) as cost,
@@ -28,6 +29,7 @@
         INSERT INTO ctop_material_report_total_result (
             CODE,
             url,
+            cover_url,
             NAME,
             stat_date,
             cost,
@@ -44,58 +46,36 @@
             media_type
         ) SELECT
               t2.signature,
-              CASE
-                  WHEN (
-                      SELECT
-                          info.url
-                      FROM
-                          ctop_material_info info
-                      WHERE
-                          info. CODE = t2.signature
-                      ORDER BY
-                          create_time DESC
-                      LIMIT 1
-                  ) IS NULL THEN
-                      ""
-                  ELSE
-                      (
-                          SELECT
+              IFNULL((SELECT
                               info.url
                           FROM
                               ctop_material_info info
                           WHERE
-                              info. CODE = t2.signature
+                              info.CODE = t2.signature
                           ORDER BY
                               create_time DESC
-                          LIMIT 1
-                      )
-                  END AS url,
-              CASE
-                  WHEN (
-                      SELECT
-                          info.material_name
-                      FROM
-                          ctop_material_info info
-                      WHERE
-                          info. CODE = t2.signature
-                      ORDER BY
-                          create_time DESC
-                      LIMIT 1
-                  ) IS NULL THEN
-                      ""
-                  ELSE
-                      (
+                          LIMIT 1),'') AS url,
+              			IFNULL((SELECT
+                              info.cover_url
+                          FROM
+                              ctop_material_info info
+                          WHERE
+                              info.CODE = t2.signature
+                          ORDER BY
+                              create_time DESC
+                          LIMIT 1),'') AS cover_url,
+                      IFNULL((
                           SELECT
                               info.material_name
                           FROM
                               ctop_material_info info
                           WHERE
-                              info. CODE = t2.signature
+                              info.CODE = t2.signature
                           ORDER BY
                               create_time DESC
                           LIMIT 1
-                      )
-                  END AS NAME,
+                      ),'')
+                   AS NAME,
               t1.stat_datetime AS statDate,
               sum(t1.cost) AS cost,
               sum(t1.click) click,
@@ -127,6 +107,7 @@
         INSERT INTO ctop_material_report_total_result (
             CODE,
             url,
+            cover_url,
             NAME,
             stat_date,
             cost,
@@ -138,50 +119,36 @@
             media_type
         ) SELECT
               t1.signature AS 'code',
-              CASE
-                  WHEN (
-                      SELECT
-                          url
-                      FROM
-                          ctop_material_info
-                      WHERE
-                          `code` = t1.signature
-                      LIMIT 1
-                  ) IS NULL THEN
-                      ""
-                  ELSE
-                      (
-                          SELECT
-                              url
+              IFNULL((SELECT
+                              info.url
                           FROM
-                              ctop_material_info
+                              ctop_material_info info
                           WHERE
-                              `code` = t1.signature
-                          LIMIT 1
-                      )
-                  END AS 'url',
-              CASE
-                  WHEN (
-                      SELECT
-                          material_name
-                      FROM
-                          ctop_material_info
-                      WHERE
-                          `code` = t1.signature
-                      LIMIT 1
-                  ) IS NULL THEN
-                      ""
-                  ELSE
-                      (
+                              info.CODE = t2.signature
+                          ORDER BY
+                              create_time DESC
+                          LIMIT 1),'') AS url,
+              			IFNULL((SELECT
+                              info.cover_url
+                          FROM
+                              ctop_material_info info
+                          WHERE
+                              info.CODE = t2.signature
+                          ORDER BY
+                              create_time DESC
+                          LIMIT 1),'') AS cover_url,
+                      IFNULL((
                           SELECT
-                              material_name
+                              info.material_name
                           FROM
-                              ctop_material_info
+                              ctop_material_info info
                           WHERE
-                              `code` = t1.signature
+                              info.CODE = t2.signature
+                          ORDER BY
+                              create_time DESC
                           LIMIT 1
-                      )
-                  END AS 'name',
+                      ),'')
+                   AS NAME,
               t1.stat_date AS 'stat_date',
               sum(t1.charge) AS 'cost',
               sum(t1.photo_click) AS 'click',

+ 412 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml

@@ -0,0 +1,412 @@
+<?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="org.jeecg.modules.ctop.mapper.MediaReportMapper">
+    <select id="queryAdvertiserNameByCompanyId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT id,
+               name
+        from ctop_advertiser
+        where company_id = #{companyId}
+    </select>
+
+    <select id="queryProjectNameByAdvertiserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT id,
+               project_name
+        from ctop_project
+        where advertiser_id = #{advertiserId}
+    </select>
+
+    <select id="queryAllBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT e.*
+        from (
+                 SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
+                 from (
+                          SELECT t1.advertiser_type                                                      as mediaType,
+                                 t1.company_id                                                           as companyId,
+                                 t1.id                                                                   as advertiserId,
+                                 t1.NAME                                                                 as advertiserName,
+                                 t2.id                                                                   as projectId,
+                                 t2.project_name                                                         as projectName,
+                                 t2.responsible_name                                                     as operatorManger,
+                                 t2.design_responsible_name                                              as designManger,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_user_allocation t3
+                                  where t2.id = t3.project_id)                                           as operator,
+                                 (SELECT realname from sys_user u WHERE u.id = t1.sale_id)               as sale,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_project_member member
+                                  where t2.id = member.project_id
+                                    and role_code = 'plan')                                              as plan,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_project_member member
+                                  where t2.id = member.project_id
+                                    and role_code = 'shot')                                              as shot,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_project_member member
+                                  where t2.id = member.project_id
+                                    and role_code = 'clip')                                              as clip,
+                                 case
+                                     when
+                                         (SELECT sum(cost)
+                                          from ctop_bytedance_report_advertiser_daily report
+                                          where report.advertiser_id in (SELECT account_id
+                                                                         from ctop_user_allocation t3
+                                                                         where t2.id = t3.project_id)
+                                            and report.stat_datetime = '${todayDate} 00:00:00') is null then 0
+                                     else (SELECT sum(cost)
+                                           from ctop_bytedance_report_advertiser_daily report
+                                           where report.advertiser_id in (SELECT account_id
+                                                                          from ctop_user_allocation t3
+                                                                          where t2.id = t3.project_id)
+                                             and report.stat_datetime = '${todayDate} 00:00:00') END     as todayCost,
+                                 case
+                                     when
+                                         (SELECT sum(cost)
+                                          from ctop_bytedance_report_advertiser_daily report
+                                          where report.advertiser_id in (SELECT account_id
+                                                                         from ctop_user_allocation t3
+                                                                         where t2.id = t3.project_id)
+                                            and report.stat_datetime = '${yesterdayDate} 00:00:00') is null then 0
+                                     else (SELECT sum(cost)
+                                           from ctop_bytedance_report_advertiser_daily report
+                                           where report.advertiser_id in (SELECT account_id
+                                                                          from ctop_user_allocation t3
+                                                                          where t2.id = t3.project_id)
+                                             and report.stat_datetime = '${yesterdayDate} 00:00:00') end as yesterdayCost
+                          FROM ctop_advertiser t1
+                                   LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
+                          where t1.advertiser_type = 1 and t2.id is not null) as r
+
+                 UNION
+
+                 SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
+                 from (
+                          SELECT t1.advertiser_type                                         as mediaType,
+                                 t1.company_id                                              as companyId,
+                                 t1.id                                                      as advertiserId,
+                                 t1.NAME                                                    as advertiserName,
+                                 t2.id                                                      as projectId,
+                                 t2.project_name                                            as projectName,
+                                 t2.responsible_name                                        as operatorManger,
+                                 t2.design_responsible_name                                 as designManger,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_user_allocation t3
+                                  where t2.id = t3.project_id)                              as operator,
+                                 (SELECT realname from sys_user u WHERE u.id = t1.sale_id)  as sale,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_project_member member
+                                  where t2.id = member.project_id
+                                    and role_code = 'plan')                                 as plan,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_project_member member
+                                  where t2.id = member.project_id
+                                    and role_code = 'shot')                                 as shot,
+                                 (SELECT GROUP_CONCAT(DISTINCT user_name)
+                                  from ctop_project_member member
+                                  where t2.id = member.project_id
+                                    and role_code = 'clip')                                 as clip,
+                                 case
+                                     when
+                                         (SELECT sum(charge)
+                                          from ctop_kuaishou_report_daily_account report
+                                          where report.account_id in (SELECT account_id
+                                                                      from ctop_user_allocation t3
+                                                                      where t2.id = t3.project_id)
+                                            and report.stat_date = '${todayDate}') is null then 0
+                                     ELSE (SELECT sum(charge)
+                                           from ctop_kuaishou_report_daily_account report
+                                           where report.account_id in (SELECT account_id
+                                                                       from ctop_user_allocation t3
+                                                                       where t2.id = t3.project_id)
+                                             and report.stat_date = '${todayDate}') END     as todayCost,
+                                 case
+                                     when
+                                         (SELECT sum(charge)
+                                          from ctop_kuaishou_report_daily_account report
+                                          where report.account_id in (SELECT account_id
+                                                                      from ctop_user_allocation t3
+                                                                      where t2.id = t3.project_id)
+                                            and report.stat_date = '${yesterdayDate}') is null then 0
+                                     ELSE (SELECT sum(charge)
+                                           from ctop_kuaishou_report_daily_account report
+                                           where report.account_id in (SELECT account_id
+                                                                       from ctop_user_allocation t3
+                                                                       where t2.id = t3.project_id)
+                                             and report.stat_date = '${yesterdayDate}') end as yesterdayCost
+                          FROM ctop_advertiser t1
+                                   LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
+                          where t1.advertiser_type = 2 and t2.id is not null) as r
+
+                 union
+
+                 SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
+                 from (
+                          SELECT '0'                                                               as mediaType,
+                                 '-'                                                                as companyId,
+                                 id                                                                as advertiserId,
+                                 corporation_name                                                  as advertiserName,
+                                 '-'                                                                as projectId,
+                                 account_name                                                      as projectName,
+                                 '-'                                                                as operatorManger,
+                                 '-'                                                                as designManger,
+                                 '-'                                                                as operator,
+                                 '-'                                                                as sale,
+                                 '-'                                                                as plan,
+                                 '-'                                                                as shot,
+                                 '-'                                                                as clip,
+                                 case
+                                     WHEN
+                                         (SELECT sum(balance)
+                                          from ctop_kuaishou_agent_account report
+                                          where report.id = t1.id
+                                            and report.create_time like '%${todayDate}%') is null THEN 0
+                                     ELSE (SELECT sum(balance)
+                                           from ctop_kuaishou_agent_account report
+                                           where report.id = t1.id
+                                             and report.create_time like '%${todayDate}%') end     as todayCost,
+                                 case
+                                     WHEN
+                                         (SELECT sum(balance)
+                                          from ctop_kuaishou_agent_account report
+                                          where report.id = t1.id
+                                            and report.create_time like '%${yesterdayDate}%') is null THEN 0
+                                     ELSE (SELECT sum(balance)
+                                           from ctop_kuaishou_agent_account report
+                                           where report.id = t1.id
+                                             and report.create_time like '%${yesterdayDate}%') end as yesterdayCost
+                          from ctop_kuaishou_agent_account t1
+                          where t1.create_time like '%${yesterdayDate}%'
+                          GROUP by advertiserName, projectName) as r) as e
+    </select>
+
+    <select id="queryMediaReportBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT e.*
+        FROM (
+                 SELECT r.*,
+                        (r.todayCost - r.yesterdayCost) AS diffCost
+                 FROM (
+                          SELECT t1.advertiser_type         AS mediaType,
+                                 t1.company_id              as companyId,
+                                 t1.id                      as advertiserId,
+                                 t1.NAME                    as advertiserName,
+                                 t2.id                      as projectId,
+                                 t2.project_name            AS projectName,
+                                 t2.responsible_name        AS operatorManger,
+                                 t2.design_responsible_name AS designManger,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_user_allocation t3
+                                     WHERE t2.id = t3.project_id
+                                 )                          AS operator,
+                                 (
+                                     SELECT realname
+                                     FROM sys_user u
+                                     WHERE u.id = t1.sale_id
+                                 )                          AS sale,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_project_member member
+                                     WHERE t2.id = member.project_id
+                                       AND role_code = 'plan'
+                                 )                          AS plan,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_project_member member
+                                     WHERE t2.id = member.project_id
+                                       AND role_code = 'shot'
+                                 )                          AS shot,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_project_member member
+                                     WHERE t2.id = member.project_id
+                                       AND role_code = 'clip'
+                                 )                          AS clip,
+                                 CASE
+                                     WHEN (
+                                         SELECT sum(cost)
+                                         FROM ctop_bytedance_report_advertiser_daily report
+                                         WHERE report.advertiser_id IN (
+                                             SELECT account_id
+                                             FROM ctop_user_allocation t3
+                                             WHERE t2.id = t3.project_id
+                                         )
+                                           AND report.stat_datetime = '${todayDate} 00:00:00'
+                                     ) IS NULL THEN
+                                         0
+                                     ELSE
+                                         (
+                                             SELECT sum(cost)
+                                             FROM ctop_bytedance_report_advertiser_daily report
+                                             WHERE report.advertiser_id IN (
+                                                 SELECT account_id
+                                                 FROM ctop_user_allocation t3
+                                                 WHERE t2.id = t3.project_id
+                                             )
+                                               AND report.stat_datetime = '${todayDate} 00:00:00'
+                                         )
+                                     END                    AS todayCost,
+                                 CASE
+                                     WHEN (
+                                         SELECT sum(cost)
+                                         FROM ctop_bytedance_report_advertiser_daily report
+                                         WHERE report.advertiser_id IN (
+                                             SELECT account_id
+                                             FROM ctop_user_allocation t3
+                                             WHERE t2.id = t3.project_id
+                                         )
+                                           AND report.stat_datetime = '${yesterdayDate} 00:00:00'
+                                     ) IS NULL THEN
+                                         0
+                                     ELSE
+                                         (
+                                             SELECT sum(cost)
+                                             FROM ctop_bytedance_report_advertiser_daily report
+                                             WHERE report.advertiser_id IN (
+                                                 SELECT account_id
+                                                 FROM ctop_user_allocation t3
+                                                 WHERE t2.id = t3.project_id
+                                             )
+                                               AND report.stat_datetime = '${yesterdayDate} 00:00:00'
+                                         )
+                                     END                    AS yesterdayCost
+                          FROM ctop_advertiser t1
+                                   LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
+                          WHERE t1.advertiser_type = 1 and t2.id is not null
+                      ) AS r
+                 UNION
+                 SELECT r.*,
+                        (r.todayCost - r.yesterdayCost) AS diffCost
+                 FROM (
+                          SELECT t1.advertiser_type         AS mediaType,
+                                 t1.company_id              as companyId,
+                                 t1.id                      as advertiserId,
+                                 t1.NAME                    as advertiserName,
+                                 t2.id                      as projectId,
+                                 t2.project_name            AS projectName,
+                                 t2.responsible_name        AS operatorManger,
+                                 t2.design_responsible_name AS designManger,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_user_allocation t3
+                                     WHERE t2.id = t3.project_id
+                                 )                          AS operator,
+                                 (
+                                     SELECT realname
+                                     FROM sys_user u
+                                     WHERE u.id = t1.sale_id
+                                 )                          AS sale,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_project_member member
+                                     WHERE t2.id = member.project_id
+                                       AND role_code = 'plan'
+                                 )                          AS plan,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_project_member member
+                                     WHERE t2.id = member.project_id
+                                       AND role_code = 'shot'
+                                 )                          AS shot,
+                                 (
+                                     SELECT GROUP_CONCAT(DISTINCT user_name)
+                                     FROM ctop_project_member member
+                                     WHERE t2.id = member.project_id
+                                       AND role_code = 'clip'
+                                 )                          AS clip,
+                                 CASE
+                                     WHEN (
+                                         SELECT sum(charge)
+                                         FROM ctop_kuaishou_report_daily_account report
+                                         WHERE report.account_id IN (
+                                             SELECT account_id
+                                             FROM ctop_user_allocation t3
+                                             WHERE t2.id = t3.project_id
+                                         )
+                                           AND report.stat_date = '${todayDate}'
+                                     ) IS NULL THEN
+                                         0
+                                     ELSE
+                                         (
+                                             SELECT sum(charge)
+                                             FROM ctop_kuaishou_report_daily_account report
+                                             WHERE report.account_id IN (
+                                                 SELECT account_id
+                                                 FROM ctop_user_allocation t3
+                                                 WHERE t2.id = t3.project_id
+                                             )
+                                               AND report.stat_date = '${todayDate}'
+                                         )
+                                     END                    AS todayCost,
+                                 CASE
+                                     WHEN (
+                                         SELECT sum(charge)
+                                         FROM ctop_kuaishou_report_daily_account report
+                                         WHERE report.account_id IN (
+                                             SELECT account_id
+                                             FROM ctop_user_allocation t3
+                                             WHERE t2.id = t3.project_id
+                                         )
+                                           AND report.stat_date = '${yesterdayDate}'
+                                     ) IS NULL THEN
+                                         0
+                                     ELSE
+                                         (
+                                             SELECT sum(charge)
+                                             FROM ctop_kuaishou_report_daily_account report
+                                             WHERE report.account_id IN (
+                                                 SELECT account_id
+                                                 FROM ctop_user_allocation t3
+                                                 WHERE t2.id = t3.project_id
+                                             )
+                                               AND report.stat_date = '${yesterdayDate}'
+                                         )
+                                     END                    AS yesterdayCost
+                          FROM ctop_advertiser t1
+                                   LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
+                          WHERE t1.advertiser_type = 2 and t2.id is not null
+                      ) AS r) as e
+        where companyId = ${condition}
+    </select>
+
+    <select id="queryAgentReportBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT e.* from(
+                           SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
+                           from (
+                                    SELECT '0'                                                               as mediaType,
+                                           '-'                                                                as companyId,
+                                           id                                                                as advertiserId,
+                                           corporation_name                                                  as advertiserName,
+                                           '-'                                                                as projectId,
+                                           account_name                                                      as projectName,
+                                           '-'                                                                as operatorManger,
+                                           '-'                                                                as designManger,
+                                           '-'                                                                as operator,
+                                           '-'                                                                as sale,
+                                           '-'                                                                as plan,
+                                           '-'                                                                as shot,
+                                           '-'                                                                as clip,
+                                           case
+                                               WHEN
+                                                   (SELECT sum(balance)
+                                                    from ctop_kuaishou_agent_account report
+                                                    where report.id = t1.id
+                                                      and report.create_time like '%${todayDate}%') is null THEN 0
+                                               ELSE (SELECT sum(balance)
+                                                     from ctop_kuaishou_agent_account report
+                                                     where report.id = t1.id
+                                                       and report.create_time like '%${todayDate}%') end     as todayCost,
+                                           case
+                                               WHEN
+                                                   (SELECT sum(balance)
+                                                    from ctop_kuaishou_agent_account report
+                                                    where report.id = t1.id
+                                                      and report.create_time like '%${yesterdayDate}%') is null THEN 0
+                                               ELSE (SELECT sum(balance)
+                                                     from ctop_kuaishou_agent_account report
+                                                     where report.id = t1.id
+                                                       and report.create_time like '%${yesterdayDate}%') end as yesterdayCost
+                                    from ctop_kuaishou_agent_account t1
+                                    where t1.create_time like '%${yesterdayDate}%'
+                                    GROUP by advertiserName, projectName
+                                )as r) as e
+    </select>
+</mapper>

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ICpaBidWarningService.java

@@ -1,6 +1,6 @@
 package org.jeecg.modules.ctop.service;
 
-import org.jeecg.modules.ctop.entity.Project;
+import cn.com.ctop.common.module.entity.Project;
 
 public interface ICpaBidWarningService {
     void cpaBidWarning(Project project);

+ 18 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IKuaishouMatcostAccountMayService.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+
+import java.math.BigDecimal;
+
+public interface IKuaishouMatcostAccountMayService extends IService<KuaishouMatcostAccountMay> {
+    KuaishouMatcostAccountMay getOne();
+
+    String getMinDate(String code);
+
+    void updateByCode(String code,String minDate);
+
+    void updateCostByCode(String code, BigDecimal cost);
+
+    BigDecimal getCostByParams(KuaishouMatcostAccountMay matcostAccountMay);
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMediaReportService.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.ctop.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+
+public interface IMediaReportService {
+
+    List<JSONObject> queryAdvertiserNameByCompanyId(String companyId);
+
+    List<JSONObject> queryProjectNameByAdvertiserId(String advertiserId);
+
+    PageInfo<JSONObject> queryReportByCondition(int pageNo,int pageSize,JSONObject requestBody);
+
+    PageInfo<JSONObject> queryAllReportByCondition(int pageNo,int pageSize,JSONObject requestBody);
+
+    List<JSONObject> queryAllByCondition(JSONObject requestBody);
+
+    List<JSONObject> queryReportByCondition(JSONObject requestBody);
+
+
+}

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java

@@ -1,7 +1,7 @@
 package org.jeecg.modules.ctop.service;
 
+import cn.com.ctop.common.module.entity.Project;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.system.entity.SysUser;
 

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

@@ -1,8 +1,10 @@
 package org.jeecg.modules.ctop.service.impl;
 
 import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.service.ICorpFeishuUserService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.BigDecimalUtil;
@@ -17,8 +19,6 @@ import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.service.IBidWarningService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.ctop.service.impl;
 
 import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.service.ICorpFeishuUserService;
@@ -16,7 +17,6 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.ICpaBidWarningService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

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

@@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.ParseException;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -130,8 +131,8 @@ public class KuaiShouUploadServiceImpl implements IKuaiShouUploadService {
                                             videoGet.setAccountId(accountId);
                                             videoGet.setId(accountId + photoId);
                                             videoGet.setUrl(materialInfo.getUrl());
-
-
+                                            videoGet.setCoverUrl(materialInfo.getUrl()+ "?x-oss-process=video/snapshot,t_00000,m_fast");
+                                            videoGet.setStatDate(DateUtils.getNowDate());
                                             videoGet.setMaterialType(finalType);
                                             videoGet.setPhotoId(photoId);
                                             videoGet.setSignature(signature);

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

@@ -0,0 +1,43 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+import org.jeecg.modules.ctop.mapper.KuaishouMatcostAccountMayMapper;
+import org.jeecg.modules.ctop.service.IKuaishouMatcostAccountMayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+
+@Service
+public class KuaishouMatcostAccountMayServiceImpl extends ServiceImpl<KuaishouMatcostAccountMayMapper, KuaishouMatcostAccountMay> implements IKuaishouMatcostAccountMayService {
+    @Autowired
+    private KuaishouMatcostAccountMayMapper kuaishouMatcostAccountMayMapper;
+    @Override
+    public KuaishouMatcostAccountMay getOne() {
+        QueryWrapper<KuaishouMatcostAccountMay>queryWrapper = new QueryWrapper<>();
+        queryWrapper.isNull("twcost").isNotNull("end_date").last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public String getMinDate(String code){
+        return kuaishouMatcostAccountMayMapper.getMinDateByCode(code);
+    }
+
+    @Override
+    public void updateByCode(String code,String minDate) {
+        kuaishouMatcostAccountMayMapper.updateByCode(code,minDate);
+    }
+
+    @Override
+    public void updateCostByCode(String code, BigDecimal cost) {
+        kuaishouMatcostAccountMayMapper.updateCostByCode(code,cost);
+    }
+
+    @Override
+    public BigDecimal getCostByParams(KuaishouMatcostAccountMay matcostAccountMay) {
+        return kuaishouMatcostAccountMayMapper.getCostByParams(matcostAccountMay.getVideoCode(),matcostAccountMay.getMinDate(),matcostAccountMay.getEndDate());
+    }
+}

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

@@ -0,0 +1,117 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.ctop.mapper.MediaReportMapper;
+import org.jeecg.modules.ctop.service.IMediaReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class MediaReportServiceImpl implements IMediaReportService {
+
+    @Autowired
+    MediaReportMapper mediaReportMapper;
+
+    @Override
+    public List<JSONObject> queryAdvertiserNameByCompanyId(String companyId) {
+        return mediaReportMapper.queryAdvertiserNameByCompanyId(companyId);
+    }
+
+    @Override
+    public List<JSONObject> queryProjectNameByAdvertiserId(String advertiserId) {
+        return mediaReportMapper.queryProjectNameByAdvertiserId(advertiserId);
+    }
+
+    @Override
+    public PageInfo<JSONObject> queryReportByCondition(int pageNO, int pageSize, JSONObject requestBody) {
+        PageInfo<JSONObject> pageInfo;
+        if(requestBody.getString("companyId").equals("6weq589875c040119adst08751712368")){
+            pageInfo=getAgentReportByCondition(pageNO,pageSize,requestBody);
+        }else {
+            pageInfo=getMediaReportByCondition(pageNO,pageSize,requestBody);
+        }
+        return pageInfo;
+    }
+
+    @Override
+    public PageInfo<JSONObject> queryAllReportByCondition(int pageNo, int pageSize, JSONObject requestBody) {
+        String todayDate = requestBody.getString("todayDate");
+        String yesterdayDate = requestBody.getString("yesterdayDate");
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> jsonObjectList = mediaReportMapper.queryAllBy(todayDate, yesterdayDate);
+        return new PageInfo<JSONObject>(jsonObjectList);
+    }
+
+    @Override
+    public List<JSONObject> queryAllByCondition(JSONObject requestBody) {
+        String todayDate = requestBody.getString("todayDate");
+        String yesterdayDate = requestBody.getString("yesterdayDate");
+        return mediaReportMapper.queryAllBy(todayDate, yesterdayDate);
+    }
+
+    @Override
+    public List<JSONObject> queryReportByCondition(JSONObject requestBody) {
+        List<JSONObject> list;
+        if(requestBody.getString("companyId").equals("6weq589875c040119adst08751712368")){
+            list=getAgentReportListByCondition(requestBody);
+        }else {
+            list=getMediaReportListByCondition(requestBody);
+        }
+        return list;
+    }
+
+    private PageInfo<JSONObject> getMediaReportByCondition(int pageNo, int pageSize, JSONObject requestBody) {
+        String condition = getSqlByCondition(requestBody);
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> jsonObjectList = mediaReportMapper.queryMediaReportBy(requestBody.getString("todayDate"), requestBody.getString("yesterdayDate"), condition);
+        return new PageInfo<JSONObject>(jsonObjectList);
+    }
+
+    private PageInfo<JSONObject> getAgentReportByCondition(int pageNo, int pageSize, JSONObject requestBody) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> jsonObjectList = mediaReportMapper.queryAgentReportBy(requestBody.getString("todayDate"), requestBody.getString("yesterdayDate"));
+        return new PageInfo<JSONObject>(jsonObjectList);
+    }
+
+    private List<JSONObject> getMediaReportListByCondition(JSONObject requestBody) {
+        String condition = getSqlByCondition(requestBody);
+        return mediaReportMapper.queryMediaReportBy(requestBody.getString("todayDate"), requestBody.getString("yesterdayDate"), condition);
+    }
+
+    private List<JSONObject> getAgentReportListByCondition(JSONObject requestBody) {
+        return mediaReportMapper.queryAgentReportBy(requestBody.getString("todayDate"), requestBody.getString("yesterdayDate"));
+    }
+
+    private String getSqlByCondition(JSONObject requestBody) {
+        StringBuilder sql = new StringBuilder();
+        if (!requestBody.getString("companyId").isEmpty()) {
+            sql.append(" '")
+                    .append(requestBody.getString("companyId"))
+                    .append("' and ");
+        }
+        if (!requestBody.getString("advertiserId").isEmpty()) {
+            sql.append("advertiserId='")
+                    .append(requestBody.getString("advertiserId"))
+                    .append("' and ");
+        }
+        if (!requestBody.getString("projectId").isEmpty()) {
+            sql.append("projectId=")
+                    .append(requestBody.getString("projectId"))
+                    .append(" and ");
+        }
+        if (!requestBody.getString("mediaType").isEmpty()) {
+            sql.append("mediaType=")
+                    .append(requestBody.getString("mediaType"))
+                    .append(" and ");
+        }
+        String result = sql.toString();
+        if (result.endsWith("and ")) {
+            result = result.substring(0,result.length() - 4);
+        }
+        return result;
+    }
+}

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
@@ -9,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;

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

@@ -7,6 +7,7 @@ import java.math.BigDecimal;
 @Data
 public class MaterialTopVO {
     private String url;
+    private String coverUrl;
     private String name ;
     private String statDate;
     private BigDecimal cost;

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileServiceImpl.java

@@ -1,6 +1,8 @@
 package org.jeecg.modules.wps.service.impl;
 
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.file.FileUtil;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.utils.CosUtils;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
@@ -11,8 +13,6 @@ import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.wps.config.Context;

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -113,7 +113,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: foobared
+    password:
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

+ 56 - 19
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,21 +5,24 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
+import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+import org.jeecg.modules.ctop.service.IKuaishouMatcostAccountMayService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -34,17 +37,24 @@ public class SampleTest {
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
     @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
+    private IByteDanceAdvertiserDataService advertiserDataService;
+    @Autowired
+    private IReportService reportService;
     @Test
     public void testOceanEngineJob() {
-       List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
-        Date startDate = DateUtils.addDay(new Date(),-1);
-        Date startDate2 = DateUtils.addDay(new Date(),-2);
-        for(CtopOauthToken token:tokens){
-            kuaishouInterfaceService.getAdvertiserReportDaily(token, startDate, startDate);
-            //1: 获取广告主信息数据
-            kuaishouInterfaceService.getAdvertiserReportDaily(token, startDate2, startDate2);
-       }
+        CtopOauthToken token1 = oauthTokenService.getTokenByAccountId(1670725854459911L);
+        CtopOauthToken token2 = oauthTokenService.getTokenByAccountId(1670827164313607L);
+        CtopOauthToken token3 = oauthTokenService.getTokenByAccountId(1670801593147405L);
+        CtopOauthToken token4 = oauthTokenService.getTokenByAccountId(1670827163327501L);
+        CtopOauthToken token5 = oauthTokenService.getTokenByAccountId(1670827163853832L);
+        for(int i=0;i<100;i++){
+            Date startDate = DateUtils.addDay(new Date(),-i);
+            reportService.getAdvertiserReport(token1,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token2,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token3,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token4,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token5,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }
     }
 
     @Autowired
@@ -122,6 +132,33 @@ public class SampleTest {
         }
     }
 
+    @Autowired
+    private IKuaishouMatcostAccountMayService matcostAccountMayService;
+    @Test
+    public void testLoadMinDate(){
+        loadData();
+    }
+
+    private void loadData(){
+        KuaishouMatcostAccountMay matcostAccountMay = matcostAccountMayService.getOne();
+        if(null!=matcostAccountMay){
+            BigDecimal cost = matcostAccountMayService.getCostByParams(matcostAccountMay);
+            if(null!=cost&&!cost.toString().trim().equals("")){
+                matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),cost);
+            }else{
+                matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),BigDecimal.ZERO);
+            }
+//            String minDate = matcostAccountMayService.getMinDate(matcostAccountMay.getVideoCode());
+//            if(null == minDate||minDate.trim().equals("")){
+//                matcostAccountMayService.updateByCode(matcostAccountMay.getVideoCode(),"-");
+//            }else{
+//                matcostAccountMayService.updateByCode(matcostAccountMay.getVideoCode(),minDate);
+//            }
+
+            loadData();
+        }
+    }
+
     @Test
     public void testPangolinData() {
         QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
@@ -132,14 +169,14 @@ public class SampleTest {
         if (list != null && !list.isEmpty()) {
             for (BindAccountLogin bindAccountLogin : list) {
                 pangolinCrawlerService.getChannelList(bindAccountLogin);
-                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
-                pangolinCrawlerService.getCheckList(bindAccountLogin);
-                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
-                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
-                if (appList != null && !appList.isEmpty()) {
-                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
-                }
+//                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
+//                pangolinCrawlerService.getCheckList(bindAccountLogin);
+//                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
+//                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
+//                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
+//                if (appList != null && !appList.isEmpty()) {
+//                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
+//                }
             }
         }
     }

+ 30 - 0
module-common/src/main/java/cn/com/ctop/common/module/annotation/AutoLog.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.common.module.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 系统日志注解
+ *
+ * @Author scott
+ * @email jeecgos@163.com
+ * @Date 2019年1月14日
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface AutoLog {
+
+	/**
+	 * 日志内容
+	 *
+	 * @return
+	 */
+	String value() default "";
+
+	/**
+	 * 日志类型
+	 *
+	 * @return 0:操作日志;1:登录日志;2:定时任务;
+	 */
+	int logType() default 2;
+}

+ 42 - 0
module-common/src/main/java/cn/com/ctop/common/module/annotation/Dict.java

@@ -0,0 +1,42 @@
+package cn.com.ctop.common.module.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *  类描述:  字典注解
+ * 作    者: dangzhenghui
+ * 日    期: 2019年03月17日-下午9:37:16
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Dict {
+    /**
+     * 方法描述:  数据code
+     * 作    者: dangzhenghui
+     * 日    期: 2019年03月17日-下午9:37:16
+     *
+     * @return 返回类型: String
+     */
+    String dicCode();
+
+    /**
+     * 方法描述:  数据Text
+     * 作    者: dangzhenghui
+     * 日    期: 2019年03月17日-下午9:37:16
+     *
+     * @return 返回类型: String
+     */
+    String dicText() default "";
+
+    /**
+     * 方法描述: 数据字典表
+     * 作    者: dangzhenghui
+     * 日    期: 2019年03月17日-下午9:37:16
+     *
+     * @return 返回类型: String
+     */
+    String dictTable() default "";
+}

+ 25 - 0
module-common/src/main/java/cn/com/ctop/common/module/annotation/PermissionData.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.common.module.annotation;
+
+import java.lang.annotation.*;
+
+/**
+  *  数据权限注解
+ * @Author taoyan
+ * @Date 2019年4月11日
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE,ElementType.METHOD})
+@Documented
+public @interface PermissionData {
+	/**
+	 * 暂时没用
+	 * @return
+	 */
+	String value() default "";
+
+
+	/**
+	 * 配置菜单的组件路径,用于数据权限
+	 */
+	String pageComponent() default "";
+}

+ 6 - 1
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.entity;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -32,7 +33,7 @@ public class MaterialInfo {
     /**
      * id
      */
-    @TableId
+    @TableId(type = IdType.UUID)
     @ApiModelProperty(value = "id")
     private String id;
     /**
@@ -48,6 +49,10 @@ public class MaterialInfo {
     @Excel(name = "url", width = 15)
     @ApiModelProperty(value = "url")
     private String url;
+    /**
+     * 封面url
+     */
+    private String coverUrl;
 
     /**
      * 水印素材链接

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java

@@ -1,5 +1,6 @@
-package org.jeecg.modules.ctop.entity;
+package cn.com.ctop.common.module.entity;
 
+import cn.com.ctop.common.module.annotation.Dict;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -10,7 +11,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecg.common.aspect.annotation.Dict;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMapper.java

@@ -1,7 +1,7 @@
-package org.jeecg.modules.ctop.mapper;
+package cn.com.ctop.common.module.mapper;
 
+import cn.com.ctop.common.module.entity.Project;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.jeecg.modules.ctop.entity.Project;
 
 /**
  * 项目

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

@@ -25,7 +25,7 @@
         from
         ctop_bind_account_login login
         left join ctop_project project on login.project_id = project.id
-        where 1=1
+        where login.status = 1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>

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

@@ -1,5 +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="org.jeecg.modules.ctop.mapper.ProjectMapper">
+<mapper namespace="cn.com.ctop.common.module.mapper.ProjectMapper">
 
-</mapper>
+</mapper>

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

@@ -1,7 +1,7 @@
-package org.jeecg.modules.ctop.service;
+package cn.com.ctop.common.module.service;
 
+import cn.com.ctop.common.module.entity.Project;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.ctop.entity.Project;
 
 /**
  * 项目

+ 13 - 11
module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountLoginServiceImpl.java

@@ -34,6 +34,8 @@ import java.util.Map;
 @Slf4j
 @Service
 public class BindAccountLoginServiceImpl extends ServiceImpl<BindAccountLoginMapper, BindAccountLogin> implements IBindAccountLoginService {
+    @Autowired
+    private BindAccountLoginMapper bindAccountLoginMapper;
     @Override
     public boolean checkLogin(BindAccountLogin bindAccountLogin, String response) {
         if (response.contains("<html>")) {
@@ -43,6 +45,7 @@ public class BindAccountLoginServiceImpl extends ServiceImpl<BindAccountLoginMap
         }
         return true;
     }
+
     @Override
     public BindAccountLogin selectByAccountId(String accountId) {
         QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
@@ -68,21 +71,20 @@ public class BindAccountLoginServiceImpl extends ServiceImpl<BindAccountLoginMap
 
     @Override
     public List<PangolinProjectVO> getProjectByParams(String userId, String loginType) {
-        List<PangolinProjectVO> projectVOS =  bindAccountLoginMapper.getProjectByParams(userId,loginType,null);
-        List<PangolinProjectVO> setProjectVOS = new ArrayList<>();
-        if(null!=projectVOS&&!projectVOS.isEmpty()){
-            projectVOS.forEach(pangolinProjectVO -> {
-                List<PangolinAccountVO>accountVOS = bindAccountLoginMapper.getAccountByParams(userId,loginType,pangolinProjectVO.getProjectId());
-                pangolinProjectVO.setAccountVOList(accountVOS);
-                setProjectVOS.add(pangolinProjectVO);
+        List<PangolinProjectVO> projectVos =  bindAccountLoginMapper.getProjectByParams(userId,loginType,null);
+        List<PangolinProjectVO> setProjectVos = new ArrayList<>();
+        if(null!=projectVos&&!projectVos.isEmpty()){
+            projectVos.forEach(pangolinProjectVO -> {
+                List<PangolinAccountVO>accountVos = bindAccountLoginMapper.getAccountByParams(userId,loginType,pangolinProjectVO.getProjectId());
+                if(null!=accountVos&&!accountVos.isEmpty()){
+                    pangolinProjectVO.setAccountVOList(accountVos);
+                    setProjectVos.add(pangolinProjectVO);
+                }
             });
         }
-        return setProjectVOS;
+        return setProjectVos;
     }
 
-    @Autowired
-    private BindAccountLoginMapper bindAccountLoginMapper;
-
     @Override
     public Map<String, Object> getListByUserId(String userId) {
         Map<String,Object>result = new HashMap<>();

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

@@ -181,7 +181,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         MaterialInfo info = new MaterialInfo();
         Long projectId = jsonObject.getLong("projectId");
         String code = jsonObject.getString("code");
-        info.setId(code + projectId);
         info.setCode(code);
         if (!Check.isNull(jsonObject.getString("watermarkUrl"))) {
             info.setWatermarkUrl(jsonObject.getString("watermarkUrl"));
@@ -474,7 +473,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             MaterialInfo info = new MaterialInfo();
             Long projectId = json.getLong("projectId");
             String code = json.getString("code");
-            info.setId(code + projectId);
             info.setCode(code);
             if (!Check.isNull(json.getString("watermarkUrl"))) {
                 info.setWatermarkUrl(json.getString("watermarkUrl"));

+ 4 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectServiceImpl.java

@@ -1,9 +1,9 @@
-package org.jeecg.modules.ctop.service.impl;
+package cn.com.ctop.common.module.service.impl;
 
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.springframework.stereotype.Service;
 
 /**

+ 0 - 7
module-common/src/main/java/cn/com/ctop/common/module/utils/CosUtils.java

@@ -284,12 +284,5 @@ public class CosUtils {
         String fileName = UUID.randomUUID().toString()+filepath.substring(filepath.lastIndexOf("."));
         String filePath = uploadFile(filepath, fileSavePath, fileName);
         System.out.println(filePath);
-//          downLoadFile(BUCKETNAME , KEY);
-        // deleteFile(BUCKETNAME , KEY01);
-//        createBucket("sunjunxian01-1251782781");
-        //deleteBucket();
-//        doesBucketExist("sunjunxian01-1251782781");
-//        System.out.println(listObjects(BUCKETNAME));
-        //System.out.println("BUCKETNAME的位置:" + getBucketLocation(BUCKETNAME));
     }
 }

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/ResultMapUtils.java

@@ -22,4 +22,10 @@ public class ResultMapUtils {
         map.put(MAP_MESSAGE, statusCode.getDesc());
         map.put(MAP_SUCCESS, statusCode.getFlag());
     }
+
+    public static void setResultMap(Map<String, Object> map, int statusCode,String message,boolean flag) {
+        map.put(MAP_CODE, statusCode);
+        map.put(MAP_MESSAGE, message);
+        map.put(MAP_SUCCESS, flag);
+    }
 }

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java

@@ -51,6 +51,9 @@ public enum StatusCode {
     KUAISHOU_OPTINIZER_PERSONNAL_DATA_IS_NULL("快手媒体优化师个人消耗数据不存在", -3002, false),
     BYTEDANCE_OPTINIZER_PERSONNAL_DATA_IS_NULL("头条媒体优化师个人消耗数据不存在", -3003, false),
     OPTINIZER_PERSONNAL_DATA_IS_NULL("优化师个人消耗数据不存在", -3004, false),
+
+    BYTEDACNE_API_GROUP_CREATE_ERROR("头条API创建广告组异常",-4001,false),
+
     KUAISHOU_CRAWLER_APP_SUCCESS("爬虫运行正常", 0, true),
     KUAISHOU_CRAWLER_APP_TASK_END("爬虫任务运行结束", 1, true),
     KUAISHOU_CRAWLER_APP_JOB_StART("任务开始执行开始", 0, true),

+ 2 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinApp.java

@@ -8,8 +8,9 @@ import lombok.Data;
 @Data
 @TableName("ctop_pangolin_app")
 public class PangolinApp {
-    @TableId(value = "id", type = IdType.INPUT)
+    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
+    private Long appId;
     private String name;
     private String accountName;
 }

+ 1 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportAppHour.java

@@ -28,6 +28,7 @@ public class PangolinReportAppHour {
      * 类型
      */
     private String type;
+    private String accountName;
     /**
      * 数字
      */

+ 2 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportBillMonth.java

@@ -44,4 +44,6 @@ public class PangolinReportBillMonth {
      * 账户质量分
      */
     private BigDecimal accountQualityScore;
+
+    private String accountName;
 }

+ 1 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportChannelDaily.java

@@ -24,6 +24,7 @@ public class PangolinReportChannelDaily {
      * 应用名称
      */
     private String appName;
+    private String accountName;
     /**
      * 操作系统
      */

+ 13 - 13
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinAppMapper.xml

@@ -2,28 +2,28 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.crawler.modules.pangolin.mapper.PangolinAppMapper">
     <select id="getListByParams" resultType="cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp">
-        select app.*
+        select distinct app.app_id as 'id',name
             from ctop_pangolin_app app
         left join ctop_bind_account_login login on login.account_name = app.account_name
         where
-        1=1
+        login.status = 1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
-              <if test="accountNames!=null">
-                  or login.account_name in
-                  <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
+                <if test="accountNames!=null">
+                    or login.account_name in
+                    <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                       #{item}
-                  </foreach>
-              </if>
-            <if test="projectIds!=null">
-                or login.project_id in
-                <foreach item="item" index="index" collection="projectIds" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
+                    </foreach>
+                </if>
+                <if test="projectIds!=null">
+                    or login.project_id in
+                    <foreach item="item" index="index" collection="projectIds" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
               )
         </if>
     </select>

+ 19 - 19
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportAppHourMapper.xml

@@ -15,12 +15,12 @@
             hour
        from (select num,date,hour
 from ctop_pangolin_report_app_hour appHourActive
-         left join ctop_pangolin_app app on app.id = appHourActive.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+         left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
 where appHourActive.type = #{type}
 and date =  #{today} and hour = #{hour}
 <if test="appId!=null">
-    and app.id = #{appId}
+    and app.app_id = #{appId}
 </if>
 <if test="userId!=null">
     and login.user_id = #{userId}
@@ -28,7 +28,7 @@ and date =  #{today} and hour = #{hour}
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or appHourActive.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -44,12 +44,12 @@ and date =  #{today} and hour = #{hour}
 group by appHourActive.date, appHourActive.hour
 union all select num,date,hour
 from ctop_pangolin_report_app_hour appHourActive
-         left join ctop_pangolin_app app on app.id = appHourActive.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+         left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
 where appHourActive.type = #{type}
         and date =  #{yesterday} and hour = #{hour}
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="userId!=null">
             and login.user_id = #{userId}
@@ -57,7 +57,7 @@ where appHourActive.type = #{type}
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or appHourActive.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -73,12 +73,12 @@ where appHourActive.type = #{type}
         group by appHourActive.date, appHourActive.hour
 union all select num,date,hour
 from ctop_pangolin_report_app_hour appHourActive
-         left join ctop_pangolin_app app on app.id = appHourActive.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+         left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
 where appHourActive.type = #{type}
         and date =  #{sevenDaysAgo} and hour = #{hour}
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="userId!=null">
             and login.user_id = #{userId}
@@ -86,7 +86,7 @@ where appHourActive.type = #{type}
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or appHourActive.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -104,8 +104,8 @@ where appHourActive.type = #{type}
     union all
     select num,date,hour
     from ctop_pangolin_report_app_hour appHourActive
-    left join ctop_pangolin_app app on app.id = appHourActive.app_id
-    left join ctop_bind_account_login login on login.account_name = app.account_name
+    left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+    left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
     where appHourActive.type = #{type}
     and date =  #{compareTime1} and hour = #{hour}
     <if test="appId!=null">
@@ -117,7 +117,7 @@ where appHourActive.type = #{type}
     <if test="accountNames!=null or projectIds!=null">
         and  ( 1=0
         <if test="accountNames!=null">
-            or login.account_name in
+            or appHourActive.account_name in
             <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                 #{item}
             </foreach>
@@ -136,12 +136,12 @@ where appHourActive.type = #{type}
             union all
             select num,date,hour
             from ctop_pangolin_report_app_hour appHourActive
-            left join ctop_pangolin_app app on app.id = appHourActive.app_id
-            left join ctop_bind_account_login login on login.account_name = app.account_name
+            left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+            left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
             where appHourActive.type = #{type}
             and date =  #{compareTime2} and hour = #{hour}
             <if test="appId!=null">
-                and app.id = #{appId}
+                and app.app_id = #{appId}
             </if>
             <if test="userId!=null">
                 and login.user_id = #{userId}
@@ -149,7 +149,7 @@ where appHourActive.type = #{type}
             <if test="accountNames!=null or projectIds!=null">
                 and  ( 1=0
                 <if test="accountNames!=null">
-                    or login.account_name in
+                    or appHourActive.account_name in
                     <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                         #{item}
                     </foreach>

+ 4 - 4
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportBillMonthMapper.xml

@@ -16,14 +16,14 @@
        round(avg(bill.account_quality_score),2) as 'account_quality_score',
        sum(bill.actual_total_price) as 'actual_total_price'
     from ctop_pangolin_report_bill_month bill
-         left join ctop_pangolin_app app on app.id = bill.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = bill.app_id
+         left join ctop_bind_account_login login on login.account_name = bill.account_name
          where 1=1
          <if test="userId!=null">
              and login.user_id = #{userId}
          </if>
          <if test="appId!=null">
-             and app.id = #{appId}
+             and app.app_id = #{appId}
          </if>
         <if test="startDate!=null">
             and bill.date &gt;= #{startDate}
@@ -37,7 +37,7 @@
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or bill.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>

+ 10 - 12
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportChannelDailyMapper.xml

@@ -6,7 +6,8 @@
             resultType="cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportChannelDaily">
         select
             daily.date,
-            channel.name as 'channel_name',
+--             daily.channel_name as 'channel_name',
+            '-' as 'channel_name',
             <if test="appId == null">
                 '-' as 'app_name',
             </if>
@@ -18,15 +19,14 @@
             sum(daily.total_price)as 'total_price'
         from
         ctop_pangolin_report_channel_daily daily
-        left join ctop_pangolin_channel channel on channel.name = daily.channel_name
-        left join ctop_bind_account_login login on login.account_name = channel.account_name
-        left join ctop_pangolin_app app on app.account_name = channel.account_name
+        left join ctop_bind_account_login login on login.account_name = daily.account_name
+        left join ctop_pangolin_app app on app.name = daily.app_name and app.account_name = daily.account_name
         where 1=1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="startDate!=null">
             and daily.date &gt;= #{startDate}
@@ -40,7 +40,7 @@
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or daily.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -60,15 +60,14 @@
             sum(daily.external_activation)
         from
         ctop_pangolin_report_channel_daily daily
-        left join ctop_pangolin_channel channel on channel.name = daily.channel_name
-        left join ctop_bind_account_login login on login.account_name = channel.account_name
-        left join ctop_pangolin_app app on app.account_name = channel.account_name
+        left join ctop_bind_account_login login on login.account_name = daily.account_name
+        left join ctop_pangolin_app app on app.account_name = daily.account_name and daily.app_name = app.name
         where 1=1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="startDate!=null">
             and daily.date &gt;= #{startDate}
@@ -82,7 +81,7 @@
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or daily.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -95,7 +94,6 @@
             </if>
             )
         </if>
-
     </select>
 
 </mapper>

+ 2 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinAppService.java

@@ -10,4 +10,6 @@ public interface PangolinAppService extends IService<PangolinApp> {
     Map<String, Object> getListByUserId(String userId, JSONObject data);
 
     Map<String, Object> getMemberList(String userId);
+
+    void saveOrUpdateApp(PangolinApp app);
 }

+ 16 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinAppServiceImpl.java

@@ -10,6 +10,7 @@ import cn.com.ctop.crawler.modules.pangolin.mapper.PangolinAppMapper;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -59,4 +60,19 @@ public class PangolinAppServiceImpl extends ServiceImpl<PangolinAppMapper, Pango
         ResultMapUtils.setResultMap(resultMap,StatusCode.COMMON_SUCCESS);
         return resultMap;
     }
+
+    @Override
+    public void saveOrUpdateApp(PangolinApp app) {
+        QueryWrapper<PangolinApp>queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_name",app.getAccountName());
+        queryWrapper.eq("app_id",app.getAppId());
+        queryWrapper.last(" limit 1");
+        PangolinApp getApp = this.getOne(queryWrapper);
+        if(null == getApp){
+            this.save(app);
+        }else{
+            getApp.setName(app.getName());
+            this.updateById(getApp);
+        }
+    }
 }

+ 24 - 13
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java

@@ -80,11 +80,13 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     pangolinReportBillMonth.setYear(Integer.parseInt(date.split("-")[0]));
                     pangolinReportBillMonth.setMonth(Integer.parseInt(date.split("-")[1]));
                     pangolinReportBillMonth.setDate(date);
+                    pangolinReportBillMonth.setAccountName(bindAccountLogin.getAccountName());
                     QueryWrapper<PangolinReportBillMonth> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("os", pangolinReportBillMonth.getOs());
                     queryWrapper.eq("app_id", pangolinReportBillMonth.getAppId());
                     queryWrapper.eq("month", pangolinReportBillMonth.getMonth());
                     queryWrapper.eq("year", pangolinReportBillMonth.getYear());
+                    queryWrapper.eq("account_name", pangolinReportBillMonth.getAccountName());
                     if (pangolinReportBillMonthService.getOne(queryWrapper) == null) {
                         pangolinReportBillMonthService.save(pangolinReportBillMonth);
                     } else {
@@ -131,21 +133,21 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     String name = appNode.get("Name").asText();
                     PangolinApp app = new PangolinApp();
                     app.setAccountName(bindAccountLogin.getAccountName());
-                    app.setId(id);
+                    app.setAppId(id);
                     app.setName(name);
-                    pangolinAppService.saveOrUpdate(app);
-                }
-                Iterator<JsonNode> channelIterator = resultNode.get("data").get("ChannelNameList").elements();
-                while (channelIterator.hasNext()) {
-                    JsonNode channelNode = channelIterator.next();
-                    Long id = channelNode.get("Id").asLong();
-                    String name = channelNode.get("Name").asText();
-                    PangolinChannel channel = new PangolinChannel();
-                    channel.setAccountName(bindAccountLogin.getAccountName());
-                    channel.setId(id);
-                    channel.setName(name);
-                    pangolinChannelService.saveOrUpdate(channel);
+                    pangolinAppService.saveOrUpdateApp(app);
                 }
+//                Iterator<JsonNode> channelIterator = resultNode.get("data").get("ChannelNameList").elements();
+//                while (channelIterator.hasNext()) {
+//                    JsonNode channelNode = channelIterator.next();
+//                    Long id = channelNode.get("Id").asLong();
+//                    String name = channelNode.get("Name").asText();
+//                    PangolinChannel channel = new PangolinChannel();
+//                    channel.setAccountName(bindAccountLogin.getAccountName());
+//                    channel.setId(id);
+//                    channel.setName(name);
+//                    pangolinChannelService.saveOrUpdate(channel);
+//                }
             }
         } catch (IOException e) {
             e.printStackTrace();
@@ -208,9 +210,12 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     pangolinReportChannelDaily.setOprateSystem(os);
                     pangolinReportChannelDaily.setRetentionRatio(retentionRatio);
                     pangolinReportChannelDaily.setTotalPrice(totalPrice);
+                    pangolinReportChannelDaily.setAccountName(bindAccountLogin.getAccountName());
                     QueryWrapper<PangolinReportChannelDaily> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("date", pangolinReportChannelDaily.getDate());
+                    queryWrapper.eq("app_name", pangolinReportChannelDaily.getAppName());
                     queryWrapper.eq("channel_name", pangolinReportChannelDaily.getChannelName());
+                    queryWrapper.eq("account_name", bindAccountLogin.getAccountName());
                     if (pangolinReportChannelDailyService.getOne(queryWrapper) == null) {
                         pangolinReportChannelDailyService.save(pangolinReportChannelDaily);
                     } else {
@@ -269,6 +274,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     for (int i = 0; i < size; i++) {
                         BigDecimal clickNum = clickNode.get(i).decimalValue();
                         PangolinReportAppHour pangolinReportAppHour = new PangolinReportAppHour();
+                        pangolinReportAppHour.setAccountName(bindAccountLogin.getAccountName());
                         pangolinReportAppHour.setAppId(appId);
                         pangolinReportAppHour.setDate(DateUtils.parseDate(date, "yyyy-MM-dd"));
                         pangolinReportAppHour.setNum(clickNum);
@@ -279,6 +285,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                         queryWrapper.eq("app_id", pangolinReportAppHour.getAppId());
                         queryWrapper.eq("type", pangolinReportAppHour.getType());
                         queryWrapper.eq("hour", pangolinReportAppHour.getHour());
+                        queryWrapper.eq("account_name", pangolinReportAppHour.getAccountName());
                         if (pangolinReportAppHourService.getOne(queryWrapper) == null) {
                             pangolinReportAppHourService.save(pangolinReportAppHour);
                         } else {
@@ -294,6 +301,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     for (int i = 0; i < size; i++) {
                         BigDecimal activeNum = activeNode.get(i).decimalValue();
                         PangolinReportAppHour pangolinReportAppHour = new PangolinReportAppHour();
+                        pangolinReportAppHour.setAccountName(bindAccountLogin.getAccountName());
                         pangolinReportAppHour.setAppId(appId);
                         pangolinReportAppHour.setDate(DateUtils.parseDate(date, "yyyy-MM-dd"));
                         pangolinReportAppHour.setNum(activeNum);
@@ -304,6 +312,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                         queryWrapper.eq("app_id", pangolinReportAppHour.getAppId());
                         queryWrapper.eq("type", pangolinReportAppHour.getType());
                         queryWrapper.eq("hour", pangolinReportAppHour.getHour());
+                        queryWrapper.eq("account_name", pangolinReportAppHour.getAccountName());
                         if (pangolinReportAppHourService.getOne(queryWrapper) == null) {
                             pangolinReportAppHourService.save(pangolinReportAppHour);
                         } else {
@@ -319,6 +328,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     for (int i = 0; i < size; i++) {
                         BigDecimal clickNum = rateNode.get(i).decimalValue();
                         PangolinReportAppHour pangolinReportAppHour = new PangolinReportAppHour();
+                        pangolinReportAppHour.setAccountName(bindAccountLogin.getAccountName());
                         pangolinReportAppHour.setAppId(appId);
                         pangolinReportAppHour.setDate(DateUtils.parseDate(date, "yyyy-MM-dd"));
                         pangolinReportAppHour.setNum(clickNum);
@@ -329,6 +339,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                         queryWrapper.eq("app_id", pangolinReportAppHour.getAppId());
                         queryWrapper.eq("type", pangolinReportAppHour.getType());
                         queryWrapper.eq("hour", pangolinReportAppHour.getHour());
+                        queryWrapper.eq("account_name", pangolinReportAppHour.getAccountName());
                         if (pangolinReportAppHourService.getOne(queryWrapper) == null) {
                             pangolinReportAppHourService.save(pangolinReportAppHour);
                         } else {

+ 0 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java

@@ -24,7 +24,6 @@ public class PangolinReportAppHourServiceImpl extends ServiceImpl<PangolinReport
 
     @Override
     public Map<String, Object> getRealTimeData(String userId, JSONObject data) {
-
         Map<String, Object> resultMap = new HashMap<>();
         String today = DateUtils.formatDate();
         String yesterday = DateUtils.addDay(today,-1);

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

@@ -13,7 +13,6 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadImageService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadService;
@@ -21,7 +20,6 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
@@ -35,7 +33,6 @@ import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
 import java.io.File;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
@@ -199,8 +196,10 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                     if (resultJson.getInteger("code") == 0) {
                                         JSONObject dataJson = resultJson.getJSONObject("data");
                                         if (!Check.isNull(dataJson)) {
-                                            String photoId = dataJson.getString("photo_id");
+
                                             String signature = dataJson.getString("signature");
+                                           /*
+                                             String photoId = dataJson.getString("photo_id");
                                             KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
                                             videoGet.setAccountId(accountId);
                                             videoGet.setId(accountId + photoId);
@@ -226,8 +225,8 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                             videoGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
                                             videoGet.setCoverUrl(materialInfo.getUrl() + "?x-oss-process=video/snapshot,t_0,m_fast");
                                             videoGet.setUploadDate(new Date());
-                                            kuaiShouVideoGetService.saveOrUpdate(videoGet);
-                                            materialUploadImageService.uploadImage(videoGet.getSignature(), accountId, ctopOauthToken.getAccessToken());
+                                            kuaiShouVideoGetService.saveOrUpdate(videoGet);*/
+                                            materialUploadImageService.uploadImage(signature, accountId, ctopOauthToken.getAccessToken());
 
                                         }
                                         log.info("快手素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);

+ 22 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceAccountBidJob.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceBidWarningService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BytedanceAccountBidJob {
+    @Autowired
+    private IBytedanceBidWarningService bidWarningService;
+
+    /**
+     * 出价预警
+     */
+    @XxlJob("bytedanceAccountBidJob")
+    public ReturnT<String> execute(String params) throws Exception {
+        bidWarningService.bidWarning();
+        return ReturnT.SUCCESS;
+    }
+}

+ 55 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceCampaignDailyReportLoadJob.java

@@ -0,0 +1,55 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+@Component
+public class BytedanceCampaignDailyReportLoadJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
+    static ExecutorService executorService = null;
+
+
+    @XxlJob("bytedanceCampaignDailyReport")
+    public ReturnT<String> execute(String params) throws Exception {
+        XxlJobLogger.log("头条广告组日报获取任务执行开始");
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobLogger.log("定时获取头条数据异常:为获取到可用的token");
+            return ReturnT.FAIL;
+        }
+        executorService = Executors.newFixedThreadPool(5);
+        CountDownLatch countDownLatch = new CountDownLatch(tokens.size());
+        tokens.forEach(token -> {
+            executorService.submit(() -> {
+                try {
+                    reportService.getAdvertiserCampaignReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                } catch (Exception e) {
+                    XxlJobLogger.log(e);
+                } finally {
+                    countDownLatch.countDown();
+                }
+            });
+        });
+        countDownLatch.await();
+        XxlJobLogger.log("头条广告组日报获取任务执行结束");
+        return ReturnT.SUCCESS;
+    }
+}

+ 54 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceCampaignHourlyReportLoadJob.java

@@ -0,0 +1,54 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class BytedanceCampaignHourlyReportLoadJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
+    static ExecutorService executorService = null;
+
+    @XxlJob("bytedanceCampaignHourlyReport")
+    public ReturnT<String> execute(String param) throws Exception {
+        XxlJobLogger.log("头条广告组时报数据获取开始");
+        Date getDate = new Date();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+        String hour = simpleDateFormat.format(getDate);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobLogger.log("定时获取头条小时数据异常:未获取到可用的token");
+            return ReturnT.FAIL;
+        }
+        executorService = Executors.newFixedThreadPool(4);
+        tokens.forEach(token -> {
+            executorService.submit(() -> {
+                if (null != hour && "00".equals(hour)) {
+                    Date finalGetDate = DateUtils.addDay(getDate, -1);
+                    //获取广告主信息数据
+                    reportService.getAdvertiserCampaignReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                }
+                reportService.getAdvertiserCampaignReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+            });
+        });
+        XxlJobLogger.log("头条广告组时报数据获取结束");
+        return ReturnT.SUCCESS;
+    }
+}

+ 22 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountBidJob.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.material.service.IKuaishouBidWarningService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class KuaishouAccountBidJob {
+    @Autowired
+    private IKuaishouBidWarningService bidWarningService;
+
+    /**
+     * 出价预警
+     **/
+    @XxlJob("kuaishouAccountBidJob")
+    public ReturnT<String> execute(String param) {
+        bidWarningService.bidWarning();
+        return ReturnT.SUCCESS;
+    }
+}

+ 7 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSuZaoLoadJob.java

@@ -6,6 +6,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -25,8 +26,13 @@ public class KuaishouSuZaoLoadJob {
     public ReturnT<String> execute(String param) throws Exception {
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         executorService = Executors.newFixedThreadPool(8);
-        tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1)));
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+        String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
+        tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate)));
         XxlJobLogger.log("快手素造数据同步完成");
         return ReturnT.SUCCESS;
     }
+
+
 }

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

@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -115,6 +116,25 @@ public class BatchController {
             spendVo.setBudget(budget);
             result.setSuccess(true);
             result.setResult(spendVo);
+
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+
+            List dateList = new ArrayList();
+            dateList.add(nowDate);
+            dateList.add(anotherDay);
+
+
+            Thread planThread = new Thread() {
+                @Override
+                public void run() {
+                    iKuaishouInterfaceService.getCampaignList(oauthToken, new java.util.Date(), new java.util.Date());
+
+                }
+            };
+            planThread.start();
+
+
             Thread thread = new Thread() {
                 @Override
                 public void run() {
@@ -131,10 +151,14 @@ public class BatchController {
             };
             thread1.start();
 
+
             Thread thread2 = new Thread() {
                 @Override
                 public void run() {
-                    iKuaishouInterfaceService.getVideoList(oauthToken, DateUtils.getNowDate("yyyy-MM-dd"));
+                    for (int i = 0; i < dateList.size(); i++) {
+                        String date = (String) dateList.get(i);
+                        iKuaishouInterfaceService.getVideoList(oauthToken, date);
+                    }
                 }
             };
             thread2.start();
@@ -142,8 +166,10 @@ public class BatchController {
             Thread thread3 = new Thread() {
                 @Override
                 public void run() {
-                    iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), oauthToken.getAccountId(), 1);
-                    videoGetService.getKeyFrame(oauthToken);
+                    String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                    String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+                    String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
+                    iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), oauthToken.getAccountId(), 1, startDate, endDate);
                 }
             };
             thread3.start();
@@ -157,7 +183,6 @@ public class BatchController {
             };
             thread4.start();
 
-
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);

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

@@ -75,8 +75,6 @@ public class KuaiShouVideoGet {
     private String signature;
 
     private Date statDate;
-    private Date  uploadDate;
-
 
     private Integer materialType;
     /**

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

@@ -17,5 +17,5 @@ import java.util.List;
 public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     void replaceBatch(List<KuaiShouVideoGet> videoGets);
 
-    void getKeyFrame(CtopOauthToken token);
+    void getKeyFrame(String token,Long accountId, String md5, String photoId);
 }

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

@@ -1,9 +0,0 @@
-package cn.com.ctop.kuaishou.modules.batch.service;
-
-
-public interface IKuaiShouVideoTimeService {
-
-    java.util.Date getVideoTime(String photoId, Long accountId);
-
-
-}

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

@@ -458,7 +458,7 @@ public interface IKuaishouInterfaceService {
      * @param accountId
      * @param page
      */
-    void getSuZaoList(String token, Long accountId, int page);
+    void getSuZaoList(String token, Long accountId, int page, String startDate,String endDate);
 
     /**
      * 异步获取创意信息

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

@@ -12,6 +12,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
@@ -85,12 +86,13 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
                         videoGet.setMaterialType(type);
                         videoGet.setPhotoId(photoId);
                         videoGet.setSignature(signature);
+                        videoGet.setStatDate(DateUtils.getNowDate());
+                        videoGet.setCoverUrl(url + "?x-oss-process=video/snapshot,t_00000,m_fast");
                         kuaiShouVideoGetService.saveOrUpdate(videoGet);
                         returnJson.put("success", true);
                         returnJson.put("photoId", photoId);
                         returnJson.put("signature", signature);
                         returnJson.put("message", "上传成功");
-
                     }
                     LoadFileUtil.delFile(localUrl);
                     log.info("快手素材上传完成,accountId:{},code:{},返回信息:{}", accountId, signature, resultJson);
@@ -99,7 +101,6 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
                     returnJson.put("success", false);
                     returnJson.put("signature", signature);
                     returnJson.put("message", resultJson.getString("message"));
-
                 }
             } else {
                 log.error("快手上传素材返回信息为空请求参数:{}", requestJson);

+ 49 - 67
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
-import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.utils.Check;
@@ -13,6 +12,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -27,10 +27,10 @@ import java.util.concurrent.Executors;
 /**
  * @Description: 快手-获取视频接口
  * @Author: jeecg-boot
- *
  * @Date: 2019-07-25
  * @Version: V1.0
  */
+@Slf4j
 @Service
 public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMapper, KuaiShouVideoGet> implements IKuaiShouVideoGetService {
     @Autowired
@@ -51,82 +51,64 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     /**
      * 获取关键帧
      *
-     *
      * @param
      */
     @Override
-    public void getKeyFrame(CtopOauthToken token) {
+    public void getKeyFrame(String token, Long accountId, String videoMd5, String photoId) {
         try {
-            QueryWrapper<KuaiShouVideoGet> videoGetQueryWrapper = new QueryWrapper<>();
-            videoGetQueryWrapper.eq("account_id", token.getAccountId());
-            videoGetQueryWrapper.eq("channel_type", 1);
-            List<KuaiShouVideoGet> kuaiShouVideoGets = videoGetMapper.selectList(videoGetQueryWrapper);
-            if (Check.isNull(kuaiShouVideoGets)) {
+            log.info("开始素造抽帧,md5:{}", videoMd5);
+            QueryWrapper<MaterialCutFrame> cutFrameQueryWrapper = new QueryWrapper<>();
+            cutFrameQueryWrapper.eq("video_signature", videoMd5);
+            cutFrameQueryWrapper.last("limit 1");
+            MaterialCutFrame one = materialCutFrameService.getOne(cutFrameQueryWrapper);
+            if (!Check.isNull(one)) {
                 return;
             }
-            for (KuaiShouVideoGet videoGet : kuaiShouVideoGets) {
-                synchronized (this) {
-                    if (!Check.isNull(videoGet.getSignature())) {
-                        QueryWrapper<MaterialCutFrame> cutFrameQueryWrapper = new QueryWrapper<>();
-                        cutFrameQueryWrapper.eq("video_signature", videoGet.getSignature());
-                        cutFrameQueryWrapper.last("limit 1");
-                        MaterialCutFrame one = materialCutFrameService.getOne(cutFrameQueryWrapper);
-                        if (!Check.isNull(one)) {
-                            continue;
-                        }
-                    }
-
-                    executorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/key_frame";
-                            JSONArray photoArr = new JSONArray();
-                            photoArr.add(videoGet.getPhotoId());
-                            Map<String, String> headers = new HashMap<>();
-                            headers.put("Access-Token", token.getAccessToken());
-                            headers.put("Content-Type", "application/json");
-                            JSONObject requestJson = new JSONObject();
-                            requestJson.put("advertiser_id", token.getAccountId());
-                            requestJson.put("photo_ids", photoArr);
-                            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
-                            JSONObject resultJson = JSONObject.parseObject(result);
-                            if (!Check.isNull(resultJson)) {
-                                Integer code = resultJson.getInteger("code");
-                                if (code == 0) {
-                                    JSONArray dataArr = resultJson.getJSONArray("data");
-                                    if (!Check.isNull(dataArr)) {
-                                        for (int i = 0; i < dataArr.size(); i++) {
-                                            String imageUrl = dataArr.getString(i);
-                                            String localPath = LoadFileUtil.downLoadFromUrl(imageUrl, downloadUrl);
-                                            String md5 = null;
-                                            try {
-                                                md5 = LoadFileUtil.getMD5(localPath);
-                                            } catch (IOException e) {
-                                                e.printStackTrace();
-                                                continue;
-                                            }
-                                            Map<String, Object> deleteMap = new HashMap<>();
-                                            deleteMap.put("video_signature", videoGet.getSignature());
-                                            deleteMap.put("signature", md5);
-                                            materialCutFrameService.removeByMap(deleteMap);
-
-                                            MaterialCutFrame materialCutFrame = new MaterialCutFrame();
-                                            materialCutFrame.setImageIndex(i);
-                                            materialCutFrame.setVideoSignature(videoGet.getSignature());
-                                            materialCutFrame.setUrl(imageUrl);
-                                            materialCutFrame.setSignature(md5);
-                                            materialCutFrameService.save(materialCutFrame);
-                                            LoadFileUtil.delFile(localPath);
-                                        }
-                                    }
-                                }
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/key_frame";
+            JSONArray photoArr = new JSONArray();
+            photoArr.add(photoId);
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", token);
+            headers.put("Content-Type", "application/json");
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            requestJson.put("photo_ids", photoArr);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONArray dataArr = resultJson.getJSONArray("data");
+                    if (!Check.isNull(dataArr)) {
+                        for (int i = 0; i < dataArr.size(); i++) {
+                            String imageUrl = dataArr.getString(i);
+                            String localPath = LoadFileUtil.downLoadFromUrl(imageUrl, downloadUrl);
+                            String md5 = null;
+                            try {
+                                md5 = LoadFileUtil.getMD5(localPath);
+                            } catch (IOException e) {
+                                e.printStackTrace();
+                                continue;
                             }
+                            Map<String, Object> deleteMap = new HashMap<>();
+                            deleteMap.put("video_signature", videoMd5);
+                            deleteMap.put("signature", md5);
+                            materialCutFrameService.removeByMap(deleteMap);
+                            MaterialCutFrame materialCutFrame = new MaterialCutFrame();
+                            materialCutFrame.setImageIndex(i);
+                            materialCutFrame.setVideoSignature(videoMd5);
+                            materialCutFrame.setUrl(imageUrl);
+                            materialCutFrame.setSignature(md5);
+                            materialCutFrameService.save(materialCutFrame);
+                            LoadFileUtil.delFile(localPath);
                         }
-                    });
+                    }
                 }
-
             }
 
+
+            // }
+
         } catch (Exception e) {
             e.printStackTrace();
         }

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

@@ -1,64 +0,0 @@
-package cn.com.ctop.kuaishou.modules.batch.service.impl;
-
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoTimeService;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAgentAccount;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAgentAccountService;
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-
-@Slf4j
-@Service
-public class KuaiShouVideoTimeServiceImpl implements IKuaiShouVideoTimeService {
-    @Autowired
-    private IKuaishouAgentAccountService agentAccountService;
-
-    @Override
-    public java.util.Date getVideoTime(String photoId, Long accountId) {
-
-        KuaishouAgentAccount agentAccount = agentAccountService.getById(accountId);
-        if (Check.isNull(agentAccount)) {
-            log.info("未获取到userId:accountId:{}",accountId);
-            return null;
-        }
-
-        try {
-            String videoUrl = "http://yongzhou.s.gifshow.com/i/photo/lwx?userId=" + agentAccount.getUserId() + "&photoId=" + photoId;
-            String res = HttpUtils.getKuaishouShareUrl(videoUrl);
-            String path = res.split("\\?")[0];
-            String photoIdStr = path.substring(path.lastIndexOf("/") + 1, path.length());
-            path = path.substring(0, path.lastIndexOf("/"));
-            String uid = path.substring(path.lastIndexOf("/") + 1, path.length());
-            String result = HttpUtils.postKuaishouVideoUrl("https://live.kuaishou.com/m_graphql", uid, photoIdStr);
-            JSONObject resultJson = JSONObject.parseObject(result);
-            if (!Check.isNull(resultJson)) {
-                JSONObject dataJson = resultJson.getJSONObject("data");
-                if (!Check.isNull(dataJson)) {
-                    JSONObject feedById = dataJson.getJSONObject("feedById");
-                    if (!Check.isNull(feedById)) {
-                        JSONObject currentWork = feedById.getJSONObject("currentWork");
-                        if (!Check.isNull(currentWork)) {
-                            Long timestamp = currentWork.getLong("timestamp");
-                            return new java.util.Date(timestamp);
-
-                        }
-
-                    }
-
-                }
-
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("获取时间错误");
-        }
-
-
-        return null;
-    }
-}

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

@@ -222,11 +222,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
                 kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
 
-                Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), token.getAccountId());
-                if (!Check.isNull(videoTime)) {
-                    kuaiShouVideoGet.setUploadDate(videoTime);
-                }
-
                 kuaiShouVideoGet.setAccountId(token.getAccountId());
                 kuaiShouVideoGet.setStatDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
                 kuaiShouVideoGet.setUpdateTime(new Date());
@@ -290,17 +285,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 detailJson.put("photo_comment", detailJson.getString("comment"));
                 detailJson.put("photo_like", detailJson.getString("like"));
                 detailJson.put("photo_show", detailJson.getString("show"));
-                detailJson.remove("share");
-                detailJson.remove("comment");
-                detailJson.remove("like");
-                detailJson.remove("show");
-                detailJson.remove("adScene");
-                detailJson.remove("stat_hour");
-                detailJson.remove("event_valid_clues");
-                detailJson.remove("event_valid_clues_cost");
-                KuaishouReportDailyAccount kuaishouReportDailyAccount = JsonUtil.jsonToObj(detailJson, KuaishouReportDailyAccount.class);
-                kuaishouReportDailyAccount.setAccountId(token.getAccountId());
-                dailyAccountMapper.insertSelective(kuaishouReportDailyAccount);
+                var KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
+                KuaishouReportDailyAccount.setAccountId(token.getAccountId());
+                dailyAccountMapper.insertSelective(KuaishouReportDailyAccount);
             }
         }
         getAccountDailyReportByPage(token, startDate, endDate, page + 1);
@@ -908,6 +895,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
         historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
 
+        getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
         String videoEndDate = DateUtils.addDay(nowDate, -180);
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -2861,20 +2849,27 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param page
      */
     @Autowired
-    private IKuaiShouVideoTimeService videoTimeService;
+    private IKuaiShouVideoGetService videoGetService;
 
     @Override
-    public void getSuZaoList(String token, Long accountId, int page) {
-        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/file/ad/video/su_zao/list";
+    public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token);
         Map<String, Object> param = new HashMap<String, Object>();
         param.put("advertiser_id", accountId);
         param.put("page", page);
-        param.put("page_size", 500);
+        param.put("page_size", 200);
+        if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+            param.put("start_date", startDate);
+            param.put("end_date", endDate);
+        }
+        System.err.println("入参:" + param);
+        System.err.println("headers:" + headers);
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println(resultJson);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {
@@ -2883,40 +2878,45 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         JSONObject dataJson = resultJson.getJSONObject("data");
         if (!Check.isNull(dataJson)) {
-            Integer total_count = dataJson.getInteger("total_count");
-           /* if (total_count > 2000) {
-                return;
-            }*/
             JSONArray details = dataJson.getJSONArray("details");
             if (Check.isNull(details)) {
                 return;
             }
             for (int i = 0; i < details.size(); i++) {
-                var detailJson = details.getJSONObject(i);
+                JSONObject jsonObject = details.getJSONObject(i);
+                if (!Check.isNull(jsonObject)) {
+                    KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
+                    Long photo_id = jsonObject.getLong("photo_id");
+                    kuaiShouVideoGet.setId(accountId + photo_id + "");
+                    kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
+                    kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
+                    kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
+                    kuaiShouVideoGet.setHeight(jsonObject.getInteger("height"));
+                    kuaiShouVideoGet.setCoverUrl(jsonObject.getString("cover_url"));
+                    kuaiShouVideoGet.setAccountId(accountId);
+                    String md5 = jsonObject.getString("md5");
+                    kuaiShouVideoGet.setSignature(md5);
+                    kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
+                    kuaiShouVideoGet.setChannelType(1);
+                    Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
+                    if (!Check.isNull(type)) {
+                        kuaiShouVideoGet.setMaterialType(type);
+                    }
+                    kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
+
+                    Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
+                        }
+                    };
+                    thread.start();
+
 
-                KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(accountId + detailJson.getString("photo_id"));
-                if (!Check.isNull(byId)) {
-                    continue;
-                }
-                var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
-               /* Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), accountId);
-                if (!Check.isNull(videoTime)) {
-                    kuaiShouVideoGet.setUploadDate(videoTime);
-                }*/
-                kuaiShouVideoGet.setStatDate(new Date());
-                kuaiShouVideoGet.setAccountId(accountId);
-                kuaiShouVideoGet.setId(accountId + kuaiShouVideoGet.getPhotoId());
-                kuaiShouVideoGet.setCreateTime(new Date());
-                kuaiShouVideoGet.setUpdateTime(new Date());
-                Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
-                if (!Check.isNull(type)) {
-                    kuaiShouVideoGet.setMaterialType(type);
                 }
-                kuaiShouVideoGet.setChannelType(1);
-                kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
             }
         }
-        getSuZaoList(token, accountId, page + 1);
+        getSuZaoList(token, accountId, page + 1, startDate, endDate);
 
     }
 

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/IKuaishouBidWarningService.java

@@ -0,0 +1,5 @@
+package cn.com.ctop.kuaishou.modules.material.service;
+
+public interface IKuaishouBidWarningService {
+    void bidWarning();
+}

+ 161 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/KuaishouBidWarningServiceImpl.java

@@ -0,0 +1,161 @@
+package cn.com.ctop.kuaishou.modules.material.service.impl;
+
+import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.service.ICorpFeishuUserService;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.SendMailUtil;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.material.service.IKuaishouBidWarningService;
+import cn.com.feishu.provider.MessageProvider;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class KuaishouBidWarningServiceImpl implements IKuaishouBidWarningService {
+    @Autowired
+    private IProjectService projectService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+
+
+    /**
+     * 预警
+     */
+
+    @Override
+    public void bidWarning() {
+        XxlJobLogger.log("快手出价预警定时任务开始");
+        long start = System.currentTimeMillis();
+        try {
+            List<Project> projects = projectService.list();
+            if (Check.isNull(projects)) {
+                return;
+            }
+            for (Project project : projects) {
+                if (Check.isNull(project)) {
+                    continue;
+                }
+                Long maxBid = project.getMaxBid();
+                Long projectId = project.getId();
+                List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                if (!Check.isNull(userAllocations)) {
+                    for (UserAllocation userAllocation : userAllocations) {
+                        if (userAllocation.getAccountStatus() == 1) {
+                            continue;
+                        }
+                        Long accountId = userAllocation.getAccountId();
+                        List<String> unitWarning = new ArrayList<>();
+                        if ("2".equals(userAllocation.getMediaId())) {
+                            unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
+                            sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                            sendFeishumessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                        }
+                    }
+                }
+            }
+            XxlJobLogger.log("出价预警定时任务执行完毕,共耗时:{} s", (System.currentTimeMillis() - start) / 1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    private void sendFeishumessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) throws Exception {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, Integer.getInteger(mediaId));
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "\n\r";
+
+        }
+        text.append("项目出价预警").append("\n\r").append("您的项目:").append(projectName + ",").append("\n\r")
+                .append("授权名称为:" + authName + " 下的,").append("\n\r").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        JSONArray openIds = corpFeishuUserService.getOpenIdByParams(projectId);
+        if(null == openIds||openIds.isEmpty()){
+            XxlJobLogger.log("该项目下运营飞书账号尚未绑定邮箱=>projectId:{}",projectId);
+            return;
+        }
+        MessageProvider.batchSend(null,openIds,null,text.toString());
+    }
+
+    @Autowired
+    private ICorpFeishuUserService corpFeishuUserService;
+
+    private void sendMessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "<br/>";
+        }
+        text.append("项目出价预警").append("<br/>").append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("授权名称为:" + authName + " 下的,").append("<br/>").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+    }
+}

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

@@ -446,7 +446,7 @@
             and t1.stat_date = #{statDate}
         </if>
         ) t2
-        WHERE t2.campaignName in(845,846,847,848,849,850,1071,1072,1066,1069,1064)
+        WHERE t2.campaignName in(845,846,847,848,849,850,1070,1071,1072,1066,1069,1064)
 
     </select>
 

+ 259 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/BytedanceAreaInfoController.java

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

+ 171 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/BytedanceInterestCategoryController.java

@@ -0,0 +1,171 @@
+package cn.com.ctop.toutiao.modules.batch.controller;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceInterestCategory;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceInterestCategoryService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+@RestController
+@Slf4j
+public class BytedanceInterestCategoryController {
+    @Autowired
+    private IBytedanceInterestCategoryService bytedanceInterestCategoryService;
+
+    @GetMapping(value = "/listbycode")
+    public Result<IPage<BytedanceInterestCategory>> queryPageListByCode(@RequestParam(name = "parentCode", defaultValue = "0") String code,
+                                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                        HttpServletRequest req) {
+        Result<IPage<BytedanceInterestCategory>> result = new Result<>();
+        BytedanceInterestCategory category = new BytedanceInterestCategory();
+        QueryWrapper<BytedanceInterestCategory> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
+        queryWrapper.eq("parent_code", code);
+        Page<BytedanceInterestCategory> page = new Page<>(pageNo, pageSize);
+        IPage<BytedanceInterestCategory> pageList = bytedanceInterestCategoryService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 分页列表查询
+     *
+     * @param bytedanceInterestCategory
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-分页列表查询")
+    @ApiOperation(value = "兴趣分类信息-分页列表查询", notes = "兴趣分类信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<BytedanceInterestCategory>> queryPageList(BytedanceInterestCategory bytedanceInterestCategory,
+                                                                  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                  HttpServletRequest req) {
+        Result<IPage<BytedanceInterestCategory>> result = new Result<>();
+        QueryWrapper<BytedanceInterestCategory> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceInterestCategory, req.getParameterMap());
+        Page<BytedanceInterestCategory> page = new Page<>(pageNo, pageSize);
+        IPage<BytedanceInterestCategory> pageList = bytedanceInterestCategoryService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param bytedanceInterestCategory
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-添加")
+    @ApiOperation(value = "兴趣分类信息-添加", notes = "兴趣分类信息-添加")
+    @PostMapping(value = "/add")
+    public Result<BytedanceInterestCategory> add(@RequestBody BytedanceInterestCategory bytedanceInterestCategory) {
+        Result<BytedanceInterestCategory> result = new Result<>();
+        try {
+            bytedanceInterestCategoryService.save(bytedanceInterestCategory);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param bytedanceInterestCategory
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-编辑")
+    @ApiOperation(value = "兴趣分类信息-编辑", notes = "兴趣分类信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<BytedanceInterestCategory> edit(@RequestBody BytedanceInterestCategory bytedanceInterestCategory) {
+        Result<BytedanceInterestCategory> result = new Result<>();
+        BytedanceInterestCategory bytedanceInterestCategoryEntity = bytedanceInterestCategoryService.getById(bytedanceInterestCategory.getId());
+        if (bytedanceInterestCategoryEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = bytedanceInterestCategoryService.updateById(bytedanceInterestCategory);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-通过id删除")
+    @ApiOperation(value = "兴趣分类信息-通过id删除", notes = "兴趣分类信息-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            bytedanceInterestCategoryService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-批量删除")
+    @ApiOperation(value = "兴趣分类信息-批量删除", notes = "兴趣分类信息-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<BytedanceInterestCategory> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<BytedanceInterestCategory> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.bytedanceInterestCategoryService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "兴趣分类信息-通过id查询")
+    @ApiOperation(value = "兴趣分类信息-通过id查询", notes = "兴趣分类信息-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<BytedanceInterestCategory> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<BytedanceInterestCategory> result = new Result<>();
+        BytedanceInterestCategory bytedanceInterestCategory = bytedanceInterestCategoryService.getById(id);
+        if (bytedanceInterestCategory == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(bytedanceInterestCategory);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+}
+

+ 72 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/entity/BytedanceAreaInfo.java

@@ -0,0 +1,72 @@
+package cn.com.ctop.toutiao.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 省市县信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-09-17
+ */
+@Data
+@TableName("ctop_bytedance_area_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_bytedance_area_info对象", description = "省市县信息")
+public class BytedanceAreaInfo {
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * name
+     */
+    @Excel(name = "name", width = 15)
+    @ApiModelProperty(value = "name")
+    private String name;
+    /**
+     * code
+     */
+    @Excel(name = "code", width = 15)
+    @ApiModelProperty(value = "code")
+    private String code;
+    /**
+     * parentCode
+     */
+    @Excel(name = "parentCode", width = 15)
+    @ApiModelProperty(value = "parentCode")
+    private String parentCode;
+    /**
+     * level
+     */
+    @Excel(name = "level", width = 15)
+    @ApiModelProperty(value = "level")
+    private Integer level;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private Boolean hasChild;
+}

+ 73 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/entity/BytedanceInterestCategory.java

@@ -0,0 +1,73 @@
+package cn.com.ctop.toutiao.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 兴趣分类信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-09-18
+ */
+@Data
+@TableName("ctop_bytedance_interest_category")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_bytedance_interest_category对象", description = "兴趣分类信息")
+public class BytedanceInterestCategory {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 名称
+     */
+    @Excel(name = "名称", width = 15)
+    @ApiModelProperty(value = "名称")
+    private String name;
+    /**
+     * code
+     */
+    @Excel(name = "code", width = 15)
+    @ApiModelProperty(value = "code")
+    private String code;
+    /**
+     * parentCode
+     */
+    @Excel(name = "parentCode", width = 15)
+    @ApiModelProperty(value = "parentCode")
+    private String parentCode;
+    /**
+     * level
+     */
+    @Excel(name = "level", width = 15)
+    @ApiModelProperty(value = "level")
+    private Integer level;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private Boolean hasChild;
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.toutiao.modules.batch.mapper;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceAreaInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 省市县信息
+ *
+ * @author: jeecg-boot
+ * @date: 2019-09-17
+ * @cersion: V1.0
+ */
+public interface BytedanceAreaInfoMapper extends BaseMapper<BytedanceAreaInfo> {
+
+}

+ 7 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/mapper/BytedanceInterestCategoryMapper.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.toutiao.modules.batch.mapper;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceInterestCategory;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface BytedanceInterestCategoryMapper extends BaseMapper<BytedanceInterestCategory> {
+}

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

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

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

@@ -0,0 +1,16 @@
+package cn.com.ctop.toutiao.modules.batch.service;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceAreaInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 省市县信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-09-17
+ */
+public interface IBytedanceAreaInfoService extends IService<BytedanceAreaInfo> {
+
+    boolean hasChild(BytedanceAreaInfo areaInfo);
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.toutiao.modules.batch.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCampaign;
+import com.alibaba.fastjson.JSONArray;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IBytedanceGroupApiService {
+    List<ByteDanceCampaign> getGroupListByParams(CtopOauthToken token, JSONArray ids, String campaignName, String landingType, String status, String campaignCreateTime, Integer page, Integer pageSize);
+    Map<String,Object>createGroup(CtopOauthToken token,String campaignName,String operation,String budgetMode,String budget,String landingType,String uniqueFk);
+    Map<String,Object>updateGroup(CtopOauthToken token, String campaignId, String campaignName, String modifyTime,String budget);
+}

+ 7 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/IBytedanceInterestCategoryService.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.toutiao.modules.batch.service;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceInterestCategory;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+public interface IBytedanceInterestCategoryService extends IService<BytedanceInterestCategory> {
+}

+ 33 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/impl/BytedanceAreaInfoServiceImpl.java

@@ -0,0 +1,33 @@
+package cn.com.ctop.toutiao.modules.batch.service.impl;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceAreaInfo;
+import cn.com.ctop.toutiao.modules.batch.mapper.BytedanceAreaInfoMapper;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceAreaInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 省市县信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-09-17
+ */
+@Service
+public class BytedanceAreaInfoServiceImpl extends ServiceImpl<BytedanceAreaInfoMapper, BytedanceAreaInfo> implements IBytedanceAreaInfoService {
+
+    @Override
+    public boolean hasChild(BytedanceAreaInfo areaInfo) {
+        QueryWrapper<BytedanceAreaInfo>queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("parent_code",areaInfo.getCode());
+        List<BytedanceAreaInfo>areaInfos = this.list(queryWrapper);
+        if(null == areaInfos||areaInfos.isEmpty()){
+            return false;
+        }else{
+            return true;
+        }
+    }
+}

+ 142 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/impl/BytedanceGroupApiServiceImpl.java

@@ -0,0 +1,142 @@
+package cn.com.ctop.toutiao.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceGroupApiService;
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCampaign;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+@Slf4j
+public class BytedanceGroupApiServiceImpl implements IBytedanceGroupApiService {
+    @Override
+    /**
+     * 获取广告组数据
+     */
+    public List<ByteDanceCampaign> getGroupListByParams(CtopOauthToken token, JSONArray ids, String campaignName, String landingType, String status, String campaignCreateTime, Integer page, Integer pageSize) {
+        List<ByteDanceCampaign> campaigns = new ArrayList<>();
+        // 请求地址
+        String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
+        // 请求参数
+        JSONObject filtering = new JSONObject();
+        if(null!=ids&&!ids.isEmpty()){
+            filtering.put("ids",ids);
+        }
+        if(null!=campaignName&&!campaignName.equals("")){
+            filtering.put("campaign_name",campaignName);
+        }
+        if(null!=landingType&&!landingType.equals("")){
+            filtering.put("landing_type",landingType);
+        }
+        if(null!=status&&!status.equals("")){
+            filtering.put("status",status);
+        }
+        if(null!=campaignCreateTime&&!campaignCreateTime.equals("")){
+            filtering.put("campaign_create_time",landingType);
+        }
+
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("page", page);
+        params.put("page_size", pageSize);
+        params.put("filtering", filtering);
+        JSONObject result = HttpUtils.bytedanceGetRequest(token.getAccessToken(),url,params);
+        if(result == null){
+            log.error("获取广告组数据异常=>param:{}",params.toJSONString());
+            return campaigns;
+        }
+        Integer code = result.getInteger("code");
+        String message = result.getString("message");
+        if(null == code||!code.equals(0)){
+            log.error("获取广告组数据异常=>{},param:{}",message,params.toJSONString());
+            return campaigns;
+        }
+        JSONArray dataList = result.getJSONObject("data").getJSONArray("list");
+        if(null == dataList||dataList.isEmpty()){
+            log.info("获取广告组数据为空=>param:{}",params.toJSONString());
+            return campaigns;
+        }
+        for(int i=0;i<dataList.size();i++){
+            JSONObject data = dataList.getJSONObject(i);
+            ByteDanceCampaign campaign = new ByteDanceCampaign(data,token.getAccountId().toString());
+            campaigns.add(campaign);
+        }
+        return campaigns;
+    }
+
+    /**
+     * 每个广告主账号下最多可允许创建500个广告组,如超出需要先删除一部分广告组后才可继续创建。
+     * @param token
+     * @param campaignName
+     * @param operation
+     * @param budgetMode
+     * @param budget
+     * @param landingType
+     * @param uniqueFk
+     * @return
+     */
+    @Override
+    public Map<String, Object> createGroup(CtopOauthToken token, String campaignName, String operation, String budgetMode, String budget, String landingType, String uniqueFk) {
+        Map<String,Object>result = new HashMap<>();
+        // 请求地址
+        String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_create");
+        // 请求参数
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id",token.getAccountId());
+        param.put("campaign_name",campaignName);
+        if(null!=operation&&!operation.trim().equals("")){
+            param.put("operation",operation);
+        }
+        param.put("budget_mode", budgetMode);
+        if(null != budget&&!budget.trim().equals("")){
+            param.put("budget",budget);
+        }
+        param.put("landing_type", landingType);
+        if(null != uniqueFk&&!uniqueFk.trim().equals("")){
+            param.put("unique_fk",uniqueFk);
+        }
+        JSONObject data = HttpUtils.bytedancePostRequest(url,token.getAccessToken(),param);
+        if(data == null){
+            log.error("创建广告组异常=>param:{}",param.toJSONString());
+            ResultMapUtils.setResultMap(result, StatusCode.BYTEDACNE_API_GROUP_CREATE_ERROR);
+            return result;
+        }
+        Integer code = data.getInteger("code");
+        String message = data.getString("message");
+        if(null == code||!code.equals(0)){
+            log.error("获取广告组数据异常=>{},parmas:{}",message,param.toJSONString());
+            ResultMapUtils.setResultMap(result,-1,message,false);
+            return result;
+        }
+        Long campaignId = data.getJSONObject("data").getLong("campaign_id");
+        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        result.put("campaign_id",campaignId);
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> updateGroup(CtopOauthToken token, String campaignId, String campaignName, String modifyTime,String budget) {
+        // 请求地址
+        String url = "https://ad.oceanengine.com/open_api/2/campaign/update/";
+        // 请求参数
+        JSONObject data = new JSONObject();
+        data.put("advertiser_id",token.getAccountId());
+        data.put("campaign_name",campaignName);
+        data.put("budget",budget);
+        data.put("campaign_id", campaignId);
+        data.put("modify_time", modifyTime);
+        JSONObject result = HttpUtils.bytedancePostRequest(token.getAccessToken(),url,data);
+        return new HashMap<>();
+    }
+}

+ 11 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/impl/BytedanceInterestCategoryServiceImpl.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.toutiao.modules.batch.service.impl;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceInterestCategory;
+import cn.com.ctop.toutiao.modules.batch.mapper.BytedanceInterestCategoryMapper;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceInterestCategoryService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BytedanceInterestCategoryServiceImpl extends ServiceImpl<BytedanceInterestCategoryMapper, BytedanceInterestCategory> implements IBytedanceInterestCategoryService {
+}

+ 4 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceCampaign.java

@@ -195,4 +195,8 @@ public class ByteDanceCampaign {
         this.createTime = now;
         this.updateTime = now;
     }
+
+    public ByteDanceCampaign(JSONObject data, CtopOauthToken token) {
+
+    }
 }

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java

@@ -11,7 +11,7 @@ import java.util.Map;
 public interface IByteDanceAdvertiserDataService {
     JSONObject getAdvertiserList(String token, Long accountId);
 
-    Map<String, Object> getAdvertiserInfo(String accountId);
+    Map<String, Object> getAdvertiserInfo(String accountId, String token);
 
     Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date, String updateDate);
 

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceBidWarningService.java

@@ -0,0 +1,5 @@
+package cn.com.ctop.toutiao.modules.material.service;
+
+public interface IBytedanceBidWarningService {
+    void bidWarning();
+}

+ 4 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -86,17 +86,17 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     }
 
     @Override
-    public Map<String, Object> getAdvertiserInfo(String accountId) {
+    public Map<String, Object> getAdvertiserInfo(String accountId,String token) {
         Map<String, Object> resultMap = new HashMap<>();
-        CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
+     //   CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
         //2: 根据token以及用户id获取用户信息数据
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_advertiser_info");
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", cTopOauthToken.getAccessToken());
+        headers.put("Access-Token", token);
         TreeMap<String, Object> params = new TreeMap<>();
         //TODO jsonArray
-        params.put("advertiser_ids", "[" + cTopOauthToken.getAccountId() + "]");
+        params.put("advertiser_ids", "[" + accountId + "]");
         String result = HttpUtils.httpGetRequest(url, headers, params);
         JSONObject jsonObject = JSONObject.parseObject(result);
         Integer code = jsonObject.getInteger("code");

+ 168 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceBidWarningServiceImpl.java

@@ -0,0 +1,168 @@
+package cn.com.ctop.toutiao.modules.material.service.impl;
+
+import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.service.ICorpFeishuUserService;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.BigDecimalUtil;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.SendMailUtil;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceBidWarningService;
+import cn.com.feishu.provider.MessageProvider;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.xxl.job.core.log.XxlJobLogger;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@Slf4j
+public class BytedanceBidWarningServiceImpl implements IBytedanceBidWarningService {
+    @Autowired
+    private ICorpFeishuUserService corpFeishuUserService;
+    @Autowired
+    private IProjectService projectService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+    @Autowired
+    private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+
+    @Override
+    public void bidWarning() {
+        XxlJobLogger.log("---------头条出价预警定时任务开始----------");
+        long start = System.currentTimeMillis();
+        try {
+            List<Project> projects = projectService.list();
+            if (Check.isNull(projects)) {
+                XxlJobLogger.log("查询所属项目为空");
+                return ;
+            }
+            for (Project project : projects) {
+                if (Check.isNull(project)) {
+                    continue;
+                }
+                Long maxBid = project.getMaxBid();
+                Long projectId = project.getId();
+                List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                if (Check.isNull(userAllocations)) {
+                    continue;
+                }
+                for (UserAllocation userAllocation : userAllocations) {
+                    if (userAllocation.getAccountStatus() == 1) {
+                        continue;
+                    }
+                    Long accountId = userAllocation.getAccountId();
+                    List<String> unitWarning = new ArrayList<>();
+                    if ("1".equals(userAllocation.getMediaId())) {
+                        BigDecimal bid = new BigDecimal(maxBid);
+                        BigDecimal bigDecimal = BigDecimalUtil.divideBigDecimal(bid, new BigDecimal(1000));
+                        unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId, bigDecimal);
+                        if (!Check.isNull(unitWarning)) {
+                            sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                            sendFeishumessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                        }
+                    }
+                }
+            }
+            XxlJobLogger.log("头条出价预警定时任务执行完毕,共耗时:{} s", (System.currentTimeMillis() - start) / 1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+    private void sendFeishumessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) throws Exception {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, Integer.getInteger(mediaId));
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "\n\r";
+
+        }
+        text.append("项目出价预警").append("\n\r").append("您的项目:").append(projectName + ",").append("\n\r")
+                .append("授权名称为:" + authName + " 下的,").append("\n\r").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        JSONArray openIds = corpFeishuUserService.getOpenIdByParams(projectId);
+        if(null == openIds||openIds.isEmpty()){
+            log.error("该项目下运营飞书账号尚未绑定邮箱=>projectId:{}",projectId);
+            return;
+        }
+        MessageProvider.batchSend(null,openIds,null,text.toString());
+    }
+
+    private void sendMessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "<br/>";
+        }
+        text.append("项目出价预警").append("<br/>").append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("授权名称为:" + authName + " 下的,").append("<br/>").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+    }
+}

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/ByteDanceVideoReportDaily.java

@@ -62,6 +62,8 @@ public class ByteDanceVideoReportDaily {
 	@Excel(name = "公司素材库提供", width = 15)
     @ApiModelProperty(value = "公司素材库提供")
 	private String url;
+
+	private String coverUrl;
 	/**环比*/
 	@Excel(name = "环比", width = 15)
     @ApiModelProperty(value = "环比")

+ 3 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java

@@ -32,6 +32,9 @@ public interface BytedanceAccountReportMapper {
     //根据时间查询数据按账户分组
     List<JSONObject> querySumByDateGroupAccount(@Param("filed") String filed,@Param("endDate") String endDate, @Param("startDate") String startDate,@Param("accountIds") JSONArray accountIds,String target, String order);
 
+    //根据时间查询数据按账户时间分组
+    List<JSONObject> querySumByDateGroupAccountAndDate(@Param("filed") String filed,@Param("endDate") String endDate, @Param("startDate") String startDate,@Param("accountIds") JSONArray accountIds,String target, String order);
+
     //根据开始、结束时间 查询明细数据
     List<JSONObject> queryDetailByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate,@Param("accountIds") JSONArray accountIds);
 

+ 0 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä