فهرست منبع

飞书推送 更改数据范围

zhaotx 1 سال پیش
والد
کامیت
96d9c65adb

+ 13 - 4
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ReportsAdPushMapper.java

@@ -10,10 +10,19 @@ public interface ReportsAdPushMapper {
 
     List<JSONObject> selectUserList();
 
+    //给老板的
     Map<String, String> tmpPushData(@Param("date") Long date);
-    Map<String, String> tmpPushHourData(@Param("date") Long date, @Param("hour") String hour);
     List<Map<String, String>> tmpTopMovie(@Param("date") Long date);
+    //部门前后项数据排名
+    List<Map<String, String>> deptRank2(@Param("date") Long date);
+
+
+
+    //给投手的
+    Map<String, String> adDailyData(@Param("date") Long date);
+    Map<String, String> adHourData(@Param("date") Long date, @Param("hour") String hour);
 
+    List<JSONObject> todayTopMovie(@Param("date") Long date, @Param("hour") String hour);
     //所有优化师消耗排名
     List<Map<String, String>> optimizerCostRank(@Param("date") Long date, @Param("hour") String hour);
     //优化师当日数据
@@ -23,16 +32,16 @@ public interface ReportsAdPushMapper {
     //全部部门排行
     List<Map<String, String>> deptCostRank(@Param("date") Long date, @Param("hour") String hour);
 
+
+
     //漏绑账户预警
     List<Map<String, String>> unbindData(@Param("date") Long date, @Param("last90Day") Long last90Day,
                                          @Param("list") List<String> list);
-
     //错绑账户预警
     List<Map<String, String>> bindAppErrorData(@Param("last30Day") Long last30Day);
-    //部门前后项数据排名
-    List<Map<String, String>> deptRank2(@Param("date") Long date);
 
 
+    //剪辑
     List<Map<String, String>> cutDeptRank(@Param("date") Long date);
     List<Map<String, String>> cutUserRank(@Param("date") Long date, @Param("deptId") Long deptId);
     String updateTime(@Param("date") Long date);

+ 84 - 19
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ReportsAdPushMapper.xml

@@ -18,15 +18,15 @@
         from
         (select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount, max(update_time) as update_time
         from application.media_ad_report_daily
-        where stat_date = #{date}
+        where stat_date = #{date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         ) tb1,
         (select sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
         sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
         from application.user_data_report_daily
-        where stat_date = #{date}
+        where stat_date = #{date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         ) tb2
     </select>
-    <select id="tmpPushHourData" resultType="java.util.Map">
+    <select id="adHourData" resultType="java.util.Map">
         select concat(round(if(ifnull(sum(cost_amount),0)=0, 0, (ifnull(sum(iaa_amount),0)+ifnull(sum(pay_amount), 0))/sum(cost_amount)*100 ), 2), '%') AS water_roi,
         concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
         ifnull(sum(cost_amount),0) AS cost_amount,
@@ -38,12 +38,12 @@
         from
         (select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
         from application.media_ad_report_hourly
-        where stat_date = #{date} and `hour`= #{hour}
+        where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         ) tb1,
         (select sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
         sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
         from application.user_data_report_hourly
-        where stat_date = #{date} and `hour`= #{hour}
+        where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         ) tb2
     </select>
     <select id="tmpTopMovie" resultType="java.util.Map">
@@ -53,17 +53,18 @@
         concat(round(if(ifnull(sum(cost_amount),0)=0, 0, sum(end_amount)/sum(cost_amount)*100), 2), '%') AS water_roi,
         concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, sum(share_end_amount)/sum(real_cost_amount)*100), 2), '%') AS real_roi
         from
-        (select product_id from application.media_product_report_daily where stat_date=${date}
-        union select movie_id from application.user_data_report_daily where stat_date=${date}) tb1
+        (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        union select movie_id from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        ) tb1
         left join
         (select product_id, round(ifnull(sum(cost_amount),0),2) as cost_amount, sum(real_cost_amount) as real_cost_amount
-        from application.media_product_report_daily where stat_date=${date}
+        from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         group by product_id
         ) tb2 on tb1.product_id=tb2.product_id
         left join
         (select movie_id, ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) as end_amount,
         ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as share_end_amount
-        from application.user_data_report_daily where stat_date=${date}
+        from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         group by movie_id
         ) tb3 on tb1.product_id=tb3.movie_id
         left join
