فهرست منبع

李娜、王垒需求,层级查看项目信息

hcst_sunzhen 4 سال پیش
والد
کامیت
d86c822bd5
20فایلهای تغییر یافته به همراه1028 افزوده شده و 23 حذف شده
  1. 46 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  2. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ProjectMember.java
  3. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java
  4. 21 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  5. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  6. 58 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  7. 185 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  8. 3 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouInfoDTO.java
  9. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/ProjectAccountDTO.java
  10. 9 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  11. 87 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  12. 7 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  13. 113 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java
  14. 101 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/ByteDanceReportAccountDailyDTO.java
  15. 21 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/BytedanceInfoDTO.java
  16. 73 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  17. 15 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java
  18. 179 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml
  19. 9 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java
  20. 86 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

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

@@ -366,4 +366,50 @@ public class ProjectMemberController {
     }
 
 
+    /**
+     * 销售的项目
+     *
+     * @return
+     */
+    @AutoLog(value = "头条视频报表-参与项目列表")
+    @ApiOperation(value = "头条视频报表-参与项目列表", notes = "头条视频报表-参与项目列表")
+    @GetMapping(value = "/getSaleOwnProjects")
+    public Result<List<ProjectMember>> getSaleOwnProjects(@RequestParam(required = true ,name = "mediaIds") List<Integer> mediaIds) {
+        Result<List<ProjectMember>> result = new Result<>();
+
+        List<ProjectMember> projectMemberList = projectMemberService.getSaleOwnProjects(mediaIds);
+        if (projectMemberList == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(projectMemberList);
+            result.setSuccess(true);
+        }
+        return result;
+
+    }
+
+    /**
+     * 自己所在的项目
+     *
+     * @return
+     */
+    @AutoLog(value = "头条视频报表-参与项目列表")
+    @ApiOperation(value = "头条视频报表-参与项目列表", notes = "头条视频报表-参与项目列表")
+    @GetMapping(value = "/getOwnProjects")
+    public Result<List<ProjectMember>> getOwnProjects(@RequestParam(required = true ,name = "mediaIds") List<Integer> mediaIds) {
+        Result<List<ProjectMember>> result = new Result<>();
+
+        List<ProjectMember> projectMemberList = projectMemberService.getOwnProjects(mediaIds);
+        if (projectMemberList == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(projectMemberList);
+            result.setSuccess(true);
+        }
+        return result;
+
+    }
+
+
+
 }

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

