Browse Source

王垒、李娜效果报表

hcst_sunzhen 4 years ago
parent
commit
f4b0fcd146
13 changed files with 306 additions and 425 deletions
  1. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 6 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  3. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouInfoDTO.java
  4. 8 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  5. 188 228
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  6. 6 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  7. 19 88
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java
  8. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/BytedanceInfoDTO.java
  9. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  10. 4 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java
  11. 59 26
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml
  12. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java
  13. 9 53
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

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

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

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

@@ -86,7 +86,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "");
+            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "", dto.getYn());
             result.setResult(projectAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -114,7 +114,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "");
+            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "",dto.getYn());
             result.setResult(projectAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -144,7 +144,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouReportDailyAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -173,7 +173,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -202,7 +202,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -230,7 +230,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());

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

@@ -18,5 +18,6 @@ public class KuaishouInfoDTO extends PageInfo implements Serializable {
     private Long accountId;  //广告主名称
     private Long campaignId;
     private Long projectId;
+    private Integer yn;
 
 }

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

@@ -18,25 +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<ProjectAccountDTO> getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<ProjectAccountDTO> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
-    List<ProjectAccountDTO> queryProjectInfoBySaleId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> 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<Long> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn")Integer yn);
 
     KuaishouVideoInfoDTO getVideoUrl(@Param("photoId")Long photoId);
 

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

@@ -531,24 +531,28 @@
     </select>
 
     <select id="getKuaishouAccountInfoByProjectId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select * from
+        (
         select
+        #{yn} as 'yn',
         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_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',  -- 行为率
+        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)
@@ -567,7 +571,7 @@
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
-        sum(a.photo_share) as 'photoShare',  -- 分享数
+        sum(a.photo_share) as 'photoShare', -- 分享数
         sum(a.photo_comment) as 'photoComment', -- 评论数
         sum(a.photo_like) as 'photoLike', -- 点赞数
         sum(a.follow) as 'follow', -- 新增关注数
@@ -575,14 +579,14 @@
         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',  -- 应用下载数据-安卓下载完成数
+        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'  -- 次日留存成本
+        ) 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
@@ -590,6 +594,7 @@
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
+
         <if test="projectId!=null and projectId != '' ">
             and
             b.project_id = #{projectId}
@@ -603,87 +608,101 @@
         </if>
         group by a.account_id
         order by sum(a.charge) desc
+        )m
+        <if test="yn=1">
+            where
+            m.charge != 0
+        </if>
     </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
+        select* from (
+             select
+        #{yn} as 'yn',
+            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 in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+            group by b.project_id
+        ) m
+        <if test="yn = 1">
         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-->
+            m.charge != 0
+        </if>
     </select>
 
     <!-- 计划汇总 -->
     <select id="getKuaishouCampaignInfoByAccountId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
-        select
+        select * from
+        (select
+        #{yn} as 'yn',
         concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
         b.project_id as 'projectId',
         b.project_name as 'projectName',
@@ -757,32 +776,41 @@
         </if>
 
         group by a.campaign_id
+        ) m
+
+        <if test="yn = 1">
+            where
+            m.charge != 0
+        </if>
     </select>
 
     <!-- 根据计划id获取组信息 -->
     <select id="getKuaishouUnitInfoByCampaignId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select * from (
         select
+        #{yn} as 'yn',
         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',  -- 组名称
+        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_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',  -- 行为率
+        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)
@@ -801,7 +829,7 @@
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
-        sum(a.photo_share) as 'photoShare',  -- 分享数
+        sum(a.photo_share) as 'photoShare', -- 分享数
         sum(a.photo_comment) as 'photoComment', -- 评论数
         sum(a.photo_like) as 'photoLike', -- 点赞数
         sum(a.follow) as 'follow', -- 新增关注数
@@ -809,45 +837,49 @@
         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',  -- 应用下载数据-安卓下载完成数
