Przeglądaj źródła

王垒、李娜效果报表

hcst_sunzhen 4 lat temu
rodzic
commit
f06f472c19

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

@@ -144,7 +144,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(),dto.getProjectList(), 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> kuaishouReportDailyAccountDTOList = accountService.getKuaishouSaleAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouSaleAccountInfoByProjectId(dto.getProjectList(), dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouReportDailyAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -202,7 +202,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getProjectList(), dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -231,7 +231,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getProjectList(), dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -259,7 +259,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getProjectList(), dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());

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

@@ -20,11 +20,11 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     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, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("projectId")Long projectId, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @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, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("projectList")List<Long> projectList, @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, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
     List<Long> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
@@ -36,7 +36,7 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     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, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("projectList")List<Long> projectList, @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);
 

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

@@ -566,8 +566,8 @@
         end
         ) as 'photoClickCost', -- 平均封面点击单价
         (CASE
-        WHEN sum(a.photo_click) != 0
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        WHEN sum(a.bclick) != 0
+        THEN round(sum(a.charge) / sum(a.bclick),2)
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
@@ -594,10 +594,18 @@
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
+        <if test="projectId !=null ">
+        and
+        b.project_id = #{projectId}
+        </if>
 
-        <if test="projectId!=null and projectId != '' ">
+        <if test="projectList !=null ">
             and
-            b.project_id = #{projectId}
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
         </if>
         <if test="accountIds !=null">
             and a.account_id in
@@ -655,8 +663,8 @@
             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)
+            WHEN ( sum(a.bclick) is not null and sum(a.bclick) != 0)
+            THEN round(sum(a.charge) / sum(a.bclick),2)
             ELSE 0
             end
             ) as 'actionCost', -- 平均行为单价
@@ -736,8 +744,8 @@
         end
         ) as 'photoClickCost', -- 平均封面点击单价
         (CASE
-        WHEN sum(a.photo_click) != 0
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        WHEN sum(a.bclick) != 0
+        THEN round(sum(a.charge) / sum(a.bclick),2)
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
@@ -775,7 +783,14 @@
                 #{item}
             </foreach>
         </if>
-
+        <if test="projectList!=null">
+        and
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by a.campaign_id
         order by sum(a.charge) desc
 <!--        ) m-->
@@ -826,8 +841,8 @@
         end
         ) as 'photoClickCost', -- 平均封面点击单价
         (CASE
-        WHEN sum(a.photo_click) != 0
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        WHEN sum(a.bclick) != 0
+        THEN round(sum(a.charge) / sum(a.bclick),2)
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
@@ -855,7 +870,8 @@
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
-            <if test="campaignId != null and campaignId != ''">and
+            <if test="campaignId != null and campaignId != ''">
+            and
                 a.campaign_id = #{campaignId}
             </if>
             <if test="accountIds !=null">
@@ -865,6 +881,14 @@
                     #{item}
                 </foreach>
             </if>
+        <if test="projectList!=null">
+            and
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
             group by unit_id
             order by sum(a.charge) desc
 <!--            ) m-->
@@ -881,7 +905,7 @@
         ctop_project_member b
         left join ctop_project c on b.project_id = c.id
         where b.user_id = #{userId}
-        and a.media_id in
+        and c.media_id in
         <foreach collection="mediaIds" item="item" separator=","
                  open="(" close=")">
             #{item}
@@ -999,8 +1023,8 @@
             end
             ) as 'photoClickCost', -- 平均封面点击单价
             (CASE
-            WHEN sum(a.photo_click) != 0
-            THEN round(sum(a.charge) / sum(a.photo_click),2)
+            WHEN sum(a.bclick) != 0
+            THEN round(sum(a.charge) / sum(a.bclick),2)
             ELSE 0
             end
             ) as 'actionCost', -- 平均行为单价
@@ -1043,6 +1067,14 @@
                     #{item}
                 </foreach>
             </if>
+        <if test="projectList!=null">
+            and
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
             group by a.creative_id
             order by sum(a.charge) desc
 <!--        )m-->
@@ -1069,8 +1101,8 @@
         (select project_id,account_id,media_id from ctop_user_allocation  group by account_id) a
         left join ctop_project_member b on a.project_id=b.project_id
         where
-        and a.media_id in (2,4)
-        order by a.create_time desc
+        a.media_id in (2,4)
+        and user_id = #{userId}
         <if test="yn==1">
         limit 50
         </if>

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

@@ -20,14 +20,14 @@ public interface IKuaishouReportDailyAccountService extends IService<KuaishouRep
 
     PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(List<Long> projectList, Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, List<Long> projectList, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(List<Long> projectList, 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, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(List<Long> projectList, 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, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(List<Long> projectList, Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
 }

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

@@ -83,14 +83,14 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(List<Long> projectList, 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();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(projectId == null){
+        if(projectList == null && projectId==null){
             if("admin".equals(roleCode)){
                 accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(0);
             }else {
@@ -99,19 +99,23 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(projectId, startDate, endDate, projectList, accountIds, yn));
     }
 
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, List<Long> projectList, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
+        //List<Long> mediaIds = new ArrayList<>();
+        //mediaIds.add(2L);
+        //mediaIds.add(4L);
+
         List<Long> accountIds = null;
-        if(projectId == null){
+        if(projectId==null && projectList==null){
             if("admin".equals(roleCode)){
                 accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(0);
             }else {
@@ -120,18 +124,18 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(projectId, startDate, endDate, projectList, accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(List<Long> projectList, 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();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(accountId == null){
+        if(accountId == null && projectList==null){
             if("admin".equals(roleCode)){
                 accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(1);
             }else {
@@ -140,11 +144,11 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId,accountIds,yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(projectList, startDate, endDate, accountId,accountIds,yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(List<Long> projectList, Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
 
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
@@ -152,7 +156,7 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(campaignId == null){
+        if(campaignId == null && projectList == null){
             if("admin".equals(roleCode)){
                 accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(1);
             }else {
@@ -161,18 +165,18 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId,accountIds, yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(projectList, startDate, endDate, campaignId,accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(List<Long> projectList, 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();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(unitId == null){
+        if(unitId == null && projectList ==null){
             if("admin".equals(roleCode)){
                 accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(1);
             }else {
@@ -181,7 +185,7 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId,accountIds, yn);
+        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(projectList, startDate, endDate, unitId,accountIds, yn);
         //for(KuaishouReportDailyAccountDTO creativeInfo:kuaishouCreativeInfoList){
         //    KuaishouVideoInfoDTO videoInfo = dailyAccountMapper.getVideoUrl(creativeInfo.getPhotoId());
         //    creativeInfo.setUrl(videoInfo.getUrl());