Forráskód Böngészése

飞书推送改版-时报

zhaotx 4 hónapja
szülő
commit
fcdd6b75dc

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

@@ -89,24 +89,63 @@
     </select>
     <select id="adHourData" resultType="java.util.Map">
         select
-        <include refid="costAmount"/>,
-        <include refid="realCostAmount"/>,
-        <include refid="payAmount"/>,
-        <include refid="shareIaaAmount"/>,
-        <include refid="realProfit"/>,
-        <include refid="waterProfit"/>,
-        <include refid="realRoi"/>,
-        <include refid="endAmount"/>
+            round(ifnull(sum(cost_amount),0), 2) as cost_amount,
+            round(ifnull(sum(mj_cost_amount),0), 2) as mj_cost_amount,
+            round(ifnull(sum(dj_cost_amount),0), 2) as dj_cost_amount,
+            round(ifnull(sum(real_cost_amount), 0), 2) as real_cost_amount,
+            round(ifnull(sum(dj_real_cost_amount), 0), 2) as dj_real_cost_amount,
+            round(ifnull(sum(mj_real_cost_amount), 0), 2) as mj_real_cost_amount,
+            round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
+            round(ifnull(sum(dj_pay_amount), 0), 2) AS dj_pay_amount,
+            round(ifnull(sum(mj_pay_amount), 0), 2) AS mj_pay_amount,
+            round(ifnull(sum(share_iaa_amount), 0), 2) as share_iaa_amount,
+            round(ifnull(sum(dj_share_iaa_amount), 0), 2) as dj_share_iaa_amount,
+            round(ifnull(sum(mj_share_iaa_amount), 0), 2) as mj_share_iaa_amount,
+            round(ifnull(sum(share_iaa_amount_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(sum(real_cost_amount), 0), 2) AS real_profit,
+            round(ifnull(sum(dj_share_iaa_amount_3), 0) + ifnull(sum(dj_share_pay_amount), 0) - ifnull(sum(dj_real_cost_amount), 0), 2) AS dj_real_profit,
+            round(ifnull(sum(mj_share_iaa_amount_3), 0) + ifnull(sum(mj_share_pay_amount), 0) - ifnull(sum(mj_real_cost_amount), 0), 2) AS mj_real_profit,
+            round(ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0), 2) AS water_profit,
+            round(ifnull(sum(dj_iaa_amount), 0) + ifnull(sum(dj_pay_amount), 0) - ifnull(sum(dj_cost_amount), 0), 2) AS dj_water_profit,
+            round(ifnull(sum(mj_iaa_amount), 0) + ifnull(sum(mj_pay_amount), 0) - ifnull(sum(mj_cost_amount), 0), 2) AS mj_water_profit,
+            concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount_3),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
+            concat(round(if(ifnull(sum(dj_real_cost_amount),0)=0, 0, (ifnull(sum(dj_share_iaa_amount_3),0)+ifnull(sum(dj_share_pay_amount),0))/sum(dj_real_cost_amount)*100), 2), '%') AS dj_real_roi,
+            concat(round(if(ifnull(sum(mj_real_cost_amount),0)=0, 0, (ifnull(sum(mj_share_iaa_amount_3),0)+ifnull(sum(mj_share_pay_amount),0))/sum(mj_real_cost_amount)*100), 2), '%') AS mj_real_roi,
+            round(ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0), 2) as end_amount,
+            round(ifnull(sum(dj_share_iaa_amount), 0) + ifnull(sum(dj_share_pay_amount), 0), 2) as dj_end_amount,
+            round(ifnull(sum(mj_share_iaa_amount), 0) + ifnull(sum(mj_share_pay_amount), 0), 2) as mj_end_amount
         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} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
+        (select sum(cost_amount) as cost_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(cost_amount, 0) else 0 end) as dj_cost_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(cost_amount, 0) else 0 end) as mj_cost_amount,
+        sum(real_cost_amount) as real_cost_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(real_cost_amount, 0) else 0 end) as dj_real_cost_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(real_cost_amount, 0) else 0 end) as mj_real_cost_amount
+        from application.media_ad_report_hourly t1
+        left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
+        join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
+        where stat_date = #{date} and `hour`= #{hour}
+        and t2.business_line in (1,6,7,4,8,9,10)
         ) tb1,
