Преглед на файлове

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

hcst_sunzhen преди 5 години
родител
ревизия
872aa0dcb4
променени са 86 файла, в които са добавени 2439 реда и са изтрити 371 реда
  1. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 12 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  3. 5 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialUploadController.java
  4. 1 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  5. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java
  6. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/TransferAccountMapper.java
  7. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml
  8. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  9. 16 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/TransferAccountMapper.xml
  10. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ITransferAccountService.java
  11. 16 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  12. 21 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java
  13. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/PeriodConstant.java
  14. 36 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/RateConstant.java
  15. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/StandardValue.java
  16. 111 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/controller/PerformanceShowCtrl.java
  17. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/DesignDetail.java
  18. 75 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/OperateDetail.java
  19. 146 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/PerformanceQuarter.java
  20. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/CalculatePerformanceMapper.java
  21. 11 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/DesignDetailMapper.java
  22. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/OperateDetailMapper.java
  23. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/PerformanceQuarterMapper.java
  24. 27 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/CalculatePerformanceMapper.xml
  25. 52 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/DesignDetailMapper.xml
  26. 78 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/OperateDetailMapper.xml
  27. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/PerformanceQuarterMapper.xml
  28. 28 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/DesignDetailServiceImpl.java
  29. 12 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ICalculatePerformanceService.java
  30. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IDesignDetailService.java
  31. 27 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IOperateDetailService.java
  32. 8 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceInfoService.java
  33. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceQuarterService.java
  34. 75 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/CalculatePerformanceServiceImpl.java
  35. 189 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/OperateDetailServiceImpl.java
  36. 81 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceInfoInfoServiceImpl.java
  37. 109 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceQuarterServiceImpl.java
  38. 35 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java
  39. 32 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/vo/TransferDetailVO.java
  40. 26 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserRoleMapper.java
  41. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java
  42. 15 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserRoleServiceImpl.java
  43. 2 2
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  44. 14 14
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  45. 5 5
      jeecg-boot-module-system/src/main/resources/application-test.yml
  46. 56 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysCompany.java
  47. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialImageInfoMapper.java
  48. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysCompanyMapper.java
  49. 2 2
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/BindAccountLoginMapper.xml
  50. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialImageInfoMapper.xml
  51. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysCompanyMapper.xml
  52. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IFileInfoService.java
  53. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageInfoService.java
  54. 9 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java
  55. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ISendMessageService.java
  56. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ISysCompanyService.java
  57. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  58. 23 14
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java
  59. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageInfoServiceImpl.java
  60. 57 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java
  61. 26 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SendMessageServiceImpl.java
  62. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysCompanyServiceImpl.java
  63. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  64. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java
  65. 42 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopMediaTypeUtil.java
  66. 1 2
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  67. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  68. 1 1
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialUploadService.java
  69. 54 55
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java
  70. 23 11
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java
  71. 132 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  72. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  73. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java
  74. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  75. 21 23
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  76. 260 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  77. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  78. 33 116
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  79. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  80. 54 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/AccountReportMapper.xml
  81. 7 33
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/DailyReportMapper.xml
  82. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  83. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  84. 48 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/AccountReportServiceImpl.java
  85. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java
  86. 8 6
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java

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

@@ -143,7 +143,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/graphql/video", "anon");
         filterChainDefinitionMap.put("/ks/web/test", "anon");
         filterChainDefinitionMap.put("/ureport/**", "anon");
-        filterChainDefinitionMap.put("/ctop/advertiser/**", "anon");
+        //filterChainDefinitionMap.put("/ctop/performance/show/**", "anon");
+        filterChainDefinitionMap.put("/job/test/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

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

@@ -324,6 +324,10 @@ public class MaterialInfoController {
      */
     @Autowired
     private IProjectService projectService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+    @Autowired
+    private ISendMessageService sendMessageService;
 
     @AutoLog(value = "素材信息-编辑")
     @ApiOperation(value = "素材信息-编辑", notes = "素材信息-编辑")
@@ -390,6 +394,14 @@ public class MaterialInfoController {
             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);
+            }
         }
 
         return result;

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