+        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'  -- 次日留存成本
+        ) 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}
-        <if test="campaignId != null and campaignId != ''">
-            and
-            a.campaign_id = #{campaignId}
-        </if>
-        <if test="accountIds !=null">
-            and a.account_id in
-            <foreach collection="accountIds" item="item" separator=","
-                     open="(" close=")">
-                #{item}
-            </foreach>
+            <if test="campaignId != null and campaignId != ''">and
+                a.campaign_id = #{campaignId}
+            </if>
+            <if test="accountIds !=null">
+                and a.account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            group by unit_id
+            ) m
+        <if test="yn = 1">
+            where
+            m.charge != 0
         </if>
-        group by unit_id
     </select>
 
-    <select id="queryProjectMemberByUserId" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+    <select id="queryProjectMemberByUserId" resultType="long">
         select
-        distinct a.project_id as projectId,
-        a.project_name as projectName,
+        distinct a.project_id as projectId
+       -- a.project_name as projectName,
 --         a.advertiser_id as advertiserId,
-        a.advertiser_name as advertiserName,
+       -- 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
+       -- 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
@@ -861,17 +893,17 @@
         order by c.create_time desc
     </select>
 
-    <select id="queryProjectInfoBySaleId" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+    <select id="queryProjectInfoBySaleId" resultType="long">
         select
-        distinct c.id as projectId,
-        c.project_name as projectName,
+        distinct c.id as projectId
+        -- c.project_name as projectName,
         --         a.advertiser_id as advertiserId,
-        c.advertiser_name as advertiserName,
+        -- 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
+        -- 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
@@ -913,13 +945,13 @@
     </select>
 
     <!-- 设计师展示所有自己的角色下制作的视频 -->
-    <select id="queryProjectMemberByAdmins" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+    <select id="queryProjectMemberByAdmins" resultType="long">
         select
-        id as projectId,
-        project_name as projectName,
-        advertiser_name as advertiserName ,
-        responsible_name as responsibleName,
-        design_responsible_name as designResponsibleName
+        id as projectId
+        -- project_name as projectName,
+        -- advertiser_name as advertiserName ,
+        -- responsible_name as responsibleName,
+        -- design_responsible_name as designResponsibleName
         from
         ctop_project
         where
@@ -931,13 +963,10 @@
         order by create_time desc
     </select>
 