-        (select sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
+        (select sum(pay_amount) as pay_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(pay_amount, 0) else 0 end) as dj_pay_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(pay_amount, 0) else 0 end) as mj_pay_amount,
+        sum(share_iaa_amount) as share_iaa_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount, 0) else 0 end) as dj_share_iaa_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount, 0) else 0 end) as mj_share_iaa_amount,
         sum(share_iaa_amount_3) as share_iaa_amount_3,
-        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} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
+        sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as dj_share_iaa_amount_3,
+        sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as mj_share_iaa_amount_3,
+        sum(share_pay_amount) as share_pay_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(share_pay_amount, 0) else 0 end) as dj_share_pay_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(share_pay_amount, 0) else 0 end) as mj_share_pay_amount,
+        sum(iaa_amount) as iaa_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(iaa_amount, 0) else 0 end) as dj_iaa_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(iaa_amount, 0) else 0 end) as mj_iaa_amount
+        from application.user_data_report_hourly t1
+        left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
+        join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
+        where stat_date = #{date} and `hour`= #{hour}
+        and t2.business_line in (1,6,7,4,8,9,10)
         ) tb2
     </select>
     <select id="tmpTopMovie" resultType="java.util.Map">
@@ -163,31 +202,71 @@
 
     <select id="adDailyData" resultType="java.util.Map">
         select
-        <include refid="costAmount"/>,
-        <include refid="realCostAmount"/>,
-        <include refid="payAmount"/>,
-        <include refid="shareIaaAmount"/>,
-        <include refid="realProfit"/>,
-        <include refid="waterProfit"/>,
-        <include refid="realRoi"/>,
-        <include refid="endAmount"/>,
+        round(ifnull(sum(cost_amount),0), 2) as cost_amount,
+        round(ifnull(sum(mj_cost_amount),0), 2) as mj_cost_amount,
+        round(ifnull(sum(dj_cost_amount),0), 2) as dj_cost_amount,
+        round(ifnull(sum(real_cost_amount), 0), 2) as real_cost_amount,
+        round(ifnull(sum(dj_real_cost_amount), 0), 2) as dj_real_cost_amount,
+        round(ifnull(sum(mj_real_cost_amount), 0), 2) as mj_real_cost_amount,
+        round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
+        round(ifnull(sum(dj_pay_amount), 0), 2) AS dj_pay_amount,
+        round(ifnull(sum(mj_pay_amount), 0), 2) AS mj_pay_amount,
+        round(ifnull(sum(share_iaa_amount), 0), 2) as share_iaa_amount,
+        round(ifnull(sum(dj_share_iaa_amount), 0), 2) as dj_share_iaa_amount,
+        round(ifnull(sum(mj_share_iaa_amount), 0), 2) as mj_share_iaa_amount,
+        round(ifnull(sum(share_iaa_amount_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(sum(real_cost_amount), 0), 2) AS real_profit,
+        round(ifnull(sum(dj_share_iaa_amount_3), 0) + ifnull(sum(dj_share_pay_amount), 0) - ifnull(sum(dj_real_cost_amount), 0), 2) AS dj_real_profit,
+        round(ifnull(sum(mj_share_iaa_amount_3), 0) + ifnull(sum(mj_share_pay_amount), 0) - ifnull(sum(mj_real_cost_amount), 0), 2) AS mj_real_profit,
+        round(ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0), 2) AS water_profit,
+        round(ifnull(sum(dj_iaa_amount), 0) + ifnull(sum(dj_pay_amount), 0) - ifnull(sum(dj_cost_amount), 0), 2) AS dj_water_profit,
+        round(ifnull(sum(mj_iaa_amount), 0) + ifnull(sum(mj_pay_amount), 0) - ifnull(sum(mj_cost_amount), 0), 2) AS mj_water_profit,
+        concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount_3),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
+        concat(round(if(ifnull(sum(dj_real_cost_amount),0)=0, 0, (ifnull(sum(dj_share_iaa_amount_3),0)+ifnull(sum(dj_share_pay_amount),0))/sum(dj_real_cost_amount)*100), 2), '%') AS dj_real_roi,
+        concat(round(if(ifnull(sum(mj_real_cost_amount),0)=0, 0, (ifnull(sum(mj_share_iaa_amount_3),0)+ifnull(sum(mj_share_pay_amount),0))/sum(mj_real_cost_amount)*100), 2), '%') AS mj_real_roi,
+        round(ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0), 2) as end_amount,
+        round(ifnull(sum(dj_share_iaa_amount), 0) + ifnull(sum(dj_share_pay_amount), 0), 2) as dj_end_amount,
+        round(ifnull(sum(mj_share_iaa_amount), 0) + ifnull(sum(mj_share_pay_amount), 0), 2) as mj_end_amount,
         date_format(max(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 tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
+        (select sum(cost_amount) as cost_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(cost_amount, 0) else 0 end) as dj_cost_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(cost_amount, 0) else 0 end) as mj_cost_amount,
+        sum(real_cost_amount) as real_cost_amount,
+        sum(case t3.movie_type when 'DJ' then ifnull(real_cost_amount, 0) else 0 end) as dj_real_cost_amount,
+        sum(case t3.movie_type when 'MJ' then ifnull(real_cost_amount, 0) else 0 end) as mj_real_cost_amount,
+                max(t1.update_time) as update_time
+        from application.media_ad_report_daily t1
+        left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
+        join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
+        where stat_date = #{date}
+        and t2.business_line in (1,6,7,4,8,9,10)
         ) 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,
