|
|
@@ -0,0 +1,157 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
|
|
+<mapper namespace="cn.com.ctop.job.bytedance.data.mapper.ReportsAdPushMapper">
|
|
|
+ <select id="tmpPushData" 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) + 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}
|
|
|
+ ) 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}
|
|
|
+ ) tb2
|
|
|
+ </select>
|
|
|
+ <select id="tmpPushHourData" 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) + 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
|
|
|
+ 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}
|
|
|
+ ) 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}
|
|
|
+ ) tb2
|
|
|
+ </select>
|
|
|
+ <select id="tmpTopMovie" resultType="java.util.Map">
|
|
|
+ select tb1.*, ifnull(COALESCE (tb2.movie_name, tb3.movie_name), tb1.movie_id) as movie_name
|
|
|
+ from
|
|
|
+ (select rank() over (order by ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) desc) as rk,
|
|
|
+ ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount, movie_id
|
|
|
+ from
|
|
|
+ application.user_data_report_daily udrd
|
|
|
+ where stat_date = #{date}
|
|
|
+ group by movie_id
|
|
|
+ having ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0)>0
|
|
|
+ order by end_amount desc
|
|
|
+ limit 10
|
|
|
+ ) tb1
|
|
|
+ left join
|
|
|
+ (select distinct movie_id, movie_name from deepthink.channel_changdunovel_info cci) tb2 on tb1.movie_id = tb2.movie_id
|
|
|
+ left JOIN
|
|
|
+ (select id, movie_name from hr_playlet.m_movie mm) tb3 on tb1.movie_id = tb3.id
|
|
|
+ order by rk
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="optimizerCostRank" resultType="java.util.Map">
|
|
|
+ select tb1.user_id, tb4.phonenumber,
|
|
|
+ rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
+ sum(cost_amount) as cost_amount,
|
|
|
+ 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
|
|
|
+ from
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, user_id from 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
|
|
|
+ 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
|
|
|
+ on tb1.advertiser_id = tb3.advertiser_id
|
|
|
+ left join (select user_id, nick_name, phonenumber from sys_user) tb4
|
|
|
+ on tb1.user_id=tb4.user_id
|
|
|
+ group by tb1.user_id
|
|
|
+ having sum(cost_amount)>1
|
|
|
+ order by rk asc
|
|
|
+ limit 10
|
|
|
+ </select>
|
|
|
+ <select id="optimizerDateData" resultType="java.util.Map">
|
|
|
+ select tb1.user_id,tb4.phonenumber,tb4.nick_name,
|
|
|
+ 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) + ifnull(sum(share_pay_amount), 0) as end_amount,
|
|
|
+ rank() over (order by sum(cost_amount) desc) as rk
|
|
|
+ from
|
|
|
+ (select advertiser_id, user_id from 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}
|
|
|
+ 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}
|
|
|
+ group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
|
+ left join (select user_id, nick_name, phonenumber from sys_user) tb4
|
|
|
+ on tb1.user_id=tb4.user_id
|
|
|
+ group by tb1.user_id
|
|
|
+ having sum(cost_amount)>0
|
|
|
+ </select>
|
|
|
+ <select id="optimizerHourData" resultType="java.util.Map">
|
|
|
+ select tb1.user_id,tb4.phonenumber,
|
|
|
+ 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) + ifnull(sum(share_pay_amount), 0) as end_amount
|
|
|
+ from
|
|
|
+ (select advertiser_id, user_id from 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}
|
|
|
+ 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}
|
|
|
+ group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
|
+ left join (select user_id, nick_name, phonenumber from sys_user) tb4
|
|
|
+ on tb1.user_id=tb4.user_id
|
|
|
+ group by tb1.user_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <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 advertiser_id, advertiser_name from advertiser_unbind_info) tb1
|
|
|
+ left join
|
|
|
+ (select advertiser_id, ifnull(sum(cost_amount),0) as ca from application.media_ad_report_daily where stat_date=#{date} group by advertiser_id) tb2
|
|
|
+ on tb1.advertiser_id = tb2.advertiser_id
|
|
|
+ left join
|
|
|
+ (select advertiser_id, ifnull(sum(cost_amount),0) as ca from application.media_ad_report_daily
|
|
|
+ where stat_date >= #{last30Day} and stat_date <= #{date} group by advertiser_id) tb3
|
|
|
+ on tb1.advertiser_id = tb3.advertiser_id
|
|
|
+ where tb3.ca >1
|
|
|
+ order by tb3.ca desc
|
|
|
+ </select>
|
|
|
+ <select id="selectUserList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select user_id, nick_name, phonenumber, remark
|
|
|
+ from sys_user u
|
|
|
+ left join 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 sys_dept t WHERE find_in_set(300, ancestors) ))
|
|
|
+ </select>
|
|
|
+</mapper>
|