@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -44,8 +46,10 @@ public class MaterialUploadController {
             if (Check.isNull(materialArray) || Check.isNull(accountArray)) {
                 throw new Exception("请选择账号或素材");
             }
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 
-            new Thread(() -> materialUploadService.uploadAccount(mediaId, materialArray, accountArray)).start();
+
+            new Thread(() -> materialUploadService.uploadAccount(mediaId, materialArray, accountArray, sysUser.getId())).start();
             returnMap.put("success", true);
             returnMap.put("message", "开始上传文件");
             returnMap.put("code", 0);

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

@@ -149,11 +149,6 @@ public class UserAllocationController {
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("project_id", projectId);
 
-           /* if (!Check.isNull(project)) {
-            Project project = projectService.getById(projectId);
-                queryWrapper.eq("media_id", project.getMediaId());
-            }*/
-
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) && !"kuaishouOperationManager".equals(roleCode) && !"designTeamLeader".equals(roleCode) && !"touTiaoOperationManager".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
@@ -182,10 +177,9 @@ public class UserAllocationController {
     public Result<List<UserAllocation>> getAccountListByProjectId(Long projectId) {
         Result<List<UserAllocation>> result = new Result<>();
         try {
-
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("project_id", projectId);
-
+            queryWrapper.eq("account_status", 0);
            /* if (!Check.isNull(project)) {
                  Project project = projectService.getById(projectId);
                  queryWrapper.eq("media_id", project.getMediaId());

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

@@ -29,4 +29,6 @@ public interface ProjectMemberMapper extends BaseMapper<ProjectMember> {
 
     String getCompanyIdByUserId(@Param("userId")String userId);
 
+    List<ProjectMember> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
+
 }

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

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -12,4 +15,6 @@ import org.jeecg.modules.ctop.entity.TransferAccount;
  */
 public interface TransferAccountMapper extends BaseMapper<TransferAccount> {
 
+    List<TransferAccount> getAccountQuarterDetail(@Param(value = "accountId") Long accountId, @Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate);
+
 }

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

@@ -108,7 +108,7 @@
               sum(t1.next_day_open) AS residue,
               sum(t1.play_duration_3s) AS play3s,
               sum(t1.play_duration_10s) AS play3s,
-              0 AS mediaType
+              1 AS mediaType
         FROM
             ctop_bytedance_report_material_daily t1
                 LEFT JOIN ctop_bytedance_video_info t2 ON t1.material_id = t2.material_id
@@ -189,7 +189,7 @@
               sum(t1.activation) AS 'active',
               sum(t1.event_register) AS 'register',
               sum(t1.form_count) AS 'form_convert',
-              '2' AS 'media_type'
+              2 AS 'media_type'
         FROM
             ctop_kuaishou_report_daily_creative t1
         WHERE

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

@@ -105,4 +105,21 @@
         where user_id = #{userId}
     </select>
 
+    <select id="queryProjectMemberByUserId" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
+        select
+        distinct b.id as projectId,
+        b.project_name as projectName,
+        a.advertiser_id as advertiserId,
+        a.advertiser_name as advertiserName,
+        a.media_id as mediaId
+        from
+        ctop_user_allocation a
+        left join ctop_project_member b on a.project_id = b.project_id
+        where b.user_id = #{userId}
+        and a.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

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

@@ -2,4 +2,20 @@
 <!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.TransferAccountMapper">
 
+    <select id="getAccountQuarterDetail" resultType="org.jeecg.modules.ctop.entity.TransferAccount">
+        select
+            *
+        from
+            ctop_transfer_account
+        where
+            status = 1
+          and
+            account_id =#{accountId}
+          and
+            transferor_date &gt;= #{startDate}
+          and
+            transferor_date &lt; #{endDate}
+        order by transferor_date asc
+    </select>
+
 </mapper>

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

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -12,4 +15,8 @@ import org.jeecg.modules.ctop.entity.TransferAccount;
  */
 public interface ITransferAccountService extends IService<TransferAccount> {
 
+    List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
+
+    List<TransferAccount> getAccountQuarterDetail(Long accountId, String startDate, String endDate);
+
 }

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

@@ -1,11 +1,11 @@
 package org.jeecg.modules.ctop.service.impl;
 
-import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 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 cn.com.ctop.common.module.utils.SpringUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.shiro.SecurityUtils;
@@ -33,6 +33,7 @@ import java.util.Map;
  */
 @Service
 public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, ProjectMember> implements IProjectMemberService {
+
     @Autowired
     private ProjectMemberMapper memberMapper;
     @Autowired
@@ -71,8 +72,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
     }
 
     //视频报表
-    @Override
-    public List<ProjectMember> getProjects(List<Integer> mediaIds){
+    public List<ProjectMember> getProjects(List<Integer> mediaIds) {
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = memberMapper.getRoleCodeByUserId(userId);
@@ -80,34 +80,27 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
 
         //角色权限判断
         List<ProjectMember> projectMemberList = null;
-        if(roleCode.equals("plan") || roleCode.equals("clip") || roleCode.equals("shot") || roleCode.equals("plane")|| roleCode.equals("planeLeader")){
+        if (roleCode.equals("plan") || roleCode.equals("clip") || roleCode.equals("shot") || roleCode.equals("plane") || roleCode.equals("planeLeader")) {
             projectMemberList = memberMapper.designProjects(userId, mediaIds);
-        }else if( roleCode.equals("designTeamLeader")){
+        } else if (roleCode.equals("designTeamLeader")) {
             projectMemberList = memberMapper.designLeaderProjects(companyId, mediaIds);
-        }else if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
+        } else if (roleCode.equals("admin")) {
             projectMemberList = memberMapper.adminProjects(mediaIds);
-        }else if(roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")||roleCode.equals("huananyunying")){
+        } else if (roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")) {
             projectMemberList = memberMapper.operationProjects(userId, mediaIds);
-        }else{
-            //如果以上角色都不是的话直接查询此角色所属项目
-            projectMemberList = memberMapper.designProjects(userId, mediaIds);
         }
 
-        if(null == projectMemberList){
-            projectMemberList = new ArrayList<>();
-        }
         return projectMemberList;
     }
 
     @Override
-    @Cacheable(value = "cache_project_account",key="'projectAccount:userId='+#userId",unless = "#result ==null")
     public List<Map<String, Object>> getProjectAccountByUserId(String userId) {
         List<Map<String, Object>> result = new ArrayList<>();
         List<Integer> mediaList = new ArrayList<>();
         mediaList.add(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INT);
         mediaList.add(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INSIDE_INT);
         //查询登录账号下的项目
-        List<ProjectMember> projectMemberList = this.getProjects(mediaList);
+        List<ProjectMember> projectMemberList = this.queryProjectMemberBy(userId,mediaList);
         if (projectMemberList.isEmpty()) {
             return result;
         }
@@ -135,4 +128,12 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         }
         return temp;
     }
+
+    private List<ProjectMember> queryProjectMemberBy(String userId, List<Integer> mediaIds) {
+        String roleCode = memberMapper.getRoleCodeByUserId(userId);
+        if(roleCode.equals("admin")){
+            return memberMapper.adminProjects(mediaIds);
+        }
+        return memberMapper.queryProjectMemberByUserId(userId,mediaIds);
+    }
 }

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

@@ -1,11 +1,16 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 import org.jeecg.modules.ctop.mapper.TransferAccountMapper;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -16,4 +21,20 @@ import org.springframework.stereotype.Service;
 @Service
 public class TransferAccountServiceImpl extends ServiceImpl<TransferAccountMapper, TransferAccount> implements ITransferAccountService {
 
+    @Autowired
+    private KuaishouReportDailyAccountMapper dailyAccountMapper;
+    @Autowired
+    private TransferAccountMapper transferAccountMapper;
+
+    @Override
+    public List<JSONObject> selectCost(Long accountId, String startDate, String endDate) {
+        return dailyAccountMapper.selectCost(accountId, startDate, endDate);
+    }
+
+
+    @Override
+    public List<TransferAccount> getAccountQuarterDetail(Long accountId, String startDate, String endDate) {
+        return transferAccountMapper.getAccountQuarterDetail(accountId, startDate, endDate);
+    }
+
 }

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/PeriodConstant.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.performance.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+@Getter
+public enum PeriodConstant {
+
+    Q1("01-01","03-31"),
+    Q2("04-01","06-30"),
+    Q3("07-01","09-30"),
+    Q4("10-01","12-31");
+
+    PeriodConstant(String start, String end) {
+        this.start = start;
+        this.end = end;
+    }
+
+    private final String start;
+    private final String end;
+
+}

+ 36 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/RateConstant.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.performance.constants;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+public class RateConstant {
+
+    private RateConstant() {
+    }
+
+    // Percentage constant
+    public static final BigDecimal PERCENT_0 = BigDecimal.valueOf(0.00);
+    public static final BigDecimal PERCENT_5 = BigDecimal.valueOf(0.05);
+    public static final BigDecimal PERCENT_10 = BigDecimal.valueOf(0.1);
+    public static final BigDecimal PERCENT_15 = BigDecimal.valueOf(0.15);
+    public static final BigDecimal PERCENT_20 = BigDecimal.valueOf(0.2);
+    public static final BigDecimal PERCENT_30 = BigDecimal.valueOf(0.3);
+    public static final BigDecimal PERCENT_40 = BigDecimal.valueOf(0.4);
+    public static final BigDecimal PERCENT_50 = BigDecimal.valueOf(0.5);
+    public static final BigDecimal PERCENT_60 = BigDecimal.valueOf(0.6);
+    public static final BigDecimal PERCENT_70 = BigDecimal.valueOf(0.7);
+    public static final BigDecimal PERCENT_80 = BigDecimal.valueOf(0.8);
+    public static final BigDecimal PERCENT_90 = BigDecimal.valueOf(0.9);
+
+
+    // Thousand constant
+    public static final BigDecimal THOUSAND_0 = BigDecimal.valueOf(0.000);
+    public static final BigDecimal THOUSAND_1 = BigDecimal.valueOf(0.001);
+    public static final BigDecimal THOUSAND_2 = BigDecimal.valueOf(0.002);
+    public static final BigDecimal THOUSAND_3 = BigDecimal.valueOf(0.003);
+    public static final BigDecimal THOUSAND_4 = BigDecimal.valueOf(0.004);
+    public static final BigDecimal THOUSAND_5 = BigDecimal.valueOf(0.005);
+
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/StandardValue.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.performance.constants;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+public class StandardValue {
+
+    private StandardValue() {
+    }
+
+    // 季度消耗门槛值
+    public static final BigDecimal QUARTER_CONSUMPTION=new BigDecimal(2400000);
+
+    // 视频有效门槛值
+    public static final BigDecimal VIDEO_CLICK=new BigDecimal(5000);
+
+    // 零绩效
+    public static final BigDecimal PERFORMANCE_ZERO=new BigDecimal(0);
+
+
+}

+ 111 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/controller/PerformanceShowCtrl.java

@@ -0,0 +1,111 @@
+package org.jeecg.modules.performance.controller;
+
+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.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.jeecg.modules.performance.service.IPerformanceInfoService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by JQ.bi on 2020.6.9
+ */
+@Slf4j
+@RestController
+@RequestMapping("/ctop/performance/show")
+public class PerformanceShowCtrl {
+
+    @Autowired
+    IPerformanceInfoService performanceService;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+    @Autowired
+    IOperateDetailService operateDetailService;
+
+    @GetMapping("/getPerformanceInfo")
+    public Result<Map<String, Object>> getPerformanceInfo() {
+        Result<Map<String, Object>> result = new Result<>();
+        result.setResult(performanceService.getPerformanceInfo());
+        result.setSuccess(true);
+        return result;
+    }
+
+    @PostMapping("/{pageNo}/{pageSize}/{order}")
+    public Result<PageInfo<PerformanceQuarter>> showPerformance(@PathVariable int pageNo,
+                                                               @PathVariable int pageSize,
+                                                               @PathVariable String order,
+                                                               @RequestBody JSONObject requestBody) {
+        Result<PageInfo<PerformanceQuarter>> result = new Result<>();
+        PageInfo<PerformanceQuarter> pageInfo = performanceQuarterService.getPerformanceByConditionsPage(pageNo, pageSize, order, requestBody);
+        result.setSuccess(true);
+        result.setResult(pageInfo);
+        return result;
+    }
+
+    /**
+     * 导出数据
+     *
+     * @param requestBody
+     * @param response
+     */
+    @PostMapping("/excel")
+    public void getExcelReport(@RequestBody JSONObject requestBody,
+                               HttpServletResponse response) {
+        List<PerformanceQuarter> excelData= performanceQuarterService.getPerformanceByConditions(requestBody);
+        if (excelData.isEmpty()) {
+            return;
+        }
+        String[] titles={"姓名","公司","职位","媒体类型","年份","季度","消耗","提成比例","绩效","管理岗绩效"};
+
+        List<List<Object>> excelList = new ArrayList<>();
+        excelData.forEach(data -> {
+            List<Object> temp = new ArrayList<>();
+            temp.add(data.getUserName());
+            temp.add(data.getCompanyName());
+            temp.add(data.getRoleName());
+            temp.add(data.getMediaType()==1?"头条":"快手");
+            temp.add(data.getYear());
+            temp.add(data.getQuarter());
+            temp.add(data.getCost());
+            temp.add(data.getPoint());
+            temp.add(data.getPerformance());
+            temp.add(data.getAdditionalFees());
+            excelList.add(temp);
+        });
+        try {
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            eeu.exportExcel(workbook, 0, "绩效", titles, excelList);
+            HttpUtils.setResponseHeader(response, "绩效.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    @PostMapping("/operateDetail")
+    public Result<List<JSONObject>> getOperateDetail(@RequestBody JSONObject requestBody){
+        Result<List<JSONObject>> result = new Result<>();
+        result.setResult(operateDetailService.getOperateGroupAccountByUser(requestBody));
+        result.setSuccess(true);
+        return result;
+    }
+
+}

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/DesignDetail.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 设计消耗详细
+ */
+@Data
+@TableName("ctop_performance_design_detail")
+public class DesignDetail {
+
+}

+ 75 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/OperateDetail.java

@@ -0,0 +1,75 @@
+package org.jeecg.modules.performance.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.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 运营消耗详细
+ */
+@Data
+@TableName("ctop_performance_operate_detail")
+public class OperateDetail {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 媒体类型 1:头条 2:快手
+     */
+    private Integer mediaType;
+    /**
+     * 账户id
+     */
+    private Long accountId;
+    /**
+     * 统计开始时间
+     */
+    private String statDate;
+
+    /**
+     * 账户消耗
+     */
+    private BigDecimal cost;
+    /**
+     * leaderId
+     */
+    private String leaderId;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    /**
+     * 是否节假日
+     */
+    private Date isHoliday;
+
+    /**
+     * 预留字段
+     */
+    private BigDecimal cost1;
+    private BigDecimal cost2;
+    private BigDecimal cost3;
+    private BigDecimal cost4;
+
+}

+ 146 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/PerformanceQuarter.java

@@ -0,0 +1,146 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Objects;
+
+@Data
+@TableName("ctop_performance_quarter")
+public class PerformanceQuarter {
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 用户姓名
+     */
+    private String userName;
+    /**
+     * 公司ID
+     */
+    private String companyId;
+    /**
+     * 公司名称
+     */
+    private String companyName;
+    /**
+     * 公司名称
+     */
+    private String department;
+    /**
+     * 职位code
+     */
+    private String roleCode;
+    /**
+     * 职位名称
+     */
+    private String roleName;
+    /**
+     * 负责人
+     */
+    private String leader;
+    /**
+     * 用户id
+     */
+    private Integer year;
+    /**
+     * 季度
+     */
+    private String quarter;
+    /**
+     * 消耗
+     */
+    private BigDecimal cost;
+    /**
+     * 绩效
+     */
+    private BigDecimal performance;
+    /**
+     * 提成点
+     */
+    private BigDecimal point;
+    /**
+     * 额外提成
+     */
+    private BigDecimal additionalFees;
+    /**
+     * 原因
+     */
+    private String reason;
+    /**
+     * 媒体类型
+     */
+    private Integer mediaType;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        PerformanceQuarter that = (PerformanceQuarter) o;
+        return Objects.equals(id, that.id) &&
+                Objects.equals(userId, that.userId) &&
+                Objects.equals(userName, that.userName) &&
+                Objects.equals(companyId, that.companyId) &&
+                Objects.equals(companyName, that.companyName) &&
+                Objects.equals(roleCode, that.roleCode) &&
+                Objects.equals(roleName, that.roleName) &&
+                Objects.equals(leader, that.leader) &&
+                Objects.equals(year, that.year) &&
+                Objects.equals(quarter, that.quarter) &&
+                Objects.equals(cost, that.cost) &&
+                Objects.equals(performance, that.performance) &&
+                Objects.equals(point, that.point) &&
+                Objects.equals(additionalFees, that.additionalFees) &&
+                Objects.equals(reason, that.reason) &&
+                Objects.equals(mediaType, that.mediaType) &&
+                Objects.equals(createTime, that.createTime) &&
+                Objects.equals(updateTime, that.updateTime);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, userId, userName, companyId, companyName, roleCode, roleName, leader, year, quarter, cost, performance, point, additionalFees, reason, mediaType, createTime, updateTime);
+    }
+
+    @Override
+    public String toString() {
+        return "PerformanceQuarter{" +
+                "id=" + id +
+                ", userId='" + userId + '\'' +
+                ", userName='" + userName + '\'' +
+                ", companyId='" + companyId + '\'' +
+                ", companyName='" + companyName + '\'' +
+                ", roleCode='" + roleCode + '\'' +
+                ", roleName='" + roleName + '\'' +
+                ", leader='" + leader + '\'' +
+                ", year=" + year +
+                ", quarter='" + quarter + '\'' +
+                ", cost=" + cost +
+                ", performance=" + performance +
+                ", point=" + point +
+                ", additionalFees=" + additionalFees +
+                ", reason='" + reason + '\'' +
+                ", mediaType=" + mediaType +
+                ", createTime=" + createTime +
+                ", updateTime=" + updateTime +
+                '}';
+    }
+}

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/CalculatePerformanceMapper.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface CalculatePerformanceMapper {
+
+    List<JSONObject> queryOperateCostGroupByUser(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("mediaType")int mediaType);
+
+}

+ 11 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/DesignDetailMapper.java

@@ -0,0 +1,11 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
+public interface DesignDetailMapper {
+
+    List<JSONObject> queryMaterialDetailByDate(String startDate,String endDate, int mediaType);
+}

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/OperateDetailMapper.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.performance.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.lettuce.core.dynamic.annotation.Param;
+import org.jeecg.modules.performance.entity.OperateDetail;
+
+import java.util.List;
+
+/**
+ * 运营消耗详细
+ *
+ * @author: jeecg-boot
+ * @date: 2020-04-23
+ * @cersion: V1.0
+ */
+public interface OperateDetailMapper extends BaseMapper<OperateDetail> {
+
+    List<OperateDetail> selectBytedanceByParams(@Param(value = "accountId") Long accountId, @Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId, @Param(value = "orgCode") String orgCode);
+
+    List<JSONObject> ByteDanceOperateDetailGroupAccountByDate(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId);
+
+    List<JSONObject> kuaiShouOperateDetailGroupAccountByDate(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId);
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/PerformanceQuarterMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+
+import java.util.List;
+
+public interface PerformanceQuarterMapper extends BaseMapper<PerformanceQuarter> {
+
+    List<JSONObject> queryYearAndQuarter();
+
+}

+ 27 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/CalculatePerformanceMapper.xml

@@ -0,0 +1,27 @@
+<?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.performance.mapper.CalculatePerformanceMapper">
+
+    <select id="queryOperateCostGroupByUser" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT res.*,
+        (SELECT realname from sys_user user where user.id=res.userId limit 1) as userName,
+        (SELECT company_id from user_company company where company.user_id=res.userId limit 1) as 'companyId',
+        (SELECT company_name from user_company company where company.user_id=res.userId limit 1) as 'companyName',
+        (SELECT role_code from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleCode',
+        (SELECT role_name from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleName'
+        from (
+        SELECT
+        user_id as userId,
+        leader_id as leaderId,
+        sum(cost) as cost
+        FROM
+        ctop_performance_operate_detail
+        WHERE
+        media_type= #{mediaType}
+        AND	stat_date &gt;= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        GROUP BY user_id
+        ) res
+    </select>
+
+</mapper>

+ 52 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/DesignDetailMapper.xml

@@ -0,0 +1,52 @@
+<?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.performance.mapper.DesignDetailMapper">
+
+    <select id="queryMaterialDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        res.*,
+        (
+        SELECT
+        USER.id
+        FROM
+        sys_user USER
+        LEFT JOIN sys_user_role userRole ON USER .id = userRole.user_id
+        LEFT JOIN sys_role role ON userRole.role_id = role.id
+        WHERE
+        USER .org_code = (
+        SELECT
+        user1.org_code
+        FROM
+        sys_user user1
+        WHERE
+        user1.id = res.clipId
+        LIMIT 1
+        )
+        AND role.role_code = 'designTeamLeader'
+        ) AS 'leaderId'
+        FROM
+        (
+        SELECT
+        report.CODE,
+        sum(report.cost) AS cost,
+        ascription.clip_id as clipID,
+        ascription.plane_id as planeId,
+        ascription.plan_id as planID,
+        ascription.shot_id as shotID,
+        ascription.material_id as materialId
+        FROM
+        ctop_material_report_total_result report
+        LEFT JOIN ctop_material_info info on report.code=info.code
+        LEFT JOIN ctop_material_ascription ascription ON info. CODE = ascription.material_id
+        WHERE
+        report.media_type = #{param3}
+        AND report.stat_date &gt;= #{param1}
+        AND report.stat_date &lt;= #{param2}
+        GROUP BY
+        report.CODE
+        ) res
+        WHERE
+        res.cost > 0
+    </select>
+
+</mapper>

+ 78 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/OperateDetailMapper.xml

@@ -0,0 +1,78 @@
+<?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.performance.mapper.OperateDetailMapper">
+
+    <select id="selectBytedanceByParams" resultType="org.jeecg.modules.performance.entity.OperateDetail">
+        select
+            #{userId} as user_id,
+            1 as media_type,
+            #{accountId} as account_id,
+            left(stat_datetime,10) as stat_date,
+            sum(cost) as cost,
+            (select
+                user.id
+            from
+                sys_user_role userRole
+            left join sys_user user on userRole.user_id = user.id
+            left join sys_role role on userRole.role_id = role.id
+            where
+                org_code = #{orgCode}
+            and
+                role.role_name = '头条运营经理'
+            ) as leader_id
+        from
+            ctop_bytedance_report_advertiser_daily
+        where
+            advertiser_id = #{accountId}
+        and
+            stat_datetime &gt;=#{startDate}
+        and
+            stat_datetime &lt;=#{endDate}
+        group by stat_datetime
+    </select>
+
+    <select id="ByteDanceOperateDetailGroupAccountByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.project_name AS projectName,
+        t2.auth_name AS authName,
+        ROUND(sum(t1.cost), 2) cost
+        FROM
+        ctop_bytedance_report_advertiser_daily t1
+        LEFT JOIN ctop_user_allocation t2 on t1.advertiser_id=t2.account_id
+        WHERE
+        t1.stat_datetime &gt;= #{startDate} '00:00:00'
+        AND t1.stat_datetime &lt;= #{endDate}
+        AND t1.advertiser_id IN (
+        SELECT
+        account_id
+        FROM
+        ctop_user_allocation
+        WHERE
+        user_id = #{userId}
+        AND media_id = 1
+        ) GROUP BY t2.account_id
+    </select>
+
+    <select id="kuaiShouOperateDetailGroupAccountByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.project_name AS projectName,
+        t2.auth_name AS authName,
+        ROUND(sum(t1.charge), 2) cost
+        FROM
+        ctop_kuaishou_report_daily_account t1
+        LEFT JOIN ctop_user_allocation t2 on t1.account_id=t2.account_id
+        WHERE
+        t1.stat_date &gt;=#{startDate}
+        AND t1.stat_date &lt;=#{endDate}
+        AND t1.account_id IN (
+        SELECT
+        account_id
+        FROM
+        ctop_user_allocation
+        WHERE
+        user_id = #{userId}
+        AND media_id = 2
+        ) GROUP BY t2.account_id
+    </select>
+
+</mapper>

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/PerformanceQuarterMapper.xml

@@ -0,0 +1,13 @@
+<?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.performance.mapper.PerformanceQuarterMapper">
+
+    <select  id="queryYearAndQuarter" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DISTINCT
+            year,
+            quarter
+        FROM
+            ctop_performance_quarter
+    </select>
+
+</mapper>

+ 28 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/DesignDetailServiceImpl.java

@@ -0,0 +1,28 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.performance.mapper.DesignDetailMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Slf4j
+public class DesignDetailServiceImpl implements IDesignDetailService {
+
+    @Autowired
+    DesignDetailMapper designDetailMapper;
+
+    @Override
+    public void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType) {
+        //查询出来素材对应的cost
+        List<JSONObject> jsonObjectList=designDetailMapper.queryMaterialDetailByDate(startDate,endDate,mediaType);
+        if(jsonObjectList.isEmpty()){
+            log.error("没有素材数据");
+        }
+
+
+    }
+}

+ 12 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ICalculatePerformanceService.java

@@ -0,0 +1,12 @@
+package org.jeecg.modules.performance.service;
+
+public interface ICalculatePerformanceService {
+
+    //运营绩效计算
+    void CalculateOperatePerformance(int year, String quarter, int mediaType);
+    //设计绩效计算
+    void CalculateDesignPerformance();
+    //销售绩效计算
+    void CalculateSalePerformance();
+
+}

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IDesignDetailService.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.performance.service;
+
+public interface IDesignDetailService {
+
+    void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType);
+
+}

+ 27 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IOperateDetailService.java

@@ -0,0 +1,27 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.performance.entity.OperateDetail;
+import org.jeecg.modules.performance.vo.TransferDetailVO;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 运营消耗详细
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-23
+ */
+public interface IOperateDetailService extends IService<OperateDetail> {
+
+    void KsCostCalculateByAccount(String startDate, String endDate);
+
+    void BtCostCalculateByAccount(String startDate, String endDate);
+
+    List<TransferDetailVO> loadTransferDetail(Long accountId, String userId, String startDate, String endDate) throws ParseException;
+
+    List<JSONObject> getOperateGroupAccountByUser(JSONObject requestBody);
+}

+ 8 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceInfoService.java

@@ -0,0 +1,8 @@
+package org.jeecg.modules.performance.service;
+
+import java.util.Map;
+
+public interface IPerformanceInfoService {
+
+    Map<String,Object> getPerformanceInfo();
+}

+ 20 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceQuarterService.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface IPerformanceQuarterService extends IService<PerformanceQuarter> {
+
+    Map<String, Set<String>> getYearQuarter();
+
+    List<PerformanceQuarter> getPerformanceByConditions(JSONObject requestBody);
+
+    PageInfo<PerformanceQuarter> getPerformanceByConditionsPage(int pageNo, int pageSize, String order,JSONObject requestBody);
+
+}

+ 75 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/CalculatePerformanceServiceImpl.java

@@ -0,0 +1,75 @@
+package org.jeecg.modules.performance.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.constants.RateConstant;
+import org.jeecg.modules.performance.constants.StandardValue;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.mapper.CalculatePerformanceMapper;
+import org.jeecg.modules.performance.service.ICalculatePerformanceService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  Created by JQ.bi
+ */
+@Service
+public class CalculatePerformanceServiceImpl implements ICalculatePerformanceService {
+
+    @Autowired
+    CalculatePerformanceMapper calculatePerformanceMapper;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+
+    @Override
+    public void CalculateOperatePerformance(int year, String quarter, int mediaType) {
+        //TODO 查询配置的提成点
+        BigDecimal point =new BigDecimal(0);
+        if (mediaType == 1) point = RateConstant.THOUSAND_2;
+        if (mediaType == 2) point = RateConstant.THOUSAND_3;
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        List<JSONObject> operateCost = calculatePerformanceMapper.queryOperateCostGroupByUser(startDate, endDate, mediaType);
+        List<PerformanceQuarter> performanceQuarters = new ArrayList<>();
+        PerformanceQuarter performanceQuarter;
+        for(JSONObject op:operateCost){
+            performanceQuarter = new PerformanceQuarter();
+            performanceQuarter.setUserId(op.getString("userId"));
+            performanceQuarter.setUserName(op.getString("userName"));
+            performanceQuarter.setCompanyId(op.getString("companyId"));
+            performanceQuarter.setCompanyName(op.getString("companyName"));
+            performanceQuarter.setDepartment("运营部");
+            performanceQuarter.setRoleCode(op.getString("roleCode"));
+            performanceQuarter.setRoleName(op.getString("roleName"));
+            performanceQuarter.setLeader(op.getString("leaderId"));
+            performanceQuarter.setYear(year);
+            performanceQuarter.setQuarter(quarter);
+            BigDecimal cost=op.getBigDecimal("cost");
+            performanceQuarter.setCost(cost);
+            if(cost.compareTo(StandardValue.QUARTER_CONSUMPTION)>=0){
+                performanceQuarter.setPerformance(cost.multiply(point));
+            }else {
+                performanceQuarter.setPerformance(StandardValue.PERFORMANCE_ZERO);
+            }
+            performanceQuarter.setPoint(point);
+            performanceQuarter.setMediaType(mediaType);
+            performanceQuarters.add(performanceQuarter);
+        }
+        performanceQuarterService.saveBatch(performanceQuarters);
+    }
+
+    @Override
+    public void CalculateDesignPerformance() {
+
+    }
+
+    @Override
+    public void CalculateSalePerformance() {
+
+    }
+}

+ 189 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/OperateDetailServiceImpl.java

@@ -0,0 +1,189 @@
+package org.jeecg.modules.performance.service.impl;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.TransferAccount;
+import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.entity.OperateDetail;
+import org.jeecg.modules.performance.mapper.OperateDetailMapper;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.jeecg.modules.performance.vo.TransferDetailVO;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysUserRoleService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 运营消耗详细
+ */
+@Service
+@Slf4j
+public class OperateDetailServiceImpl extends ServiceImpl<OperateDetailMapper, OperateDetail> implements IOperateDetailService {
+
+    @Autowired
+    private OperateDetailMapper operateDetailMapper;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private ITransferAccountService transferAccountService;
+    @Autowired
+    private IKuaishouReportDailyAccountService dailyAccountService;
+    @Autowired
+    private ISysUserRoleService roleService;
+    @Autowired
+    private ISysUserService sysUserService;
+
+
+    /**
+     * 快手账户消耗计算
+     */
+    @Override
+    public void KsCostCalculateByAccount(String startStatDate, String endStatDate) {
+
+        List<UserAllocation> list = userAllocationService.getByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        for (UserAllocation allocation : list) {
+            List<TransferDetailVO> transferDetailVOS = loadTransferDetail(allocation.getAccountId(), allocation.getUserId(), startStatDate, endStatDate);
+            if (Check.isNull(transferDetailVOS)) {
+                log.error("错误,未返回转户信息,accountId:{}", allocation.getAccountId());
+                continue;
+            }
+            for (TransferDetailVO transferDetail : transferDetailVOS) {
+                String userId = transferDetail.getUserId();
+                Long accountId = transferDetail.getAccountId();
+                String startDate = transferDetail.getStartDate();
+                String endDate = transferDetail.getEndDate();
+                String leaderId = roleService.getLeaderId(userId, "kuaishouOperationManager");
+                List<JSONObject> costJsonArr = dailyAccountService.selectCost(accountId, startDate, endDate);
+                if (!Check.isNull(costJsonArr)) {
+                    costJsonArr.stream().filter(costJson -> !Check.isNull(costJson)).forEach(costJson -> {
+                        BigDecimal cost = costJson.getBigDecimal("cost");
+                        if (Check.isNull(cost)) {
+                            return;
+                        }
+                        OperateDetail detail = new OperateDetail();
+                        detail.setCost(cost);
+                        detail.setAccountId(accountId);
+                        detail.setStatDate(costJson.getString("statDate"));
+                        detail.setLeaderId(leaderId);
+                        detail.setUserId(userId);
+                        detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
+                        //TODO 判断是否为节假日
+                        operateDetailMapper.insert(detail);
+                    });
+
+                }
+            }
+        }
+
+    }
+
+
+    /**
+     * 头条账户消耗计算
+     */
+    @Override
+    public void BtCostCalculateByAccount(String startStatDate, String endStatDate) {
+
+        //1:获取头条账户
+        List<UserAllocation> allocations = userAllocationService.getByMediaId(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (allocations.isEmpty()) {
+            log.info("获取头条用户失败");
+            return;
+        }
+        allocations.forEach(allocation->{
+            List<TransferDetailVO> transferDetailVOS = loadTransferDetail(allocation.getAccountId(), allocation.getUserId(), startStatDate, endStatDate);
+            if (null != transferDetailVOS && transferDetailVOS.size() > 0) {
+                transferDetailVOS.forEach(vo->{
+                    SysUser user = sysUserService.getById(vo.getUserId());
+                    List<OperateDetail> details = operateDetailMapper.selectBytedanceByParams(allocation.getAccountId(), vo.getStartDate() + " 00:00:00", vo.getEndDate() + "00:00:00", vo.getUserId(), user.getOrgCode());
+                    if (!details.isEmpty()) {
+                        details.forEach(detail->{
+                            if (null != detail && null != detail.getCost()) {
+                                if (detail.getUserId().equals(detail.getLeaderId())) {
+                                    detail.setLeaderId(null);
+                                }
+                                //TODO 判断是否为节假日
+                                this.save(detail);
+                            }
+                        });
+                    }
+                });
+            }
+        });
+    }
+
+    @Override
+    public List<TransferDetailVO> loadTransferDetail(Long accountId, String userId, String startDate, String endDate) {
+        List<TransferDetailVO> vos = new ArrayList<>();
+        String realEndDate = DateUtils.addDay(endDate, -1);
+        List<TransferAccount> transferAccounts = transferAccountService.getAccountQuarterDetail(accountId, startDate, endDate);
+        if (Check.isNull(transferAccounts)) {
+            vos.add(new TransferDetailVO(startDate, endDate, userId, accountId));
+            return vos;
+        } else if (transferAccounts.size() == 1) {
+            TransferAccount account = transferAccounts.get(0);
+            if (account.getTransferorDate().equals(startDate)) {
+                //极限情况 季度末最后一天转让
+                vos.add(new TransferDetailVO(startDate, endDate, userId, accountId));
+                return vos;
+            } else {
+                vos.add(new TransferDetailVO(startDate, account.getAssigneeDate(), userId, accountId));
+                vos.add(new TransferDetailVO(account.getAssigneeDate(), endDate, userId, accountId));
+                return vos;
+            }
+        } else {
+            TransferAccount firstAccount = transferAccounts.get(0);
+            TransferAccount lastAccout = transferAccounts.get(transferAccounts.size() - 1);
+            vos.add(new TransferDetailVO(startDate, firstAccount.getAssigneeDate(), firstAccount.getTransferor(), accountId));
+            String lastTwoAssigneeDate = "";
+            for (int i = 1; i <= transferAccounts.size() - 1; i++) {
+                TransferAccount account = transferAccounts.get(i);
+                TransferAccount preAccount = transferAccounts.get(i - 1);
+                vos.add(new TransferDetailVO(preAccount.getAssigneeDate(), account.getAssigneeDate(), account.getTransferor(), accountId));
+                lastTwoAssigneeDate = account.getAssigneeDate();
+            }
+            if (lastAccout.getTransferorDate().equals(realEndDate)) {
+                //最后一条数据的转让时间为季度末尾
+                vos.add(new TransferDetailVO(lastTwoAssigneeDate, endDate, lastAccout.getTransferor(), accountId));
+            } else {
+                vos.add(new TransferDetailVO(lastTwoAssigneeDate, lastAccout.getAssigneeDate(), lastAccout.getTransferor(), accountId));
+                vos.add(new TransferDetailVO(lastAccout.getAssigneeDate(), endDate, lastAccout.getAssignee(), accountId));
+            }
+            vos = vos.parallelStream().filter(
+                    vo -> !vo.getStartDate().equals(vo.getEndDate())
+            ).collect(Collectors.toList());
+        }
+        return vos;
+    }
+
+    @Override
+    public List<JSONObject> getOperateGroupAccountByUser(JSONObject requestBody) {
+        String userId=requestBody.getString("userId");
+        int year= requestBody.getInteger("year");
+        String quarter=requestBody.getString("quarter");
+        int mediaType=requestBody.getInteger("mediaType");
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        List<JSONObject> result=new ArrayList<>();
+        if(mediaType==CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INT){
+            result=operateDetailMapper.ByteDanceOperateDetailGroupAccountByDate(startDate,endDate,userId);
+        }else if(mediaType==CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT){
+            result=operateDetailMapper.kuaiShouOperateDetailGroupAccountByDate(startDate,endDate,userId);
+        }
+        return result;
+    }
+}

+ 81 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceInfoInfoServiceImpl.java

@@ -0,0 +1,81 @@
+package org.jeecg.modules.performance.service.impl;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import cn.com.ctop.common.module.service.ISysCompanyService;
+import cn.com.ctop.common.module.service.ISysRoleService;
+import cn.com.ctop.common.module.utils.CtopMediaTypeUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
+import org.jeecg.modules.performance.service.IPerformanceInfoService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *  Created by JQ.bi on 2020.6.10
+ */
+@Service
+public class PerformanceInfoInfoServiceImpl implements IPerformanceInfoService {
+
+    @Autowired
+    ISysCompanyService sysCompanyService;
+    @Autowired
+    ISysRoleService sysRoleService;
+    @Autowired
+    ISysUserService sysUserService;
+    @Autowired
+    ProjectMemberMapper projectMemberMapper;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+
+    @Override
+    public Map<String, Object> getPerformanceInfo() {
+
+        Map<String,Object> result= new HashMap<>();
+        //获取公司名称
+        result.put("company",this.getCompany());
+        //部门
+        result.put("depart",this.getDepart());
+        //获取媒体类型
+        result.put("mediaType", CtopMediaTypeUtil.getMediaTypeAll());
+        //获取年份,季度
+        result.put("data",performanceQuarterService.getYearQuarter());
+        //获取职位
+        result.put("post",sysRoleService.list());
+
+        return result;
+    }
+
+    //根据权限查看绩效
+    private List<SysCompany> getCompany(){
+        List<SysCompany> result;
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        Map<String,Object> role=sysUserService.queryRoleCode(userId);
+        if(role.get("roleName").equals("管理员")){
+            result=sysCompanyService.list();
+        }else {
+            String companyId=projectMemberMapper.getCompanyIdByUserId(userId);
+            QueryWrapper<SysCompany> queryWrapper= new QueryWrapper<>();
+            queryWrapper.eq("company_id",companyId);
+            result= sysCompanyService.list(queryWrapper);
+        }
+        return result;
+    }
+    //TODO 部门暂时写死
+    private List<String> getDepart(){
+        List<String> depart=new ArrayList<>();
+        depart.add("运营部");
+        depart.add("设计部");
+        depart.add("销售部");
+        return depart;
+    }
+}

+ 109 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceQuarterServiceImpl.java

@@ -0,0 +1,109 @@
+package org.jeecg.modules.performance.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.mapper.PerformanceQuarterMapper;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class PerformanceQuarterServiceImpl extends ServiceImpl<PerformanceQuarterMapper, PerformanceQuarter> implements IPerformanceQuarterService {
+
+    @Autowired
+    PerformanceQuarterMapper performanceQuarterMapper;
+
+    /**
+     *  获取绩效表里有的年份季度
+     *
+     */
+    @Override
+    public Map<String, Set<String>> getYearQuarter() {
+        Map<String, Set<String>> result= new HashMap<>();
+        List<JSONObject> jsonObjectList=performanceQuarterMapper.queryYearAndQuarter();
+        if(jsonObjectList.isEmpty()){
+            return result;
+        }
+        jsonObjectList.forEach(it->{
+            if(result.get(it.getInteger("year").toString())==null){
+                Set<String> quarter= new HashSet<>();
+                quarter.add(it.getString("quarter"));
+                result.put(it.getInteger("year").toString(),quarter);
+            }else {
+                result.get(it.getInteger("year").toString()).add(it.getString("quarter"));
+            }
+        });
+        return result;
+    }
+
+    @Override
+    public List<PerformanceQuarter> getPerformanceByConditions(JSONObject requestBody) {
+        QueryWrapper<PerformanceQuarter> quarterWrapper=new QueryWrapper<>();
+        String[] columns={"user_id","user_name","company_name","role_name","media_type","year","quarter","cost","point","performance","additional_fees"};
+        quarterWrapper.select(columns);
+        Map<String,Object> map = new HashMap<>(10);
+        if(!requestBody.getString("company").equals("")) {
+            map.put("company_id",requestBody.getString("company"));
+        }
+        if(!requestBody.getString("department").equals("")) {
+            map.put("department",requestBody.getString("department"));
+        }
+        if(requestBody.getInteger("mediaType")!=0) {
+            map.put("media_type",requestBody.getInteger("mediaType"));
+        }
+        if(requestBody.getInteger("year")!=0) {
+            map.put("year",requestBody.getInteger("year"));
+        }
+        if(!requestBody.getString("quarter").equals("")) {
+            map.put("quarter",requestBody.getString("quarter"));
+        }
+        if(!requestBody.getString("roleCode").equals("")) {
+            map.put("role_code",requestBody.getString("roleCode"));
+        }
+        quarterWrapper.allEq(map);
+        quarterWrapper.like("user_name",requestBody.getString("userName"));
+        return performanceQuarterMapper.selectList(quarterWrapper);
+    }
+
+    @Override
+    public PageInfo<PerformanceQuarter> getPerformanceByConditionsPage(int pageNo, int pageSize, String order,JSONObject requestBody) {
+        QueryWrapper<PerformanceQuarter> quarterWrapper=new QueryWrapper<>();
+        String[] columns={"user_id","user_name","company_name","department","role_name","media_type","year","quarter","cost","point","performance","additional_fees"};
+        quarterWrapper.select(columns);
+        Map<String,Object> map = new HashMap<>(16);
+        if(!requestBody.getString("company").equals("")) {
+            map.put("company_id",requestBody.getString("company"));
+        }
+        if(!requestBody.getString("department").equals("")) {
+            map.put("department",requestBody.getString("department"));
+        }
+        if(requestBody.getInteger("mediaType")!=0) {
+            map.put("media_type",requestBody.getInteger("mediaType"));
+        }
+        if(requestBody.getInteger("year")!=0) {
+            map.put("year",requestBody.getInteger("year"));
+        }
+        if(!requestBody.getString("quarter").equals("")) {
+            map.put("quarter",requestBody.getString("quarter"));
+        }
+        if(!requestBody.getString("roleCode").equals("")) {
+            map.put("role_code",requestBody.getString("roleCode"));
+        }
+        quarterWrapper.allEq(map);
+        quarterWrapper.like("user_name",requestBody.getString("userName"));
+        if(order.equals("asc"))
+            quarterWrapper.orderByAsc("cost");
+        else
+            quarterWrapper.orderByDesc("cost");
+        PageHelper.startPage(pageNo,pageSize);
+        List<PerformanceQuarter> maps = performanceQuarterMapper.selectList(quarterWrapper);
+        return (PageInfo<PerformanceQuarter>) new PageInfo(maps);
+    }
+
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.performance;
+
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.performance.service.ICalculatePerformanceService;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+
+@RestController
+public class testCtrl {
+
+    @Autowired
+    IOperateDetailService operateDetailService;
+
+    @Autowired
+    ICalculatePerformanceService  calculatePerformanceService;
+
+    @GetMapping("/job/test/operator")
+    public String testOperator(){
+/*
+        Date nowDate= new Date();
+
+        String startStatDate = DateUtils.getQuarterStartDate(nowDate);
+        String endStatDate = DateUtils.getQuarterEndDate(nowDate);
+
+        operateDetailService.KsCostCalculateByAccount(startStatDate,endStatDate);
+        operateDetailService.BtCostCalculateByAccount(startStatDate,endStatDate);*/
+        calculatePerformanceService.CalculateOperatePerformance(2020,"Q2",2);
+        return "success";
+    }
+
+}

+ 32 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/vo/TransferDetailVO.java

@@ -0,0 +1,32 @@
+package org.jeecg.modules.performance.vo;
+
+import lombok.Data;
+
+@Data
+public class TransferDetailVO {
+    private String startDate;
+    private String endDate;
+    private String userId;
+    private Long accountId;
+
+    public TransferDetailVO() {
+
+    }
+
+    public TransferDetailVO(String startDate, String endDate, String userId, Long accountId) {
+        this.startDate = startDate;
+        this.endDate = endDate;
+        this.userId = userId;
+        this.accountId = accountId;
+    }
+
+    @Override
+    public String toString() {
+        return "TransferDetailVO{" +
+                "startDate='" + startDate + '\'' +
+                ", endDate='" + endDate + '\'' +
+                ", userId='" + userId + '\'' +
+                ", accountId=" + accountId +
+                '}';
+    }
+}

+ 26 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserRoleMapper.java

@@ -18,4 +18,30 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
 
 	@Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = (select id from sys_user where username=#{username}))")
 	List<String> getRoleByUserName(@Param("username") String username);
+
+	@Select("SELECT\n" +
+			"\tt3.user_id\n" +
+			"FROM\n" +
+			"\t(\n" +
+			"\t\tSELECT\n" +
+			"\t\t\tt2.user_id,\n" +
+			"\t\t\tt2.role_id\n" +
+			"\t\tFROM\n" +
+			"\t\t\tsys_user_depart t1\n" +
+			"\t\tLEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id\n" +
+			"\t\tWHERE\n" +
+			"\t\t\tt1.dep_id = (\n" +
+			"\t\t\t\tSELECT\n" +
+			"\t\t\t\t\tdep_id\n" +
+			"\t\t\t\tFROM\n" +
+			"\t\t\t\t\tsys_user_depart\n" +
+			"\t\t\t\tWHERE\n" +
+			"\t\t\t\t\tuser_id = #{userId}\n" +
+			"\t\t\t)\n" +
+			"\t) t3\n" +
+			"LEFT JOIN sys_role t4 ON t3.role_id = t4.id\n" +
+			"WHERE\n" +
+			"\tt4.role_code =  #{roleCode}\n")
+	String getLeaderIdByUser(@Param("userId") String userId, @Param("roleCode") String roleCode);
+
 }

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java

@@ -22,4 +22,7 @@ public interface ISysUserRoleService extends IService<SysUserRole> {
 	Map<String,String> queryUserRole();
 
 	SysUserRole getUserRoleByUserId(String userId);
+
+	String getLeaderId(String userId, String roleCode);
+
 }

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

@@ -1,6 +1,7 @@
 package org.jeecg.modules.system.service.impl;
 
 import cn.com.ctop.common.module.entity.SysRole;
+import cn.com.ctop.common.module.mapper.SysRoleMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -31,7 +32,10 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
 	private ISysUserService userService;
 	@Autowired
 	private ISysRoleService roleService;
-
+	@Autowired
+	private SysUserRoleMapper roleMapper;
+	@Autowired
+	private SysRoleMapper sysRoleMapper;
 	/**
 	 * 查询所有用户对应的角色信息
 	 */
@@ -83,4 +87,14 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
 		}
 	}
 
+	@Override
+	public String getLeaderId(String userId, String roleCode) {
+		String roleCodeStr = sysRoleMapper.getRoleCodeByUserId(userId);
+		if ("kuaishouOperationManager".equals(roleCodeStr) || "touTiaoOperationManager".equals(roleCodeStr)) {
+			return null;
+		}
+		String leaderId = roleMapper.getLeaderIdByUser(userId, roleCode);
+		return leaderId;
+	}
+
 }

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

@@ -129,8 +129,8 @@ mybatis-plus:
       # 默认数据库表下划线命名
       table-underline: true
     configuration:
-      # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
-      #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
+    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #jeecg专用配置
 jeecg:
   ffmpeg:

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

@@ -1,5 +1,5 @@
 server:
-  port: 8080
+  port: 8804
   ip: 39.97.120.42
   servlet:
     context-path: /jeecg-boot
@@ -97,7 +97,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://39.97.120.42:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
@@ -110,7 +110,7 @@ spring:
   #redis 配置
   redis:
     database: 0
-    host: 127.0.0.1
+    host: 172.30.0.17
     lettuce:
       pool:
         max-active: 8   #最大连接数据库连接数,设 0 为没有限制
@@ -139,16 +139,16 @@ jeecg:
     bin: ffmpeg
   path:
     #文件上传根目录 设置
-    upload: /mnt/upload
+    upload: /data/upload
     #webapp文件路径
-    webapp: /mnt/webapp
-    video-upload: /mnt/upload/video/
-    image-upload: /mnt/upload/image/
+    webapp: /data/webapp
+    video-upload: /data/upload/video/
+    image-upload: /data/upload/image/
     chrome-driver: /usr/bin/chromedriver
-    csv-upload: /mnt/upload/csv/
-    bak-database-file: /mnt/data/bak/
-    report-history: /mnt/upload/report/history/
-    report-daily: /mnt/upload/report/daily/
+    csv-upload: /data/upload/csv/
+    bak-database-file: /data/data/bak/
+    report-history: /data/upload/report/history/
+    report-daily: /data/upload/report/daily/
 kuaishou:
   group-control:
     path: http://39.106.184.70
@@ -159,10 +159,10 @@ logging:
   config: classpath:logback-prod.xml
 chrome:
   script:
-    clean: sh /mnt/webapp/cleanProcess.sh
+    clean: sh /data/webapp/cleanProcess.sh
 
 oss:
   replace:
-    replace-value: oss-cn-beijing-internal
+    replace-value: oss-cn-beijing
     replace-old-value: oss-cn-beijing
-    download: /mnt/file/video/
+    download: /data/file/video/

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

@@ -94,16 +94,16 @@ spring:
         filters: stat,slf4j
         # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
-      #      datasource:
-      #        master:
-      #          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-      #          username: hcst
-      #          password: test@20190531
       datasource:
         master:
           url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: test@20190531
+#      datasource:
+#        master:
+#          url: jdbc:mysql://39.97.120.42:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#          username: hcst
+#          password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
   #redis 配置
   redis:

+ 56 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/SysCompany.java

@@ -0,0 +1,56 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Objects;
+
+@Data
+@TableName("sys_company")
+public class SysCompany {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private String companyId;
+
+    private String companyCode;
+
+    private String companyName;
+
+    private String area;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        SysCompany that = (SysCompany) o;
+        return id.equals(that.id) &&
+                companyId.equals(that.companyId) &&
+                companyCode.equals(that.companyCode) &&
+                companyName.equals(that.companyName) &&
+                area.equals(that.area);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, companyId, companyCode, companyName, area);
+    }
+
+    @Override
+    public String toString() {
+        return "SysCompany{" +
+                "id=" + id +
+                ", companyId='" + companyId + '\'' +
+                ", companyCode='" + companyCode + '\'' +
+                ", companyName='" + companyName + '\'' +
+                ", area='" + area + '\'' +
+                '}';
+    }
+
+}

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialImageInfoMapper.java

@@ -1,7 +1,9 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.MaterialImageInfo;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -16,4 +18,6 @@ public interface MaterialImageInfoMapper extends BaseMapper<MaterialImageInfo> {
     void insertSelective(MaterialImageInfo materialImageInfo);
 
     List<String> getCodeList();
+
+    List<JSONObject> getUrlList(@Param("videoId") String videoId);
 }

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysCompanyMapper.java

@@ -0,0 +1,8 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface SysCompanyMapper extends BaseMapper<SysCompany> {
+
+}

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

@@ -11,10 +11,10 @@
             left join ctop_project project on login.project_id = project.id
         where 1=1
         <if test="userId!=null">
-            and user_id = #{userId}
+            and login.user_id = #{userId}
         </if>
         <if test="loginType!=null">
-            and login_type = #{loginType}
+            and login.login_type = #{loginType}
         </if>
         group by project_id
     </select>

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

@@ -120,4 +120,15 @@
      SELECT DISTINCT(code)  from  ctop_material_image_info
     </select>
 
+    <select id="getUrlList" resultType="com.alibaba.fastjson.JSONObject">
+
+        SELECT t.url as 'imageUrl',t.`code` as 'signature'  from (
+        SELECT url,`code` from ctop_material_image_info
+        WHERE video_id = #{videoId}
+        UNION ALL
+        SELECT url,signature  from ctop_material_cut_frame WHERE video_signature = #{videoId}
+        ) t
+
+    </select>
+
 </mapper>

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

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

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

@@ -16,7 +16,7 @@ import java.util.Map;
  */
 public interface IFileInfoService extends IService<FileInfo> {
 
-    void uploadVideoToBytedance(String accountId, String videoUrl);
+    void uploadVideoToBytedance(String accountId, String videoUrl, String userId,String materialName);
 
     Map<String, Object> uploadImageToBytedance(String accountId, String imageFileId);
 

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.MaterialImageInfo;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -26,4 +27,5 @@ public interface IMaterialImageInfoService extends IService<MaterialImageInfo> {
 
     List<String> getCodeList();
 
+    List<JSONObject> getUrlList(String videoId);
 }

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

@@ -0,0 +1,9 @@
+package cn.com.ctop.common.module.service;
+
+public interface IMessageTemplate {
+
+    String getMaterialSyncTemplate(String projectName, Long accountId, String accountName, String materialName, String reason);
+
+
+    String getMaterialRejectTemplate(String projectName, String materialName, String refuseReason);
+}

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

@@ -0,0 +1,5 @@
+package cn.com.ctop.common.module.service;
+
+public interface ISendMessageService {
+    void sendMessage(String id, String text);
+}

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ISysCompanyService.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+public interface ISysCompanyService  extends IService<SysCompany> {
+}

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

@@ -24,4 +24,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     Map<String, Object> getPangolinProjectListByParams(String userId);
 
     List<UserAllocation> selectAccountListByProjectId(Long projectId);
+
+    List<UserAllocation> getByMediaId(String mediaId);
 }

+ 23 - 14
module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -2,10 +2,11 @@ package cn.com.ctop.common.module.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.FileInfo;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.FileInfoMapper;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.service.IFileInfoService;
+import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.BytedanceInterfaceConstant;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import com.alibaba.fastjson.JSONArray;
@@ -53,14 +54,31 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
     FileInfoMapper fileInfoMapper;
     @Resource
     private ICtopOauthTokenService ctopOauthTokenService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+    @Autowired
+    private ISendMessageService sendMessageService;
 
     @Override
-    public void uploadVideoToBytedance(String accountId, String videoUrl) {
+    public void uploadVideoToBytedance(String accountId, String videoUrl, String userId, String materialName) {
         try {
             CtopOauthToken token = ctopOauthTokenService.getOauthTokenByAccountId(accountId);
-            uploadAdvideo(token, videoUrl, token.getAccountId() + "");
             JSONObject jsonObject = videoUpload(token, videoUrl);
-            log.info("头条上传素材返回信息:{},accountId:{}", jsonObject, accountId);
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("code");
+                if (code == 0) {
+                    log.info("头条上传素材成功,返回信息:{},accountId:{}", jsonObject, accountId);
+                } else {
+                    UserAllocation allocation = userAllocationService.getByAccountId(Long.valueOf(accountId));
+                    String message = messageTemplate.getMaterialSyncTemplate(allocation.getProjectName(), Long.valueOf(accountId), allocation.getAuthName(), materialName, jsonObject.getString("message"));
+                    sendMessageService.sendMessage(userId, message);
+                }
+
+            }
+
+
         } catch (Exception e) {
             log.error("头条上传视频文件失败,accountId:{}", accountId);
             log.error(e.getMessage(), e);
@@ -207,15 +225,6 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         }
     }
 
-    public void uploadAdvideo(CtopOauthToken token, String videoUrl, String advertiserId) {
-        //1:下载文件到本地
-
-
-        //文件上传
-        // JSONObject bytedanceObject = videoUpload(token, advertiserId, videoPath);
-        // log.info("头条上传返回信息:{},accountId:{}", bytedanceObject, advertiserId);
-
-    }
 
     private JSONObject videoUpload(CtopOauthToken token, String videoPath) {
         CloseableHttpResponse response = null;

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

@@ -128,4 +128,9 @@ public class MaterialImageInfoServiceImpl extends ServiceImpl<MaterialImageInfoM
         return materialImageInfoMapper.getCodeList();
     }
 
+    @Override
+    public List<JSONObject> getUrlList(String videoId) {
+        return materialImageInfoMapper.getUrlList(videoId);
+    }
+
 }

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

@@ -0,0 +1,57 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.service.IMessageTemplate;
+import cn.com.ctop.common.module.utils.Check;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MessageTemplateImpl implements IMessageTemplate {
+
+
+    /**
+     * 同步素材失败
+     *
+     * @param projectName
+     * @param accountId
+     * @param accountName
+     * @param materialName
+     * @param reason
+     * @return
+     */
+    @Override
+    public String getMaterialSyncTemplate(String projectName, Long accountId, String accountName, String materialName, String reason) {
+        StringBuilder text = new StringBuilder();
+        text.append("素材同步失败").append("<br/>")
+                .append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("下的账户:").append(accountId + ",").append("<br/>")
+                .append("授权名称为:" + accountName).append("<br/>")
+                .append("同步素材失败。").append("<br/>")
+                .append("素材名称为:").append(materialName).append("<br/>")
+                .append("失败原因:").append(reason);
+        return text.toString();
+    }
+
+
+    /**
+     * 素材库素材驳回
+     *
+     * @param projectName
+     * @param materialName
+     * @param refuseReason
+     * @return
+     */
+    @Override
+    public String getMaterialRejectTemplate(String projectName, String materialName, String refuseReason) {
+        StringBuilder text = new StringBuilder();
+        text.append("素材驳回通知").append("<br/>")
+                .append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("素材名称为:").append(materialName).append("<br/>")
+                .append("已被驳回。").append("<br/>");
+        if (!Check.isNull(refuseReason)) {
+            text.append("驳回原因为:").append(refuseReason).append("</br>");
+
+        }
+        text.append("请您联系相关同学及时调整");
+        return text.toString();
+    }
+}

+ 26 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SendMessageServiceImpl.java

@@ -0,0 +1,26 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.service.ISendMessageService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class SendMessageServiceImpl implements ISendMessageService {
+    @Autowired
+    private MailLogMapper mailLogMapper;
+
+    @Override
+    public void sendMessage(String userId, String text) {
+        String weChatId = mailLogMapper.getWChatIdByUserId(userId);
+        if (!Check.isNull(weChatId)) {
+            CorpWexinUtils.sendMessageByWeChatId(weChatId, text);
+            log.info("消息发送成功,userId:{}", userId);
+        }
+    }
+
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import cn.com.ctop.common.module.mapper.SysCompanyMapper;
+import cn.com.ctop.common.module.service.ISysCompanyService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SysCompanyServiceImpl extends ServiceImpl<SysCompanyMapper, SysCompany> implements ISysCompanyService {
+}

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

@@ -88,5 +88,13 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         return list;
     }
 
-
+    @Override
+    public List<UserAllocation> getByMediaId(String mediaId) {
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        if ("".equals(mediaId)) {
+            queryWrapper.eq("media_id", mediaId);
+        }
+        queryWrapper.orderByDesc("id");
+        return this.list(queryWrapper);
+    }
 }

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java

@@ -11,7 +11,7 @@ public class CtopAdConstant {
     public static final  int PLATFORM_TYPE_BYTEDANCE_INT = 1;
     //快手
     public static final String PLATFORM_TYPE_KUAISHOU = "2";
-    public static final  int PLATFORM_TYPE_KUAISHOU_INT = 2;
+    public static final  int   PLATFORM_TYPE_KUAISHOU_INT = 2;
     //头条内广
     public static final String PLATFORM_TYPE_BYTEDANCE_INSIDE = "3";
     public static final  int PLATFORM_TYPE_BYTEDANCE_INSIDE_INT = 3;

+ 42 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopMediaTypeUtil.java

@@ -0,0 +1,42 @@
+package cn.com.ctop.common.module.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *  Created by JQ.bi on 2020.6.10
+ */
+public class CtopMediaTypeUtil {
+
+    /**
+     *  获取全部媒体类型
+     */
+    public static List<Map<String,Object>>  getMediaTypeAll(){
+
+        List<Map<String,Object>> mediaType= new ArrayList<>();
+        Map<String,Object> byteDance= new HashMap<>();
+        byteDance.put("code","PLATFORM_TYPE_BYTEDANCE");
+        byteDance.put("num",1);
+        byteDance.put("name","头条");
+        Map<String,Object> kuaiShou= new HashMap<>();
+        kuaiShou.put("code","PLATFORM_TYPE_KUAISHOU");
+        kuaiShou.put("num",2);
+        kuaiShou.put("name","快手");
+/*        Map<String,Object> byteDanceInside= new HashMap<>();
+        byteDanceInside.put("code","PLATFORM_TYPE_BYTEDANCE_INSIDE");
+        byteDanceInside.put("num",3);
+        byteDanceInside.put("name","头条内广");
+        Map<String,Object> kuaiShouInside= new HashMap<>();
+        kuaiShouInside.put("code","PLATFORM_TYPE_KUAISHOU_INSIDE");
+        kuaiShouInside.put("num",4);
+        kuaiShouInside.put("name","快手内广");*/
+        mediaType.add(byteDance);
+        //mediaType.add(byteDanceInside);
+        mediaType.add(kuaiShou);
+        //mediaType.add(kuaiShouInside);
+
+        return mediaType;
+    }
+}

+ 1 - 2
module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -77,8 +77,7 @@ public class ExportExcelUtils {
                             BigDecimal bigDecimal = (BigDecimal) obj;
                             cell.setCellValue(bigDecimal.doubleValue());
                         } else if (obj instanceof Long) {
-                            Long aLong = Long.valueOf(String.valueOf(obj));
-                            cell.setCellValue(aLong.doubleValue());
+                            cell.setCellValue(String.valueOf(obj));
                         } else {
                             cell.setCellValue(obj.toString());
                         }

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

@@ -114,6 +114,11 @@ public class KuaishouInterfaceConstant {
      */
     public static final String CONVERT_LIST = "/rest/openapi/v1/tool/convert/list";
 
+    /**
+     * 获取可选的动态词包
+     */
+    public static final String CREATIVE_WORD = "/rest/openapi/v1/tool/creative_word/list";
+
 
     /**
      * 获取定向标签

+ 1 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialUploadService.java

@@ -11,5 +11,5 @@ public interface IMaterialUploadService {
      * @param materialArray
      * @param accountArray
      */
-    void uploadAccount(String mediaId, JSONArray materialArray, JSONArray accountArray);
+    void uploadAccount(String mediaId, JSONArray materialArray, JSONArray accountArray,String userId);
 }

+ 54 - 55
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java

@@ -1,22 +1,20 @@
 package cn.com.ctop.manage.modules.material.service.impl;
 
-import cn.com.ctop.common.module.entity.MaterialImageInfo;
 import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.service.IMaterialImageInfoService;
 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.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadImageService;
+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.apache.http.ParseException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.io.FileSystemResource;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
@@ -26,7 +24,6 @@ import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
-import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -36,7 +33,7 @@ import java.util.concurrent.Executors;
 @Slf4j
 @Service
 public class MaterialUploadImageServiceImpl implements IMaterialUploadImageService {
-    static ExecutorService executorService = Executors.newFixedThreadPool(4);
+    static ExecutorService executorService = Executors.newFixedThreadPool(8);
     @Value("${oss.replace.replace-value}")
     private String replaceValue;
     @Value("${oss.replace.replace-old-value}")
@@ -55,63 +52,65 @@ public class MaterialUploadImageServiceImpl implements IMaterialUploadImageServi
     @Override
     public void uploadImage(String videoId, Long accountId, String accessToken) {
         try {
-            QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
-            imageInfoQueryWrapper.eq("video_id", videoId);
-            imageInfoQueryWrapper.eq("status", 0);
-            List<MaterialImageInfo> imageList = materialImageInfoService.list(imageInfoQueryWrapper);
+            List<JSONObject> imageList = materialImageInfoService.getUrlList(videoId);
             if (!Check.isNull(imageList)) {
-                for (MaterialImageInfo imageInfo : imageList) {
-                    QueryWrapper<KuaiShouImageGet> imageQueryWrapper = new QueryWrapper<>();
-                    imageQueryWrapper.eq("account_id", accountId);
-                    imageQueryWrapper.eq("signature", imageInfo.getCode());
-                    List<KuaiShouImageGet> imageGetList = imageGetService.list(imageQueryWrapper);
-                    if (!Check.isNull(imageGetList)) {
-                        log.info("此封面已上传");
+                for (int i = 0; i < imageList.size(); i++) {
+                    JSONObject imageInfo = imageList.get(i);
+                    if (Check.isNull(imageInfo)) {
                         continue;
                     }
-                    String url = String.valueOf(imageInfo.getUrl());
-                    String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
-                    FileSystemResource resource = new FileSystemResource(new File(localUrl));
-                    Map<String, String> headerMap = new HashMap<>();
-                    JSONObject requestJson = new JSONObject();
-                    requestJson.put("advertiser_id", accountId);
-                    headerMap.put("Access-Token", accessToken);
-                    headerMap.put("Content-Type", "multipart/form-data");
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            QueryWrapper<KuaiShouImageGet> imageQueryWrapper = new QueryWrapper<>();
+                            imageQueryWrapper.eq("account_id", accountId);
+                            imageQueryWrapper.eq("signature", imageInfo.getString("signature"));
+                            List<KuaiShouImageGet> imageGetList = imageGetService.list(imageQueryWrapper);
+                            if (Check.isNull(imageGetList)) {
+                                Map<String, String> headerMap = new HashMap<>();
+                                JSONObject requestJson = new JSONObject();
+                                requestJson.put("advertiser_id", accountId);
+                                headerMap.put("Access-Token", accessToken);
+                                headerMap.put("Content-Type", "multipart/form-data");
 
-                    requestJson.put("file", resource);
-                    requestJson.put("signature", imageInfo.getCode());
-                    requestJson.put("type", "2");
-                    requestJson.put("upload_type", "1");
-                    String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
-                    String result = exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
-                    JSONObject resultJson = JSONObject.parseObject(result);
-                    if (!Check.isNull(resultJson)) {
-                        if (resultJson.getInteger("code") == 0) {
-                            JSONObject dataJson = resultJson.getJSONObject("data");
-                            if (!Check.isNull(dataJson)) {
-                                String signature = dataJson.getString("signature");
-                                String image_token = dataJson.getString("image_token");
-                                KuaiShouImageGet imageGet = new KuaiShouImageGet();
-                                imageGet.setId(accountId + image_token);
-                                imageGet.setAccountId(accountId);
-                                imageGet.setUrl(dataJson.getString("url"));
-                                imageGet.setWidth(dataJson.getInteger("width"));
-                                imageGet.setHeight(dataJson.getInteger("height"));
-                                imageGet.setSize(dataJson.getInteger("size"));
-                                imageGet.setFormat(dataJson.getString("format"));
-                                Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
-                                if (!Check.isNull(type)) {
-                                    imageGet.setMaterialType(type);
+                                requestJson.put("url", imageInfo.getString("imageUrl"));
+                                requestJson.put("signature", imageInfo.getString("signature"));
+                                requestJson.put("type", "2");
+                                requestJson.put("upload_type", "2");
+                                String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
+                                String result = exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
+                                JSONObject resultJson = JSONObject.parseObject(result);
+                                if (!Check.isNull(resultJson)) {
+                                    if (resultJson.getInteger("code") == 0) {
+                                        JSONObject dataJson = resultJson.getJSONObject("data");
+                                        if (!Check.isNull(dataJson)) {
+                                            String signature = dataJson.getString("signature");
+                                            String image_token = dataJson.getString("image_token");
+                                            KuaiShouImageGet imageGet = new KuaiShouImageGet();
+                                            imageGet.setId(accountId + image_token);
+                                            imageGet.setAccountId(accountId);
+                                            imageGet.setUrl(dataJson.getString("url"));
+                                            imageGet.setWidth(dataJson.getInteger("width"));
+                                            imageGet.setHeight(dataJson.getInteger("height"));
+                                            imageGet.setSize(dataJson.getInteger("size"));
+                                            imageGet.setFormat(dataJson.getString("format"));
+                                            Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
+                                            if (!Check.isNull(type)) {
+                                                imageGet.setMaterialType(type);
+                                            }
+                                            imageGet.setSignature(signature);
+                                            imageGet.setImageToken(image_token);
+                                            imageGetService.saveOrUpdate(imageGet);
+                                        }
+                                        log.info("快手封面素材素材同步完成,accountId:{},code:{},返回信息:{}", accountId, imageInfo.getString("signature"), resultJson);
+                                    } else {
+                                        log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
+                                    }
                                 }
-                                imageGet.setSignature(signature);
-                                imageGet.setImageToken(image_token);
-                                imageGetService.saveOrUpdate(imageGet);
                             }
-                            log.info("快手封面素材素材同步完成,accountId:{},code:{},返回信息:{}", accountId, imageInfo.getCode(), resultJson);
-                        } else {
-                            log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
+
                         }
-                    }
+                    });
                 }
             }
         } catch (Exception e) {

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

@@ -3,12 +3,12 @@ package cn.com.ctop.manage.modules.material.service.impl;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import cn.com.ctop.common.module.entity.MaterialParameter;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
 import cn.com.ctop.common.module.mapper.MaterialParameterMapper;
-import cn.com.ctop.common.module.service.IFileInfoService;
-import cn.com.ctop.common.module.service.IMaterialParameterService;
+import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
@@ -67,6 +67,12 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
     private IKuaiShouVideoGetService kuaiShouVideoGetService;
     @Autowired
     private IMaterialUploadImageService materialUploadImageService;
+    @Autowired
+    private ISendMessageService sendMessageService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+    @Autowired
+    private IUserAllocationService userAllocationService;
 
 
     /**
@@ -78,12 +84,12 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
      */
 
     @Override
-    public void uploadAccount(String mediaId, JSONArray materialArray, JSONArray accountArray) {
+    public void uploadAccount(String mediaId, JSONArray materialArray, JSONArray accountArray, String userId) {
         try {
             if ("2".equals(mediaId)) {
-                this.kuaiShouUpload(mediaId, materialArray, accountArray);
+                this.kuaiShouUpload(mediaId, materialArray, accountArray, userId);
             } else if ("1".equals(mediaId)) {
-                this.touTiaoUpload(mediaId, materialArray, accountArray);
+                this.touTiaoUpload(mediaId, materialArray, accountArray, userId);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -93,7 +99,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
     }
 
 
-    private void touTiaoUpload(String mediaId, JSONArray materialArray, JSONArray accountArray) {
+    private void touTiaoUpload(String mediaId, JSONArray materialArray, JSONArray accountArray, String userId) {
         for (int j = 0; j < materialArray.size(); j++) {
             String materialId = materialArray.getString(j);
             MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
@@ -110,12 +116,12 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                         continue;
                     }
                     touTiaoExecutorService.submit(new Runnable() {
-                                @Override
-                                public void run() {
+                        @Override
+                        public void run() {
                             try {
                                 log.info("头条文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
                                 if ("VIDEO".equals(materialInfo.getType())) {
-                                    fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl);
+                                    fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl, userId, materialInfo.getMaterialName());
 
                                 } else if ("IMAGE".equals(materialInfo.getType())) {
                                     fileInfoService.uploadImageToBytedance(String.valueOf(accountId), localUrl);
@@ -138,7 +144,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
     }
 
 
-    private void kuaiShouUpload(String mediaId, JSONArray materialArray, JSONArray accountArray) {
+    private void kuaiShouUpload(String mediaId, JSONArray materialArray, JSONArray accountArray, String userId) {
         for (int j = 0; j < materialArray.size(); j++) {
             String materialId = materialArray.getString(j);
             MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
@@ -216,12 +222,16 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                             videoGet.setPhotoId(photoId);
                                             videoGet.setSignature(signature);
                                             kuaiShouVideoGetService.saveOrUpdate(videoGet);
-                                            materialUploadImageService.uploadImage(videoGet.getId(), accountId, ctopOauthToken.getAccessToken());
+                                            materialUploadImageService.uploadImage(videoGet.getSignature(), accountId, ctopOauthToken.getAccessToken());
 
                                         }
                                         log.info("快手素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);
                                     } else {
                                         log.error("快手同步素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
+                                        //  发送消息到上传人
+                                        UserAllocation allocation = userAllocationService.getByAccountId(accountId);
+                                        String message = messageTemplate.getMaterialSyncTemplate(allocation.getProjectName(), accountId, allocation.getAuthName(), materialInfo.getMaterialName(), resultJson.getString("message"));
+                                        sendMessageService.sendMessage(userId, message);
                                     }
                                 }
 
@@ -271,4 +281,6 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
         }
         return null;
     }
+
+
 }

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

@@ -147,6 +147,16 @@ public class BatchController {
             };
             thread3.start();
 
+            Thread thread4 = new Thread() {
+                @Override
+                public void run() {
+                    kuaiShouGroupService.getGroupList(oauthToken.getAccessToken(), oauthToken.getAccountId());
+
+                }
+            };
+            thread4.start();
+
+
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
@@ -1062,13 +1072,13 @@ public class BatchController {
     public Result<IPage<KuaiShouVideoGet>> getVideoList(KuaiShouVideoGet kuaiShouVideoGet, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                         @RequestParam(name = "startDate", defaultValue = "2010-01-01") String startDate,
-                                                        @RequestParam(name = "endDate", defaultValue = "2100-01-01") String endDate,HttpServletRequest req) {
+                                                        @RequestParam(name = "endDate", defaultValue = "2100-01-01") String endDate, HttpServletRequest req) {
         Result<IPage<KuaiShouVideoGet>> result = new Result<>();
         try {
             QueryWrapper<KuaiShouVideoGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouVideoGet, req.getParameterMap());
             startDate = startDate + " 00:00:00";
             endDate = endDate + " 23:59:59";
-            queryWrapper.between("create_time",startDate,endDate);
+            queryWrapper.between("create_time", startDate, endDate);
             queryWrapper.orderByDesc("create_time");
             Page<KuaiShouVideoGet> page = new Page<>(pageNo, pageSize);
             IPage<KuaiShouVideoGet> pageList = kuaiShouVideoGetService.page(page, queryWrapper);
@@ -1390,7 +1400,13 @@ public class BatchController {
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
-            JSONObject unitJson = batchService.updateUnit(requestJson);
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            JSONObject unitJson = batchService.updateUnit(requestJson, oauthToken);
             result.setSuccess(true);
             result.setResult(unitJson);
         } catch (Exception e) {
@@ -1420,12 +1436,18 @@ public class BatchController {
             if (Check.isNull(unitIds)) {
                 throw new Exception("请选择需要修改的广告组");
             }
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
             JSONObject returnJson = new JSONObject();
             JSONArray failArr = new JSONArray();
             for (int i = 0; i < unitIds.size(); i++) {
                 Long unitId = unitIds.getLong(i);
                 requestJson.put("unitId", unitId);
-                JSONObject unitJson = batchService.updateUnit(requestJson);
+                JSONObject unitJson = batchService.updateUnit(requestJson, oauthToken);
                 if (!Check.isNull(unitJson)) {
                     Integer code = unitJson.getInteger("code");
                     if (code != 0) {
@@ -1466,7 +1488,18 @@ public class BatchController {
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
-            JSONObject creativeJson = batchService.updateCreative(requestJson);
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请输入需创建账号");
+            }
+
+
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            JSONObject creativeJson = batchService.updateCreative(requestJson, oauthToken);
             result.setSuccess(true);
             result.setResult(creativeJson);
         } catch (Exception e) {
@@ -1863,4 +1896,98 @@ public class BatchController {
     }
 
 
+    /**
+     * 批量修改广告创意
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateCreative")
+    public Result<JSONObject> batchUpdateCreative(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参为空");
+            }
+
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请输入需创建账号");
+            }
+
+
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+
+            JSONArray creativeIds = requestJson.getJSONArray("creativeIds");
+            if (Check.isNull(creativeIds)) {
+                throw new Exception("请选择需要修改的广告创意");
+            }
+            JSONObject creativeJson = requestJson.getJSONObject("creativeJson");
+            JSONObject returnJson = new JSONObject();
+            JSONArray failArr = new JSONArray();
+            for (int i = 0; i < creativeIds.size(); i++) {
+                Long creativeId = creativeIds.getLong(i);
+                creativeJson.put("creativeId", creativeId);
+                JSONObject unitJson = batchService.updateCreative(creativeJson, oauthToken);
+                if (!Check.isNull(unitJson)) {
+                    Integer code = unitJson.getInteger("code");
+                    if (code != 0) {
+                        JSONObject failJson = new JSONObject();
+                        failJson.put("message", unitJson.get("message"));
+                        KuaiShouCreative creative = batchService.getCreativeInfo(requestJson.getLong("accountId"), creativeId);
+                        if (!Check.isNull(creative)) {
+                            failJson.put("creativeName", creative.getCreativeName());
+                        }
+                        failArr.add(failJson);
+                    }
+                }
+            }
+            returnJson.put("totalCount", creativeIds.size());
+            returnJson.put("failCount", failArr.size());
+            returnJson.put("failInfo", failArr);
+
+            result.setSuccess(true);
+            result.setResult(returnJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 获取可选的动态词包
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/creativeWord")
+    public Result<JSONArray> creativeWord(Long accountId) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONArray creativeWordArr = iKuaishouInterfaceService.getCreativeWord(accountId, oauthToken.getAccessToken());
+            result.setResult(creativeWordArr);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
@@ -109,7 +110,7 @@ public interface IBatchService {
      * @param requestJson
      * @return
      */
-    JSONObject updateUnit(JSONObject requestJson) throws Exception;
+    JSONObject updateUnit(JSONObject requestJson,CtopOauthToken token) throws Exception;
 
     /**
      * 修改广告创意
@@ -117,7 +118,7 @@ public interface IBatchService {
      * @param requestJson
      * @return
      */
-    JSONObject updateCreative(JSONObject requestJson) throws Exception;
+    JSONObject updateCreative(JSONObject requestJson, CtopOauthToken token) throws Exception;
 
 
     /**

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

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
 
+    void getGroupList(String accessToken, Long accountId);
 }

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

@@ -494,6 +494,14 @@ public interface IKuaishouInterfaceService {
      */
     List<ConvertVo> getConvertList(Long accountId, String accessToken, Integer type);
 
+    /**
+     * 获取可选的动态词包
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONArray getCreativeWord(Long accountId, String accessToken);
 }
 
 

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

@@ -467,10 +467,7 @@ public class BatchServiceImpl implements IBatchService {
     @Override
     public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId) {
         JSONObject returnJson = new JSONObject();
-
         try {
-
-
             CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(group.getAccountId());
             if (Check.isNull(oauthToken)) {
                 throw new Exception("未获取到token信息");
@@ -784,6 +781,20 @@ public class BatchServiceImpl implements IBatchService {
                 creativeJson.put("photo_id", photo_id);
                 creativeJson.put("click_track_url", click_track_url);
 
+                //封面广告语标题
+                if (!Check.isNull(creative.getStickerTitle())) {
+                    creativeJson.put("sticker_title", creative.getStickerTitle());
+                }
+                // 贴纸样式类型
+                if (!Check.isNull(creative.getOverlayType())) {
+                    creativeJson.put("overlay_type", creative.getOverlayType());
+                }
+                // 安卓下载中间页
+                /*if (!Check.isNull(creative.getSiteId())) {
+                    creativeJson.put("site_id", creative.getSiteId());
+                }*/
+
+
                 Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson);
                 if (!Check.isNullMap(returnCreativeMap)) {
                     Integer code = (Integer) returnCreativeMap.get("code");
@@ -990,15 +1001,10 @@ public class BatchServiceImpl implements IBatchService {
      * @return
      */
     @Override
-    public JSONObject updateUnit(JSONObject requestJson) throws Exception {
+    public JSONObject updateUnit(JSONObject requestJson, CtopOauthToken token) throws Exception {
 
-        Long accountId = requestJson.getLong("accountId");
-        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-        if (Check.isNull(oauthToken)) {
-            throw new Exception("未获取到账户信息");
-        }
         JSONObject unitJson = new JSONObject();
-        unitJson.put("advertiser_id", accountId);
+        unitJson.put("advertiser_id", token.getAccountId());
 
         Long unitId = requestJson.getLong("unitId");
         if (Check.isNull(unitId)) {
@@ -1175,7 +1181,7 @@ public class BatchServiceImpl implements IBatchService {
 
         unitJson.put("target", targetJson);
 
-        JSONObject returnJson = updateService.updateUnit(oauthToken.getAccessToken(), unitJson);
+        JSONObject returnJson = updateService.updateUnit(token.getAccessToken(), unitJson);
         return returnJson;
     }
 
@@ -1186,22 +1192,14 @@ public class BatchServiceImpl implements IBatchService {
      * @return
      */
     @Override
-    public JSONObject updateCreative(JSONObject requestJson) throws Exception {
+    public JSONObject updateCreative(JSONObject requestJson, CtopOauthToken token) throws Exception {
         if (Check.isNull(requestJson)) {
             throw new Exception("入参为空");
         }
 
-        Long accountId = requestJson.getLong("accountId");
-        if (Check.isNull(accountId)) {
-            throw new Exception("请输入需创建账号");
-        }
-        JSONObject creativeJson = new JSONObject();
-        creativeJson.put("advertiser_id", accountId);
 
-        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-        if (Check.isNull(oauthToken)) {
-            throw new Exception("未获取到账户信息");
-        }
+        JSONObject creativeJson = new JSONObject();
+        creativeJson.put("advertiser_id", token.getAccountId());
 
         Long creativeId = requestJson.getLong("creativeId");
         if (Check.isNull(creativeId)) {
@@ -1258,7 +1256,7 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.get("impressionUrl"))) {
             creativeJson.put("impression_url", requestJson.get("impressionUrl"));
         }
-        JSONObject returnJson = updateService.updateCreative(oauthToken.getAccessToken(), creativeJson);
+        JSONObject returnJson = updateService.updateCreative(token.getAccessToken(), creativeJson);
 
         return returnJson;
     }

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

@@ -1,12 +1,27 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppInfoMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTargetMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouScheduleMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
-
+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.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * @Description: 广告组信息
@@ -14,7 +29,249 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  * @Date: 2019-07-23
  * @Version: V1.0
  */
+
+@Slf4j
 @Service
 public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, KuaiShouGroup> implements IKuaiShouGroupService {
+    @Autowired
+    private IKuaiShouCampaignService kuaiShouCampaignService;
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+    @Autowired
+    private KuaiShouAppInfoMapper appInfoMapper;
+    @Autowired
+    private KuaiShouScheduleMapper shouScheduleMapper;
+    @Autowired
+    private KuaiShouGroupTargetMapper groupTargetMapper;
+    private static ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+
+    /**
+     * 获取广告组
+     *
+     * @param accessToken
+     * @param accountId
+     */
+    @Override
+    public void getGroupList(String accessToken, Long accountId) {
+
+        QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
+        campaignQueryWrapper.eq("account_id", accountId);
+        campaignQueryWrapper.eq("status", 4);
+        campaignQueryWrapper.eq("put_status", 1);
+        campaignQueryWrapper.orderByDesc("put_create_time");
+        List<KuaiShouCampaign> list = kuaiShouCampaignService.list(campaignQueryWrapper);
+        if (Check.isNull(list)) {
+            return;
+        }
+        for (KuaiShouCampaign campaign : list) {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    getGroupListByPage(accessToken, accountId, campaign.getCampaignId(), 1);
+                }
+            });
+        }
+
+
+    }
+
+
+    private void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("campaign_id", campaignId);
+        param.put("page_size", 200);
+        param.put("page", page);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            log.error("获取广告组接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            log.error("获取广告组返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        addGroupV2(accountId, details);
+        getGroupListByPage(accessToken, accountId, campaignId, page + 1);
+    }
+
+
+    private void addGroupV2(Long advertiserId, JSONArray details) {
+        if (!Check.isNull(details)) {
+            List<KuaiShouGroup> groups = new ArrayList<>();
+            List<KuaiShouAppInfo> appInfos = new ArrayList<>();
+            List<KuaiShouSchedule> schedules = new ArrayList<>();
+            List<KuaiShouGroupTarget> targets = new ArrayList<>();
+            for (int i = 0; i < details.size(); i++) {
+                JSONObject detail = JSONObject.parseObject(details.get(i).toString());
+                if (!Check.isNull(detail)) {
+                    KuaiShouGroup group = new KuaiShouGroup();
+                    Long unitId = detail.getLong("unit_id");
+                    group.setId("" + advertiserId + unitId);
+                    group.setAccountId(advertiserId);
+                    group.setCampaignId(detail.getLong("campaign_id"));
+                    group.setUnitId(unitId);
+                    group.setUnitName(detail.getString("unit_name"));
+                    group.setStatus(detail.getInteger("status"));
+                    group.setPutStatus(detail.getInteger("put_status"));
+                    group.setCreateChannel(detail.getInteger("create_channel"));
+                    group.setReviewDetail(detail.getString("review_detail"));
+                    group.setBidType(detail.getInteger("bid_type"));
+                    group.setBid(detail.getLong("bid"));
+                    group.setCpaBid(detail.getLong("cpa_bid"));
+                    group.setOcpxActionType(detail.getInteger("ocpx_action_type"));
+                    group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
+                    group.setDeepConversionBid(detail.getLong("deep_conversion_bid"));
+                    group.setDayBudget(detail.getLong("day_budget"));
+                    group.setSpeed(detail.getInteger("speed"));
+                    group.setBeginTime(detail.getString("begin_time"));
+                    group.setEndTime(detail.getString("end_time"));
+                    group.setScheduleTime(detail.getString("schedule_time"));
+                    group.setSceneId(detail.getJSONArray("scene_id") + "");
+                    group.setShowMode(detail.getInteger("show_mode"));
+                    group.setUnitType(detail.getInteger("unit_type"));
+                    group.setUrlType(detail.getInteger("url_type"));
+                    group.setUrl(detail.getString("url"));
+                    group.setAppId(detail.getLong("app_id"));
+                    group.setAppIconUrl(detail.getString("app_icon_url"));
+                    group.setGroupCreateTime(detail.getString("create_time"));
+                    group.setGroupUpdateTime(detail.getString("update_time"));
+                    group.setConvertId(detail.getLong("convert_id"));
+                    group.setUseAppMarket(detail.getInteger("use_app_market"));
+                    group.setCreateTime(new Date());
+                    group.setUpdateTime(new Date());
+                    groups.add(group);
+                    // 添加应用信息
+
+                    JSONObject diverseJson = detail.getJSONObject("diverse_data");
+                    if (!Check.isNull(diverseJson)) {
+                        KuaiShouAppInfo appInfo = new KuaiShouAppInfo();
+                        appInfo.setAccountId(advertiserId);
+                        appInfo.setAppName(diverseJson.getString("app_name"));
+                        appInfo.setAppPackageName(diverseJson.getString("app_package_name"));
+                        appInfo.setDeviceOsType(diverseJson.getInteger("device_os_type"));
+                        appInfo.setUnitId(unitId);
+                        appInfo.setCreateTime(new Date());
+                        appInfo.setUpdateTime(new Date());
+                        appInfos.add(appInfo);
+                    }
+                    //时间段信息
+                    JSONObject scheduleJson = detail.getJSONObject("schedule");
+                    if (!Check.isNull(scheduleJson)) {
+                        KuaiShouSchedule schedule = new KuaiShouSchedule();
+                        schedule.setUnitId(unitId);
+                        schedule.setAccountId(advertiserId);
+                        schedule.setMon(scheduleJson.getJSONArray("mon").toJSONString());
+                        schedule.setTues(scheduleJson.getJSONArray("tues").toJSONString());
+                        schedule.setWed(scheduleJson.getJSONArray("wed").toJSONString());
+                        schedule.setThur(scheduleJson.getJSONArray("thur").toJSONString());
+                        schedule.setFri(scheduleJson.getJSONArray("fri").toJSONString());
+                        schedule.setSat(scheduleJson.getJSONArray("sat").toJSONString());
+                        schedule.setSun(scheduleJson.getJSONArray("sun").toJSONString());
+                        schedule.setCreateTime(new Date());
+                        schedule.setUpdateTime(new Date());
+                        schedules.add(schedule);
+                    }
+
+                    JSONObject targetJson = detail.getJSONObject("target");
+                    if (!Check.isNull(targetJson)) {
+                        KuaiShouGroupTarget groupTarget = new KuaiShouGroupTarget();
+                        groupTarget.setAccountId(advertiserId);
+                        groupTarget.setUnitId(unitId);
+
+                        if (!Check.isNull(targetJson.getJSONArray("region"))) {
+                            groupTarget.setRegion(targetJson.getJSONArray("region").toJSONString());
+                        }
+
+                        JSONObject age = targetJson.getJSONObject("age");
+                        if (!Check.isNull(age)) {
+                            groupTarget.setAgeMin(age.getInteger("min"));
+                            groupTarget.setAgeMax(age.getInteger("max"));
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("ages_range"))) {
+                            groupTarget.setAgesRange(targetJson.getJSONArray("ages_range").toJSONString());
+                        }
+
+                        groupTarget.setGender(targetJson.getInteger("gender"));
+                        groupTarget.setPlatformOs(targetJson.getInteger("platform_os"));
+                        groupTarget.setAndroidOsv(targetJson.getInteger("android_osv"));
+                        groupTarget.setIosOsv(targetJson.getInteger("ios_osv"));
+                        groupTarget.setNetwork(targetJson.getInteger("network"));
+                        if (!Check.isNull(targetJson.getJSONArray("device_brand"))) {
+                            groupTarget.setDeviceBrand(targetJson.getJSONArray("device_brand").toJSONString());
+                        }
+
+                        if (!Check.isNull(targetJson.getJSONArray("device_price"))) {
+                            groupTarget.setDevicePrice(targetJson.getJSONArray("device_price").toJSONString());
+                        }
+
+                        groupTarget.setBusinessInterestType(targetJson.getInteger("business_interest_type"));
+                        if (!Check.isNull(targetJson.getJSONArray("business_interest"))) {
+                            groupTarget.setBusinessInterest(targetJson.getJSONArray("business_interest").toJSONString());
+                        }
+
+                        if (!Check.isNull(targetJson.getJSONArray("fans_star"))) {
+                            groupTarget.setFansStar(targetJson.getJSONArray("fans_star").toJSONString());
+                        }
+
+                        if (!Check.isNull(targetJson.getJSONArray("interest_video"))) {
+                            groupTarget.setInterestVideo(targetJson.getJSONArray("interest_video").toJSONString());
+                        }
+
+                        if (!Check.isNull(targetJson.getJSONArray("app_interest"))) {
+                            groupTarget.setAppInterest(targetJson.getJSONArray("app_interest").toJSONString());
+                        }
+
+                        if (!Check.isNull(targetJson.getJSONArray("app_ids"))) {
+                            groupTarget.setAppIds(targetJson.getJSONArray("app_ids").toJSONString());
+                        }
+
+                        if (!Check.isNull(targetJson.getJSONArray("population"))) {
+                            groupTarget.setPopulation(targetJson.getJSONArray("population").toJSONString());
+                        }
+
+                        if (!Check.isNull(targetJson.getJSONArray("exclude_population"))) {
+                            groupTarget.setExcludePopulation(targetJson.getJSONArray("exclude_population").toJSONString());
+                        }
+
+                        JSONObject intelliExtend = targetJson.getJSONObject("intelli_extend");
+                        if (!Check.isNull(intelliExtend)) {
+                            groupTarget.setIsOpen(intelliExtend.getInteger("is_open"));
+                            groupTarget.setNoAgeBreak(intelliExtend.getInteger("no_age_break"));
+                            groupTarget.setNoGenderBreak(intelliExtend.getInteger("no_gender_break"));
+                            groupTarget.setNoAreaBreak(intelliExtend.getInteger("no_area_break"));
+
+                        }
+                        targets.add(groupTarget);
+                    }
+                }
+            }
+            if (!Check.isNull(groups)) {
+                groupMapper.replaceBatch(groups);
+            }
+            if (!Check.isNull(schedules)) {
+                shouScheduleMapper.replaceBatch(schedules);
+            }
+            if (!Check.isNull(appInfos)) {
+                appInfoMapper.replaceBatch(appInfos);
+            }
+            if (!Check.isNull(targets)) {
+                groupTargetMapper.replaceBatch(targets);
+            }
+        }
+    }
 
 }

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

@@ -643,7 +643,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     if (!Check.isNull(data)) {
 
                         try {
-                            Thread.sleep(500);
+                            Thread.sleep(200);
                             interfaceService.getCreativeByCreativeId(accessToken, creativeJson.getLong("advertiser_id"), data.getLong("creative_id"));
                         } catch (InterruptedException e) {
                             e.printStackTrace();

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

@@ -1244,9 +1244,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private void addGroup(Long advertiserId, JSONArray details) {
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();
-            List<KuaiShouAppInfo> appInfos = new ArrayList<>();
-            List<KuaiShouSchedule> schedules = new ArrayList<>();
-            List<KuaiShouGroupTarget> targets = new ArrayList<>();
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detail = JSONObject.parseObject(details.get(i).toString());
                 if (!Check.isNull(detail)) {
@@ -1287,125 +1284,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     group.setUpdateTime(new Date());
                     groups.add(group);
                     // 添加应用信息
-
-                    JSONObject diverseJson = detail.getJSONObject("diverse_data");
-                    if (!Check.isNull(diverseJson)) {
-                        KuaiShouAppInfo appInfo = new KuaiShouAppInfo();
-                        appInfo.setAccountId(advertiserId);
-                        appInfo.setAppName(diverseJson.getString("app_name"));
-                        appInfo.setAppPackageName(diverseJson.getString("app_package_name"));
-                        appInfo.setDeviceOsType(diverseJson.getInteger("device_os_type"));
-                        appInfo.setUnitId(unitId);
-                        appInfo.setCreateTime(new Date());
-                        appInfo.setUpdateTime(new Date());
-                        appInfos.add(appInfo);
-                    }
-                    //时间段信息
-                    JSONObject scheduleJson = detail.getJSONObject("schedule");
-                    if (!Check.isNull(scheduleJson)) {
-                        KuaiShouSchedule schedule = new KuaiShouSchedule();
-                        schedule.setUnitId(unitId);
-                        schedule.setAccountId(advertiserId);
-                        schedule.setMon(scheduleJson.getJSONArray("mon").toJSONString());
-                        schedule.setTues(scheduleJson.getJSONArray("tues").toJSONString());
-                        schedule.setWed(scheduleJson.getJSONArray("wed").toJSONString());
-                        schedule.setThur(scheduleJson.getJSONArray("thur").toJSONString());
-                        schedule.setFri(scheduleJson.getJSONArray("fri").toJSONString());
-                        schedule.setSat(scheduleJson.getJSONArray("sat").toJSONString());
-                        schedule.setSun(scheduleJson.getJSONArray("sun").toJSONString());
-                        schedule.setCreateTime(new Date());
-                        schedule.setUpdateTime(new Date());
-                        schedules.add(schedule);
-                    }
-
-                    JSONObject targetJson = detail.getJSONObject("target");
-                    if (!Check.isNull(targetJson)) {
-                        KuaiShouGroupTarget groupTarget = new KuaiShouGroupTarget();
-                        groupTarget.setAccountId(advertiserId);
-                        groupTarget.setUnitId(unitId);
-
-                        if (!Check.isNull(targetJson.getJSONArray("region"))) {
-                            groupTarget.setRegion(targetJson.getJSONArray("region").toJSONString());
-                        }
-
-                        JSONObject age = targetJson.getJSONObject("age");
-                        if (!Check.isNull(age)) {
-                            groupTarget.setAgeMin(age.getInteger("min"));
-                            groupTarget.setAgeMax(age.getInteger("max"));
-                        }
-                        if (!Check.isNull(targetJson.getJSONArray("ages_range"))) {
-                            groupTarget.setAgesRange(targetJson.getJSONArray("ages_range").toJSONString());
-                        }
-
-                        groupTarget.setGender(targetJson.getInteger("gender"));
-                        groupTarget.setPlatformOs(targetJson.getInteger("platform_os"));
-                        groupTarget.setAndroidOsv(targetJson.getInteger("android_osv"));
-                        groupTarget.setIosOsv(targetJson.getInteger("ios_osv"));
-                        groupTarget.setNetwork(targetJson.getInteger("network"));
-                        if (!Check.isNull(targetJson.getJSONArray("device_brand"))) {
-                            groupTarget.setDeviceBrand(targetJson.getJSONArray("device_brand").toJSONString());
-                        }
-
-                        if (!Check.isNull(targetJson.getJSONArray("device_price"))) {
-                            groupTarget.setDevicePrice(targetJson.getJSONArray("device_price").toJSONString());
-                        }
-
-                        groupTarget.setBusinessInterestType(targetJson.getInteger("business_interest_type"));
-                        if (!Check.isNull(targetJson.getJSONArray("business_interest"))) {
-                            groupTarget.setBusinessInterest(targetJson.getJSONArray("business_interest").toJSONString());
-                        }
-
-                        if (!Check.isNull(targetJson.getJSONArray("fans_star"))) {
-                            groupTarget.setFansStar(targetJson.getJSONArray("fans_star").toJSONString());
-                        }
-
-                        if (!Check.isNull(targetJson.getJSONArray("interest_video"))) {
-                            groupTarget.setInterestVideo(targetJson.getJSONArray("interest_video").toJSONString());
-                        }
-
-                        if (!Check.isNull(targetJson.getJSONArray("app_interest"))) {
-                            groupTarget.setAppInterest(targetJson.getJSONArray("app_interest").toJSONString());
-                        }
-
-                        if (!Check.isNull(targetJson.getJSONArray("app_ids"))) {
-                            groupTarget.setAppIds(targetJson.getJSONArray("app_ids").toJSONString());
-                        }
-
-                        if (!Check.isNull(targetJson.getJSONArray("population"))) {
-                            groupTarget.setPopulation(targetJson.getJSONArray("population").toJSONString());
-                        }
-
-                        if (!Check.isNull(targetJson.getJSONArray("exclude_population"))) {
-                            groupTarget.setExcludePopulation(targetJson.getJSONArray("exclude_population").toJSONString());
-                        }
-
-                        JSONObject intelliExtend = targetJson.getJSONObject("intelli_extend");
-                        if (!Check.isNull(intelliExtend)) {
-                            groupTarget.setIsOpen(intelliExtend.getInteger("is_open"));
-                            groupTarget.setNoAgeBreak(intelliExtend.getInteger("no_age_break"));
-                            groupTarget.setNoGenderBreak(intelliExtend.getInteger("no_gender_break"));
-                            groupTarget.setNoAreaBreak(intelliExtend.getInteger("no_area_break"));
-
-                        }
-                        targets.add(groupTarget);
-                    }
                 }
             }
             if (!Check.isNull(groups)) {
-                groupMapper.replaceBatch(groups);
-            }
-            if (!Check.isNull(schedules)) {
-                shouScheduleMapper.replaceBatch(schedules);
-            }
-            if (!Check.isNull(appInfos)) {
-                appInfoMapper.replaceBatch(appInfos);
-            }
-            if (!Check.isNull(targets)) {
-                groupTargetMapper.replaceBatch(targets);
+                try {
+                    Thread.sleep(200L);
+                    groupMapper.replaceBatch(groups);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+
             }
         }
     }
 
+
     @Override
     public void getCreativeList(CtopOauthToken token, Date startDate, Date endDate) {
         getCreativeListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
@@ -3040,7 +2933,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
-    private static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    private static ExecutorService executorService = Executors.newFixedThreadPool(10);
 
     @Override
     public void getAsyncCreativeList(Long accountId, String accessToken, Long campaignId) {
@@ -3211,4 +3104,28 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         return convertVoList;
     }
 
+    @Override
+    public JSONArray getCreativeWord(Long accountId, String accessToken) {
+
+        try {
+            log.info("获取动态词包:accountId:{}", accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_WORD;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", "application/json");
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                return resultJson.getJSONArray("data");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
 }

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

@@ -1,11 +1,18 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouReportDailyAccount> {
+
     void loadAccountDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
 
     void insertSelective(KuaishouReportDailyAccount dailyAccount);
+
+    List<JSONObject> selectCost(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
 }

+ 54 - 45
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/AccountReportMapper.xml

@@ -21,6 +21,22 @@
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
 
+        sum(form_count + activation) conversionNum, -- 转化数
+
+        (case
+        when sum(activation +form_count) != 0
+        then (sum(charge) / sum(activation +form_count))
+        else 0
+        end
+        ) conversionPrice, -- 转化单价
+
+        (case
+        when sum(activation +form_count) != 0
+        then (sum(charge) / sum(activation +form_count)) / #{discount}
+        else 0
+        end
+        ) afterConversionPrice, -- 折后转化单价
+
         (case
         when sum(event_register) != 0
         then (sum(charge) / sum(event_register))
@@ -57,13 +73,13 @@
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then (sum(event_next_day_stay)/sum(activation))
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where account_id in
@@ -92,6 +108,8 @@
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
+        sum(form_count + activation) conversionNum, -- 转化数
+        (sum(charge) / sum(activation +form_count )) conversionPrice, -- 转化单价
         (case
         when sum(event_register) != 0
         then (sum(charge) / sum(event_register))
@@ -100,13 +118,13 @@
         ) eventRegisterCost, -- 注册成本
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then (sum(event_next_day_stay)/sum(activation))
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where stat_date &lt;= #{startDate}
@@ -135,6 +153,15 @@
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
+        sum(form_count + activation) conversionNum, -- 转化数
+
+        (
+        case when sum(activation +form_count ) != 0
+        then (sum(charge) / sum(activation +form_count))
+        else 0
+        end
+        )conversionPrice, -- 转化单价
+
 
         (case
         when sum(event_register) != 0
@@ -173,6 +200,14 @@
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
+        sum(form_count + activation) conversionNum, -- 转化数
+        (
+        case when sum(activation +form_count ) != 0
+        then (sum(charge) / sum(activation +form_count))
+        else 0
+        end
+        )conversionPrice, -- 转化单价
+
         (case
         when sum(event_register) != 0
         then (sum(charge) / sum(event_register))
@@ -181,13 +216,13 @@
         ) eventRegisterCost, -- 注册成本
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then ( sum(event_next_day_stay) / sum(activation) )
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where stat_date = #{statDate}
@@ -416,30 +451,17 @@
         sum(bclick) bClick,-- 行为数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(charge) / sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(charge) / sum(activation)
+        WHEN sum(form_count + activation) != 0 THEN
+        sum(charge) / sum(form_count + activation)
         ELSE
         0
         END
         ) conversionPrice, -- 转化单价
+        sum(form_count + activation) conversions, -- 转化数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        (sum(charge) / sum(form_count)) / #{discount}
-        WHEN sum(activation) != 0 THEN
-        (sum(charge) / sum(activation)) / #{discount}
+        WHEN sum(form_count + activation) != 0 THEN
+        (sum(charge) / sum(form_count + activation)) / #{discount}
         ELSE
         0
         END
@@ -451,13 +473,13 @@
         else 0
         end
         ) eventRegisterCost, -- 注册成本
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then (sum(event_next_day_stay)/sum(activation))
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
 
         from
         ctop_kuaishou_report_daily_account
@@ -520,34 +542,21 @@
         else 0
         end
         ) cpm,
-
+        sum(form_count + activation) conversions, -- 转化数
         sum(bclick) bClick,-- 行为数
+
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(charge) / sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(charge) / sum(activation)
+        WHEN sum(activation + form_count) != 0 THEN
+        sum(charge) / sum(activation + form_count)
         ELSE
         0
         END
         ) conversionPrice, -- 转化单价
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        (sum(charge) / sum(form_count)) / #{discount}
-        WHEN sum(activation) != 0 THEN
-        (sum(charge) / sum(activation)) / #{discount}
+        WHEN sum(activation + form_count) != 0 THEN
+        (sum(charge) / sum(activation + form_count)) / #{discount}
         ELSE
         0
         END

+ 7 - 33
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/DailyReportMapper.xml

@@ -26,7 +26,6 @@
             </if>
         </where>
         ) contractRebateRealCharged -- 激励花费
-
         FROM (
         SELECT
         sum(charge) cost, -- 消耗
@@ -73,25 +72,12 @@
         0
         END
         ) impression1kCost, -- 平均千次展现花费
+        sum(form_count + activation) conversions, -- 转化数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        (
-        truncate(sum(charge) / sum(form_count),2)
-        )
-        WHEN sum(activation) != 0 THEN
+        WHEN sum(form_count + activation) != 0 THEN
         (
-        truncate(sum(charge) / sum(activation),2)
+        truncate(sum(charge) / sum(form_count + activation),2)
         )
         ELSE
         0
@@ -184,25 +170,13 @@
         0
         END
         ) photoClickCost, -- 平均点击花费
+
+        sum(form_count + activation) conversions, -- 转化数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        (
-        truncate(sum(charge) / sum(form_count),2)
-        )
-        WHEN sum(activation) != 0 THEN
+        WHEN sum(form_count + activation) != 0 THEN
         (
-        truncate(sum(charge) / sum(activation),2)
+        truncate(sum(charge) / sum(form_count + activation),2)
         )
         ELSE
         0

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

@@ -491,4 +491,16 @@
         )
           set account_id = #{accountId}
     </insert>
+
+    <select id="selectCost" resultType="com.alibaba.fastjson.JSONObject">
+        select
+            sum(charge) cost,
+            stat_date statDate
+        from ctop_kuaishou_report_daily_account
+        where account_id = #{accountId}
+          and stat_date &gt;= #{startDate}
+          and stat_date &lt; #{endDate}
+        group by stat_date
+    </select>
+
 </mapper>

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

@@ -1,7 +1,13 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 public interface IKuaishouReportDailyAccountService extends IService<KuaishouReportDailyAccount> {
+
+    List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
+
 }

+ 48 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/AccountReportServiceImpl.java

@@ -402,6 +402,53 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             chainRatioJson.put("bClickProportion", 0);
                         }
 
+                        // 转化数
+                        Long nowConversionNum = nowAccountSummary.getLong("conversionNum");
+                        Long yesterdayConversionNum = yesterdayAccountSummary.getLong("conversionNum");
+                        //表单提交数环比
+                        if (!Check.isNull(nowConversionNum) && !Check.isNull(yesterdayConversionNum)) {
+                            if (yesterdayAClick != 0L) {
+                                double nowConversionNumProportion = (nowConversionNum.doubleValue() - yesterdayConversionNum.doubleValue()) / yesterdayConversionNum.doubleValue();
+                                chainRatioJson.put("nowConversionNumProportion", nowConversionNumProportion);
+                            } else {
+                                chainRatioJson.put("nowConversionNumProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("nowConversionNumProportion", 0);
+                        }
+
+
+                        // 折后转化单价
+                        BigDecimal nowAfterConversionPrice = nowAccountSummary.getBigDecimal("afterConversionPrice");
+                        BigDecimal yesterdayAfterConversionPrice = yesterdayAccountSummary.getBigDecimal("afterConversionPrice");
+                        // 折前消耗单价
+                        if (!Check.isNull(nowAfterConversionPrice) && !Check.isNull(yesterdayAfterConversionPrice)) {
+                            if (yesterdayAfterConversionPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal afterConversionPriceProportion = (nowAfterConversionPrice.subtract(yesterdayAfterConversionPrice)).divide(yesterdayAfterConversionPrice, 2, RoundingMode.HALF_UP);
+                                chainRatioJson.put("afterConversionPriceProportion", afterConversionPriceProportion);
+                            } else {
+                                chainRatioJson.put("afterConversionPriceProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("afterConversionPriceProportion", 0);
+                        }
+
+                        // 折前转化单价
+                        BigDecimal nowConversionPrice = nowAccountSummary.getBigDecimal("conversionPrice");
+                        BigDecimal yesterdayConversionPrice = yesterdayAccountSummary.getBigDecimal("conversionPrice");
+                        // 折前消耗单价
+                        if (!Check.isNull(nowConversionPrice) && !Check.isNull(yesterdayConversionPrice)) {
+                            if (yesterdayConversionPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal beforeConversionPriceProportion = (nowConversionPrice.subtract(yesterdayConversionPrice)).divide(yesterdayConversionPrice, 2, RoundingMode.HALF_UP);
+                                chainRatioJson.put("beforeConversionPriceProportion", beforeConversionPriceProportion);
+                            } else {
+                                chainRatioJson.put("beforeConversionPriceProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("beforeConversionPriceProportion", 0);
+                        }
+
+
                         // 表单提交数
                         Long nowFormCount = nowAccountSummary.getLong("formCount");
                         Long yesterdayFormCount = yesterdayAccountSummary.getLong("formCount");
@@ -421,7 +468,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
                         // 激活数
                         Long nowActivationCount = nowAccountSummary.getLong("activationCount");
                         Long yesterdayActivationCount = yesterdayAccountSummary.getLong("activationCount");
-                        //表单提交数环比
+                        //激活数环比
                         if (!Check.isNull(nowActivationCount) && !Check.isNull(yesterdayActivationCount)) {
                             if (yesterdayAClick != 0L) {
                                 double activationCountProportion = (nowActivationCount.doubleValue() - yesterdayActivationCount.doubleValue()) / yesterdayActivationCount.doubleValue();

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

@@ -3,9 +3,21 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouReportDailyAccountMapper, KuaishouReportDailyAccount> implements IKuaishouReportDailyAccountService {
+
+    @Autowired
+    private KuaishouReportDailyAccountMapper dailyAccountMapper;
+
+    @Override
+    public List<JSONObject> selectCost(Long accountId, String startDate, String endDate) {
+        return dailyAccountMapper.selectCost(accountId, startDate, endDate);
+    }
 }

+ 8 - 6
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java

@@ -101,12 +101,12 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
             //今天
             case 1:
                 resultChart = getCompareGroupByHour(nowDate, anotherDay);
-                resultList = getFormDetailByDate(nowDate,nowDate,"hour");
+                resultList = getFormDetailByDate(nowDate,anotherDay,"hour");
                 break;
             //昨天
             case 2:
                 resultChart = getCompareGroupByHour(anotherDay, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, anotherDay, -1));
-                resultList = getFormDetailByDate(anotherDay,anotherDay,"hour");
+                resultList = getFormDetailByDate(anotherDay,DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, anotherDay, -1),"hour");
                 break;
             //近一周
             case 3:
@@ -173,13 +173,15 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
 
     //表格数据查询
     private List<JSONObject> getFormDetailByDate(String endDate, String startDate, String group){
-        List<JSONObject> result =null;
+        List<JSONObject> result ;
         if("day".equals(group)){
-            result= bytedanceHomepageMapper.queryDetailByStartEndDate(endDate,startDate);
+            result= getListLink(bytedanceHomepageMapper.queryDetailByStartEndDate(endDate,startDate));
         }else {
-            result= bytedanceHomepageMapper.queryTodayDetailReportBy(endDate);
+            List<JSONObject> after=bytedanceHomepageMapper.queryTodayDetailReportBy(endDate);
+            List<JSONObject> before=bytedanceHomepageMapper.queryTodayDetailReportBy(startDate);
+            result=LinkUtils.getCompareDate(after,before,"statHour");
         }
-        return getListLink(result);
+        return result;
     }
 
     //自定义日期对比(日对比,月对比)