@@ -75,6 +76,64 @@
         limit 10
     </select>
 
+    <select id="adDailyData" resultType="java.util.Map">
+        select concat(round(if(ifnull(sum(cost_amount),0)=0, 0, (ifnull(sum(iaa_amount),0)+ifnull(sum(pay_amount), 0))/sum(cost_amount)*100 ), 2), '%') AS water_roi,
+        concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
+        ifnull(sum(cost_amount),0) AS cost_amount,
+        round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
+        ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
+        ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(round(sum(real_cost_amount), 2), 0) AS real_profit,
+        ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0) AS water_profit,
+        ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount,
+        date_format(update_time, '%Y-%m-%d %H:%i:%s') as update_time
+        from
+        (select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount, max(update_time) as update_time
+        from application.media_ad_report_daily
+        where stat_date = #{date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        ) tb1,
+        (select sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
+        sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
+        from application.user_data_report_daily
+        where stat_date = #{date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        ) tb2
+    </select>
+
+    <select id="todayTopMovie" resultType="com.alibaba.fastjson.JSONObject" >
+        select tb4.standard_movie_id,
+        tb4.standard_movie_name as movie_name,
+        group_concat(distinct case tb4.movie_source when 2 then 2 else 1 end) as movie_source,
+        sum(share_end_amount) as share_end_amount, sum(end_amount) as end_amount,
+        sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount,
+        concat(round(if(ifnull(sum(cost_amount),0)=0, 0, sum(end_amount)/sum(cost_amount)*100), 2), '%') AS water_roi,
+        concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, sum(share_end_amount)/sum(real_cost_amount)*100), 2), '%') AS real_roi,
+        round(ifnull(sum(hour_cost_amount), 0), 2) as hour_cost_amount
+        from
+        (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        union select movie_id from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))) tb1
+        left join
+        (select product_id, round(ifnull(sum(cost_amount),0),2) as cost_amount, sum(real_cost_amount) as real_cost_amount
+        from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by product_id
+        ) tb2 on tb1.product_id=tb2.product_id
+        left join
+        (select movie_id, ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) as end_amount,
+        ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as share_end_amount
+        from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by movie_id
+        ) tb3 on tb1.product_id=tb3.movie_id
+        left join
+        (select moive_id, standard_movie_id, standard_movie_name, movie_source from deepthink.all_moive
+        ) tb4 on tb1.product_id=tb4.moive_id
+        left join
+        (select product_id, ifnull(sum(cost_amount), 0) as hour_cost_amount from application.media_product_report_hourly
+        where stat_date=${date} and `hour`=${hour}  and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by product_id) tb5 on tb1.product_id=tb5.product_id
+        where 1=1 and tb1.product_id != '-9999'
+        group by tb4.standard_movie_name
+        order by sum(end_amount) desc
+        limit 10
+    </select>
+
 
     <select id="optimizerCostRank" resultType="java.util.Map">
         select tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id, tb5.dept_name,
