Pārlūkot izejas kodu

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

syh 4 gadi atpakaļ
vecāks
revīzija
9022df6608
20 mainītis faili ar 609 papildinājumiem un 513 dzēšanām
  1. 26 0
      jeecg-boot-module-system/pom.xml
  2. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 1 1
      jeecg-boot-module-system/src/main/resources/application.yml
  4. 35 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  5. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouInfoDTO.java
  6. 12 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  7. 201 228
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  8. 8 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  9. 37 86
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java
  10. 80 33
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceAdvertisePlanController.java
  11. 107 50
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertisePlanServiceImpl.java
  12. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/BytedanceInfoDTO.java
  13. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  14. 6 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java
  15. 75 27
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml
  16. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java
  17. 11 55
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java
  18. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java
  19. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/utils/LinkUtils.java
  20. 1 1
      module-toutiao/src/main/resources/bytedance_config.properties

+ 26 - 0
jeecg-boot-module-system/pom.xml

@@ -179,6 +179,32 @@
             <version>7.6.0.Final</version>
         </dependency>
 
+        <!--drools规则引擎-->
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-core</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-compiler</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-templates</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.kie</groupId>
+            <artifactId>kie-api</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.kie</groupId>
+            <artifactId>kie-spring</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
     </dependencies>
 
     <dependencyManagement>

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

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

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: @activatedProperties@
+    active: test
   application:
     name: system-web
 #分页pageHelper

+ 35 - 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,36 @@ 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());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouSaleAccountInfoByProjectId")
+    public Result<PageInfo<KuaishouReportDailyAccountDTO>> getKuaishouSaleAccountInfoByProjectId(@RequestBody KuaishouInfoDTO dto) {
+        Result<PageInfo<KuaishouReportDailyAccountDTO>> 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{
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouSaleAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouReportDailyAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -173,7 +202,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 +231,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 +259,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;
 
 }

+ 12 - 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);
 
@@ -45,4 +45,8 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
     List<Long> getUserProjectAccountIdsByAdmin();
 
 
+
+    List<Long> getSaleProjectAccountIds(@Param("userId")String userId);
+
+
 }

+ 201 - 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 -->
@@ -1128,4 +1087,17 @@
         limit 50
     </select>
 
+    <select id="getSaleProjectAccountIds" resultType="long">
+        select
+        a.account_id
+        from
+        (select project_id,account_id,media_id,create_time from ctop_user_allocation  group by account_id) a
+        left join ctop_project b on a.project_id=b.id
+        where
+        b.sale_id = #{userId}
+        and b.media_id in (1,3)
+        order by a.create_time desc
+        limit 50
+    </select>
+
 </mapper>

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

@@ -16,16 +16,18 @@ 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> getKuaishouSaleAccountInfoByProjectId(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> getKuaishouAccountInfoByProjectId(Long projectId, 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> getKuaishouCampaignInfoByAccountId(Long accountId, 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> 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, Integer yn);
 
 }

+ 37 - 86
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,40 @@ 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);
+
+                projectList = 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);
+        PageHelper.startPage(pageNum,pageSize);
+        return new PageInfo<>(dailyAccountMapper.getKuaishouProjectInfo(startDate,endDate,projectList,yn));
+    }
+
+    @Override
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(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("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getSaleProjectAccountIds(userId);
+            }
         }
 
-        return new PageInfo<>(projectAccountDTOList);
+        PageHelper.startPage(pageNum,pageSize);
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, 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 +121,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 +141,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 +162,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 +182,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());

+ 80 - 33
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceAdvertisePlanController.java

