فهرست منبع

Merge remote-tracking branch 'origin/test' into test

syh 4 سال پیش
والد
کامیت
74f5dae158
23فایلهای تغییر یافته به همراه1704 افزوده شده و 4 حذف شده
  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. 57 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. 22 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouInfoDTO.java
  9. 53 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccountDTO.java
  10. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouVideoInfoDTO.java
  11. 45 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/ProjectAccountDTO.java
  12. 100 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/ProjectMember.java
  13. 24 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  14. 464 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  15. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  16. 159 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java
  17. 101 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/ByteDanceReportAccountDailyDTO.java
  18. 21 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/BytedanceInfoDTO.java
  19. 73 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  20. 15 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java
  21. 179 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml
  22. 9 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java
  23. 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

@@ -341,4 +341,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

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

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

@@ -89,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;
@@ -151,4 +158,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;
+    }
 }

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

@@ -0,0 +1,22 @@
+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;
+import java.math.BigDecimal;
+import java.util.List;
+
+
+@Data
+public class KuaishouInfoDTO 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;
+
+}

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

@@ -0,0 +1,53 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class KuaishouReportDailyAccountDTO implements Serializable {
+    private String statDate;
+    private String accountId;
+    private String authName;
+    private Long projectId;
+    private String projectName;
+    private Long campaignId;
+    private String campaignName;
+    private Long creativeId;
+    private String creativeName;
+    private Long unitId;
+    private String unitName;
+    private BigDecimal charge;  //消耗
+    private Long photoShow;  //封面曝光数
+    private Long photoClick;  //封面点击数
+    private Long aclick;  //素材曝光数
+    private Long bclick;  //行为数
+    private Long activation;  //激活数
+    private Long submit;  //提交按钮点击数
+    private Long eventRegister;  //注册数
+    private Long eventNextDayStay;  //次日留存数
+    private BigDecimal activationCost;  //激活成本
+    private String photoClickRatio;  //封面点击率
+    private String actionRate;  //行为率
+    //@JsonSerialize(using = ToStringSerializer.class)
+    private BigDecimal impression1kCost;  //均千次封面曝光花费
+    private BigDecimal photoClickCost;  //平均封面点击单价
+    private BigDecimal actionCost;  //平均行为单价
+    private Long photoShare;  //分享数
+    private Long photoComment;  //评论数
+    private Long photoLike;  //点赞数
+    private Long follow;  //新增关注数
+    private Long report;  //举报数
+    private Long cancelFollow;  //取消关注数
+    private Long block;  //拉黑数
+    private Long nagative;  //减少此类作品数
+    private Long downloadStarted;  //应用下载数据-安卓下载开始数
+    private Long downloadCompleted;  //应用下载数据-安卓下载完成数
+    private BigDecimal eventNextDayStayCost;  //次日留存成本
+    private Long photoId;
+    private String url;
+    private String coverUrl;
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+@Data
+public class KuaishouVideoInfoDTO implements Serializable {
+    private String url;
+    private String coverUrl;
+
+}

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

@@ -0,0 +1,45 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+
+@Data
+public class ProjectAccountDTO implements Serializable {
+    private String statDate;
+    private Long projectId;
+    private String projectName;
+    private String responsibleName;
+    private String advertiserName;  //广告主名称
+    private String designResponsibleName;
+    private String saleId;
+    private String saleName;
+    private BigDecimal charge;
+    private Long photoShow;
+    private Long photoClick;
+    private Long aclick;
+    private Long bclick;
+    private Long activation;
+    private Long submit;
+    private Long eventRegister;
+    private Long eventNextDayStay;
+    private BigDecimal activationCost;
+    private String photoClickRate;
+    private String bclickRate;
+    private BigDecimal impression1kCost;
+    private BigDecimal photoClickCost;
+    private BigDecimal actionCost;
+    private Long photoShare;
+    private Long photoComment;
+    private Long photoLike;
+    private Long follow;
+    private Long report;
+    private Long cancelFollow;
+    private Long block;
+    private Long nagative;
+    private Long downloadStarted;
+    private Long downloadCompleted;
+    private BigDecimal eventNextDayStayCost;
+}

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

@@ -0,0 +1,100 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 项目成员
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-11-19
+ */
+@Data
+@TableName("ctop_project_member")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_project_member对象", description = "项目成员")
+public class ProjectMember implements  Serializable{
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目id
+     */
+    @Excel(name = "项目id", width = 15)
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+
+    @Excel(name = "项目名称", width = 15)
+    @ApiModelProperty(value = "项目名称")
+    private String projectName;
+    /**
+     * 成员id
+     */
+    @Excel(name = "成员id", width = 15)
+    @ApiModelProperty(value = "成员id")
+    private String userId;
+
+    @Excel(name = "成员名称", width = 15)
+    @ApiModelProperty(value = "成员名称")
+    private String userName;
+
+    private String roleCode;
+
+    @TableField(exist = false)
+    private Long maxBid;
+
+
+    @TableField(exist = false)
+    private String responsibleName;
+
+
+    @TableField(exist = false)
+    private String designResponsibleName;
+
+    @TableField(exist = false)
+    private String advertiserName;
+    @TableField(exist = false)
+    private String advertiserId;
+
+
+    @TableField(exist = false)
+    private String mediaId;
+
+
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -1,6 +1,9 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -15,4 +18,25 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<JSONObject> selectCost(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
+    ProjectAccountDTO getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId);
+
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId);
+
+    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);
+
+    KuaishouVideoInfoDTO getVideoUrl(@Param("photoId")Long photoId);
 }

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

