|
@@ -33,7 +33,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getTotalChargeHourly" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getTotalChargeHourly" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */
|
|
|
|
|
|
|
+ SELECT
|
|
|
IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'todayCost',
|
|
IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'todayCost',
|
|
|
IFNULL(SUM(CASE WHEN report.stat_date = #{yesterday} AND report.stat_hour <= #{hour} THEN report.cost END), 0.00) AS 'yesterdayCost',
|
|
IFNULL(SUM(CASE WHEN report.stat_date = #{yesterday} AND report.stat_hour <= #{hour} THEN report.cost END), 0.00) AS 'yesterdayCost',
|
|
|
IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'thisWeekTodayCost',
|
|
IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'thisWeekTodayCost',
|
|
@@ -70,7 +70,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getHourCost" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getHourCost" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.stat_hour AS 'time',
|
|
|
|
|
|
|
+ SELECT report.stat_hour AS 'time',
|
|
|
IFNULL(SUM(report.cost), 0.00) AS 'cost'
|
|
IFNULL(SUM(report.cost), 0.00) AS 'cost'
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
|
WHERE report.stat_date = #{startTime}
|
|
WHERE report.stat_date = #{startTime}
|
|
@@ -82,7 +82,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getDataCost" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getDataCost" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ DATE_FORMAT(report.stat_date, '%Y-%m-%d') AS 'time',
|
|
|
|
|
|
|
+ SELECT DATE_FORMAT(report.stat_date, '%Y-%m-%d') AS 'time',
|
|
|
IFNULL(SUM(report.cost), 0.00) AS 'cost'
|
|
IFNULL(SUM(report.cost), 0.00) AS 'cost'
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
|
WHERE report.stat_date >= #{startTime}
|
|
WHERE report.stat_date >= #{startTime}
|
|
@@ -95,7 +95,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getProjectTodayBase" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getProjectTodayBase" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id AS 'projectId',
|
|
|
|
|
|
|
+ SELECT report.project_id AS 'projectId',
|
|
|
MAX(report.advertiser_name) AS 'companyName',
|
|
MAX(report.advertiser_name) AS 'companyName',
|
|
|
SUM(report.cost) AS 'cost',
|
|
SUM(report.cost) AS 'cost',
|
|
|
SUM(report.view_count) AS 'aclick',
|
|
SUM(report.view_count) AS 'aclick',
|
|
@@ -139,7 +139,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getProjectPrevHourlyCostByDayAndIds" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getProjectPrevHourlyCostByDayAndIds" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id AS 'projectId',
|
|
|
|
|
|
|
+ SELECT report.project_id AS 'projectId',
|
|
|
SUM(report.cost) AS 'cost'
|
|
SUM(report.cost) AS 'cost'
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
|
WHERE report.stat_date = #{statDate}
|
|
WHERE report.stat_date = #{statDate}
|
|
@@ -166,7 +166,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getProjectAccountOperatorCountByCurrentHourlyAndIds" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getProjectAccountOperatorCountByCurrentHourlyAndIds" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id AS 'projectId',
|
|
|
|
|
|
|
+ SELECT report.project_id AS 'projectId',
|
|
|
COUNT(DISTINCT report.account_id) AS 'accountNum',
|
|
COUNT(DISTINCT report.account_id) AS 'accountNum',
|
|
|
COUNT(DISTINCT report.user_id) AS 'operaterNum'
|
|
COUNT(DISTINCT report.user_id) AS 'operaterNum'
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
@@ -182,7 +182,7 @@
|
|
|
|
|
|
|
|
<select id="getProjectToDayReport" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getProjectToDayReport" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
WITH active_projects AS (
|
|
WITH active_projects AS (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[t1]) */ t1.project_id AS projectId,
|
|
|
|
|
|
|
+ SELECT t1.project_id AS projectId,
|
|
|
MAX(t1.advertiser_name) AS companyName,
|
|
MAX(t1.advertiser_name) AS companyName,
|
|
|
SUM(t1.cost) AS cost,
|
|
SUM(t1.cost) AS cost,
|
|
|
SUM(t1.view_count) AS aclick,
|
|
SUM(t1.view_count) AS aclick,
|
|
@@ -229,7 +229,7 @@
|
|
|
LEFT JOIN `jeecg-boot`.sys_user t4 ON t3.responsible_id = t4.id
|
|
LEFT JOIN `jeecg-boot`.sys_user t4 ON t3.responsible_id = t4.id
|
|
|
LEFT JOIN `jeecg-boot`.sys_user t5 ON t3.sale_id = t5.id
|
|
LEFT JOIN `jeecg-boot`.sys_user t5 ON t3.sale_id = t5.id
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id,
|
|
|
|
|
|
|
+ SELECT report.project_id,
|
|
|
SUM(report.cost) AS 'costs'
|
|
SUM(report.cost) AS 'costs'
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
|
INNER JOIN active_projects active ON active.projectId = report.project_id
|
|
INNER JOIN active_projects active ON active.projectId = report.project_id
|
|
@@ -238,7 +238,7 @@
|
|
|
GROUP BY report.project_id
|
|
GROUP BY report.project_id
|
|
|
) t7 ON ap.projectId = t7.project_id
|
|
) t7 ON ap.projectId = t7.project_id
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id,
|
|
|
|
|
|
|
+ SELECT report.project_id,
|
|
|
COUNT(DISTINCT report.account_id) AS 'accountNum',
|
|
COUNT(DISTINCT report.account_id) AS 'accountNum',
|
|
|
COUNT(DISTINCT report.user_id) AS 'operaterNum'
|
|
COUNT(DISTINCT report.user_id) AS 'operaterNum'
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
@@ -379,7 +379,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getAdqOperateInfoHourly" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getAdqOperateInfoHourly" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[t]) */ COUNT(DISTINCT t.account_id) AS 'accountNum',
|
|
|
|
|
|
|
+ SELECT COUNT(DISTINCT t.account_id) AS 'accountNum',
|
|
|
COUNT(DISTINCT t.project_id) AS 'projectNums',
|
|
COUNT(DISTINCT t.project_id) AS 'projectNums',
|
|
|
SUM(t.cost) AS 'totalCost',
|
|
SUM(t.cost) AS 'totalCost',
|
|
|
t.user_id AS 'userId',
|
|
t.user_id AS 'userId',
|
|
@@ -391,7 +391,7 @@
|
|
|
FROM application.adq_advertiser_report_hourly t
|
|
FROM application.adq_advertiser_report_hourly t
|
|
|
LEFT JOIN `jeecg-boot`.sys_user t2 ON t.user_id = t2.id
|
|
LEFT JOIN `jeecg-boot`.sys_user t2 ON t.user_id = t2.id
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ SUM(d.cost) AS 'lastCost', d.user_id
|
|
|
|
|
|
|
+ SELECT SUM(d.cost) AS 'lastCost', d.user_id
|
|
|
FROM application.adq_advertiser_report_hourly d
|
|
FROM application.adq_advertiser_report_hourly d
|
|
|
WHERE d.cost > 0
|
|
WHERE d.cost > 0
|
|
|
AND d.stat_hour <= #{hour}
|
|
AND d.stat_hour <= #{hour}
|
|
@@ -468,7 +468,7 @@
|
|
|
NULL AS 'unitNum',
|
|
NULL AS 'unitNum',
|
|
|
NULL AS 'projectNum'
|
|
NULL AS 'projectNum'
|
|
|
FROM (
|
|
FROM (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ COUNT(DISTINCT d.account_id) AS 'accountNum',
|
|
|
|
|
|
|
+ SELECT COUNT(DISTINCT d.account_id) AS 'accountNum',
|
|
|
COUNT(DISTINCT d.project_id) AS 'projectNum',
|
|
COUNT(DISTINCT d.project_id) AS 'projectNum',
|
|
|
SUM(d.cost) AS 'totalCost',
|
|
SUM(d.cost) AS 'totalCost',
|
|
|
d.user_id
|
|
d.user_id
|
|
@@ -486,7 +486,7 @@
|
|
|
GROUP BY d.user_id
|
|
GROUP BY d.user_id
|
|
|
) t1
|
|
) t1
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ SUM(d.cost) AS 'lastCost'
|
|
|
|
|
|
|
+ SELECT SUM(d.cost) AS 'lastCost'
|
|
|
FROM application.adq_advertiser_report_hourly d
|
|
FROM application.adq_advertiser_report_hourly d
|
|
|
WHERE d.cost > 0
|
|
WHERE d.cost > 0
|
|
|
AND d.stat_hour <= #{hour}
|
|
AND d.stat_hour <= #{hour}
|
|
@@ -551,7 +551,7 @@
|
|
|
LEFT JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
|
|
|
LEFT JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
|
|
LEFT JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
|
|
|
INNER JOIN (
|
|
INNER JOIN (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ DISTINCT report.user_id
|
|
|
|
|
|
|
+ SELECT DISTINCT report.user_id
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
|
WHERE report.stat_date >= #{startDate}
|
|
WHERE report.stat_date >= #{startDate}
|
|
|
AND report.stat_date <= #{endDate}
|
|
AND report.stat_date <= #{endDate}
|
|
@@ -566,7 +566,7 @@
|
|
|
AND u.del_flag = 0
|
|
AND u.del_flag = 0
|
|
|
GROUP BY m.manage_id, u.id
|
|
GROUP BY m.manage_id, u.id
|
|
|
UNION ALL
|
|
UNION ALL
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.user_id AS managerId, report.user_id AS userId
|
|
|
|
|
|
|
+ SELECT report.user_id AS managerId, report.user_id AS userId
|
|
|
FROM application.adq_advertiser_report_hourly report
|
|
FROM application.adq_advertiser_report_hourly report
|
|
|
WHERE report.user_id IN
|
|
WHERE report.user_id IN
|
|
|
<foreach collection="managerIds" item="item" separator="," open="(" close=")">
|
|
<foreach collection="managerIds" item="item" separator="," open="(" close=")">
|
|
@@ -588,7 +588,7 @@
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="getOperateGroupCurrentHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getOperateGroupCurrentHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id AS 'userId',
|
|
|
|
|
|
|
+ SELECT d.user_id AS 'userId',
|
|
|
COUNT(DISTINCT d.account_id) AS 'accountNum',
|
|
COUNT(DISTINCT d.account_id) AS 'accountNum',
|
|
|
COUNT(DISTINCT d.project_id) AS 'projectNum',
|
|
COUNT(DISTINCT d.project_id) AS 'projectNum',
|
|
|
SUM(d.cost) AS 'totalCost'
|
|
SUM(d.cost) AS 'totalCost'
|
|
@@ -621,7 +621,7 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getOperateGroupPreviousHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getOperateGroupPreviousHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id AS 'userId',
|
|
|
|
|
|
|
+ SELECT d.user_id AS 'userId',
|
|
|
SUM(d.cost) AS 'lastCost'
|
|
SUM(d.cost) AS 'lastCost'
|
|
|
FROM application.adq_advertiser_report_hourly d
|
|
FROM application.adq_advertiser_report_hourly d
|
|
|
WHERE d.cost > 0
|
|
WHERE d.cost > 0
|
|
@@ -649,16 +649,92 @@
|
|
|
GROUP BY d.user_id
|
|
GROUP BY d.user_id
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
+ <select id="getOperateGroupHourlyMetricsByUsers" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
+ SELECT d.user_id AS 'userId',
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{currentStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.account_id
|
|
|
|
|
+ END) AS 'accountNum',
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{currentStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.project_id
|
|
|
|
|
+ END) AS 'projectNum',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{currentStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'totalCost',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{previousStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{previousEndDate}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'lastCost'
|
|
|
|
|
+ FROM application.adq_advertiser_report_hourly d
|
|
|
|
|
+ WHERE d.user_id IN
|
|
|
|
|
+ <foreach collection="userIds" item="item" separator="," open="(" close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ AND d.stat_date >= #{previousStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ GROUP BY d.user_id
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="getOperateGroupDailyMetricsByUsers" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
+ SELECT d.user_id AS 'userId',
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{currentStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.account_id
|
|
|
|
|
+ END) AS 'accountNum',
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{currentStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.project_id
|
|
|
|
|
+ END) AS 'projectNum',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{currentStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'totalCost',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{previousStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{previousEndDate}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'lastCost'
|
|
|
|
|
+ FROM application.adq_advertiser_report_daily d
|
|
|
|
|
+ WHERE d.user_id IN
|
|
|
|
|
+ <foreach collection="userIds" item="item" separator="," open="(" close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ AND d.stat_date >= #{previousStartDate}
|
|
|
|
|
+ AND d.stat_date <= #{currentEndDate}
|
|
|
|
|
+ GROUP BY d.user_id
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
<select id="getAdqOperateGroupInfoHourlyBatch" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getAdqOperateGroupInfoHourlyBatch" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT rel.managerId AS 'userId',
|
|
SELECT rel.managerId AS 'userId',
|
|
|
COUNT(DISTINCT rel.userId) AS 'operationNum',
|
|
COUNT(DISTINCT rel.userId) AS 'operationNum',
|
|
|
- IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
|
|
|
|
|
- IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
|
|
|
|
|
- IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
|
|
|
|
|
- IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
|
|
|
|
|
|
|
+ IFNULL(SUM(metrics.accountNum), 0) AS 'accountNum',
|
|
|
|
|
+ IFNULL(SUM(metrics.projectNum), 0) AS 'projectNums',
|
|
|
|
|
+ IFNULL(SUM(metrics.totalCost), 0) AS 'totalCost',
|
|
|
|
|
+ IFNULL(SUM(metrics.lastCost), 0) AS 'lastCost',
|
|
|
CASE
|
|
CASE
|
|
|
- WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
|
|
|
|
|
- ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
|
|
|
|
|
|
|
+ WHEN IFNULL(SUM(metrics.lastCost), 0) = 0 THEN '0%'
|
|
|
|
|
+ ELSE CONCAT(CAST(ROUND((IFNULL(SUM(metrics.totalCost), 0) - SUM(metrics.lastCost)) / SUM(metrics.lastCost) * 100, 2) AS CHAR), '%')
|
|
|
END AS 'yearOnYearCost',
|
|
END AS 'yearOnYearCost',
|
|
|
NULL AS 'unitNum',
|
|
NULL AS 'unitNum',
|
|
|
NULL AS 'projectNum'
|
|
NULL AS 'projectNum'
|
|
@@ -666,47 +742,57 @@
|
|
|
<include refid="adqOperateGroupRelationTable"/>
|
|
<include refid="adqOperateGroupRelationTable"/>
|
|
|
) rel
|
|
) rel
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id,
|
|
|
|
|
- COUNT(DISTINCT d.account_id) AS 'accountNum',
|
|
|
|
|
- COUNT(DISTINCT d.project_id) AS 'projectNum',
|
|
|
|
|
- SUM(d.cost) AS 'totalCost'
|
|
|
|
|
|
|
+ SELECT d.user_id,
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{startDate}
|
|
|
|
|
+ AND d.stat_date <= #{endDate}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.account_id
|
|
|
|
|
+ END) AS 'accountNum',
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{startDate}
|
|
|
|
|
+ AND d.stat_date <= #{endDate}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.project_id
|
|
|
|
|
+ END) AS 'projectNum',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{startDate}
|
|
|
|
|
+ AND d.stat_date <= #{endDate}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'totalCost',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{lastTimeStart}
|
|
|
|
|
+ AND d.stat_date <= #{lastTimeEnd}
|
|
|
|
|
+ AND d.stat_hour <= #{hour}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'lastCost'
|
|
|
FROM application.adq_advertiser_report_hourly d
|
|
FROM application.adq_advertiser_report_hourly d
|
|
|
INNER JOIN (
|
|
INNER JOIN (
|
|
|
<include refid="adqOperateGroupUsersTable"/>
|
|
<include refid="adqOperateGroupUsersTable"/>
|
|
|
) users ON users.userId = d.user_id
|
|
) users ON users.userId = d.user_id
|
|
|
- WHERE d.cost > 0
|
|
|
|
|
- AND d.stat_hour <= #{hour}
|
|
|
|
|
- AND d.stat_date >= #{startDate}
|
|
|
|
|
|
|
+ WHERE d.stat_date >= #{lastTimeStart}
|
|
|
AND d.stat_date <= #{endDate}
|
|
AND d.stat_date <= #{endDate}
|
|
|
GROUP BY d.user_id
|
|
GROUP BY d.user_id
|
|
|
- ) cur ON rel.userId = cur.user_id
|
|
|
|
|
- LEFT JOIN (
|
|
|
|
|
- SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id,
|
|
|
|
|
- SUM(d.cost) AS 'lastCost'
|
|
|
|
|
- FROM application.adq_advertiser_report_hourly d
|
|
|
|
|
- INNER JOIN (
|
|
|
|
|
- <include refid="adqOperateGroupUsersTable"/>
|
|
|
|
|
- ) users ON users.userId = d.user_id
|
|
|
|
|
- WHERE d.cost > 0
|
|
|
|
|
- AND d.stat_hour <= #{hour}
|
|
|
|
|
- AND d.stat_date >= #{lastTimeStart}
|
|
|
|
|
- AND d.stat_date <= #{lastTimeEnd}
|
|
|
|
|
- GROUP BY d.user_id
|
|
|
|
|
- ) prev ON rel.userId = prev.user_id
|
|
|
|
|
|
|
+ ) metrics ON rel.userId = metrics.user_id
|
|
|
GROUP BY rel.managerId
|
|
GROUP BY rel.managerId
|
|
|
- ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
|
|
|
|
|
|
|
+ ORDER BY IFNULL(SUM(metrics.totalCost), 0) DESC
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getAdqOperateGroupInfoBatch" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="getAdqOperateGroupInfoBatch" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT rel.managerId AS 'userId',
|
|
SELECT rel.managerId AS 'userId',
|
|
|
COUNT(DISTINCT rel.userId) AS 'operationNum',
|
|
COUNT(DISTINCT rel.userId) AS 'operationNum',
|
|
|
- IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
|
|
|
|
|
- IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
|
|
|
|
|
- IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
|
|
|
|
|
- IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
|
|
|
|
|
|
|
+ IFNULL(SUM(metrics.accountNum), 0) AS 'accountNum',
|
|
|
|
|
+ IFNULL(SUM(metrics.projectNum), 0) AS 'projectNums',
|
|
|
|
|
+ IFNULL(SUM(metrics.totalCost), 0) AS 'totalCost',
|
|
|
|
|
+ IFNULL(SUM(metrics.lastCost), 0) AS 'lastCost',
|
|
|
CASE
|
|
CASE
|
|
|
- WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
|
|
|
|
|
- ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
|
|
|
|
|
|
|
+ WHEN IFNULL(SUM(metrics.lastCost), 0) = 0 THEN '0%'
|
|
|
|
|
+ ELSE CONCAT(CAST(ROUND((IFNULL(SUM(metrics.totalCost), 0) - SUM(metrics.lastCost)) / SUM(metrics.lastCost) * 100, 2) AS CHAR), '%')
|
|
|
END AS 'yearOnYearCost',
|
|
END AS 'yearOnYearCost',
|
|
|
NULL AS 'unitNum',
|
|
NULL AS 'unitNum',
|
|
|
NULL AS 'projectNum'
|
|
NULL AS 'projectNum'
|
|
@@ -715,32 +801,40 @@
|
|
|
) rel
|
|
) rel
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
SELECT d.user_id,
|
|
SELECT d.user_id,
|
|
|
- COUNT(DISTINCT d.account_id) AS 'accountNum',
|
|
|
|
|
- COUNT(DISTINCT d.project_id) AS 'projectNum',
|
|
|
|
|
- SUM(d.cost) AS 'totalCost'
|
|
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{startDate}
|
|
|
|
|
+ AND d.stat_date <= #{endDate}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.account_id
|
|
|
|
|
+ END) AS 'accountNum',
|
|
|
|
|
+ COUNT(DISTINCT CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{startDate}
|
|
|
|
|
+ AND d.stat_date <= #{endDate}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.project_id
|
|
|
|
|
+ END) AS 'projectNum',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{startDate}
|
|
|
|
|
+ AND d.stat_date <= #{endDate}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'totalCost',
|
|
|
|
|
+ IFNULL(SUM(CASE
|
|
|
|
|
+ WHEN d.stat_date >= #{lastTimeStart}
|
|
|
|
|
+ AND d.stat_date <= #{lastTimeEnd}
|
|
|
|
|
+ AND d.cost > 0
|
|
|
|
|
+ THEN d.cost
|
|
|
|
|
+ END), 0) AS 'lastCost'
|
|
|
FROM application.adq_advertiser_report_daily d
|
|
FROM application.adq_advertiser_report_daily d
|
|
|
INNER JOIN (
|
|
INNER JOIN (
|
|
|
<include refid="adqOperateGroupUsersTable"/>
|
|
<include refid="adqOperateGroupUsersTable"/>
|
|
|
) users ON users.userId = d.user_id
|
|
) users ON users.userId = d.user_id
|
|
|
- WHERE d.cost > 0
|
|
|
|
|
- AND d.stat_date >= #{startDate}
|
|
|
|
|
|
|
+ WHERE d.stat_date >= #{lastTimeStart}
|
|
|
AND d.stat_date <= #{endDate}
|
|
AND d.stat_date <= #{endDate}
|
|
|
GROUP BY d.user_id
|
|
GROUP BY d.user_id
|
|
|
- ) cur ON rel.userId = cur.user_id
|
|
|
|
|
- LEFT JOIN (
|
|
|
|
|
- SELECT d.user_id,
|
|
|
|
|
- SUM(d.cost) AS 'lastCost'
|
|
|
|
|
- FROM application.adq_advertiser_report_daily d
|
|
|
|
|
- INNER JOIN (
|
|
|
|
|
- <include refid="adqOperateGroupUsersTable"/>
|
|
|
|
|
- ) users ON users.userId = d.user_id
|
|
|
|
|
- WHERE d.cost > 0
|
|
|
|
|
- AND d.stat_date >= #{lastTimeStart}
|
|
|
|
|
- AND d.stat_date <= #{lastTimeEnd}
|
|
|
|
|
- GROUP BY d.user_id
|
|
|
|
|
- ) prev ON rel.userId = prev.user_id
|
|
|
|
|
|
|
+ ) metrics ON rel.userId = metrics.user_id
|
|
|
GROUP BY rel.managerId
|
|
GROUP BY rel.managerId
|
|
|
- ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
|
|
|
|
|
|
|
+ ORDER BY IFNULL(SUM(metrics.totalCost), 0) DESC
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
</mapper>
|
|
</mapper>
|