-        sum(share_iaa_amount_3) as share_iaa_amount_3
-        from application.user_data_report_daily
-        where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
+        (select sum(pay_amount) as pay_amount,
+                sum(case t3.movie_type when 'DJ' then ifnull(pay_amount, 0) else 0 end) as dj_pay_amount,
+                sum(case t3.movie_type when 'MJ' then ifnull(pay_amount, 0) else 0 end) as mj_pay_amount,
+                sum(share_iaa_amount) as share_iaa_amount,
+                sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount, 0) else 0 end) as dj_share_iaa_amount,
+                sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount, 0) else 0 end) as mj_share_iaa_amount,
+                sum(share_iaa_amount_3) as share_iaa_amount_3,
+                sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as dj_share_iaa_amount_3,
+                sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as mj_share_iaa_amount_3,
+                sum(share_pay_amount) as share_pay_amount,
+                sum(case t3.movie_type when 'DJ' then ifnull(share_pay_amount, 0) else 0 end) as dj_share_pay_amount,
+                sum(case t3.movie_type when 'MJ' then ifnull(share_pay_amount, 0) else 0 end) as mj_share_pay_amount,
+                sum(iaa_amount) as iaa_amount,
+                sum(case t3.movie_type when 'DJ' then ifnull(iaa_amount, 0) else 0 end) as dj_iaa_amount,
+                sum(case t3.movie_type when 'MJ' then ifnull(iaa_amount, 0) else 0 end) as mj_iaa_amount
+        from application.user_data_report_daily t1
+             left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
+             join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
+         where stat_date = #{date}
+           and t2.business_line in (1,6,7,4,8,9,10)
         ) tb2
     </select>
 
     <select id="todayTopMovie" resultType="com.alibaba.fastjson.JSONObject" >
         select
-        tb4.ly_movie_name as movie_name, tb4.movie_project_source, tb6.dict_name as movie_project_source_name,
+        tb4.ly_movie_name as movie_name, tb4.movie_project_source, tb6.dict_name as movie_project_source_name, tb4.movie_type,
         case
         when (DATEDIFF(STR_TO_DATE(tb1.stat_date, '%Y%m%d'), STR_TO_DATE(tb4.project_ad_date, '%Y%m%d')) + 1) between 1
         and 3 then '新剧1阶'
@@ -237,7 +316,7 @@
         group by movie_id
         ) tb3 on tb1.movie_id=tb3.movie_id
         left join