@@ -80,6 +80,12 @@ public class ProjectMember implements  Serializable{
     @TableField(exist = false)
     private String mediaId;
 
+    @TableField(exist = false)
+    private String saleId;
+
+    @TableField(exist = false)
+    private String saleName;
+
 
     /**
      * 创建时间

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

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

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

@@ -122,4 +122,25 @@
             #{item}
         </foreach>
     </select>
+
+    <select id="getSaleProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
+            select
+            distinct a.id as projectId,
+            a.project_name as projectName,
+            a.advertiser_id as advertiserId,
+            a.advertiser_name as advertiserName,
+            a.media_id as mediaId,
+            a.sale_id as saleId,
+            b.realname as saleName
+        from
+        ctop_project a
+        left join sys_user b on a.sale_id = b.id
+        where a.sale_id = #{userId}
+        and a.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>

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

@@ -24,4 +24,8 @@ public interface IProjectMemberService extends IService<ProjectMember> {
 
     List<Map<String, Object>> getProjectAccountByUserId(String userId);
 
+    List<ProjectMember> getOwnProjects(List<Integer> mediaIds);
+
+    List<ProjectMember> getSaleOwnProjects(List<Integer> mediaIds);
+
 }

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

@@ -73,6 +73,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
     }
 
     //视频报表
+    @Override
     public List<ProjectMember> getProjects(List<Integer> mediaIds) {
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
@@ -88,7 +89,14 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         } else if (roleCode.equals("admin")) {
             projectMemberList = memberMapper.adminProjects(mediaIds);
         } else if (roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")) {
-            projectMemberList = memberMapper.operationProjects(userId, mediaIds);
+            projectMemberList = memberMapper.designProjects(userId, mediaIds);
+        }else{
+            //如果以上角色都不是的话直接查询此角色所属项目
+            projectMemberList = memberMapper.designProjects(userId, mediaIds);
+        }
+
+        if(null == projectMemberList){
+            projectMemberList = new ArrayList<>();
         }
 
         return projectMemberList;
@@ -137,4 +145,53 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         }
         return memberMapper.queryProjectMemberByUserId(userId, mediaIds);
     }
+
+
+    //查看销售所在平台项目
+    @Override
+    public List<ProjectMember> getSaleOwnProjects(List<Integer> mediaIds) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        String roleCode = memberMapper.getRoleCodeByUserId(userId);
+
+        //角色权限判断
+        List<ProjectMember> projectMemberList = null;
+        if (roleCode.equals("admin")) {
+            projectMemberList = memberMapper.adminProjects(mediaIds);
+        }else{
+            //如果以上角色都不是的话直接查询此角色所属项目
+            projectMemberList = memberMapper.getSaleProjects(userId, mediaIds);
+        }
+
+        if(null == projectMemberList){
+            projectMemberList = new ArrayList<>();
+        }
+
+        return projectMemberList;
+    }
+
+    //视频报表
+    @Override
+    public List<ProjectMember> getOwnProjects(List<Integer> mediaIds) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        String roleCode = memberMapper.getRoleCodeByUserId(userId);
+
+        //角色权限判断
+        List<ProjectMember> projectMemberList = null;
+       if (roleCode.equals("admin")) {
+            projectMemberList = memberMapper.adminProjects(mediaIds);
+        }else{
+            //如果以上角色都不是的话直接查询此角色所属项目
+            projectMemberList = memberMapper.designProjects(userId, mediaIds);
+        }
+
+        if(null == projectMemberList){
+            projectMemberList = new ArrayList<>();
+        }
+
+        return projectMemberList;
+    }
+
+
 }

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

@@ -3,17 +3,25 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouInfoDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
+import com.baomidou.mybatisplus.extension.api.R;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
  * @author yumeng
  * 2019年11月12日10:04:00
  */
+@Slf4j
 @RestController
 @RequestMapping("/kuaishou")
 public class KuaiShouController {
@@ -22,6 +30,8 @@ public class KuaiShouController {
     private IKuaishouInterfaceService kuaishouInterfaceService;
     @Autowired
     private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouReportDailyAccountService accountService;
 
     @RequestMapping("report")
     public Map<String, Object> getReport(String accountId, String startDate, String endDate, Integer type, String temporalGranularity) {
@@ -56,4 +66,177 @@ public class KuaiShouController {
         }
         return result;
     }
+
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouProjectInfo")
+    public Result<List<ProjectAccountDTO>> getKuaishouProjectInfo(@RequestBody KuaishouInfoDTO dto) {
+        Result<List<ProjectAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+        if(dto.getPageSize() == 0){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "");
+            result.setResult(projectAccountDTOList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouSaleProjectInfo")
+    public Result<List<ProjectAccountDTO>> getKuaishouSaleProjectInfo(@RequestBody KuaishouInfoDTO dto) {
+        Result<List<ProjectAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+        if(dto.getPageSize() == 0){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "");
+            result.setResult(projectAccountDTOList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouAccountInfoByProjectId")
+    public Result<List<KuaishouReportDailyAccountDTO>> getKuaishouAccountInfoByProjectId(@RequestBody KuaishouInfoDTO dto) {
+        Result<List<KuaishouReportDailyAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getProjectId()==null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+
+        if(dto.getPageSize() == 0){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            result.setResult(kuaishouReportDailyAccountDTOList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouCampaignInfoByAccountId")
+    public Result<List<KuaishouReportDailyAccountDTO>> getKuaishouCampaignInfoByAccountId(@RequestBody KuaishouInfoDTO dto) {
+        Result<List<KuaishouReportDailyAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getAccountId()==null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+
+        if(dto.getPageSize() == 0){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            result.setResult(kuaishouCampaignInfoList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouUnitInfoByCampaignId")
+    public Result<List<KuaishouReportDailyAccountDTO>> getKuaishouUnitInfoByCampaignId(@RequestBody KuaishouInfoDTO dto) {
+        Result<List<KuaishouReportDailyAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getCampaignId()==null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+        if(dto.getPageSize() == 0){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            result.setResult(kuaishouCampaignInfoList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouCreativeInfoByUnitId")
+    public Result<List<KuaishouReportDailyAccountDTO>> getKuaishouCreativeInfoByUnitId(@RequestBody KuaishouInfoDTO dto) {
+        Result<List<KuaishouReportDailyAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getUnitId()==null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+        if(dto.getPageSize() == 0){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            result.setResult(kuaishouCampaignInfoList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
 }

+ 3 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouInfoDTO.java

@@ -1,5 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
+import com.github.pagehelper.PageInfo;
+import com.github.pagehelper.page.PageMethod;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -8,7 +10,7 @@ import java.util.List;
 
 
 @Data
-public class KuaishouInfoDTO implements Serializable {
+public class KuaishouInfoDTO extends PageInfo implements Serializable {
     private String startDate;
     private String endDate;
     private Long unitId;

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

@@ -14,6 +14,8 @@ public class ProjectAccountDTO implements Serializable {
     private String responsibleName;
     private String advertiserName;  //广告主名称
     private String designResponsibleName;
+    private String saleId;
+    private String saleName;
     private BigDecimal charge;
     private Long photoShow;
     private Long photoClick;

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

@@ -26,7 +26,15 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId);
 
-    List<Long> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<ProjectAccountDTO> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+
+    List<ProjectAccountDTO> queryProjectInfoBySaleId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+
+    List<ProjectAccountDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
+
+    String getRoleCodeByUserId(@Param("userId")String userId);
+
+    List<ProjectAccountDTO> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
 
     List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId);
 

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

@@ -656,14 +656,19 @@
         ) as 'eventNextDayStayCost'  -- 次日留存成本
         from
         ctop_kuaishou_report_daily_account a
-        left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
-        left join ctop_project c on b.project_id = c.id
+        left join  (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+        -- left join ctop_project c on b.project_id = c.id
         where
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
         and
         b.project_id = #{projectId}
+<!--        <foreach collection="projectList" item="item" separator=","-->
+<!--                 open="(" close=")">-->
+<!--            #{item}-->
+<!--        </foreach>-->
+<!--        group by b.project_id-->
     </select>
 
     <!-- 计划汇总 -->
@@ -805,24 +810,98 @@
         group by unit_id
     </select>
 
-    <select id="queryProjectMemberByUserId" resultType="long">
+    <select id="queryProjectMemberByUserId" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
         select
-        distinct b.project_id as projectId
+        distinct a.project_id as projectId,
+        a.project_name as projectName,
 --         a.advertiser_id as advertiserId,
+        a.advertiser_name as advertiserName,
 --         (SELECT media_id from ctop_project c where c.id=a.project_id limit 1) as mediaId,
+        c.responsible_name as responsibleName,
+        c.design_responsible_name as designResponsibleName
         from
         ctop_user_allocation a
         left join ctop_project_member b on a.project_id = b.project_id
+        left join ctop_project c on a.project_id = c.id
         where b.user_id = #{userId}
         and a.media_id in
         <foreach collection="mediaIds" item="item" separator=","
                  open="(" close=")">
             #{item}
         </foreach>
+        order by c.create_time desc
+    </select>
+
+    <select id="queryProjectInfoBySaleId" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+        select
+        distinct c.id as projectId,
+        c.project_name as projectName,
+        --         a.advertiser_id as advertiserId,
+        c.advertiser_name as advertiserName,
+        --         (SELECT media_id from ctop_project c where c.id=a.project_id limit 1) as mediaId,
+        c.responsible_name as responsibleName,
+        c.design_responsible_name as designResponsibleName,
+        c.sale_id as saleId,
+        u.realname as saleName
+        from
+        ctop_project c
+        left join sys_user u on c.sale_id = u.id
+        where c.sale_id = #{userId}
+        and c.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        order by c.create_time desc
+    </select>
+
+    <select id="queryProjectMemberByIds" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+        select
+        distinct id as projectId,
+                project_name as projectName,
+        --         a.advertiser_id as advertiserId,
+                advertiser_name as advertiserName,
+        --         (SELECT media_id from ctop_project c where c.id=a.project_id limit 1) as mediaId,
+                responsible_name as responsibleName,
+                design_responsible_name as designResponsibleName
+        from
+
+        left join ctop_project
+        where
+        id in
+            <foreach collection="projectIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        order by create_time desc
+    </select>
+
+    <select id="getRoleCodeByUserId" resultType="string">
+        select
+        role_code
+        from
+        sys_user_role a
+        left join sys_role b on a.role_id = b.id
+        where a.user_id = #{userId}
+    </select>
+
+    <!-- 设计师展示所有自己的角色下制作的视频 -->
+    <select id="queryProjectMemberByAdmins" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+        select
+        id as projectId,
+        project_name as projectName,
+        advertiser_name as advertiserName ,
+        responsible_name as responsibleName,
+        design_responsible_name as designResponsibleName
+        from
+        ctop_project
+        where
+        media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        order by create_time desc
     </select>
 
     <select id="getKuaishouCreativeInfoByUnitId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">

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

@@ -15,14 +15,16 @@ public interface IKuaishouReportDailyAccountService extends IService<KuaishouRep
 
     List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
 
-    List<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList);
+    List<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList , Integer pageSize, Integer pageNum, String sort );
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate);
+    List<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum);
+
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum);
 
 }

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

@@ -8,12 +8,14 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapp
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.mgt.SecurityManager;
 import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -29,43 +31,145 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
     }
 
     @Override
-    public List<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList){
+    public List<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ){
+        List<ProjectAccountDTO> projectAccountDTOList = new ArrayList<>();
+
         if(projectList==null || projectList.size()==0){
             //LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             String userId = "a6abfea0f27843bf8595a234410afb04";
+            String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
             List<Long> mediaIds = new ArrayList<>();
             mediaIds.add(2L);
             mediaIds.add(4L);
-            projectList = dailyAccountMapper.queryProjectMemberByUserId(userId,mediaIds);
+
+            if("admin".equals(roleCode)){
+                PageHelper.startPage(pageNum,pageSize);
+                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
+            }else{
+                PageHelper.startPage(pageNum,pageSize);
+                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByUserId(userId,mediaIds);
+            }
+        }else{
+            PageHelper.startPage(pageNum,pageSize);
+            projectAccountDTOList = dailyAccountMapper.queryProjectMemberByIds(projectList);
+        }
+
+        for(ProjectAccountDTO project:projectAccountDTOList){
+            ProjectAccountDTO project2 = dailyAccountMapper.getKuaishouProjectInfo(startDate, endDate, project.getProjectId());
+            project.setCharge(project2.getCharge());
+            project.setPhotoShow(project2.getPhotoShow());
+            project.setPhotoClick(project2.getPhotoClick());
+            project.setAclick(project2.getAclick());
+            project.setBclick(project2.getBclick());
+            project.setActivation(project2.getActivation());
+            project.setSubmit(project2.getSubmit());
+            project.setEventRegister(project2.getEventRegister());
+            project.setEventNextDayStay(project2.getEventNextDayStay());
+            project.setActivationCost(project2.getActivationCost());
+            project.setPhotoClickRate(project2.getPhotoClickRate());
+            project.setBclickRate(project2.getBclickRate());
+            project.setImpression1kCost(project2.getImpression1kCost());
+            project.setPhotoClickCost(project2.getPhotoClickCost());
+            project.setPhotoShare(project2.getPhotoShare());
+            project.setActionCost(project2.getActionCost());
+            project.setPhotoComment(project2.getPhotoComment());
+            project.setPhotoLike(project2.getPhotoLike());
+            project.setFollow(project2.getFollow());
+            project.setReport(project2.getReport());
+            project.setCancelFollow(project2.getCancelFollow());
+            project.setBlock(project2.getBlock());
+            project.setNagative(project2.getNagative());
+            project.setDownloadStarted(project2.getDownloadStarted());
+            project.setDownloadCompleted(project2.getDownloadCompleted());
+            project.setEventNextDayStayCost(project2.getEventNextDayStayCost());
+            project.setStatDate(startDate + "~" + endDate);
         }
 
+        return projectAccountDTOList;
+    }
+
+    @Override
+    public List<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ){
         List<ProjectAccountDTO> projectAccountDTOList = new ArrayList<>();
 
-        for(Long projectId:projectList){
-            ProjectAccountDTO kuaishouProjectInfo = dailyAccountMapper.getKuaishouProjectInfo(startDate, endDate, projectId);
-            projectAccountDTOList.add(kuaishouProjectInfo);
+        if(projectList==null || projectList.size()==0){
+            //LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String userId = "e9ca23d68d884d4ebb19d07889727dae";
+            String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+            List<Long> mediaIds = new ArrayList<>();
+            mediaIds.add(2L);
+            mediaIds.add(4L);
+
+            if("admin".equals(roleCode)){
+                PageHelper.startPage(pageNum,pageSize);
+                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
+            }else{
+                PageHelper.startPage(pageNum,pageSize);
+                projectAccountDTOList = dailyAccountMapper.queryProjectInfoBySaleId(userId,mediaIds);
+            }
+        }else{
+            PageHelper.startPage(pageNum,pageSize);
+            projectAccountDTOList = dailyAccountMapper.queryProjectMemberByIds(projectList);
+        }
+
+        for(ProjectAccountDTO project:projectAccountDTOList){
+            ProjectAccountDTO project2 = dailyAccountMapper.getKuaishouProjectInfo(startDate, endDate, project.getProjectId());
+            project.setCharge(project2.getCharge());
+            project.setPhotoShow(project2.getPhotoShow());
+            project.setPhotoClick(project2.getPhotoClick());
+            project.setAclick(project2.getAclick());
+            project.setBclick(project2.getBclick());
+            project.setActivation(project2.getActivation());
+            project.setSubmit(project2.getSubmit());
+            project.setEventRegister(project2.getEventRegister());
+            project.setEventNextDayStay(project2.getEventNextDayStay());
+            project.setActivationCost(project2.getActivationCost());
+            project.setPhotoClickRate(project2.getPhotoClickRate());
+            project.setBclickRate(project2.getBclickRate());
+            project.setImpression1kCost(project2.getImpression1kCost());
+            project.setPhotoClickCost(project2.getPhotoClickCost());
+            project.setPhotoShare(project2.getPhotoShare());
+            project.setActionCost(project2.getActionCost());
+            project.setPhotoComment(project2.getPhotoComment());
+            project.setPhotoLike(project2.getPhotoLike());
+            project.setFollow(project2.getFollow());
+            project.setReport(project2.getReport());
+            project.setCancelFollow(project2.getCancelFollow());
+            project.setBlock(project2.getBlock());
+            project.setNagative(project2.getNagative());
+            project.setDownloadStarted(project2.getDownloadStarted());
+            project.setDownloadCompleted(project2.getDownloadCompleted());
+            project.setEventNextDayStayCost(project2.getEventNextDayStayCost());
+            project.setStatDate(startDate + "~" + endDate);
         }
 
         return projectAccountDTOList;
     }
 
+
     @Override
-    public List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate){
+    public List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+        PageHelper.startPage(pageNum,pageSize);
         return dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId);
     }
 
     @Override
-    public List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate){
+    public List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+        PageHelper.startPage(pageNum,pageSize);
         return dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId);
     }
 
     @Override
-    public List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate){
+    public List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+        PageHelper.startPage(pageNum,pageSize);
         return dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId);
     }
 
     @Override
-    public List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate){
+    public List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+        PageHelper.startPage(pageNum,pageSize);
         List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId);
         for(KuaishouReportDailyAccountDTO creativeInfo:kuaishouCreativeInfoList){
             KuaishouVideoInfoDTO videoInfo = dailyAccountMapper.getVideoUrl(creativeInfo.getPhotoId());

+ 101 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/ByteDanceReportAccountDailyDTO.java

@@ -0,0 +1,101 @@
+package cn.com.ctop.toutiao.modules.report.DTO;
+
+import lombok.Data;
+
+@Data
+public class ByteDanceReportAccountDailyDTO {
+	private Integer mediaId;
+
+	private String advertiserId;
+
+	private String advertiserName;
+
+	private String responsibleName;
+
+	private String designResponsibleName;
+
+	private String saleId;
+
+	private String saleName;
+
+	private String statDate;
+
+	private String accountId;
+
+	private String authName;
+
+	private Long projectId;
+
+	private String projectName;
+
+	private java.math.BigDecimal cost;  //消耗
+
+	private Long active;  //应用下载-激活
+
+	private Long downloadFinish;  //应用下载-安卓下载完成
+
+	private Long downloadStart;  //应用下载-安卓下载开始
+
+	private Long installFinish;  //应用下载-安卓安装完成
+
+	private Long register;  //应用下载-注册
+
+	private Long payCount;  //应用下载-付费数
+
+	private Long form;  //表单提交数
+
+	private Long totalPlay;  //视频-总播放
+
+	private Long validPlay;  //视频-有效播放
+
+	private Long wifiPlay;  //视频-wifi播放
+
+	private java.math.BigDecimal play25FeedBreakRate;  //25%进度播放率
+
+	private Long play25FeedBreak;  //视频-播放25%进度总数
+
+	private Long play50FeedBreak;  //视频-播放50%进度总数
+
+	private Long play75FeedBreak;  //视频-播放75%进度总数
+
+	private Long play100FeedBreak;  //视频-播放100%进度总数
+
+	private Long shareMaterial;  //互动数据-分享数
+
+	private Long follow;  //互动数据-新增关注数
+
+	private Long nextDayOpen;  //次留数
+
+	private java.math.BigDecimal nextDayOpenRate;  //次留率 = 次留数/激活数
+
+	private java.math.BigDecimal nextDayOpenCost;  //次留成本 = 消耗/次留数
+
+	private Long convertMaterial;  //转化数据-转化数
+
+	private java.math.BigDecimal cpc;  //平均点击单价
+
+	private java.math.BigDecimal ctr;  //展现数据-点击率   广告被点击的次数占展示次数的百分比。计算方法:点击数/展示数*100%
+
+	private java.math.BigDecimal cpm;  //平均千次展现费用  广告平均每一千次展现所付出的费用,计算公式是:总花费/展示数*1000。
+
+	private Long likeMaterial;  //互动数据-点赞数
+
+	private java.math.BigDecimal activeCost;  //应用下载广告数据-激活成本  计算方式:总花费/激活数。
+
+	private java.math.BigDecimal activeRate;  //应用下载广告数据-激活率   计算方式:激活数/点击数*100%
+
+	private java.math.BigDecimal activeRegisterRate;  //应用下载广告数据-注册率   注册用户占激活用户的比例
+
+	private java.math.BigDecimal activeRegisterCost;  //应用下载广告数据-注册成本  总花费/注册数,当天数据可能会有波动,次日早8点后稳定。
+
+	private Long showMaterial;  //展现数据-展示数
+
+	private java.math.BigDecimal convertRate;  //转化率  转化数/点击数*100%
+
+	private java.math.BigDecimal convertCost;
+
+    private Long clickMaterial;  //点击数
+
+	private Long clickInstall;  //应用下载-点击安装数
+
+}

+ 21 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/BytedanceInfoDTO.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.toutiao.modules.report.DTO;
+
+import com.github.pagehelper.PageInfo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+@Data
+public class BytedanceInfoDTO extends PageInfo implements Serializable{
+    private String startDate;
+    private String endDate;
+    private Long unitId;
+    private List<Long> projectList;
+    private Long accountId;  //广告主名称
+    private Long campaignId;
+    private Long projectId;
+    private String sort;
+
+}

+ 73 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java

@@ -2,8 +2,11 @@ package cn.com.ctop.toutiao.modules.report.controller;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
+import cn.com.ctop.toutiao.modules.report.DTO.BytedanceInfoDTO;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceAccountReportService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
@@ -13,7 +16,9 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -28,6 +33,8 @@ public class BytedanceReportController {
     private ICtopOauthTokenService tokenService;
     @Autowired
     private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
+    @Autowired
+    private IBytedanceAccountReportService bytedanceAccountReportService;
 
     @PostMapping("/kuaiShou/accountReport")
     public Result<JSONObject> getKuaiShouAccountReport(@RequestBody JSONObject requestJson) {
@@ -383,4 +390,70 @@ public class BytedanceReportController {
         return result;
     }
 
+    @ResponseBody
+    @RequestMapping("/getBytedanceAccountInfoByProjectId")
+    public Result<List<ByteDanceReportAccountDailyDTO>> getBytedanceAccountInfoByProjectId(@RequestBody BytedanceInfoDTO dto) {
+        Result<List<ByteDanceReportAccountDailyDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getProjectId()==null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+
+        if(dto.getPageSize() == 0 ){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceAccountInfoByProjectId(dto.getStartDate(), dto.getEndDate(), dto.getProjectId(),dto.getPageNum(),dto.getPageSize(),dto.getSort());
+            result.setResult(byteDanceReportAccountDailyDTOList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+    @ResponseBody
+    @RequestMapping("/getBytedanceSaleProjectInfo")
+    public Result<List<ByteDanceReportAccountDailyDTO>> getBytedanceSaleProjectInfo(@RequestBody BytedanceInfoDTO dto) {
+        Result<List<ByteDanceReportAccountDailyDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
+            //result.setSuccess(false);
+            //result.setMessage("参数有误");
+            //return result;
+
+            Date getDate = DateUtils.addDay(new Date(), -1);
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            String dateString = dateFormat.format(getDate);
+
+            dto = new BytedanceInfoDTO();
+            dto.setStartDate(dateString);
+            dto.setEndDate(dateString);
+        }
+
+        if(dto.getPageSize() == 0 ){
+            dto.setPageSize(20);
+        }
+
+        try{
+            List<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),dto.getSort());
+            result.setResult(byteDanceReportAccountDailyDTOList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
+import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
@@ -44,4 +45,18 @@ public interface BytedanceAccountReportMapper {
     //查询固定月的明细数据
     List<JSONObject> queryDetailGroupDayByMonth(@Param("month") String month);
 
+    List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+
+    ByteDanceReportAccountDailyDTO getBytedanceProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+
+    String getRoleCodeByUserId(@Param("userId")String userId);
+
+    //List<Long> queryProjectInfoByAdmin(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+
+    List<ByteDanceReportAccountDailyDTO> getSaleProjects(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+
+    List<ByteDanceReportAccountDailyDTO> queryProjectInfoByAdmin(@Param("mediaIds")List<Long> mediaIds);
+
+    List<ByteDanceReportAccountDailyDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
+
 }

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

@@ -212,4 +212,183 @@
         order by stat_datetime asc
     </select>
 
+    <sql id="selectSql">
+        ifnull(sum(a.show_num),0)                          as showMaterial,                   -- 展现数据-展示数
+        ifnull(sum(a.click),0)                             as clickMaterial,                  -- 点击数
+        ifnull(sum(a.convert_num),0)                       as convertMaterial,                -- 转化数据-转化数
+        ifnull(sum(a.cost),0)                              as cost,                           -- 消耗
+        ifnull(sum(a.active),0)                            as active,                         -- 应用下载-激活
+        ifnull(sum(a.download_finish),0)                   as downloadFinish,                 -- 应用下载-安卓下载完成
+        ifnull(sum(a.download_start),0)                    as downloadStart,                  -- 应用下载-安卓下载开始
+		ifnull(sum(a.click_install),0)                     as clickInstall,                   -- 应用下载-点击安装数
+		ifnull(sum(a.install_finish),0)                    as installFinish,                  -- 应用下载-安卓安装完成
+		ifnull(sum(a.register),0)                          as register,                       -- 应用下载-注册
+        ifnull(sum(a.pay_count),0)                         as payCount,                       -- 应用下载-付费数
+		ifnull(sum(a.form),0)                              as form,                           --  表单提交数
+		ifnull(sum(a.total_play),0)                        as totalPlay,                      -- 视频-总播放
+        ifnull(sum(a.valid_play),0)                        as validPlay,                      -- 视频-有效播放
+        ifnull(sum(a.wifi_play),0)                         as wifiPlay,                       -- 视频-wifi播放
+        ifnull(sum(a.play25_feed_break),0)                 as play25FeedBreak,                -- 视频-播放25%进度总数
+        ifnull(sum(a.play50_feed_break),0)                 as play50FeedBreak,                -- 视频-播放50%进度总数
+        ifnull(sum(a.play75_feed_break),0)                 as play75FeedBreak,                -- 视频-播放75%进度总数
+        ifnull(sum(a.play100_feed_break),0)                as play100FeedBreak,               -- 视频-播放100%进度总数
+		ifnull(sum(a.share),0)                             as shareMaterial,                  -- 互动数据-分享数
+		ifnull(sum(a.like_num),0)                          as likeMaterial,                   -- 互动数据-点赞数
+		case
+        when sum(a.total_play) != 0 and sum(a.total_play) is not null and sum(a.play25_feed_break) is not null
+        then round(sum(a.play25_feed_break) / sum(a.total_play),2)
+        else 0 end                               as play25FeedBreakRate,            -- 25%进度播放率
+		case
+        when sum(a.click) != 0 and sum(a.click) is not null and sum(a.convert_num) is not null
+        then round(sum(a.convert_num) / sum(a.click),2)
+        else 0 end                               as convertRate,                    -- 转化率  转化数/点击数*100% !
+        case
+        when sum(a.convert_num) != 0 and sum(a.convert_num) is not null and sum(a.cost) is not null
+        then round(sum(a.cost)/sum(a.convert_num),2)
+        else 0 end as convertCost, --  转化数据-转化成本=总花费/转化数
+		ifnull(sum(a.follow),0)                            as follow,                         -- 互动数据-新增关注数
+        ifnull(sum(a.next_day_open),0)                     as nextDayOpen,                    -- 次留数
+        case
+        when sum(a.active) != 0 and sum(a.next_day_open) is not null and sum(a.active) is not null
+        then round(sum(a.next_day_open) / sum(a.active),2)
+        else 0 end                               as nextDayOpenRate,                -- 次留率 = 次留数/激活数
+        case
+        when sum(a.next_day_open) != 0 and sum(a.next_day_open) is not null and sum(a.cost) is not null
+        then round(sum(a.cost) / sum(a.next_day_open),2)
+        else 0 end                               as nextDayOpenCost,                -- 次留成本 = 消耗/次留数
+		case
+        when sum(a.click) != 0 and sum(a.click) is not null and sum(a.cost) is not null
+        then round(sum(a.cost) / sum(a.click),2)
+        else 0 end                               as cpc,                            -- 平均点击单价
+        case
+        when sum(a.show_num) != 0 and sum(a.show_num) is not null and sum(a.click) is not null
+        then round(sum(a.click) / sum(a.show_num),2)
+        else 0 end                               as ctr,                            -- 展现数据-点击率   广告被点击的次数占展示次数的百分比。计算方法:点击数/展示数*100%
+        case
+        when sum(a.show_num) != 0 and sum(a.cost) is not null and sum(a.show_num) is not null
+        then round(sum(a.cost) / sum(a.show_num) * 1000,2)
+        else 0 end                               as cpm,                            -- 平均千次展现费用  广告平均每一千次展现所付出的费用,计算公式是:总花费/展示数*1000。
+		case
+        when sum(a.active) != 0 and sum(a.cost) is not null and sum(a.active) is not null
+        then round(sum(a.cost) / sum(a.active),2)
+        else 0 end                               as activeCost,                     -- 应用下载广告数据-激活成本  计算方式:总花费/激活数。
+		case
+        when sum(a.click) != 0 and sum(a.active) is not null and sum(a.click) is not null
+        then round(sum(a.active) / sum(a.click),2)
+        else 0 end                               as activeRate,                     -- 应用下载广告数据-激活率   计算方式:激活数/点击数*100%
+        case
+        when sum(a.active) != 0 and sum(a.register) is not null and sum(a.active) is not null
+        then round(sum(a.register) / sum(a.active),2)
+        else 0 end                               as activeRegisterRate,             -- 应用下载广告数据-注册率   注册用户占激活用户的比例
+        case
+        when sum(a.register) != 0 and sum(a.cost) is not null and sum(a.register) is not null
+        then round(sum(a.cost) / sum(a.register),2)
+        else 0 end                               as activeRegisterCost               -- 应用下载广告数据-注册成本  总花费/注册数,当天数据可能会有波动,次日早8点后稳定。
+    </sql>
+
+    <select id="getBytedanceAccountInfoByProjectId" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+            select
+            concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
+            a.advertiser_id as 'accountId',
+            b.auth_name as 'authName',
+            b.project_id as 'projectId',
+            b.project_name as 'projectName',
+            <include refid="selectSql"></include>
+        from
+        ctop_bytedance_report_advertiser_daily a
+        left join (select * from ctop_user_allocation group by account_id) b on a.advertiser_id = b.account_id
+        where
+        date_format(a.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
+        and
+        date_format(a.stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
+        and
+        b.project_id = #{projectId}
+        group by a.advertiser_id
+        -- order by sum(a.cost) desc
+    </select>
+
+    <select id="getBytedanceProjectInfo" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+            select
+            <include refid="selectSql"></include>
+        from
+        ctop_bytedance_report_advertiser_daily a
+        left join (select * from ctop_user_allocation group by account_id) b on a.advertiser_id = b.account_id
+        left join ctop_project c on b.project_id = c.id
+        where
+        date_format(a.stat_datetime, '%Y-%m-%d') &gt;= #{startDate}
+        and
+        date_format(a.stat_datetime, '%Y-%m-%d') &lt;= #{endDate}
+        and
+        b.project_id = #{projectId}
+    </select>
+
+    <select id="getRoleCodeByUserId" resultType="string">
+        select
+        role_code
+        from
+        sys_user_role a
+        left join sys_role b on a.role_id = b.id
+        where a.user_id = #{userId}
+    </select>
+
+    <select id="queryProjectInfoByAdmin" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+        select
+        id as projectId,
+        project_name as projectName,
+        advertiser_id as advertiserId,
+        advertiser_name as advertiserName,
+        responsible_name as responsibleName,
+        media_id as mediaId
+        from
+        ctop_project
+        where
+        media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getSaleProjects" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+        select
+        distinct a.id as projectId,
+        a.project_name as projectName,
+        a.advertiser_id as advertiserId,
+        a.advertiser_name as advertiserName,
+        a.media_id as mediaId,
+        a.sale_id as saleId,
+        b.realname as saleName
+        from
+        ctop_project a
+        left join sys_user b on a.sale_id = b.id
+        where a.sale_id = #{userId}
+        and a.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="queryProjectMemberByIds" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+        select
+        distinct id as projectId,
+        project_name as projectName,
+        advertiser_id as advertiserId,
+        advertiser_name as advertiserName,
+        media_id as mediaId,
+        responsible_name as responsibleName,
+        design_responsible_name as designResponsibleName
+        from
+        left join ctop_project
+        where
+        id in
+        <foreach collection="projectIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        order by create_time desc
+    </select>
+
+
+
 </mapper>

+ 9 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.service;
 
+import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 
@@ -16,4 +17,12 @@ public interface IBytedanceAccountReportService {
     List<JSONObject> getListDataBy(String mediaId,BigDecimal discount, JSONArray accounts,String startDate ,String endDate, int hour, String target, String order);
 
     List<JSONObject> getExcelDataBy(String filed, String mediaId, JSONArray accounts,String startDate ,String endDate, int hour, String target, String order);
+
+    //List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList);
+
+    List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId,Integer pageNo, Integer pageSize, String sort);
+
+    List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort);
+
+    //List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, Long projectId, int pageNum, int pageSize, String sort);
 }

+ 86 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

@@ -1,11 +1,14 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceAccountReportMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAccountReportService;
 import cn.com.ctop.toutiao.modules.utils.LinkUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.constant.SystemDateConstant;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.JsonResourceUtil;
@@ -180,4 +183,87 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
         });
         return jsonObject;
     }
+
+    @Override
+    public List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort){
+        List<ByteDanceReportAccountDailyDTO> list = new ArrayList<>();
+
+        if(projectList==null || projectList.size()==0){
+            //LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String userId = "388e787edd294ecfb9243fe176a3ae56";
+            String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
+
+            List<Long> mediaIds = new ArrayList<>();
+            mediaIds.add(1L);
+            mediaIds.add(3L);
+
+            if("admin".equals(roleCode)){
+                PageHelper.startPage(pageNum,pageSize);
+                list = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
+            }else{
+                PageHelper.startPage(pageNum,pageSize);
+                list = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
+            }
+        }else{
+            PageHelper.startPage(pageNum,pageSize);
+            list = bytedanceAccountReportMapper.queryProjectMemberByIds(projectList);
+        }
+
+        //List<ByteDanceReportAccountDailyDTO> projectAccountDTOList = new ArrayList<>();
+
+        for(ByteDanceReportAccountDailyDTO project:list){
+            ByteDanceReportAccountDailyDTO p = bytedanceAccountReportMapper.getBytedanceProjectInfo(startDate, endDate, project.getProjectId());
+
+            project.setShowMaterial(p.getShowMaterial());
+            project.setClickMaterial(p.getClickMaterial());
+            project.setConvertMaterial(p.getConvertMaterial());
+            project.setCost(p.getCost());
+            project.setActive(p.getActive());
+            project.setDownloadFinish(p.getDownloadFinish());
+            project.setDownloadStart(p.getDownloadStart());
+            project.setClickInstall(p.getClickInstall());
+            project.setInstallFinish(p.getInstallFinish());
+            project.setRegister(p.getRegister());
+            project.setPayCount(p.getPayCount());
+            project.setForm(p.getForm());
+            project.setTotalPlay(p.getTotalPlay());
+            project.setValidPlay(p.getValidPlay());
+            project.setWifiPlay(p.getWifiPlay());
+            project.setPlay25FeedBreak(p.getPlay25FeedBreak());
+            project.setPlay50FeedBreak(p.getPlay50FeedBreak());
+            project.setPlay75FeedBreak(p.getPlay75FeedBreak());
+            project.setPlay100FeedBreak(p.getPlay100FeedBreak());
+            project.setShareMaterial(p.getShareMaterial());
+            project.setLikeMaterial(p.getLikeMaterial());
+            project.setPlay25FeedBreakRate(p.getPlay25FeedBreakRate());
+            project.setConvertRate(p.getConvertRate());
+            project.setConvertCost(p.getConvertCost());
+            project.setFollow(p.getFollow());
+            project.setNextDayOpen(p.getNextDayOpen());
+            project.setNextDayOpenRate(p.getNextDayOpenRate());
+            project.setNextDayOpenCost(p.getNextDayOpenCost());
+            project.setCpc(p.getCpc());
+            project.setCtr(p.getCtr());
+            project.setCpm(p.getCpm());
+            project.setActiveCost(p.getActiveCost());
+            project.setActiveRate(p.getActiveRate());
+            project.setActiveRegisterRate(p.getActiveRegisterRate());
+            project.setActiveRegisterCost(p.getActiveRegisterCost());
+        }
+
+        return list;
+    }
+
+    @Override
+    public List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId,Integer pageNo, Integer pageSize, String sort){
+        if(StringUtils.isBlank(sort)){
+            sort = "cost-";
+        }
+        sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
+        sort = sort.substring(0, sort.length() - 1);
+        PageHelper.startPage(pageNo,pageSize,sort);
+        return bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId);
+    }
+
+
 }