-    <select id="getKuaishouCreativeInfoByUnitId2" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
-        select
-        a.*,
-        b.photo_id as 'photoId'
-        from
-        (
+    <select id="getKuaishouCreativeInfoByUnitId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select * from (
             select
+        #{yn} as 'yn',
             concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
             b.project_id as 'projectId',
             b.project_name as 'projectName',
@@ -994,104 +1023,34 @@
             THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
             ELSE 0
             end
-            ) as 'eventNextDayStayCost'  -- 次日留存成本
+            ) as 'eventNextDayStayCost',  -- 次日留存成本
+            (select url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as url,
+            (select cover_url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as coverUrl
             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
+            left join ctop_kuaishou_creative c on a.creative_id = c.creative_id
             where
             a.stat_date &gt;= #{startDate}
             and
             a.stat_date &lt;= #{endDate}
+
             <if test="unitId != null and unitId !='' ">
                 and
                 a.unit_id = #{unitId}
             </if>
-            group by creative_id
-        ) a
-        left join  ctop_kuaishou_creative b on a.creativeId = b.creative_id
-    </select>
-
-    <select id="getKuaishouCreativeInfoByUnitId" 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.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',  -- 次日留存成本
-        (select url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as url,
-        (select cover_url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as coverUrl
-        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
-        left join ctop_kuaishou_creative c on a.creative_id = c.creative_id
-        where
-        a.stat_date &gt;= #{startDate}
-        and
-        a.stat_date &lt;= #{endDate}
-        <if test="unitId != null and unitId !='' ">
-            and
-            a.unit_id = #{unitId}
-        </if>
-        <if test="accountIds !=null">
-            and a.account_id in
-            <foreach collection="accountIds" item="item" separator=","
-                     open="(" close=")">
-                #{item}
-            </foreach>
+            <if test="accountIds !=null">
+                and a.account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            group by a.creative_id
+        )m
+        <if test="yn=1">
+            where m.charge != 0
         </if>
-        group by a.creative_id
     </select>
 
     <!-- 获取项目成员所在所有项目下的所有账户id -->

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

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

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

@@ -33,7 +33,7 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
 
     //获取快手参与的项目的信息
     @Override
-    public PageInfo<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ){
+    public PageInfo<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ,Integer yn){
         List<ProjectAccountDTO> projectAccountDTOList = new ArrayList<>();
 
         if(projectList==null || projectList.size()==0){
@@ -47,53 +47,18 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
             mediaIds.add(4L);
 
             if("admin".equals(roleCode)){
-                PageHelper.startPage(pageNum,pageSize);
-                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
+                projectList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
             }else{
-                PageHelper.startPage(pageNum,pageSize);
-                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByUserId(userId,mediaIds);
+                projectList = 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 new PageInfo<>(projectAccountDTOList);
+        PageHelper.startPage(pageNum,pageSize);
+        return new PageInfo<>(dailyAccountMapper.getKuaishouProjectInfo(startDate, endDate, projectList, yn));
     }
 
     @Override
-    public PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ){
+    public PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort,Integer yn ){
         List<ProjectAccountDTO> projectAccountDTOList = new ArrayList<>();
 
         if(projectList==null || projectList.size()==0){
@@ -107,54 +72,20 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
             mediaIds.add(4L);
 
             if("admin".equals(roleCode)){
-                PageHelper.startPage(pageNum,pageSize);
-                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
+                projectList = 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);
+                projectList = dailyAccountMapper.queryProjectInfoBySaleId(userId,mediaIds);
+            }
         }
 
-        return new PageInfo<>(projectAccountDTOList);
+        PageHelper.startPage(pageNum,pageSize);
+        return new PageInfo<>(dailyAccountMapper.getKuaishouProjectInfo(startDate,endDate,projectList,yn));
     }
 
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
@@ -170,11 +101,11 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
@@ -190,11 +121,11 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId,accountIds));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId,accountIds,yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
 
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
@@ -211,11 +142,11 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId,accountIds));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId,accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
@@ -231,7 +162,7 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId,accountIds);
+        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId,accountIds, yn);
         //for(KuaishouReportDailyAccountDTO creativeInfo:kuaishouCreativeInfoList){
         //    KuaishouVideoInfoDTO videoInfo = dailyAccountMapper.getVideoUrl(creativeInfo.getPhotoId());
         //    creativeInfo.setUrl(videoInfo.getUrl());

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

@@ -17,5 +17,5 @@ public class BytedanceInfoDTO extends PageInfo implements Serializable{
     private Long campaignId;
     private Long projectId;
     private String sort;
-
+    private Integer yn;
 }

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