@@ -1,9 +1,11 @@
 package cn.com.ctop.toutiao.modules.material.controller;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -43,18 +45,22 @@ public class ByteDanceAdvertisePlanController {
                                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                HttpServletRequest req) {
         Result<IPage<ByteDanceAdvertisePlan>> result = new Result<>();
-        if(!accountId.isEmpty()){
+        if (!accountId.isEmpty()) {
             byteDanceAdvertisePlan.setAccountId(accountId);
         }
+        if(byteDanceAdvertisePlan.getToutiaoStatus()!=null){
+            String toutiaoStatus="AD_STATUS"+byteDanceAdvertisePlan.getToutiaoStatus();
+            byteDanceAdvertisePlan.setToutiaoStatus(toutiaoStatus);
+        }
         QueryWrapper<ByteDanceAdvertisePlan> queryWrapper = QueryGenerator.initQueryWrapper(byteDanceAdvertisePlan, req.getParameterMap());
         Page<ByteDanceAdvertisePlan> page = new Page<>(pageNo, pageSize);
         IPage<ByteDanceAdvertisePlan> pageList = byteDanceAdvertisePlanService.page(page, queryWrapper);
         //处理计划投放状态
-        if(!pageList.getRecords().isEmpty()){
-            pageList.getRecords().forEach(it->{
-                if(it.getToutiaoStatus().equals("AD_STATUS_DELIVERY_OK")){
+        if (!pageList.getRecords().isEmpty()) {
+            pageList.getRecords().forEach(it -> {
+                if (it.getToutiaoStatus().equals("AD_STATUS_DELIVERY_OK")) {
                     it.setStatus(true);
-                }else{
+                } else {
                     it.setStatus(false);
                 }
             });
@@ -68,25 +74,25 @@ public class ByteDanceAdvertisePlanController {
      * 添加
      */
     @PostMapping(value = "/add")
-        public Result<List<ByteDanceAdvertisePlan>> add(@RequestBody ByteDanceAdvertisePlan byteDanceAdvertisePlan) {
+    public Result<List<ByteDanceAdvertisePlan>> add(@RequestBody ByteDanceAdvertisePlan byteDanceAdvertisePlan) {
 
         Result<List<ByteDanceAdvertisePlan>> result = new Result<>();
-        List<String> names= (List) byteDanceAdvertisePlan.getNames();
+        List<String> names = (List) byteDanceAdvertisePlan.getNames();
         String landingType = byteDanceAdvertisePlan.getLandingType();
-        List<ByteDanceAdvertisePlan> byteDanceAdvertisePlanList=new ArrayList<>();
+        List<ByteDanceAdvertisePlan> byteDanceAdvertisePlanList = new ArrayList<>();
         try {
-            names.forEach(name->{
+            for (String name : names) {
                 byteDanceAdvertisePlan.setName(name);
                 Map<String, Object> advertiserPlan = byteDanceAdvertisePlanService.createAdvertiserPlan(ctopOauthTokenService.getTokenByAccountId(Long.valueOf(byteDanceAdvertisePlan.getAccountId())), landingType, byteDanceAdvertisePlan);
-                if(advertiserPlan.get("code").equals(0)){
-                    byteDanceAdvertisePlan.setId(Long.valueOf(((Map)advertiserPlan.get("data")).get("ad_id").toString()));
-                    byteDanceAdvertisePlanService.save(byteDanceAdvertisePlan);
-                    byteDanceAdvertisePlanList.add(byteDanceAdvertisePlan);
-                }else {
+                if (advertiserPlan.get("code").equals(0)) {
+                    byteDanceAdvertisePlan.setId(((ByteDanceAdvertisePlan)advertiserPlan.get("data")).getId());
+                    byteDanceAdvertisePlanService.save((ByteDanceAdvertisePlan)advertiserPlan.get("data"));
+                    byteDanceAdvertisePlanList.add(byteDanceAdvertisePlanService.getById(((ByteDanceAdvertisePlan) advertiserPlan.get("data")).getId()));
+                } else {
                     result.setCode(-200);
                     result.setMessage(advertiserPlan.get("message").toString());
                 }
-            });
+            }
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             result.error500("操作失败");
@@ -101,36 +107,77 @@ public class ByteDanceAdvertisePlanController {
     @PostMapping(value = "/edit")
     public Result<ByteDanceAdvertisePlan> edit(@RequestBody ByteDanceAdvertisePlan byteDanceAdvertisePlan) {
         Result<ByteDanceAdvertisePlan> result = new Result<>();
-        ByteDanceAdvertisePlan byteDanceAdvertisePlanEntity = byteDanceAdvertisePlanService.getById(byteDanceAdvertisePlan.getId());
-        if (byteDanceAdvertisePlanEntity == null) {
-            result.error500("未找到数据");
-        } else {
+        String landingType = byteDanceAdvertisePlan.getLandingType();
+        Map<String, Object> map = byteDanceAdvertisePlanService.updateAdvertiserPlan(ctopOauthTokenService.getTokenByAccountId(Long.valueOf(byteDanceAdvertisePlan.getAccountId())), landingType, byteDanceAdvertisePlan);
+        if(!map.get("code").equals(0)){
+            result.error500(map.get("message").toString());
+        }else {
             boolean ok = byteDanceAdvertisePlanService.updateById(byteDanceAdvertisePlan);
             if (ok) {
                 result.success("修改成功!");
-            }else {
+            } else {
                 result.error500("未知错误");
             }
         }
-
         return result;
     }
 
-    @PostMapping(value = "/batchEdit")
-    public Result<List<ByteDanceAdvertisePlan>> edit(@RequestBody List<ByteDanceAdvertisePlan> byteDanceAdvertisePlanList) {
+    @PostMapping(value = "/batchEdit/{operate}")
+    public Result<List<ByteDanceAdvertisePlan>> edit(@RequestBody List<ByteDanceAdvertisePlan> byteDanceAdvertisePlanList,
+                                                     @PathVariable String operate) {
         Result<List<ByteDanceAdvertisePlan>> result = new Result<>();
-        byteDanceAdvertisePlanList.forEach(it->{
-            ByteDanceAdvertisePlan byteDanceAdvertisePlanEntity = byteDanceAdvertisePlanService.getById(it.getId());
-            if (byteDanceAdvertisePlanEntity == null) {
-                result.error500("未找到数据");
-            } else {
-                boolean ok = byteDanceAdvertisePlanService.updateById(it);
-                if (ok) {
-                    result.success("修改成功!");
-                }else {
-                    result.error500("未知错误");
+        if (byteDanceAdvertisePlanList.isEmpty()) {
+            log.error("未选择数据");
+            result.error500("请选择数据");
+        }
+        CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(Long.valueOf(byteDanceAdvertisePlanList.get(0).getAccountId()));
+        try {
+            if ("status".equals(operate)) {
+                JSONArray adIds = new JSONArray();
+                String optStatus = byteDanceAdvertisePlanList.get(0).getOptStatus();
+                byteDanceAdvertisePlanList.forEach(it -> {
+                    adIds.add(it.getId());
+                });
+                Map<String, Object> map = byteDanceAdvertisePlanService.updateAdvertiserPlanStatus(token, adIds, optStatus);
+                if (!map.get("code").equals(0)) {
+                    result.error500(map.get("message").toString());
+                    return result;
+                }
+            } else if ("bid".equals(operate)) {
+                JSONArray adIds = new JSONArray();
+                JSONArray bids = new JSONArray();
+                byteDanceAdvertisePlanList.forEach(it -> {
+                    adIds.add(it.getId());
+                    bids.add(it.getBid());
+                });
+                Map<String, Object> map = byteDanceAdvertisePlanService.updateAdvertiserPlanBid(token, adIds, bids);
+                if (!map.get("code").equals(0)) {
+                    result.error500(map.get("message").toString());
+                    return result;
+                }
+            } else if ("budget".equals(operate)) {
+                JSONArray adIds = new JSONArray();
+                JSONArray budgets = new JSONArray();
+                byteDanceAdvertisePlanList.forEach(it -> {
+                    adIds.add(it.getId());
+                    budgets.add(it.getBudget());
+                });
+                Map<String, Object> map = byteDanceAdvertisePlanService.updateAdvertiserPlanBudget(token, adIds, budgets);
+                if (!map.get("code").equals(0)) {
+                    result.error500(map.get("message").toString());
+                    return result;
                 }
             }
+        } catch (Exception e) {
+            log.error("头条批量更新接口错误");
+        }
+        byteDanceAdvertisePlanList.forEach(it -> {
+            boolean ok = byteDanceAdvertisePlanService.updateById(it);
+            if (ok) {
+                result.success("修改成功!");
+            } else {
+                result.error500("未知错误");
+            }
         });
         result.setResult(byteDanceAdvertisePlanList);
         return result;

+ 107 - 50
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertisePlanServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -55,7 +56,9 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         params.put("start_time", byteDanceAdvertisePlan.getStartTime());
         params.put("end_time", byteDanceAdvertisePlan.getEndTime());
         //广告投放时段
-        //params.put("schedule_time",byteDanceAdvertisePlan.getString("scheduleTime"));
+        if(!byteDanceAdvertisePlan.getScheduleTime().equals("")){
+            params.put("schedule_time",byteDanceAdvertisePlan.getScheduleTime());
+        }
         params.put("pricing", byteDanceAdvertisePlan.getPricing());
         params.put("bid", byteDanceAdvertisePlan.getBid());
         params.put("cpa_bid", byteDanceAdvertisePlan.getCpaBid());
@@ -65,7 +68,9 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
                 //查询必填参数convert_id
                 params.put("convert_id", byteDanceAdvertisePlan.getConvertId());
             }else{
-                params.put("convert_id",getConvertIdByExternalAction(byteDanceAdvertisePlan.getExternalAction()));
+                int convertId=getConvertIdByExternalAction(byteDanceAdvertisePlan.getExternalAction());
+                params.put("convert_id",convertId);
+                byteDanceAdvertisePlan.setConvertId((long) convertId);
             }
         }
         params.put("deep_bid_type", byteDanceAdvertisePlan.getDeepBidType());
@@ -124,7 +129,8 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpPostRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_create"), params, headers));
         if (jsonObject.getInteger("code") == 0) {
             resultMap.put("code", 0);
-            resultMap.put("data",jsonObject.getJSONObject("data"));
+            byteDanceAdvertisePlan.setId(jsonObject.getJSONObject("data").getLong("ad_id"));
+            resultMap.put("data",byteDanceAdvertisePlan);
         } else {
             log.error("广告计划创建失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             resultMap.put("code",-200);
@@ -138,53 +144,70 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
 
         Map<String, Object> resultMap = new HashMap<>();
 
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", token.getAccessToken());
-
-        JSONObject params = new JSONObject();
-        params.put("advertiser_id", byteDanceAdvertisePlan.getAccountId());
-        params.put("ad_id", byteDanceAdvertisePlan.getId());
-        params.put("name", byteDanceAdvertisePlan.getName());
-        params.put("modify_time", byteDanceAdvertisePlan.getModifyTime());
-        params.put("budget", byteDanceAdvertisePlan.getBudget());
-        params.put("schedule_type", byteDanceAdvertisePlan.getScheduleType());
-        params.put("start_time", byteDanceAdvertisePlan.getStartTime());
-        params.put("end_time", byteDanceAdvertisePlan.getEndTime());
-        //广告投放时段
-        params.put("schedule_time",byteDanceAdvertisePlan.getScheduleTime());
-        params.put("bid", byteDanceAdvertisePlan.getBid());
-        params.put("cpa_bid", byteDanceAdvertisePlan.getCpaBid());
-        params.put("flow_control_mode", byteDanceAdvertisePlan.getFlowControlMode());
-        if (byteDanceAdvertisePlan.getPricing().equals("OCPM")) {
+        //查询记录,获取修改时间等字段
+        List adId=new ArrayList();
+        adId.add(byteDanceAdvertisePlan.getId());
+        Map<String, Object> map = queryAdByAdId(token, Long.valueOf(byteDanceAdvertisePlan.getAccountId()), adId);
+        if(!map.get("code").equals(0)){
+            log.error("获取修改时间接口错误");
+        }else {
+            Object modifyTime = ((Map) ((JSONObject) map.get("data")).getJSONArray("list").get(0)).get("modify_time");
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", token.getAccessToken());
+
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", byteDanceAdvertisePlan.getAccountId());
+            params.put("ad_id", byteDanceAdvertisePlan.getId());
+            params.put("name", byteDanceAdvertisePlan.getName());
+            params.put("modify_time", modifyTime);
+            params.put("budget", byteDanceAdvertisePlan.getBudget());
+            params.put("schedule_type", byteDanceAdvertisePlan.getScheduleType());
+            params.put("start_time", byteDanceAdvertisePlan.getStartTime());
+            params.put("end_time", byteDanceAdvertisePlan.getEndTime());
+            //广告投放时段
+            if(!byteDanceAdvertisePlan.getScheduleTime().equals("")){
+                params.put("schedule_time",byteDanceAdvertisePlan.getScheduleTime());
+            }
+            params.put("bid", byteDanceAdvertisePlan.getBid());
+            params.put("cpa_bid", byteDanceAdvertisePlan.getCpaBid());
+            params.put("flow_control_mode", byteDanceAdvertisePlan.getFlowControlMode());
             params.put("convert_id", byteDanceAdvertisePlan.getConvertId());
-        }
-        params.put("deep_bid_type", byteDanceAdvertisePlan.getDeepBidType());
-        params.put("deep_cpabid", byteDanceAdvertisePlan.getDeepCpaBid());
-        params.put("hide_if_converted", byteDanceAdvertisePlan.getHideIfConverted());
-        params.put("hide_if_exists", byteDanceAdvertisePlan.getHideIfExists() == null ? 0 : byteDanceAdvertisePlan.getHideIfExists());
-        params.put("converted_time_duration", byteDanceAdvertisePlan.getConvertedTimeDuration());
-        //params.put("luban_roi_goal",byteDanceAdvertisePlan.getLubanRoiGoal()==null?0.00:byteDanceAdvertisePlan.getFloat("lubanRoiGoal"));
-        //params.put("roi_goal",byteDanceAdvertisePlan.getFroiGoal")==null?0.00:byteDanceAdvertisePlan.getFloat("roiGoal"));
-        //params.put("audience_package_id",byteDanceAdvertisePlan.getLong("audiencePackageId"));
-        params.put("open_url", byteDanceAdvertisePlan.getOpenUrl());
-        //判断推广目的
-        if (landingType.equals("Link")) {
+            params.put("deep_bid_type", byteDanceAdvertisePlan.getDeepBidType());
+            params.put("deep_cpabid", byteDanceAdvertisePlan.getDeepCpaBid());
+            params.put("hide_if_converted", byteDanceAdvertisePlan.getHideIfConverted());
+            params.put("hide_if_exists", byteDanceAdvertisePlan.getHideIfExists() == null ? 0 : byteDanceAdvertisePlan.getHideIfExists());
+            //params.put("converted_time_duration", byteDanceAdvertisePlan.getConvertedTimeDuration());
+            //params.put("luban_roi_goal",byteDanceAdvertisePlan.getLubanRoiGoal()==null?0.00:byteDanceAdvertisePlan.getFloat("lubanRoiGoal"));
+            //params.put("roi_goal",byteDanceAdvertisePlan.getFroiGoal")==null?0.00:byteDanceAdvertisePlan.getFloat("roiGoal"));
+            //params.put("audience_package_id",byteDanceAdvertisePlan.getLong("audiencePackageId"));
+            params.put("adjust_cpa", 0);
+            //暂时不需要定向包id
+            //params.put("audience_package_id",byteDanceAdvertisePlan.getLong("audiencePackageId"));
+        /*if(byteDanceAdvertisePlan.getUseOpenUrl().equals("YES")){
+            params.put("open_url", byteDanceAdvertisePlan.getOpenUrl());
+        }*/
+            //判断推广目的
+        /*if (landingType.equals("LINK")) {
             params.put("external_url", byteDanceAdvertisePlan.getExternalUrl());
         }
         if (landingType.equals("APP")) {
-            params.put("download_type", byteDanceAdvertisePlan.getExternalUrl());
-
-        }
-        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpPostRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update"), params, headers));
-        if (jsonObject.getInteger("code") != 0) {
-            log.error("广告计划创建失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
-            resultMap.put("code", -1);
-            resultMap.put("message", jsonObject.getString("message"));
-            return resultMap;
+            params.put("download_type", byteDanceAdvertisePlan.getDownloadType());
+            params.put("download_url", byteDanceAdvertisePlan.getDownloadUrl());
+            params.put("package", byteDanceAdvertisePlan.getToutiaoPackage());
+            params.put("app_type",byteDanceAdvertisePlan.getAppType());
+        }*/
+            JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpPostRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update"), params, headers));
+            if (jsonObject.getInteger("code") != 0) {
+                log.error("广告计划修改失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
+                resultMap.put("code", -1);
+                resultMap.put("message", jsonObject.getString("message"));
+                return resultMap;
+            }
+            resultMap.put("code", 0);
+            resultMap.put("message", "广告组状态修改成功");
         }
-        resultMap.put("code", 0);
-        resultMap.put("message", "广告组状态修改成功");
+
         return resultMap;
     }
 
@@ -194,7 +217,17 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token.getAccessToken());
-
+        switch (optStatus) {
+            case "AD_STATUS_DISABLE":
+                optStatus = "disable";
+                break;
+            case "AD_STATUS_ENABLE":
+                optStatus = "enable";
+                break;
+            case "AD_STATUS_DELETE":
+                optStatus = "delete";
+                break;
+        }
         JSONObject params = new JSONObject();
         params.put("advertiser_id", token.getAccountId());
         params.put("ad_ids", adIds.toJSONString());
@@ -220,8 +253,8 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         if (adIds.size() > 0) {
             for (int i = 0; i < adIds.size(); i++) {
                 JSONObject object = new JSONObject();
-                Long adId = (Long)adIds.get(i);
-                Long budget = (Long)budgets.get(i);
+                Long adId = Long.valueOf(adIds.get(i).toString());
+                Long budget = Long.valueOf(budgets.get(i).toString());
                 object.put("ad_id", adId);
                 object.put("budget", budget);
                 data.add(object);
@@ -255,8 +288,8 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         if (adIds.size() > 0) {
             for (int i = 0; i < adIds.size(); i++) {
                 JSONObject object = new JSONObject();
-                Long adId = (Long)adIds.get(i);
-                Long bid = (Long)bids.get(i);
+                Long adId = Long.valueOf(adIds.get(i).toString());
+                Long bid = Long.valueOf(bids.get(i).toString());
                 object.put("ad_id", adId);
                 object.put("bid", bid);
                 data.add(object);
@@ -375,6 +408,30 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         return byteDanceAdvertisePlanMapper.selectWarningCpaBid(accountId, maxCapBid);
     }
 
+    private Map<String, Object> queryAdByAdId(CtopOauthToken token, Long accountId, List adId){
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", accountId);
+        Map<String, Object> filtering = new HashMap<>();
+        filtering.put("ids",adId);
+        params.put("filtering", filtering);
+        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpGetRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get"), headers, params));
+        Map<String, Object> resultMap = new HashMap<>();
+        if (jsonObject.getInteger("code") == 0) {
+            resultMap.put("code", 0);
+            resultMap.put("data",jsonObject.getJSONObject("data"));
+        } else {
+            log.error("广告计划查询失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
+            resultMap.put("code",-200);
+            resultMap.put("message", jsonObject.getString("message"));
+        }
+        return resultMap;
+    }
+
     private int getConvertIdByExternalAction(String externalAction){
         int result=0;
         switch (externalAction) {

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

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

@@ -45,22 +45,24 @@ 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);
 
     List<Long> getUserProjectAccountIds(@Param("userId")String userId);
 
+    List<Long> getSaleProjectAccountIds(@Param("userId")String userId);
+
     List<Long> getUserProjectAccountIdsByAdmin();
 
 }

+ 75 - 27
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
@@ -402,14 +435,29 @@
         select
         a.account_id
         from
-        (select project_id,account_id,media_id from ctop_user_allocation  group by account_id) a
+        (select project_id,account_id,media_id,create_time from ctop_user_allocation  group by account_id) a
         left join ctop_project_member b on a.project_id=b.project_id
         where
+        a.user_id = #{userId}
         and a.media_id in (1,3)
         order by a.create_time desc
         limit 50
     </select>
 
+
+    <select id="getSaleProjectAccountIds" resultType="long">
+        select
+        a.account_id
+        from
+        (select project_id,account_id,media_id,create_time from ctop_user_allocation  group by account_id) a
+        left join ctop_project b on a.project_id=b.id
+        where
+        b.sale_id = #{userId}
+        and b.media_id in (1,3)
+        order by a.create_time desc
+        limit 50
+    </select>
+
     <select id="getUserProjectAccountIdsByAdmin" resultType="long">
         select
         a.account_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);
 }

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

@@ -4,7 +4,7 @@ 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 cn.com.ctop.toutiao.modules.report.utils.LinkUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
@@ -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";
@@ -271,7 +227,7 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
             if("admin".equals(roleCode)){
                 accountIds = bytedanceAccountReportMapper.getUserProjectAccountIdsByAdmin();
             }else {
-                accountIds = bytedanceAccountReportMapper.getUserProjectAccountIds(userId);
+                accountIds = bytedanceAccountReportMapper.getSaleProjectAccountIds(userId);
             }
         }
 
@@ -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));
     }
 
 

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

@@ -2,7 +2,7 @@ package cn.com.ctop.toutiao.modules.report.service.impl;
 
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceHomepageMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceHomepageReportService;
-import cn.com.ctop.toutiao.modules.utils.LinkUtils;
+import cn.com.ctop.toutiao.modules.report.utils.LinkUtils;
 import com.alibaba.fastjson.JSONObject;
 import org.jeecg.common.constant.SystemDateConstant;
 import org.jeecg.common.util.DateUtils;

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/utils/LinkUtils.java

@@ -1,4 +1,4 @@
-package cn.com.ctop.toutiao.modules.utils;
+package cn.com.ctop.toutiao.modules.report.utils;
 
 import com.alibaba.fastjson.JSONObject;
 

+ 1 - 1
module-toutiao/src/main/resources/bytedance_config.properties

@@ -16,7 +16,7 @@ bytedance_v2_advertiser_info=/2/advertiser/public_info/
 bytedance_v2_ad_get=/2/ad/get/
 bytedance_v2_advertiser_fund_daily_stat=/2/advertiser/fund/daily_stat/
 bytedance_v2_ad_create=/2/ad/create/
-bytedance_v2_ad_update=2/ad/update/
+bytedance_v2_ad_update=/2/ad/update/
 bytedance_v2_ad_update_status=/2/ad/update/status/
 bytedance_v2_ad_update_bid=/2/ad/update/bid/
 bytedance_v2_ad_update_budget=/2/ad/update/budget/