|
@@ -5,15 +5,14 @@
|
|
|
<select id="queryTodaySumReportBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
ROUND(sum(cost),2) cost,
|
|
|
- sum(show_num) showNum,
|
|
|
+ sum(`show`) showNum,
|
|
|
sum(click) click,
|
|
|
- sum(convert_num) as convertNum,
|
|
|
- max(stat_hour) maxHour
|
|
|
+ sum(`convert`) as convertNum,
|
|
|
+ max(`hour`) maxHour
|
|
|
FROM
|
|
|
- ctop_bytedance_report_advertiser_hourly
|
|
|
- WHERE
|
|
|
- stat_datetime = #{statDate}
|
|
|
- AND advertiser_id in
|
|
|
+ application.bytedance_advertiser_report_hourly_dw
|
|
|
+ WHERE stat_datetime = DATE_FORMAT(#{statDate},'%Y%m%d')
|
|
|
+ AND account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
@@ -21,48 +20,44 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="queryTodayReportByAccount" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT
|
|
|
- ROUND(sum(cost),2) cost,
|
|
|
- sum(show_num) showNum,
|
|
|
- sum(click) click,
|
|
|
- sum(convert_num) as convertNum
|
|
|
- FROM
|
|
|
- ctop_bytedance_report_advertiser_daily
|
|
|
- WHERE
|
|
|
- stat_datetime = #{statDate} '00:00:00'
|
|
|
- AND advertiser_id= #{accountId}
|
|
|
+ SELECT ROUND(sum(cost), 2) cost,
|
|
|
+ sum(show_num) showNum,
|
|
|
+ sum(click) click,
|
|
|
+ sum(convert_num) as convertNum
|
|
|
+ FROM ctop_bytedance_report_advertiser_daily
|
|
|
+ WHERE stat_datetime = #{statDate} '00:00:00'
|
|
|
+ AND account_id= #{accountId}
|
|
|
</select>
|
|
|
|
|
|
<select id="queryTodaySumByHourGroupAccount" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
- t2.account_id as accountId,
|
|
|
- t2.auth_name as authName,
|
|
|
+ t1.account_id as accountId,
|
|
|
+ t1.account_name as authName,
|
|
|
${filed}
|
|
|
- FROM ctop_bytedance_report_advertiser_hourly t1
|
|
|
- left join ctop_user_allocation t2 on t1.advertiser_id=t2.account_id
|
|
|
- WHERE t1.stat_datetime = #{statDate}
|
|
|
- and t1.stat_hour <= #{hour}
|
|
|
- AND t1.advertiser_id in
|
|
|
+ FROM application.bytedance_advertiser_report_hourly_dw t1
|
|
|
+ WHERE t1.stat_datetime = DATE_FORMAT(#{statDate}, '%Y%m%d' )
|
|
|
+ and t1.`hour` <= #{hour}
|
|
|
+ AND t1.account_id IN
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- group by t1.advertiser_id
|
|
|
+ group by t1.account_id
|
|
|
order by ${target} ${order}
|
|
|
</select>
|
|
|
|
|
|
<select id="queryTodaySumByHour" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
ROUND(sum(cost),2) cost,
|
|
|
- sum(show_num) showNum,
|
|
|
+ sum(`show`) showNum,
|
|
|
sum(click) click,
|
|
|
- sum(convert_num) as convertNum
|
|
|
+ sum(`convert`) as convertNum
|
|
|
FROM
|
|
|
- ctop_bytedance_report_advertiser_hourly
|
|
|
+ application.bytedance_advertiser_report_hourly_dw
|
|
|
WHERE
|
|
|
- stat_datetime = #{statDate}
|
|
|
- and stat_hour <= #{hour}
|
|
|
- AND advertiser_id in
|
|
|
+ stat_datetime = DATE_FORMAT(#{statDate},'%Y%m%d')
|
|
|
+ and `hour` <= #{hour}
|
|
|
+ AND account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
@@ -73,11 +68,11 @@
|
|
|
SELECT
|
|
|
${filed}
|
|
|
FROM
|
|
|
- ctop_bytedance_report_advertiser_hourly t1
|
|
|
+ application.bytedance_advertiser_report_hourly_dw t1
|
|
|
WHERE
|
|
|
- t1.stat_datetime = #{statDate}
|
|
|
- and t1.stat_hour <= #{hour}
|
|
|
- AND t1.advertiser_id in
|
|
|
+ t1.stat_datetime = DATE_FORMAT(#{statDate},'%Y%m%d')
|
|
|
+ and t1.`hour` <= #{hour}
|
|
|
+ AND t1.account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
@@ -87,32 +82,32 @@
|
|
|
<select id="queryTodayDetailReportBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
ROUND(sum(cost),2) cost,
|
|
|
- sum(show_num) showNum,
|
|
|
+ sum(`show`) showNum,byteDance/dailyPage
|
|
|
sum(click) click,
|
|
|
- sum(convert_num) as convertNum,
|
|
|
- stat_hour as statHour
|
|
|
+ sum(`convert`) as convertNum,
|
|
|
+ `hour` as statHour
|
|
|
FROM
|
|
|
- ctop_bytedance_report_advertiser_hourly
|
|
|
+ application.bytedance_advertiser_report_hourly_dw
|
|
|
WHERE
|
|
|
- stat_datetime = #{statDate}
|
|
|
- AND advertiser_id in
|
|
|
+ stat_datetime = DATE_FORMAT(#{statDate},'%Y%m%d')
|
|
|
+ AND account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
GROUP BY
|
|
|
- stat_hour
|
|
|
+ `hour`
|
|
|
ORDER BY
|
|
|
- stat_hour ASC
|
|
|
+ `hour` ASC
|
|
|
</select>
|
|
|
|
|
|
<select id="queryAllSumByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
${filed}
|
|
|
- FROM ctop_bytedance_report_advertiser_daily t1
|
|
|
- WHERE t1.stat_datetime <= #{endDate} '00:00:00'
|
|
|
- AND t1.stat_datetime >= #{startDate}
|
|
|
- AND t1.advertiser_id in
|
|
|
+ FROM application.bytedance_advertiser_report_hourly_dw t1
|
|
|
+ WHERE t1.stat_datetime <=DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
+ AND t1.stat_datetime >= DATE_FORMAT(#{statDate},'%Y%m%d')
|
|
|
+ AND t1.account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
@@ -121,13 +116,14 @@
|
|
|
|
|
|
<select id="querySumByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT ROUND(sum(cost), 2) cost,
|
|
|
- sum(show_num) showNum,
|
|
|
+ sum(`show`) showNum,
|
|
|
sum(click) click,
|
|
|
- sum(convert_num) as convertNum
|
|
|
- FROM ctop_bytedance_report_advertiser_daily t1
|
|
|
- WHERE t1.stat_datetime <= #{endDate} '00:00:00'
|
|
|
- AND t1.stat_datetime >= #{startDate}
|
|
|
- AND advertiser_id in
|
|
|
+ sum(`convert`) as convertNum
|
|
|
+ FROM
|
|
|
+ application.bytedance_advertiser_report_hourly_dw
|
|
|
+ WHERE stat_datetime <= DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
+ AND stat_datetime >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
+ AND account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
@@ -137,37 +133,35 @@
|
|
|
<select id="querySumByDateGroupAccount" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
DATE_FORMAT(t1.stat_datetime,'%Y-%m-%d') as statDate,
|
|
|
- t2.account_id as accountId,
|
|
|
- t2.auth_name as authName,
|
|
|
+ t1.account_id as accountId,
|
|
|
+ t1.account_name as authName,
|
|
|
${filed}
|
|
|
FROM
|
|
|
- ctop_bytedance_report_advertiser_daily t1
|
|
|
- left join ctop_user_allocation t2 on t1.advertiser_id=t2.account_id
|
|
|
+ FROM application.bytedance_advertiser_report_hourly_dw t1
|
|
|
WHERE
|
|
|
- t1.stat_datetime <= #{endDate} '00:00:00'
|
|
|
- AND t1.stat_datetime >= #{startDate}
|
|
|
- AND t1.advertiser_id in
|
|
|
+ t1.stat_datetime <= DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
+ AND t1.stat_datetime >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
+ AND t1.account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- group by t1.advertiser_id
|
|
|
+ group by t1.account_id
|
|
|
order by ${target} ${order}
|
|
|
</select>
|
|
|
|
|
|
<select id="querySumByDateGroupAccountAndDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
DATE_FORMAT(t1.stat_datetime,'%Y-%m-%d') as statDate,
|
|
|
- t2.account_id as accountId,
|
|
|
- t2.auth_name as authName,
|
|
|
+ t1.account_id as accountId,
|
|
|
+ t1.account_name as authName,
|
|
|
${filed}
|
|
|
FROM
|
|
|
- ctop_bytedance_report_advertiser_daily t1
|
|
|
- left join ctop_user_allocation t2 on t1.advertiser_id=t2.account_id
|
|
|
+ FROM application.bytedance_advertiser_report_hourly_dw t1
|
|
|
WHERE
|
|
|
- t1.stat_datetime <= #{endDate} '00:00:00'
|
|
|
- AND t1.stat_datetime >= #{startDate}
|
|
|
- AND t1.advertiser_id in
|
|
|
+ t1.stat_datetime <= DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
+ AND t1.stat_datetime >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
+ AND t1.account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
@@ -179,45 +173,44 @@
|
|
|
<select id="queryDetailByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
ROUND(sum(cost),2) cost,
|
|
|
- sum(show_num) showNum,
|
|
|
+ sum(`show`) showNum,
|
|
|
sum(click) click,
|
|
|
- sum(convert_num) convertNum,
|
|
|
+ sum(`convert`) convertNum,
|
|
|
DATE_FORMAT(stat_datetime, '%Y-%m-%d') statDate
|
|
|
FROM
|
|
|
- ctop_bytedance_report_advertiser_daily
|
|
|
- WHERE stat_datetime <= #{endDate} '00:00:00'
|
|
|
- AND stat_datetime >= #{startDate}
|
|
|
- AND advertiser_id in
|
|
|
+ application.bytedance_advertiser_report_daily_dw
|
|
|
+ WHERE stat_datetime <= DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
+ AND stat_datetime >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
+ AND account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
group by stat_datetime
|
|
|
- order by stat_datetime asc
|
|
|
+ order by stat_datetime
|
|
|
</select>
|
|
|
|
|
|
<select id="queryDetailGroupMonthByDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
ROUND(sum(cost),2) cost,
|
|
|
- sum(show_num) showNum,
|
|
|
+ sum(`show`) showNum,
|
|
|
sum(click) click,
|
|
|
- sum(convert_num) convertNum,
|
|
|
+ sum(`convert`) convertNum,
|
|
|
DATE_FORMAT(t1.stat_datetime, '%Y-%m') statDate
|
|
|
- FROM ctop_bytedance_report_advertiser_daily t1
|
|
|
- WHERE t1.stat_datetime <= #{endDate} '00:00:00'
|
|
|
- AND t1.stat_datetime >= #{startDate}
|
|
|
- AND t1.advertiser_id in
|
|
|
+ FROM application.bytedance_advertiser_report_daily_dw t1
|
|
|
+ WHERE t1.stat_datetime <= DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
+ AND t1.stat_datetime >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
+ AND t1.account_id in
|
|
|
<foreach item="item" index="index" collection="accountIds"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
group by DATE_FORMAT(t1.stat_datetime, '%Y-%m')
|
|
|
- order by t1.stat_datetime asc
|
|
|
+ order by t1.stat_datetime
|
|
|
</select>
|
|
|
|
|
|
<select id="queryDetailGroupDayByMonth" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT
|
|
|
- DATE_FORMAT(stat_datetime, '%Y-%m-%d') statDate,
|
|
|
+ SELECT DATE_FORMAT(stat_datetime, '%Y-%m-%d') statDate,
|
|
|
SUBSTR(DATE_FORMAT(stat_datetime, '%Y-%m-%d') FROM 9 FOR 2) day
|
|
|
FROM ctop_bytedance_report_advertiser_daily
|
|
|
WHERE stat_datetime like '${month}%'
|
|
@@ -226,7 +219,8 @@
|
|
|
</select>
|
|
|
|
|
|
<sql id="selectSql">
|
|
|
- ifnull(sum(a.show_num),0) as showMaterial,
|
|
|
+ ifnull
|
|
|
+ (sum(a.show_num),0) as showMaterial,
|
|
|
ifnull(sum(a.click),0) as clickMaterial,
|
|
|
ifnull(sum(a.convert_num),0) as convertMaterial,
|
|
|
ifnull(sum(a.cost),0) as cost,
|
|
@@ -250,53 +244,65 @@
|
|
|
case
|
|
|
when sum(a.total_play) != 0 and sum(a.total_play) is not null and sum(a.play25_feed_break) is not null
|
|
|
then round(sum(a.play25_feed_break) / sum(a.total_play),2)
|
|
|
- else 0 end as play25FeedBreakRate,
|
|
|
+ else 0
|
|
|
+ end as play25FeedBreakRate,
|
|
|
case
|
|
|
when sum(a.click) != 0 and sum(a.click) is not null and sum(a.convert_num) is not null
|
|
|
then round(sum(a.convert_num) / sum(a.click),2)
|
|
|
- else 0 end as convertRate,
|
|
|
+ else 0
|
|
|
+ end as convertRate,
|
|
|
case
|
|
|
when sum(a.convert_num) != 0 and sum(a.convert_num) is not null and sum(a.cost) is not null
|
|
|
then round(sum(a.cost)/sum(a.convert_num),2)
|
|
|
- else 0 end as convertCost,
|
|
|
+ else 0
|
|
|
+ end as convertCost,
|
|
|
ifnull(sum(a.follow),0) as follow,
|
|
|
ifnull(sum(a.next_day_open),0) as nextDayOpen,
|
|
|
case
|
|
|
when sum(a.active) != 0 and sum(a.next_day_open) is not null and sum(a.active) is not null
|
|
|
then round(sum(a.next_day_open) / sum(a.active),2)
|
|
|
- else 0 end as nextDayOpenRate,
|
|
|
+ else 0
|
|
|
+ end as nextDayOpenRate,
|
|
|
case
|
|
|
when sum(a.next_day_open) != 0 and sum(a.next_day_open) is not null and sum(a.cost) is not null
|
|
|
then round(sum(a.cost) / sum(a.next_day_open),2)
|
|
|
- else 0 end as nextDayOpenCost,
|
|
|
+ else 0
|
|
|
+ end as nextDayOpenCost,
|
|
|
case
|
|
|
when sum(a.click) != 0 and sum(a.click) is not null and sum(a.cost) is not null
|
|
|
then round(sum(a.cost) / sum(a.click),2)
|
|
|
- else 0 end as cpc,
|
|
|
+ else 0
|
|
|
+ end as cpc,
|
|
|
case
|
|
|
when sum(a.show_num) != 0 and sum(a.show_num) is not null and sum(a.click) is not null
|
|
|
then round(sum(a.click) / sum(a.show_num),2)
|
|
|
- else 0 end as ctr,
|
|
|
+ else 0
|
|
|
+ end as ctr,
|
|
|
case
|
|
|
when sum(a.show_num) != 0 and sum(a.cost) is not null and sum(a.show_num) is not null
|
|
|
then round(sum(a.cost) / sum(a.show_num) * 1000,2)
|
|
|
- else 0 end as cpm,
|
|
|
+ else 0
|
|
|
+ end as cpm,
|
|
|
case
|
|
|
when sum(a.active) != 0 and sum(a.cost) is not null and sum(a.active) is not null
|
|
|
then round(sum(a.cost) / sum(a.active),2)
|
|
|
- else 0 end as activeCost,
|
|
|
+ else 0
|
|
|
+ end as activeCost,
|
|
|
case
|
|
|
when sum(a.click) != 0 and sum(a.active) is not null and sum(a.click) is not null
|
|
|
then round(sum(a.active) / sum(a.click),2)
|
|
|
- else 0 end as activeRate,
|
|
|
+ else 0
|
|
|
+ end as activeRate,
|
|
|
case
|
|
|
when sum(a.active) != 0 and sum(a.register) is not null and sum(a.active) is not null
|
|
|
then round(sum(a.register) / sum(a.active),2)
|
|
|
- else 0 end as activeRegisterRate,
|
|
|
+ else 0
|
|
|
+ end as activeRegisterRate,
|
|
|
case
|
|
|
when sum(a.register) != 0 and sum(a.cost) is not null and sum(a.register) is not null
|
|
|
then round(sum(a.cost) / sum(a.register),2)
|
|
|
- else 0 end as activeRegisterCost
|
|
|
+ else 0
|
|
|
+ end as activeRegisterCost
|
|
|
</sql>
|
|
|
|
|
|
<select id="getBytedanceAccountInfoByProjectId"
|
|
@@ -400,11 +406,9 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getRoleCodeByUserId" resultType="string">
|
|
|
- select
|
|
|
- role_code
|
|
|
- from
|
|
|
- sys_user_role a
|
|
|
- left join sys_role b on a.role_id = b.id
|
|
|
+ select role_code
|
|
|
+ from sys_user_role a
|
|
|
+ left join sys_role b on a.role_id = b.id
|
|
|
where a.user_id = #{userId}
|
|
|
</select>
|
|
|
|
|
@@ -460,40 +464,30 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getUserProjectAccountIds" 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_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 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_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)
|
|
|
+ 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
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getUserProjectAccountIdsByAdmin" resultType="long">
|
|
|
- select
|
|
|
- a.account_id
|
|
|
- from
|
|
|
- ctop_user_allocation a
|
|
|
- left join ctop_project b on a.project_id = b.id
|
|
|
- where
|
|
|
- b.media_id in (1,3)
|
|
|
+ select a.account_id
|
|
|
+ from ctop_user_allocation a
|
|
|
+ left join ctop_project b on a.project_id = b.id
|
|
|
+ where b.media_id in (1, 3)
|
|
|
|
|
|
</select>
|
|
|
<select id="getBytedanceProjectInfoEntity"
|