|
@@ -73,7 +73,7 @@
|
|
|
t2.operator_id as 'operatorId',
|
|
|
t2.operator_name as 'operatorName',
|
|
|
SUM(cost_total) as 'costTotal',
|
|
|
- IFNULL(ROUND(SUM(t1.gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
+ IFNULL(ROUND(SUM(t1.t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
FROM kuaishou_live_account_report_hourly_dw t1
|
|
|
LEFT JOIN `kuaishou_project` t2 ON t1.project_id = t2.id
|
|
|
WHERE report_date = #{today}
|
|
@@ -93,7 +93,7 @@
|
|
|
SELECT
|
|
|
t1.project_id as 'projectId',
|
|
|
SUM(cost_total) as 'costTotal',
|
|
|
- IFNULL(ROUND(SUM(t1.gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
+ IFNULL(ROUND(SUM(t1.t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
FROM kuaishou_live_account_report_hourly_dw t1
|
|
|
WHERE report_date = #{yesterday}
|
|
|
AND hour <= #{hour}
|
|
@@ -120,7 +120,7 @@
|
|
|
t2.operator_id as 'operatorId',
|
|
|
t2.operator_name as 'operatorName',
|
|
|
SUM(cost_total) as 'costTotal',
|
|
|
- IFNULL(ROUND(SUM(t1.gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
+ IFNULL(ROUND(SUM(t1.t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
FROM kuaishou_live_account_report_daily_dw t1
|
|
|
LEFT JOIN `kuaishou_project` t2 ON t1.project_id = t2.id
|
|
|
WHERE report_date >= #{startDate}
|
|
@@ -140,7 +140,7 @@
|
|
|
SELECT
|
|
|
project_id as 'projectId',
|
|
|
SUM(cost_total) as 'costTotal',
|
|
|
- IFNULL(ROUND(SUM(gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
+ IFNULL(ROUND(SUM(t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
|
|
|
FROM kuaishou_live_account_report_daily_dw
|
|
|
WHERE report_date >=#{lastStart}
|
|
|
AND report_date <=#{lastEnd}
|
|
@@ -474,8 +474,8 @@
|
|
|
(
|
|
|
SELECT
|
|
|
IFNULL(SUM(cost_total),0)AS'costTotal',
|
|
|
- IFNULL(SUM(gmv),0)AS't0Gmv',
|
|
|
- IFNULL(SUM(gmv)/SUM(cost_total),0)AS't0Roi',
|
|
|
+ IFNULL(SUM(t0_gmv),0)AS't0Gmv',
|
|
|
+ IFNULL(SUM(t0_gmv)/SUM(cost_total),0)AS't0Roi',
|
|
|
IFNULL(SUM(cost_total)/SUM(standard_live_played_started),0)AS'viewCost',
|
|
|
IFNULL(SUM(merchant_reco_fans),0)AS'upFans',
|
|
|
IFNULL(SUM(cost_total)/SUM(t0_order_cnt),0)AS'orderCost'
|
|
@@ -495,8 +495,8 @@
|
|
|
(
|
|
|
SELECT
|
|
|
IFNULL(SUM(cost_total),0)AS'costTotal',
|
|
|
- IFNULL(SUM(gmv),0)AS't0Gmv',
|
|
|
- IFNULL(SUM(gmv)/SUM(cost_total),0)AS't0Roi',
|
|
|
+ IFNULL(SUM(t0_gmv),0)AS't0Gmv',
|
|
|
+ IFNULL(SUM(t0_gmv)/SUM(cost_total),0)AS't0Roi',
|
|
|
IFNULL(SUM(cost_total)/SUM(standard_live_played_started),0)AS'viewCost',
|
|
|
IFNULL(SUM(merchant_reco_fans),0)AS'upFans',
|
|
|
IFNULL(SUM(cost_total)/SUM(t0_order_cnt),0)AS'orderCost'
|
|
@@ -610,15 +610,26 @@
|
|
|
|
|
|
|
|
|
<select id="getNodeAccountsCostByHourly" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT * FROM (
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ 2 as 'orders',
|
|
|
+ t1.hour as 'time',
|
|
|
+ t1.account_id as 'accountId',
|
|
|
+ t1.account_name as 'accountName',
|
|
|
+ SUM(t1.cost_total) AS 'costTotal',
|
|
|
+ IFNULL(CONCAT(CAST(ROUND((SUM(t1.cost_total)-t2.costTotal)/t2.costTotal * 100,2) AS CHAR) ,'%'),'-') as 'roi'
|
|
|
+ FROM
|
|
|
+ kuaishou_live_account_report_hourly_dw t1
|
|
|
+ LEFT JOIN (
|
|
|
SELECT
|
|
|
- hour as 'time',
|
|
|
- account_id as 'accountId',
|
|
|
- account_name as 'accountName',
|
|
|
+ account_id ,
|
|
|
+ account_name ,
|
|
|
SUM(cost_total) AS 'costTotal'
|
|
|
FROM
|
|
|
kuaishou_live_account_report_hourly_dw
|
|
|
WHERE account_type = 1
|
|
|
- AND report_date = #{date}
|
|
|
+ AND report_date = DATE_FORMAT(DATE_SUB(#{date}, INTERVAL 1 DAY ),'%Y%m%d')
|
|
|
AND hour = #{hour}
|
|
|
<if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
AND account_id in
|
|
@@ -628,17 +639,82 @@
|
|
|
</if>
|
|
|
GROUP BY account_id
|
|
|
ORDER BY account_id
|
|
|
+ ) t2 ON t1.account_id = t2.account_id
|
|
|
+
|
|
|
+ WHERE t1.account_type = 1
|
|
|
+ AND t1.report_date = #{date}
|
|
|
+ AND t1.hour = #{hour}
|
|
|
+ <if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
+ AND t1.account_id in
|
|
|
+ <foreach collection="accountIdList" item="accountId" open="(" separator="," close=")">
|
|
|
+ #{accountId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY t1.account_id
|
|
|
+ HAVING SUM(t1.cost_total) >0
|
|
|
+ ORDER BY t1.account_id
|
|
|
+ )
|
|
|
+ UNION ALL
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ 1 as 'orders',
|
|
|
+ hour as 'time',
|
|
|
+ '汇总' as 'accountId',
|
|
|
+ '汇总' as 'accountName',
|
|
|
+ SUM(t1.cost_total) AS 'costTotal',
|
|
|
+ IFNULL(CONCAT(CAST(ROUND((SUM(t1.cost_total)-t2.costTotal)/t2.costTotal * 100,2) AS CHAR) ,'%'),'-') as 'roi'
|
|
|
+ FROM
|
|
|
+ kuaishou_live_account_report_hourly_dw t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ account_id ,
|
|
|
+ account_name ,
|
|
|
+ SUM(cost_total) AS 'costTotal'
|
|
|
+ FROM
|
|
|
+ kuaishou_live_account_report_hourly_dw
|
|
|
+ WHERE account_type = 1
|
|
|
+ AND report_date = DATE_FORMAT(DATE_SUB(#{date}, INTERVAL 1 DAY ),'%Y%m%d')
|
|
|
+ AND hour = #{hour}
|
|
|
+ <if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
+ AND account_id in
|
|
|
+ <foreach collection="accountIdList" item="accountId" open="(" separator="," close=")">
|
|
|
+ #{accountId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ ) t2 ON 1=1
|
|
|
+ WHERE t1.account_type = 1
|
|
|
+ AND t1.report_date = #{date}
|
|
|
+ AND t1.hour = #{hour}
|
|
|
+ <if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
+ AND t1.account_id in
|
|
|
+ <foreach collection="accountIdList" item="accountId" open="(" separator="," close=")">
|
|
|
+ #{accountId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ ) t ORDER BY orders,costTotal DESC
|
|
|
</select>
|
|
|
<select id="getNodeAccountsCostByDaily" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT * FROM (
|
|
|
+ (
|
|
|
SELECT
|
|
|
+ 2 as 'orders',
|
|
|
date_format(report_date, '%Y-%m-%d') as 'time',
|
|
|
- account_id as 'accountId',
|
|
|
- account_name as 'accountName',
|
|
|
+ t1.account_id as 'accountId',
|
|
|
+ t1.account_name as 'accountName',
|
|
|
+ SUM(t1.cost_total) AS 'costTotal',
|
|
|
+ IFNULL(CONCAT(CAST(ROUND((SUM(t1.cost_total)-t2.costTotal)/t2.costTotal * 100,2) AS CHAR) ,'%'),'-') as 'roi'
|
|
|
+ FROM
|
|
|
+ kuaishou_live_account_report_daily_dw t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ account_id ,
|
|
|
+ account_name ,
|
|
|
SUM(cost_total) AS 'costTotal'
|
|
|
FROM
|
|
|
kuaishou_live_account_report_daily_dw
|
|
|
WHERE account_type = 1
|
|
|
- AND report_date = #{date}
|
|
|
+ AND report_date = DATE_FORMAT(DATE_SUB(#{date}, INTERVAL 1 DAY ),'%Y%m%d')
|
|
|
<if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
AND account_id in
|
|
|
<foreach collection="accountIdList" item="accountId" open="(" separator="," close=")">
|
|
@@ -647,6 +723,56 @@
|
|
|
</if>
|
|
|
GROUP BY account_id
|
|
|
ORDER BY account_id
|
|
|
+ ) t2 ON t1.account_id = t2.account_id
|
|
|
+ WHERE t1.account_type = 1
|
|
|
+ AND t1.report_date = #{date}
|
|
|
+ <if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
+ AND t1.account_id in
|
|
|
+ <foreach collection="accountIdList" item="accountId" open="(" separator="," close=")">
|
|
|
+ #{accountId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY t1.account_id
|
|
|
+ HAVING SUM(t1.cost_total) >0
|
|
|
+ ORDER BY t1.account_id
|
|
|
+ )
|
|
|
+ UNION ALL
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ 1 as 'orders',
|
|
|
+ date_format(report_date, '%Y-%m-%d') as 'time',
|
|
|
+ '汇总' as 'accountId',
|
|
|
+ '汇总' as 'accountName',
|
|
|
+ SUM(t1.cost_total) AS 'costTotal',
|
|
|
+ IFNULL(CONCAT(CAST(ROUND((SUM(t1.cost_total)-t2.costTotal)/t2.costTotal * 100,2) AS CHAR) ,'%'),'-') as 'roi'
|
|
|
+ FROM
|
|
|
+ kuaishou_live_account_report_daily_dw t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ account_id ,
|
|
|
+ account_name ,
|
|
|
+ SUM(cost_total) AS 'costTotal'
|
|
|
+ FROM
|
|
|
+ kuaishou_live_account_report_daily_dw
|
|
|
+ WHERE account_type = 1
|
|
|
+ AND report_date = DATE_FORMAT(DATE_SUB(#{date}, INTERVAL 1 DAY ),'%Y%m%d')
|
|
|
+ <if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
+ AND account_id in
|
|
|
+ <foreach collection="accountIdList" item="accountId" open="(" separator="," close=")">
|
|
|
+ #{accountId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ ) t2 ON 1=1
|
|
|
+ WHERE t1.account_type = 1
|
|
|
+ AND t1.report_date = #{date}
|
|
|
+ <if test="accountIdList != null and accountIdList.size() > 0 ">
|
|
|
+ AND t1.account_id in
|
|
|
+ <foreach collection="accountIdList" item="accountId" open="(" separator="," close=")">
|
|
|
+ #{accountId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ ) t ORDER BY orders,costTotal DESC
|
|
|
</select>
|
|
|
|
|
|
|