@@ -408,7 +408,7 @@ public class BytedanceReportController {
         }
 
         try{
-            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceAccountInfoByProjectId(dto.getStartDate(), dto.getEndDate(), dto.getProjectId(),dto.getPageNum(),dto.getPageSize(),dto.getSort());
+            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceAccountInfoByProjectId(dto.getStartDate(), dto.getEndDate(), dto.getProjectId(),dto.getPageNum(),dto.getPageSize(),dto.getSort(), dto.getYn());
             result.setResult(byteDanceReportAccountDailyDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -445,7 +445,7 @@ public class BytedanceReportController {
         }
 
         try{
-            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),dto.getSort());
+            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),dto.getSort(), dto.getYn());
             result.setResult(byteDanceReportAccountDailyDTOList);
         }catch(Exception e){
             log.error(e.getMessage());

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

@@ -45,17 +45,17 @@ 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, @Param("accountIds")List<Long> accountIds);
+    List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    ByteDanceReportAccountDailyDTO getBytedanceProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+    List<ByteDanceReportAccountDailyDTO> getBytedanceProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
 
     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<Long> getSaleProjects(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
-    List<ByteDanceReportAccountDailyDTO> queryProjectInfoByAdmin(@Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectInfoByAdmin(@Param("mediaIds")List<Long> mediaIds);
 
     List<ByteDanceReportAccountDailyDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
 

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

@@ -287,16 +287,23 @@
     </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>
+        select * from (
+        select
+        concat(#{startDate},'~',#{endDate}) as statDate,
+        a.advertiser_id as 'accountId',
+        c.advertiser_id as 'advertiserId',
+        c.advertiser_name as 'advertiserName',
+        c.responsible_name as 'responsibleName',
+        c.design_responsible_name as 'designResponsibleName',
+        b.auth_name as 'authName',
+        b.project_id as 'projectId',
+        b.project_name as 'projectName',
+        c.media_id as 'mediaId',
+        <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
@@ -313,12 +320,28 @@
             </foreach>
         </if>
         group by a.advertiser_id
-        -- order by sum(a.cost) desc
+        order by sum(a.cost) desc
+        )m
+        <if test="yn =1">
+            where
+            m.cost != 0
+        </if>
     </select>
 
     <select id="getBytedanceProjectInfo" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
-            select
-            <include refid="selectSql"></include>
+        select * from (
+        select
+        concat(#{startDate},'~',#{endDate}) as statDate,
+        a.advertiser_id as 'accountId',
+        c.advertiser_id as 'advertiserId',
+        c.advertiser_name as 'advertiserName',
+        c.responsible_name as 'responsibleName',
+        c.design_responsible_name as 'designResponsibleName',
+        b.auth_name as 'authName',
+        b.project_id as 'projectId',
+        b.project_name as 'projectName',
+        c.media_id as 'mediaId',
+        <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
@@ -328,7 +351,17 @@
         and
         date_format(a.stat_datetime, '%Y-%m-%d') &lt;= #{endDate}
         and
-        b.project_id = #{projectId}
+        b.project_id in
+        <foreach collection="projectList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        group by b.project_id
+        )m
+        <if test="yn = 1">
+            where
+            m.cost != 0
+        </if>
     </select>
 
     <select id="getRoleCodeByUserId" resultType="string">
@@ -340,14 +373,14 @@
         where a.user_id = #{userId}
     </select>
 
-    <select id="queryProjectInfoByAdmin" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+    <select id="queryProjectInfoByAdmin" resultType="long">
         select
-        id as projectId,
-        project_name as projectName,
-        advertiser_id as advertiserId,
-        advertiser_name as advertiserName,
-        responsible_name as responsibleName,
-        media_id as mediaId
+        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
@@ -358,15 +391,15 @@
         </foreach>
     </select>
 
-    <select id="getSaleProjects" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+    <select id="getSaleProjects" resultType="long">
         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
+        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

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

@@ -21,9 +21,9 @@ public interface IBytedanceAccountReportService {
 
     //List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList);
 
-    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort);
+    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn);
 
-    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort);
+    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn);
 
     //List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, Long projectId, int pageNum, int pageSize, String sort);
 }

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

@@ -188,8 +188,8 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
     }
 
     @Override
-    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort){
-        List<ByteDanceReportAccountDailyDTO> list = new ArrayList<>();
+    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn){
+        //List<ByteDanceReportAccountDailyDTO> list = new ArrayList<>();
 
         if(projectList==null || projectList.size()==0){
             LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -202,64 +202,20 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
             mediaIds.add(3L);
 
             if("admin".equals(roleCode)){
-                PageHelper.startPage(pageNum,pageSize);
-                list = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
+                projectList = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
             }else{
-                PageHelper.startPage(pageNum,pageSize);
-                list = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
+                projectList = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
             }
-        }else{
-            PageHelper.startPage(pageNum,pageSize);
-            list = bytedanceAccountReportMapper.queryProjectMemberByIds(projectList);
         }
 
-        //List<ByteDanceReportAccountDailyDTO> projectAccountDTOList = new ArrayList<>();
+        PageHelper.startPage(pageNum,pageSize);
+        List<ByteDanceReportAccountDailyDTO> p = bytedanceAccountReportMapper.getBytedanceProjectInfo(startDate, endDate, projectList, yn);
 
-        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 new PageInfo<>(list);
+        return new PageInfo<>(p);
     }
 
     @Override
-    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort){
+    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn){
 
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
@@ -281,7 +237,7 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
         sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
         sort = sort.substring(0, sort.length() - 1);
         PageHelper.startPage(pageNo,pageSize,sort);
-        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId,accountIds));
+        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId,accountIds,yn));
     }