|
|
@@ -12,60 +12,90 @@
|
|
|
<sql id="realRoi">
|
|
|
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
|
|
|
</sql>
|
|
|
+ <sql id="costAmount">
|
|
|
+ round(ifnull(sum(cost_amount),0), 2) AS cost_amount
|
|
|
+ </sql>
|
|
|
+ <sql id="payAmount">
|
|
|
+ round(ifnull(sum(pay_amount), 0), 2) AS pay_amount
|
|
|
+ </sql>
|
|
|
+ <sql id="endAmount">
|
|
|
+ round(ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0), 2) as end_amount
|
|
|
+ </sql>
|
|
|
+ <sql id="waterEndAmount">
|
|
|
+ round(ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0), 2) as water_end_amount
|
|
|
+ </sql>
|
|
|
+ <sql id="realProfit">
|
|
|
+ round(ifnull(sum(share_iaa_amount_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(sum(real_cost_amount), 0), 2) AS real_profit
|
|
|
+ </sql>
|
|
|
+ <sql id="waterProfit">
|
|
|
+ round(ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0), 2) AS water_profit
|
|
|
+ </sql>
|
|
|
+ <sql id="shareIaaAmount">
|
|
|
+ round(ifnull(sum(share_iaa_amount), 0), 2) as share_iaa_amount
|
|
|
+ </sql>
|
|
|
+ <sql id="iaaAmount">
|
|
|
+ round(ifnull(sum(iaa_amount), 0), 2) as iaa_amount
|
|
|
+ </sql>
|
|
|
+ <sql id="sharePayAmount">
|
|
|
+ round(ifnull(sum(share_pay_amount), 0), 2) as share_pay_amount
|
|
|
+ </sql>
|
|
|
+ <sql id="realCostAmount">
|
|
|
+ round(ifnull(sum(real_cost_amount), 0), 2) as real_cost_amount
|
|
|
+ </sql>
|
|
|
|
|
|
<select id="tmpPushData" resultType="java.util.Map">
|
|
|
select
|
|
|
- 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_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(round(sum(real_cost_amount), 2), 0) AS real_profit,
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="payAmount"/>,
|
|
|
+ <include refid="shareIaaAmount"/>,
|
|
|
+ <include refid="realProfit"/>,
|
|
|
+ <include refid="endAmount"/>
|
|
|
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,3,8))
|
|
|
+ where stat_date = ${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
) tb1,
|
|
|
(select sum(pay_amount) as pay_amount,
|
|
|
sum(iaa_amount) as iaa_amount,
|
|
|
- round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
|
+ sum(share_iaa_amount_3) as share_iaa_amount_3,
|
|
|
sum(share_pay_amount) as share_pay_amount,
|
|
|
sum(share_iaa_amount) as share_iaa_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,3,8))
|
|
|
+ where stat_date = ${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
) tb2
|
|
|
</select>
|
|
|
<select id="adHourData" resultType="java.util.Map">
|
|
|
select
|
|
|
- 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,
|
|
|
- round(ifnull(sum(share_iaa_amount_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(sum(real_cost_amount), 0), 2) 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
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="payAmount"/>,
|
|
|
+ <include refid="shareIaaAmount"/>,
|
|
|
+ <include refid="realProfit"/>,
|
|
|
+ <include refid="waterProfit"/>,
|
|
|
+ <include refid="endAmount"/>
|
|
|
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 deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
) tb1,
|
|
|
(select sum(pay_amount) as pay_amount, sum(iaa_amount) as 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 deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
) tb2
|
|
|
</select>
|
|
|
<select id="tmpTopMovie" resultType="java.util.Map">
|
|
|
- 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,
|
|
|
+ select tb4.standard_movie_name as movie_name,
|
|
|
+ group_concat(distinct case tb4.movie_source when 2 then '2' else '1' end) as movie_source,
|
|
|
rank() over (order by sum(iaa_amount)+sum(pay_amount) desc) as rk,
|
|
|
- round(sum(share_pay_amount)+sum(share_iaa_amount),2) as share_end_amount, sum(iaa_amount)+sum(pay_amount) as end_amount,
|
|
|
- sum(cost_amount) as cost_amount,
|
|
|
- round(sum(real_cost_amount),2) as real_cost_amount,
|
|
|
+ <include refid="endAmount"/>,
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="realCostAmount"/>,
|
|
|
concat(round(if(ifnull(sum(iaa_real_cost_amount),0)=0, 0, sum(share_iaa_amount_3)/sum(iaa_real_cost_amount)*100), 2), '%') AS iaa_roi,
|
|
|
concat(round(if(ifnull(sum(iap_real_cost_amount),0)=0, 0, sum(share_pay_amount)/sum(iap_real_cost_amount)*100), 2), '%') AS iap_roi
|
|
|
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,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,3,8))
|
|
|
+ (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ union select movie_id 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_type in (1,3,8))
|
|
|
) tb1
|
|
|
left join
|
|
|
(select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
|
@@ -74,11 +104,12 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
from
|
|
|
(select product_id, round(ifnull(sum(cost_amount),0),2) as iaa_cost_amount, sum(real_cost_amount) as iaa_real_cost_amount, 0 as iap_cost_amount, 0 as iap_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,3,8) and business_method='IAA')
|
|
|
+ from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAA')
|
|
|
group by product_id
|
|
|
union all
|
|
|
- select product_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,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,3,8) and business_method='IAP')
|
|
|
+ select product_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,
|
|
|
+ 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 tidb.deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAP')
|
|
|
group by product_id) subt2
|
|
|
group by product_id
|
|
|
) tb2 on tb1.product_id=tb2.product_id
|
|
|
@@ -88,11 +119,11 @@
|
|
|
ifnull(sum(share_pay_amount), 0) as share_pay_amount,
|
|
|
ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3
|
|
|
- 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,3,8))
|
|
|
+ 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_type in (1,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
|
|
|
+ (select moive_id, standard_movie_id, standard_movie_name, movie_source from tidb.deepthink.all_moive
|
|
|
) tb4 on tb1.product_id=tb4.moive_id
|
|
|
where 1=1 and tb1.product_id!='-9999'
|
|
|
group by tb4.standard_movie_name
|
|
|
@@ -102,38 +133,40 @@
|
|
|
|
|
|
<select id="adDailyData" resultType="java.util.Map">
|
|
|
select
|
|
|
- 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,
|
|
|
- round(ifnull(sum(share_iaa_amount_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(sum(real_cost_amount), 0), 2) 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
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="payAmount"/>,
|
|
|
+ <include refid="shareIaaAmount"/>,
|
|
|
+ <include refid="realProfit"/>,
|
|
|
+ <include refid="waterProfit"/>,
|
|
|
+ <include refid="endAmount"/>,
|
|
|
+ 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 deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,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,
|
|
|
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 deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
) tb2
|
|
|
</select>
|
|
|
|
|
|
<select id="todayTopMovie" resultType="com.alibaba.fastjson.JSONObject" >
|
|
|
- select tb4.standard_movie_id,
|
|
|
+ select
|
|
|
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_iaa_amount)+sum(share_pay_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,
|
|
|
+ group_concat(distinct case tb4.movie_source when 2 then '2' else '1' end) as movie_source,
|
|
|
+ <include refid="endAmount"/>,
|
|
|
+ <include refid="waterEndAmount"/>,
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="realCostAmount"/>,
|
|
|
concat(round(if(ifnull(sum(iaa_real_cost_amount),0)=0, 0, sum(share_iaa_amount_3)/sum(iaa_real_cost_amount)*100), 2), '%') AS iaa_roi,
|
|
|
concat(round(if(ifnull(sum(iap_real_cost_amount),0)=0, 0, sum(share_pay_amount)/sum(iap_real_cost_amount)*100), 2), '%') AS iap_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,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,3,8))) tb1
|
|
|
+ (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ union select movie_id 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_type in (1,3,8))) tb1
|
|
|
left join
|
|
|
(
|
|
|
select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
|
@@ -142,32 +175,32 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
from
|
|
|
(select product_id, round(ifnull(sum(cost_amount),0),2) as iaa_cost_amount, sum(real_cost_amount) as iaa_real_cost_amount, 0 as iap_cost_amount, 0 as iap_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,3,8) and business_method='IAA')
|
|
|
+ from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAA')
|
|
|
group by product_id
|
|
|
union all
|
|
|
select product_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,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,3,8) and business_method='IAP')
|
|
|
+ from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAP')
|
|
|
group by product_id) subt2
|
|
|
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,
|
|
|
- round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
|
+ (select movie_id, sum(iaa_amount) as iaa_amount, sum(pay_amount) as pay_amount,
|
|
|
+ sum(share_iaa_amount_3) as share_iaa_amount_3,
|
|
|
ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
ifnull(sum(share_pay_amount), 0) 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,3,8))
|
|
|
+ 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_type in (1,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
|
|
|
+ (select moive_id, standard_movie_id, standard_movie_name, movie_source from tidb.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,3,8))
|
|
|
+ where stat_date=${date} and `hour`=${hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,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
|
|
|
+ order by end_amount desc
|
|
|
limit 10
|
|
|
</select>
|
|
|
|
|
|
@@ -175,11 +208,11 @@
|
|
|
<select id="optimizerCostRank" resultType="java.util.Map">
|
|
|
select tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id, tb5.dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
- sum(cost_amount) as cost_amount,
|
|
|
+ <include refid="costAmount"/>,
|
|
|
concat(round(if(ifnull(sum(iaa_real_cost_amount),0)=0, 0, sum(share_iaa_amount_3)/sum(iaa_real_cost_amount)*100), 2), '%') AS iaa_roi,
|
|
|
concat(round(if(ifnull(sum(iap_real_cost_amount),0)=0, 0, sum(share_pay_amount)/sum(iap_real_cost_amount)*100), 2), '%') AS iap_roi
|
|
|
from
|
|
|
- (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info) tb1
|
|
|
left join
|
|
|
(select advertiser_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
|
sum(iap_cost_amount) as iap_cost_amount, sum(iap_real_cost_amount) as iap_real_cost_amount,
|
|
|
@@ -187,11 +220,11 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
FROM
|
|
|
(select advertiser_id, round(ifnull(sum(cost_amount),0),2) as iaa_cost_amount, sum(real_cost_amount) as iaa_real_cost_amount, 0 as iap_cost_amount, 0 as iap_real_cost_amount
|
|
|
- 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,3,8) and business_method='IAA')
|
|
|
+ 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_type in (1,3,8) and business_method='IAA')
|
|
|
group by advertiser_id
|
|
|
UNION ALL
|
|
|
select advertiser_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,round(ifnull(sum(cost_amount),0),2) as iap_cost_amount, sum(real_cost_amount) as iap_real_cost_amount
|
|
|
- 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,3,8) and business_method='IAP')
|
|
|
+ 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_type in (1,3,8) and business_method='IAP')
|
|
|
group by advertiser_id)subtb2
|
|
|
group by advertiser_id
|
|
|
) tb2
|
|
|
@@ -200,64 +233,64 @@
|
|
|
round(ifnull(sum(share_iaa_amount_3), 0),2) 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_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ 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_type in (1,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
|
|
|
+ left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
- left join (select dept_id, dept_name from deepthink.sys_dept) tb5
|
|
|
+ left join (select dept_id, dept_name from tidb.deepthink.sys_dept) tb5
|
|
|
on tb4.dept_id = tb5.dept_id
|
|
|
- group by tb1.user_id
|
|
|
+ group by tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id, tb5.dept_name
|
|
|
having sum(cost_amount)>1
|
|
|
order by rk asc
|
|
|
</select>
|
|
|
<select id="optimizerDateData" resultType="java.util.Map">
|
|
|
select tb1.user_id,tb4.phonenumber,tb4.nick_name, tb4.dept_id,
|
|
|
- ifnull(sum(cost_amount),0) AS cost_amount,
|
|
|
- ifnull(sum(iaa_amount), 0) as iaa_amount,
|
|
|
- round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount,
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="iaaAmount"/>,
|
|
|
+ <include refid="payAmount"/>,
|
|
|
+ <include refid="endAmount"/>,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk
|
|
|
from
|
|
|
- (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info) tb1
|
|
|
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} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,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} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,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
|
|
|
+ left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
- group by tb1.user_id
|
|
|
+ group by tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id
|
|
|
having sum(cost_amount)>0
|
|
|
</select>
|
|
|
<select id="optimizerHourData" resultType="java.util.Map">
|
|
|
select tb1.user_id,tb4.phonenumber,
|
|
|
- ifnull(sum(cost_amount),0) AS cost_amount,
|
|
|
- ifnull(sum(iaa_amount), 0) as iaa_amount,
|
|
|
- round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="iaaAmount"/>,
|
|
|
+ <include refid="payAmount"/>,
|
|
|
+ <include refid="endAmount"/>
|
|
|
from
|
|
|
- (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info) tb1
|
|
|
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} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,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} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,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
|
|
|
+ left join (select user_id, nick_name, phonenumber from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
- group by tb1.user_id
|
|
|
+ group by tb1.user_id, tb4.phonenumber
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@@ -265,23 +298,23 @@
|
|
|
<select id="deptCostRank" resultType="java.util.Map">
|
|
|
select tb4.dept_id, tb5.dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
- ifnull(sum(cost_amount), 0) as cost_amount,
|
|
|
+ <include refid="costAmount"/>,
|
|
|
ifnull(sum(cost_amount_hour), 0) as cost_amount_hour
|
|
|
from
|
|
|
- (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, user_id from tidb.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} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ 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_type in (1,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} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
+ 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_type in (1,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
|
|
|
+ left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
- left join (select dept_id, dept_name from deepthink.sys_dept) tb5
|
|
|
+ left join (select dept_id, dept_name from tidb.deepthink.sys_dept) tb5
|
|
|
on tb4.dept_id = tb5.dept_id
|
|
|
- group by tb4.dept_id
|
|
|
+ group by tb4.dept_id, tb5.dept_name
|
|
|
having sum(cost_amount)>1
|
|
|
order by rk asc
|
|
|
limit 10
|
|
|
@@ -290,7 +323,7 @@
|
|
|
|
|
|
<select id="unbindData" resultType="java.util.Map">
|
|
|
select tb1.advertiser_id, tb1.advertiser_name, ifnull(tb2.ca,0) as today_cost, tb3.ca as last_30_cost from
|
|
|
- (select cast(advertiser_id as char) advertiser_id, advertiser_name from deepthink.advertiser_unbind_info
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, advertiser_name from tidb.deepthink.advertiser_unbind_info
|
|
|
where 1=1
|
|
|
<if test="list != null and list.size > 0">
|
|
|
and advertiser_id in
|
|
|
@@ -311,10 +344,10 @@
|
|
|
</select>
|
|
|
<select id="selectUserList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
select user_id, nick_name, phonenumber, remark, u.dept_id
|
|
|
- from deepthink.sys_user u
|
|
|
- left join deepthink.sys_dept d on u.dept_id = d.dept_id
|
|
|
+ from tidb.deepthink.sys_user u
|
|
|
+ left join tidb.deepthink.sys_dept d on u.dept_id = d.dept_id
|
|
|
where u.del_flag = '0'
|
|
|
- AND (u.dept_id = 300 OR u.dept_id IN ( SELECT t.dept_id FROM deepthink.sys_dept t WHERE find_in_set(300, ancestors) ))
|
|
|
+ AND (u.dept_id = 300 OR u.dept_id IN ( SELECT t.dept_id FROM tidb.deepthink.sys_dept t WHERE find_in_set(300, ancestors) ))
|
|
|
</select>
|
|
|
<select id="bindAppErrorData" resultType="java.util.Map">
|
|
|
select tb1.advertiser_id, tb2.advertiser_name, tb1.ma_appid as right_app, tb2.ma_appid as error_app,
|
|
|
@@ -335,17 +368,17 @@
|
|
|
) t2 where t2.rn = 1
|
|
|
) tb1
|
|
|
inner join
|
|
|
- (select advertiser_id, advertiser_name, ma_appid, user_id from deepthink.advertiser_bind_info
|
|
|
+ (select advertiser_id, advertiser_name, ma_appid, user_id from tidb.deepthink.advertiser_bind_info
|
|
|
where advertiser_id not in (select advertiser_id from application.user_data_report_daily
|
|
|
where stat_date >= #{last30Day} and advertiser_id!='-9999'
|
|
|
group by advertiser_id having count(distinct ma_appid)>1)
|
|
|
) tb2
|
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
|
- left join (select distinct app_id, app_name from deepthink.mini_app_info) tb3
|
|
|
+ left join (select distinct app_id, app_name from tidb.deepthink.mini_app_info) tb3
|
|
|
on tb1.ma_appid = tb3.app_id
|
|
|
- left join (select distinct app_id, app_name from deepthink.mini_app_info) tb4
|
|
|
+ left join (select distinct app_id, app_name from tidb.deepthink.mini_app_info) tb4
|
|
|
on tb2.ma_appid = tb4.app_id
|
|
|
- left join (select user_id, phonenumber, nick_name from deepthink.sys_user) tb5
|
|
|
+ left join (select user_id, phonenumber, nick_name from tidb.deepthink.sys_user) tb5
|
|
|
on tb2.user_id=tb5.user_id
|
|
|
where tb1.ma_appid != tb2.ma_appid
|
|
|
order by tb2.user_id
|
|
|
@@ -353,11 +386,11 @@
|
|
|
<select id="deptRank2" resultType="java.util.Map">
|
|
|
select tb4.dept_id, tb5.dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
- ifnull(sum(cost_amount), 0) as cost_amount,
|
|
|
+ <include refid="costAmount"/>,
|
|
|
concat(round(if(ifnull(sum(iaa_real_cost_amount),0)=0, 0, sum(share_iaa_amount_3)/sum(iaa_real_cost_amount)*100), 2), '%') AS iaa_roi,
|
|
|
concat(round(if(ifnull(sum(iap_real_cost_amount),0)=0, 0, sum(share_pay_amount)/sum(iap_real_cost_amount)*100), 2), '%') AS iap_roi
|
|
|
from
|
|
|
- (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info) tb1
|
|
|
left join
|
|
|
(select advertiser_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
|
sum(iap_cost_amount) as iap_cost_amount, sum(iap_real_cost_amount) as iap_real_cost_amount,
|
|
|
@@ -365,11 +398,11 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
FROM
|
|
|
(select advertiser_id, round(ifnull(sum(cost_amount),0),2) as iaa_cost_amount, sum(real_cost_amount) as iaa_real_cost_amount, 0 as iap_cost_amount, 0 as iap_real_cost_amount
|
|
|
- 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,3,8) and business_method='IAA')
|
|
|
+ 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_type in (1,3,8) and business_method='IAA')
|
|
|
group by advertiser_id
|
|
|
UNION ALL
|
|
|
select advertiser_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,round(ifnull(sum(cost_amount),0),2) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
- 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,3,8) and business_method='IAP')
|
|
|
+ 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_type in (1,3,8) and business_method='IAP')
|
|
|
group by advertiser_id)subtb2
|
|
|
group by advertiser_id
|
|
|
) tb2
|
|
|
@@ -378,19 +411,19 @@
|
|
|
round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
|
ifnull(sum(share_iaa_amount), 0) 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,3,8))
|
|
|
+ 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_type in (1,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
|
|
|
+ left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
- left join (select dept_id, dept_name from deepthink.sys_dept) tb5
|
|
|
+ left join (select dept_id, dept_name from tidb.deepthink.sys_dept) tb5
|
|
|
on tb4.dept_id = tb5.dept_id
|
|
|
- group by tb4.dept_id
|
|
|
+ group by tb4.dept_id, tb5.dept_name
|
|
|
having sum(cost_amount)>1
|
|
|
order by rk
|
|
|
</select>
|
|
|
<select id="cutDeptRank" resultType="java.util.Map">
|
|
|
- select row_number() over (order by cost desc) as ranks,
|
|
|
+ select row_number() over (order by sum(cost) desc) as ranks,
|
|
|
dept_name as dept_name,
|
|
|
round(sum(cost),2) as todayData,
|
|
|
concat(round(ifnull(sum(conversion_num)/sum(click)*100,0),2),'%') as conversionRate
|
|
|
@@ -398,9 +431,9 @@
|
|
|
(select stat_datetime, customer_user_name2, CAST(cost AS float) as 'cost', conversion_num, click
|
|
|
from media_api.media_material_designer_report
|
|
|
where stat_datetime=${date} ) a
|
|
|
- left join deepthink.sys_user b
|
|
|
+ left join tidb.deepthink.sys_user b
|
|
|
on a.customer_user_name2=b.nick_name
|
|
|
- left join deepthink.sys_dept c
|
|
|
+ left join tidb.deepthink.sys_dept c
|
|
|
on b.dept_id=c.dept_id
|
|
|
where dept_name is not null
|
|
|
group by dept_name
|
|
|
@@ -411,23 +444,23 @@
|
|
|
b.phonenumber as phonenumber,
|
|
|
CAST(cost AS float) as rankTodayData,
|
|
|
concat(round(ifnull(conversion_num/click*100,0),2),'%') as conversionRate
|
|
|
- from media_api.media_material_designer_report a
|
|
|
- left join deepthink.sys_user b
|
|
|
+ from tidb.media_api.media_material_designer_report a
|
|
|
+ left join tidb.deepthink.sys_user b
|
|
|
on a.customer_user_name2=b.nick_name
|
|
|
- left join deepthink.sys_dept c
|
|
|
+ left join tidb.deepthink.sys_dept c
|
|
|
on b.dept_id=c.dept_id
|
|
|
where stat_datetime=${date} and b.dept_id=${deptId}
|
|
|
</select>
|
|
|
<select id="allBusinessPushData" resultType="java.util.Map">
|
|
|
select
|
|
|
- ifnull(sum(cost_amount),0) AS cost_amount,
|
|
|
- round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
- round(ifnull(sum(iaa_amount), 0), 2) as iaa_amount,
|
|
|
- ifnull(sum(share_iaa_amount), 0) as 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,
|
|
|
- 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
|
|
|
+ <include refid="costAmount"/>,
|
|
|
+ <include refid="payAmount"/>,
|
|
|
+ <include refid="iaaAmount"/>,
|
|
|
+ <include refid="shareIaaAmount"/>,
|
|
|
+ <include refid="realProfit"/>,
|
|
|
+ <include refid="waterProfit"/>,
|
|
|
+ <include refid="endAmount"/>,
|
|
|
+ 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
|
|
|
@@ -435,17 +468,16 @@
|
|
|
) 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,
|
|
|
- round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3
|
|
|
+ sum(share_iaa_amount_3) as share_iaa_amount_3
|
|
|
from application.user_data_report_daily
|
|
|
where stat_date = #{date}
|
|
|
) tb2
|
|
|
</select>
|
|
|
<select id="allBusinessTopMovie" resultType="java.util.Map">
|
|
|
- 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,
|
|
|
+ select tb4.standard_movie_name as movie_name, group_concat(distinct case tb4.movie_source when 2 then '2' else '1' end) as movie_source,
|
|
|
rank() over (order by sum(share_iaa_amount)+sum(share_pay_amount) desc) as rk,
|
|
|
- round(sum(share_iaa_amount)+sum(share_pay_amount),2) as share_end_amount,
|
|
|
- round(sum(iaa_amount)+sum(pay_amount),2) as end_amount,
|
|
|
- sum(cost_amount) as cost_amount
|
|
|
+ <include refid="endAmount"/>,
|
|
|
+ <include refid="costAmount"/>
|
|
|
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}
|
|
|
@@ -465,7 +497,7 @@
|
|
|
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
|
|
|
+ (select moive_id, standard_movie_id, standard_movie_name, movie_source from tidb.deepthink.all_moive
|
|
|
) tb4 on tb1.product_id=tb4.moive_id
|
|
|
where 1=1 and tb1.product_id!='-9999'
|
|
|
group by tb4.standard_movie_name
|
|
|
@@ -473,13 +505,14 @@
|
|
|
limit 10
|
|
|
</select>
|
|
|
<select id="businessTypeData" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- select ifnull(sum(share_pay_amount),0) as iap_end_amount,
|
|
|
- ifnull(sum(share_iaa_amount),0) as iaa_end_amount,
|
|
|
- ifnull(sum(share_pay_amount),0) + ifnull(sum(share_iaa_amount),0) as end_amount,
|
|
|
- ifnull(sum(pay_amount),0)+ ifnull(sum(iaa_amount),0) as water_end_amount
|
|
|
+ select
|
|
|
+ <include refid="sharePayAmount"/>,
|
|
|
+ <include refid="shareIaaAmount"/>,
|
|
|
+ <include refid="endAmount"/>,
|
|
|
+ <include refid="waterEndAmount"/>
|
|
|
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
|
|
|
+ (select app_id from tidb.deepthink.mini_app_info where business_type in
|
|
|
<if test="businessTypes != null and businessTypes.size > 0">
|
|
|
<foreach item="item" index="index" collection="businessTypes" open="(" separator="," close=")">
|
|
|
#{item}
|