@@ -530,4 +530,467 @@
         group by stat_date
     </select>
 
-</mapper>
+    <select id="getKuaishouAccountInfoByProjectId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select
+        concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
+        a.account_id as 'accountId',
+        b.auth_name as 'authName',
+        b.project_id as 'projectId',
+        b.project_name as 'projectName',
+        round(sum(a.charge),2) as 'charge',
+        sum(a.photo_show) as 'photoShow',  -- 封面曝光数
+        sum(a.photo_click) as 'photoClick', -- 封面点击数
+        sum(a.aclick) as 'aclick',  -- 素材曝光数
+        sum(a.bclick) as 'bclick',  -- 行为数
+        sum(a.activation) as 'activation',  -- 激活数
+        sum(a.submit) as 'submit',   -- 提交按钮点击数
+        sum(a.event_register) as 'eventRegister',   -- 注册数
+        sum(a.event_next_day_stay) as 'eventNextDayStay',  -- 次日留存数
+        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
+        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRatio',   -- 封面点击率
+        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate',  -- 行为率
+        (case
+        when sum(a.photo_show) != 0
+        then round((sum(a.charge) / sum(a.photo_show)) * 1000,2)
+        else 0
+        end
+        ) as 'impression1kCost', -- 均千次封面曝光花费
+        (case
+        when sum(a.photo_click) != 0
+        then round(sum(a.charge) / sum(a.photo_click),2)
+        else 0
+        end
+        ) as 'photoClickCost', -- 平均封面点击单价
+        (CASE
+        WHEN sum(a.photo_click) != 0
+        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        ELSE 0
+        end
+        ) as 'actionCost', -- 平均行为单价
+        sum(a.photo_share) as 'photoShare',  -- 分享数
+        sum(a.photo_comment) as 'photoComment', -- 评论数
+        sum(a.photo_like) as 'photoLike', -- 点赞数
+        sum(a.follow) as 'follow', -- 新增关注数
+        sum(a.report) as 'report', -- 举报数
+        sum(a.cancel_follow) as 'cancelFollow', -- 取消关注数
+        sum(a.block) as 'block', -- 拉黑数
+        sum(a.negative) as 'nagative', -- 减少此类作品数
+        sum(a.download_started) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
+        sum(a.download_completed) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+        (CASE
+        WHEN sum(a.event_next_day_stay) != 0
+        THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
+        ELSE 0
+        end
+        ) 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
+        where
+        a.stat_date &gt;= #{startDate}
+        and
+        a.stat_date &lt;= #{endDate}
+        and
+        b.project_id = #{projectId}
+        group by a.account_id
+        order by sum(a.charge) desc
+    </select>
+
+    <select id="getKuaishouProjectInfo" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+        select
+        concat(#{startDate}, '~' , #{endDate}) as 'statDate',
+        (select project_id from ctop_user_allocation where account_id = a.account_id limit 1) as 'projectId',
+        (select project_name from ctop_user_allocation where account_id = a.account_id limit 1) as 'projectName',
+        (select advertiser_name from ctop_project where id = (select project_id from ctop_user_allocation where
+         					account_id = a.account_id limit 1
+					)) as 'advertiserName',
+        (select responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where
+        					account_id = a.account_id limit 1
+					)) as 'responsibleName',
+        (select design_responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where 					account_id = a.account_id limit 1
+					)) as 'designResponsibleName',
+        ifnull(round(sum(a.charge),2),0) as 'charge',
+        ifnull(sum(a.photo_show),0) as 'photoShow',  -- 封面曝光数
+        ifnull(sum(a.photo_click),0) as 'photoClick', -- 封面点击数
+        ifnull(sum(a.aclick),0) as 'aclick',  -- 素材曝光数
+        ifnull(sum(a.bclick),0) as 'bclick',  -- 行为数
+        ifnull(sum(a.activation),0) as 'activation',  -- 激活数
+        ifnull(sum(a.submit),0) as 'submit',   -- 提交按钮点击数
+        ifnull(sum(a.event_register),0) as 'eventRegister',   -- 注册数
+        ifnull(sum(event_next_day_stay),0) as 'eventNextDayStay',  -- 次日留存数
+        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
+        case when (sum(a.photo_show) is not null and sum(a.photo_show)!=0) then concat(round(ifnull(sum(a.photo_click),0)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRate',   -- 封面点击率
+        case when (sum(a.aclick) is not null and sum(a.aclick)!=0) then concat(round(ifnull(sum(a.bclick),0)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'bclickRate',  -- 行为率
+        (case
+        when (sum(a.photo_show) is not null and sum(a.photo_show) != 0)
+        then round((ifnull(sum(a.charge),0) / sum(a.photo_show)) * 1000,2)
+        else 0
+        end
+        ) as 'impression1kCost', -- 均千次封面曝光花费
+        (case
+        when (sum(a.photo_click) is not null and sum(a.photo_click) != 0)
+        then round( ifnull(sum(a.charge),0) / sum(a.photo_click),2)
+        else 0
+        end
+        ) as 'photoClickCost', -- 平均封面点击单价
+        (CASE
+        WHEN ( sum(a.photo_click) is not null and sum(a.photo_click) != 0)
+        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        ELSE 0
+        end
+        ) as 'actionCost', -- 平均行为单价
+        ifnull(sum(a.photo_share),0) as 'photoShare',  -- 分享数
+        ifnull(sum(a.photo_comment),0) as 'photoComment', -- 评论数
+        ifnull(sum(a.photo_like),0) as 'photoLike', -- 点赞数
+        ifnull(sum(a.follow),0) as 'follow', -- 新增关注数
+        ifnull(sum(a.report),0) as 'report', -- 举报数
+        ifnull(sum(a.cancel_follow),0) as 'cancelFollow', -- 取消关注数
+        ifnull(sum(a.block),0) as 'block', -- 拉黑数
+        ifnull(sum(a.negative),0) as 'nagative', -- 减少此类作品数
+        ifnull(sum(a.download_started),0) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
+        ifnull(sum(a.download_completed),0) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+        (CASE
+        WHEN ( sum(a.event_next_day_stay) is not null and sum(a.event_next_day_stay) != 0)
+        THEN round(  ifnull(sum(a.charge),0) / sum(a.event_next_day_stay)  ,2)
+        ELSE 0
+        end
+        ) 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
+        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>
+
+    <!-- 计划汇总 -->
+    <select id="getKuaishouCampaignInfoByAccountId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select
+        concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
+        b.project_id as 'projectId',
+        b.project_name as 'projectName',
+        b.auth_name as 'authName',
+        a.account_id as 'accountId',
+        a.campaign_id as 'campaignId',  -- 计划id
+        a.campaign_name as 'campaignName',   -- 计划名称
+        round(sum(a.charge),2) as 'charge',
+        sum(a.photo_show) as 'photoShow',  -- 封面曝光数
+        sum(a.photo_click) as 'photoClick', -- 封面点击数
+        sum(a.aclick) as 'aclick',  -- 素材曝光数
+        sum(a.bclick) as 'bclick',  -- 行为数
+        sum(a.activation) as 'activation',  -- 激活数
+        sum(a.submit) as 'submit',   -- 提交按钮点击数
+        sum(a.event_register) as 'eventRegister',   -- 注册数
+        sum(event_next_day_stay) as 'eventNextDayStay',  -- 次日留存数
+        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
+        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRatio',   -- 封面点击率
+        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate',  -- 行为率
+        (case
+        when sum(a.photo_show) != 0
+        then round((sum(a.charge) / sum(a.photo_show)) * 1000,2)
+        else 0
+        end
+        ) as 'impression1kCost', -- 均千次封面曝光花费
+        (case
+        when sum(a.photo_click) != 0
+        then round(sum(a.charge) / sum(a.photo_click),2)
+        else 0
+        end
+        ) as 'photoClickCost', -- 平均封面点击单价
+        (CASE
+        WHEN sum(a.photo_click) != 0
+        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        ELSE 0
+        end
+        ) as 'actionCost', -- 平均行为单价
+        sum(a.photo_share) as 'photoShare',  -- 分享数
+        sum(a.photo_comment) as 'photoComment', -- 评论数
+        sum(a.photo_like) as 'photoLike', -- 点赞数
+        sum(a.follow) as 'follow', -- 新增关注数
+        sum(a.report) as 'report', -- 举报数
+        sum(a.cancel_follow) as 'cancelFollow', -- 取消关注数
+        sum(a.block) as 'block', -- 拉黑数
+        sum(a.negative) as 'nagative', -- 减少此类作品数
+        sum(a.download_started) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
+        sum(a.download_completed) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+        (CASE
+        WHEN sum(a.event_next_day_stay) != 0
+        THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
+        ELSE 0
+        end
+        ) as 'eventNextDayStayCost'  -- 次日留存成本
+        from
+        ctop_kuaishou_report_daily_campaign a
+        left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+        where
+        a.stat_date &gt;= #{startDate}
+        and
+        a.stat_date &lt;= #{endDate}
+        and
+        a.account_id = #{accountId}
+        group by a.campaign_id
+    </select>
+
+    <!-- 根据计划id获取组信息 -->
+    <select id="getKuaishouUnitInfoByCampaignId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select
+        concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
+        b.project_id as 'projectId',
+        b.project_name as 'projectName',
+        a.account_id as 'accountId',
+        b.auth_name as 'authName',
+        a.campaign_id as 'campaignId',  -- 计划id
+        a.campaign_name as 'campaignName',  -- 计划名称
+        a.unit_id as 'unitId',  -- 组id,
+        a.unit_name as 'unitName',  -- 组名称
+        round(sum(a.charge),2) as 'charge',
+        sum(a.photo_show) as 'photoShow',  -- 封面曝光数
+        sum(a.photo_click) as 'photoClick', -- 封面点击数
+        sum(a.aclick) as 'aclick',  -- 素材曝光数
+        sum(a.bclick) as 'bclick',  -- 行为数
+        sum(a.activation) as 'activation',  -- 激活数
+        sum(a.submit) as 'submit',   -- 提交按钮点击数
+        sum(a.event_register) as 'eventRegister',   -- 注册数
+        sum(event_next_day_stay) as 'eventNextDayStay',  -- 次日留存数
+        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
+        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRatio',   -- 封面点击率
+        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate',  -- 行为率
+        (case
+        when sum(a.photo_show) != 0
+        then round((sum(a.charge) / sum(a.photo_show)) * 1000,2)
+        else 0
+        end
+        ) as 'impression1kCost', -- 均千次封面曝光花费
+        (case
+        when sum(a.photo_click) != 0
+        then round(sum(a.charge) / sum(a.photo_click),2)
+        else 0
+        end
+        ) as 'photoClickCost', -- 平均封面点击单价
+        (CASE
+        WHEN sum(a.photo_click) != 0
+        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        ELSE 0
+        end
+        ) as 'actionCost', -- 平均行为单价
+        sum(a.photo_share) as 'photoShare',  -- 分享数
+        sum(a.photo_comment) as 'photoComment', -- 评论数
+        sum(a.photo_like) as 'photoLike', -- 点赞数
+        sum(a.follow) as 'follow', -- 新增关注数
+        sum(a.report) as 'report', -- 举报数
+        sum(a.cancel_follow) as 'cancelFollow', -- 取消关注数
+        sum(a.block) as 'block', -- 拉黑数
+        sum(a.negative) as 'nagative', -- 减少此类作品数
+        sum(a.download_started) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
+        sum(a.download_completed) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+        (CASE
+        WHEN sum(a.event_next_day_stay) != 0
+        THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
+        ELSE 0
+        end
+        ) as 'eventNextDayStayCost'  -- 次日留存成本
+        from
+        ctop_kuaishou_report_daily_group a
+        left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+--         left join ctop_kuaishou_campaign c on a.campaign_id = c.campaign_id
+        where
+        a.stat_date &gt;= #{startDate}
+        and
+        a.stat_date &lt;= #{endDate}
+        and
+        a.campaign_id = #{campaignId}
+        group by unit_id
+    </select>
+
+    <select id="queryProjectMemberByUserId" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+        select
+        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">
+        select
+        a.*,
+        b.photo_id as 'photoId'
+        from
+        (
+            select
+            concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
+            b.project_id as 'projectId',
+            b.project_name as 'projectName',
+            a.account_id as 'accountId',
+            b.auth_name as 'authName',
+            a.creative_id as 'creativeId',
+            a.creative_name as 'creativeName',
+            a.campaign_id as 'campaignId',  -- 计划id
+            a.campaign_name as 'campaignName',  -- 计划名称
+            a.unit_id as 'unitId',  -- 组id,
+            a.unit_name as 'unitName',  -- 组名称
+            round(sum(a.charge),2) as 'charge',
+            sum(a.photo_show) as 'photoShow',  -- 封面曝光数
+            sum(a.photo_click) as 'photoClick', -- 封面点击数
+            sum(a.aclick) as 'aclick',  -- 素材曝光数
+            sum(a.bclick) as 'bclick',  -- 行为数
+            sum(a.activation) as 'activation',  -- 激活数
+            sum(a.submit) as 'submit',   -- 提交按钮点击数
+            sum(a.event_register) as 'eventRegister',   -- 注册数
+            sum(event_next_day_stay) as 'eventNextDayStay',  -- 次日留存数
+            ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
+            case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRatio',   -- 封面点击率
+            case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate',  -- 行为率
+            (case
+            when sum(a.photo_show) != 0 and sum(a.photo_show) is not null
+            then round((sum(a.charge) / sum(a.photo_show)) * 1000,2)
+            else 0
+            end
+            ) as 'impression1kCost', -- 均千次封面曝光花费
+            (case
+            when sum(a.photo_click) != 0
+            then round(sum(a.charge) / sum(a.photo_click),2)
+            else 0
+            end
+            ) as 'photoClickCost', -- 平均封面点击单价
+            (CASE
+            WHEN sum(a.photo_click) != 0
+            THEN round(sum(a.charge) / sum(a.photo_click),2)
+            ELSE 0
+            end
+            ) as 'actionCost', -- 平均行为单价
+            sum(a.photo_share) as 'photoShare',  -- 分享数
+            sum(a.photo_comment) as 'photoComment', -- 评论数
+            sum(a.photo_like) as 'photoLike', -- 点赞数
+            sum(a.follow) as 'follow', -- 新增关注数
+            sum(a.report) as 'report', -- 举报数
+            sum(a.cancel_follow) as 'cancelFollow', -- 取消关注数
+            sum(a.block) as 'block', -- 拉黑数
+            sum(a.negative) as 'nagative', -- 减少此类作品数
+            sum(a.download_started) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
+            sum(a.download_completed) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+            (CASE
+            WHEN sum(a.event_next_day_stay) != 0
+            THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
+            ELSE 0
+            end
+            ) as 'eventNextDayStayCost'  -- 次日留存成本
+            from
+            ctop_kuaishou_report_daily_creative a
+            left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+            where
+            a.stat_date &gt;= #{startDate}
+            and
+            a.stat_date &lt;= #{endDate}
+            and
+            a.unit_id = #{unitId}
+            group by creative_id
+        ) a
+        left join  ctop_kuaishou_creative b on a.creativeId = b.creative_id
+    </select>
+
+    <select id="getVideoUrl" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO">
+        select
+        url as url,
+        cover_url as coverUrl
+        from
+        ctop_kuaishou_video_get
+        where photo_id = #{photoId}
+        limit 1
+    </select>
+
+</mapper>

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

@@ -1,13 +1,30 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public interface IKuaishouReportDailyAccountService extends IService<KuaishouReportDailyAccount> {
 
     List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
 
+    List<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList , Integer pageSize, Integer pageNum, String sort );
+
+    List<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort);
+
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum);
+
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum);
+
+    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);
+
 }

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

@@ -1,13 +1,22 @@
 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.entity.KuaishouReportDailyAccountDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
 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 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;
 
 @Service
@@ -20,4 +29,154 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
     public List<JSONObject> selectCost(Long accountId, String startDate, String endDate) {
         return dailyAccountMapper.selectCost(accountId, startDate, endDate);
     }
+
+    @Override
+    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);
+
+            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<>();
+
+        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, 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, 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, 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, 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());
+            creativeInfo.setUrl(videoInfo.getUrl());
+            creativeInfo.setCoverUrl(videoInfo.getCoverUrl());
+        }
+        return kuaishouCreativeInfoList;
+    }
+
 }

+ 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);
+    }
+
+
 }