@@ -84,10 +143,12 @@
         from
         (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
         left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
-        from application.media_ad_report_daily where stat_date=#{date} group by advertiser_id) tb2
+        from application.media_ad_report_daily where stat_date=#{date}  and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by advertiser_id) tb2
         on tb1.advertiser_id = tb2.advertiser_id
         left join (select advertiser_id, sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
-        from application.user_data_report_daily where stat_date=#{date} group by advertiser_id) tb3
+        from application.user_data_report_daily where stat_date=#{date}  and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by advertiser_id) tb3
         on tb1.advertiser_id = tb3.advertiser_id
         left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
         on tb1.user_id=tb4.user_id
@@ -110,13 +171,13 @@
         left join
         (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount, max(update_time) as update_time
         from application.media_ad_report_daily
-        where stat_date = #{date}
+        where stat_date = #{date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         group by advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
         left join
         (select advertiser_id, sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
         sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
         from application.user_data_report_daily
-        where stat_date = #{date}
+        where stat_date = #{date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
         left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
         on tb1.user_id=tb4.user_id
@@ -135,13 +196,13 @@
         left join
         (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount, max(update_time) as update_time
         from application.media_ad_report_hourly
-        where stat_date = #{date} and `hour`= #{hour}
+        where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         group by advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
         left join
         (select advertiser_id, sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
         sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
         from application.user_data_report_hourly
-        where stat_date = #{date} and `hour`= #{hour}
+        where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
         group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
         left join (select user_id, nick_name, phonenumber from deepthink.sys_user) tb4
         on tb1.user_id=tb4.user_id
@@ -158,10 +219,12 @@
         from
         (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
         left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
-        from application.media_ad_report_daily where stat_date=#{date} group by advertiser_id) tb2
+        from application.media_ad_report_daily where stat_date=#{date}  and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by advertiser_id) tb2
         on tb1.advertiser_id = tb2.advertiser_id
         left join (select advertiser_id, sum(cost_amount) as cost_amount_hour
-        from application.media_ad_report_hourly where stat_date=#{date} and `hour`= ${hour} group by advertiser_id) tb3
+        from application.media_ad_report_hourly where stat_date=#{date} and `hour`= ${hour}  and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by advertiser_id) tb3
         on tb1.advertiser_id = tb3.advertiser_id
         left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
         on tb1.user_id=tb4.user_id
@@ -244,10 +307,12 @@
         from
         (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
         left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
-        from application.media_ad_report_daily where stat_date=${date} group by advertiser_id) tb2
+        from application.media_ad_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by advertiser_id) tb2
         on tb1.advertiser_id = tb2.advertiser_id
         left join (select advertiser_id, sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
-        from application.user_data_report_daily where stat_date=${date} group by advertiser_id) tb3
+        from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,2,3,8))
+        group by advertiser_id) tb3
         on tb1.advertiser_id = tb3.advertiser_id
         left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
         on tb1.user_id=tb4.user_id

+ 2 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IDateReportsPushService.java

@@ -9,4 +9,6 @@ public interface IDateReportsPushService {
     void preSend();
 
     public void send12hour();
+
+    void test();
 }

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IReportsAdPushService.java

@@ -4,5 +4,5 @@ public interface IReportsAdPushService {
 
     void send();
 
-    void preSend();
+    void test();
 }

+ 10 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/DateReportsPushServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -33,7 +34,7 @@ public class DateReportsPushServiceImpl implements IDateReportsPushService {
     @Autowired
     ReportsAdPushMapper reportsPushMapper;
 
-    private static final String TEMPLATE_VERSION = "1.0.3";
+    private static final String TEMPLATE_VERSION = "1.0.6";
     private static final String TEMPLATE_ID = "AAqRhJzMBoO0E";
 
     /**
@@ -94,6 +95,11 @@ public class DateReportsPushServiceImpl implements IDateReportsPushService {
         sendParam("暂不包含广点通当日数据", userIds, chatid);
     }
 
+    @Override
+    public void test(){
+        sendParam("", Arrays.asList("44fbaed6"), Collections.EMPTY_LIST);
+    }
+
 
     private void sendParam(String description, List<String> userIds, List<String> chatid){
         String token;
@@ -168,7 +174,9 @@ public class DateReportsPushServiceImpl implements IDateReportsPushService {
             String movieSource = String.valueOf(movie.get("movie_source"));
             String movieName = String.valueOf(movie.get("movie_name"));
             if (!Check.isNull(movieSource) && movieSource.contains("1")){
-                movieName = "欢瑞自制-"+movieName;
+                obj.put("movieNameColor", "blue");
+            }else {
+                obj.put("movieNameColor", "grey");
             }
             obj.put("rank", String.valueOf(movie.get("rk")));
             obj.put("movieName", movieName);

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/OptimizerRankPushServiceImpl.java

@@ -32,7 +32,7 @@ public class OptimizerRankPushServiceImpl implements IOptimizerRankPushService {
     @Autowired
     ReportsAdPushMapper reportsPushMapper;
 
-    private static final String TEMPLATE_VERSION = "1.0.5";
+    private static final String TEMPLATE_VERSION = "1.0.6";
     private static final String TEMPLATE_ID = "AAqRUxrkkWuZf";
 
     public void send() {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 69 - 49
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ReportsAdPushServiceImpl.java