-        (select moive_id, standard_movie_id, standard_movie_name, movie_source, movie_project_source,project_ad_date, ly_movie_name from tidb.deepthink.all_moive
+        (select moive_id, standard_movie_id, standard_movie_name, movie_source, movie_project_source,project_ad_date, ly_movie_name, movie_type from tidb.deepthink.all_moive
         ) tb4 on tb1.movie_id=tb4.moive_id
         left join
         (select movie_id, ifnull(sum(cost_amount), 0) as hour_cost_amount from application.media_ad_report_hourly
@@ -247,7 +326,7 @@
         (select dict_key, dict_name from tidb.deepthink.dt_dictionary where select_key='movie_project_source'
         ) tb6 on tb4.movie_project_source=tb6.dict_key
         where 1=1 and tb1.movie_id != '-9999'
-        group by 1,2,3,4
+        group by 1,2,3,4,5
         order by ${sort}
         limit 20
     </select>

+ 8 - 6
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/MovieRankPushServiceImpl.java

@@ -21,10 +21,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -34,7 +31,7 @@ public class MovieRankPushServiceImpl implements IMovieRankPushService {
     ReportsAdPushMapper reportsAdPushMapper;
 
     public static final String TEMPLATE_ID = "AAqhiuoh0Nohp";
-    public static final String TEMPLATE_VERSION = "1.0.17";
+    public static final String TEMPLATE_VERSION = "1.0.19";
 
     @Override
     public void send() {
@@ -108,8 +105,13 @@ public class MovieRankPushServiceImpl implements IMovieRankPushService {
                 obj.put("iapCostAmount", m.getString("iap_cost_amount"));
                 String movieProjectSource = String.valueOf(m.get("movie_project_source_name"));
                 String projectAdStep = m.getString("project_ad_step");
+                String movieType = m.getString("movie_type");
+                if (movieType != null){
+                    movieType = Objects.equals(movieType, "MJ") ? "漫剧" : "短剧";
+                }
                 String sb = "<text_tag color='blue'>" + movieProjectSource + "</text_tag>" +
-                        "<text_tag color='green'>" + projectAdStep + "</text_tag>";
+                        "<text_tag color='green'>" + projectAdStep + "</text_tag>"
+                        + "<text_tag color='purple'>" + movieType + "</text_tag>";
                 obj.put("movieProjectSource", sb);
                 object_list.add(obj);
             }

+ 19 - 7
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ReportsAdPushServiceImpl.java

@@ -33,7 +33,7 @@ public class ReportsAdPushServiceImpl implements IReportsAdPushService {
     public static final String APP_KEY = "OUlg7WTa6UWZItfTmJw2JdQvhVI4VcRj";
 
     public static final String TEMPLATE_ID = "AAqBGlVblKabY";
-    public static final String TEMPLATE_VERSION = "1.0.24";
+    public static final String TEMPLATE_VERSION = "1.0.27";
     @Autowired
     ReportsAdPushMapper reportsPushMapper;
 
@@ -102,14 +102,26 @@ public class ReportsAdPushServiceImpl implements IReportsAdPushService {
 
         List<Pair<String, String>> columns = Arrays.asList(
                 new Pair<>("cost_amount", "消耗金额"),
-                new Pair<>("real_cost_amount", "折后消耗"),
+                new Pair<>("dj_cost_amount", "真人剧"),
+                new Pair<>("mj_cost_amount", "漫剧"),
+//                new Pair<>("real_cost_amount", "折后消耗"),
+//                new Pair<>("dj_real_cost_amount", "  真人剧折后消耗"),
+//                new Pair<>("mj_real_cost_amount", "  漫剧折后消耗"),
                 new Pair<>("end_amount", "结算金额"),
-                new Pair<>("pay_amount", "充值金额"),
-                new Pair<>("share_iaa_amount", "广告预估收入"),
-//                new Pair<>("water_roi", "流水ROI"),
+                new Pair<>("dj_end_amount", "  真人剧"),
+                new Pair<>("mj_end_amount", "  漫剧"),
+//                new Pair<>("pay_amount", "充值金额"),
+//                new Pair<>("dj_pay_amount", "  真人剧充值金额"),
+//                new Pair<>("mj_pay_amount", "  漫剧充值金额"),
+//                new Pair<>("share_iaa_amount", "广告预估收入"),
+//                new Pair<>("dj_share_iaa_amount", "  真人剧广告预估收入"),
+//                new Pair<>("mj_share_iaa_amount", "  漫剧广告预估收入"),
                 new Pair<>("real_roi", "投流真实ROI"),
-//                new Pair<>("water_profit", "流水利润"),
-                new Pair<>("real_profit", "真实利润")
+                new Pair<>("dj_real_roi", "  真人剧"),
+                new Pair<>("mj_real_roi", "  漫剧"),
+                new Pair<>("real_profit", "真实利润"),
+                new Pair<>("dj_real_profit", "  真人剧"),
+                new Pair<>("mj_real_profit", "  漫剧")
         );
 
         JSONArray object_list_1 = new JSONArray();