|
@@ -34,20 +34,26 @@
|
|
|
where manage_id = #{userId}
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
<select id="getCompanyAccountIds" resultType="Long">
|
|
|
- SELECT t1.account_id
|
|
|
- FROM `jeecg-boot`.ctop_user_allocation t1
|
|
|
- LEFT JOIN `jeecg-boot`.user_company t2 ON t1.user_id = t2.user_id
|
|
|
- WHERE t2.company_id = #{companyId}
|
|
|
+ SELECT account_id
|
|
|
+ FROM `jeecg-boot`.ctop_user_allocation
|
|
|
+ WHERE project_id in (
|
|
|
+ SELECT DISTINCT
|
|
|
+ t1.project_id
|
|
|
+ FROM
|
|
|
+ `jeecg-boot`.ctop_project_member t1
|
|
|
+ LEFT JOIN `jeecg-boot`.ctop_project t2 ON t1.project_id = t2.id
|
|
|
+ WHERE t2.company_id =#{companyId}
|
|
|
<if test='mediaId ==2'>
|
|
|
AND (media_id = 2 or media_id = 4)
|
|
|
</if>
|
|
|
<if test='mediaId ==1'>
|
|
|
AND (media_id = 1 or media_id = 3)
|
|
|
</if>
|
|
|
- and t1.account_status = 0
|
|
|
- GROUP BY t1.account_id
|
|
|
+ AND t1.project_name IS NOT NULL
|
|
|
+ AND t1.project_name != ''
|
|
|
+ ) and account_status = 0
|
|
|
+ GROUP BY account_id
|
|
|
</select>
|
|
|
|
|
|
|
|
@@ -57,26 +63,32 @@
|
|
|
FROM (
|
|
|
SELECT sum(charge) as 'charge'
|
|
|
FROM application.kuaishou_account_report_hourly_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_date = DATE_FORMAT(#{statDay}, '%Y%m%d')
|
|
|
- <if test="hour !=null">
|
|
|
- AND hour <= #{hour}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ and stat_date = DATE_FORMAT(#{statDay}, '%Y%m%d')
|
|
|
+ <if test="hour !=null">
|
|
|
+ AND hour <= #{hour}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) t
|
|
|
LEFT JOIN
|
|
|
(
|
|
|
SELECT sum(charge) as 'charge'
|
|
|
FROM application.kuaishou_account_report_hourly_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_date = DATE_FORMAT(DATE_ADD(#{statDay},INTERVAL -1 day), '%Y%m%d')
|
|
|
+ where stat_date = DATE_FORMAT(DATE_ADD(#{statDay},INTERVAL -1 day), '%Y%m%d')
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
<if test="hour !=null">
|
|
|
AND hour <= #{hour}
|
|
|
</if>
|
|
@@ -89,12 +101,15 @@
|
|
|
FROM (
|
|
|
SELECT sum(cost) as 'charge'
|
|
|
FROM application.bytedance_advertiser_report_hourly_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_datetime = DATE_FORMAT(#{statDay}, '%Y%m%d')
|
|
|
+ where stat_datetime = DATE_FORMAT(#{statDay}, '%Y%m%d')
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
<if test="hour !=null">
|
|
|
AND hour <= #{hour}
|
|
|
</if>
|
|
@@ -103,12 +118,14 @@
|
|
|
(
|
|
|
SELECT sum(cost) as 'charge'
|
|
|
FROM application.bytedance_advertiser_report_hourly_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_datetime = DATE_FORMAT(DATE_ADD(#{statDay},INTERVAL -1 day), '%Y%m%d')
|
|
|
+ WHERE stat_datetime = DATE_FORMAT(DATE_ADD(#{statDay},INTERVAL -1 day), '%Y%m%d')
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
<if test="hour !=null">
|
|
|
AND hour <= #{hour}
|
|
|
</if>
|
|
@@ -117,54 +134,64 @@
|
|
|
|
|
|
<select id="queryTtManydaysTotalCharge" resultType="String">
|
|
|
SELECT IFNULL(sum(cost), 0.00)
|
|
|
- FROM application.bytedance_advertiser_report_daily_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_datetime >= DATE_FORMAT(#{startDay}, '%Y%m%d')
|
|
|
- and stat_datetime < DATE_FORMAT(#{endDay}, '%Y%m%d')
|
|
|
+ FROM application.bytedance_advertiser_report_hourly_dw
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT(#{startDay}, '%Y%m%d')
|
|
|
+ and stat_datetime <= DATE_FORMAT(#{endDay}, '%Y%m%d')
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
</select>
|
|
|
|
|
|
<select id="queryTtManydaysCharge" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT DATE_FORMAT(stat_datetime,'%Y-%m-%d') as 'statDate', IFNULL(sum(cost), 0.00) as 'charge'
|
|
|
- FROM application.bytedance_advertiser_report_daily_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
+ FROM application.bytedance_advertiser_report_hourly_dw
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
and stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY stat_datetime
|
|
|
order by stat_datetime
|
|
|
</select>
|
|
|
|
|
|
<select id="queryKsManydaysCharge" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT DATE_FORMAT(stat_date,'%Y-%m-%d') as 'statDate', IFNULL(sum(charge), 0.00) as 'charge'
|
|
|
- FROM application.kuaishou_account_report_daily_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
+ FROM application.kuaishou_account_report_hourly_dw
|
|
|
+ WHERE
|
|
|
+ stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
and stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY stat_date
|
|
|
order by stat_date
|
|
|
</select>
|
|
|
|
|
|
<select id="queryKsManydaysTotalCharge" resultType="String">
|
|
|
SELECT IFNULL(sum(charge), 0.00)
|
|
|
- FROM application.kuaishou_account_report_daily_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_date >= DATE_FORMAT(#{startDay}, '%Y%m%d')
|
|
|
- and stat_date < DATE_FORMAT(#{endDay}, '%Y%m%d')
|
|
|
+ FROM application.kuaishou_account_report_hourly_dw
|
|
|
+ WHERE
|
|
|
+ stat_date >= DATE_FORMAT(#{startDay}, '%Y%m%d')
|
|
|
+ and stat_date <= DATE_FORMAT(#{endDay}, '%Y%m%d')
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
</select>
|
|
|
|
|
|
<select id="queryKsRealCharged" resultType="com.alibaba.fastjson.JSONObject">
|
|
@@ -178,28 +205,31 @@
|
|
|
IFNULL( sum( real_charged_in_yuan ), 0.00 ) AS 'realCharged'
|
|
|
FROM
|
|
|
application.app_kuaishou_agent_report_d
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_date >= DATE_FORMAT( #{monthFirstday}, '%Y%m%d' )
|
|
|
+ WHERE stat_date >= DATE_FORMAT( #{monthFirstday}, '%Y%m%d' )
|
|
|
AND stat_date <= DATE_FORMAT( #{statDay}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) thisMonth
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
IFNULL( sum( real_charged_in_yuan ), 0.00 ) AS 'realCharged'
|
|
|
FROM
|
|
|
application.app_kuaishou_agent_report_d
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_date >= DATE_FORMAT(#{lastMonthFirstday}, '%Y%m%d' )
|
|
|
+ WHERE stat_date >= DATE_FORMAT(#{lastMonthFirstday}, '%Y%m%d' )
|
|
|
AND stat_date < DATE_FORMAT(#{monthFirstday}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND
|
|
|
+ account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) lastMonth ON 1=1
|
|
|
</select>
|
|
|
|
|
@@ -214,28 +244,31 @@
|
|
|
IFNULL( sum( cash_cost ), 0.00 ) AS 'realCharged'
|
|
|
FROM
|
|
|
application.app_bytedance_agent_report_d
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_datetime >= DATE_FORMAT( #{monthFirstday}, '%Y%m%d' )
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT( #{monthFirstday}, '%Y%m%d' )
|
|
|
AND stat_datetime <= DATE_FORMAT( #{statDay}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND
|
|
|
+ account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) thisMonth
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
IFNULL( sum( cash_cost ), 0.00 ) AS 'realCharged'
|
|
|
FROM
|
|
|
application.app_bytedance_agent_report_d
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_datetime >= DATE_FORMAT(#{lastMonthFirstday}, '%Y%m%d' )
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT(#{lastMonthFirstday}, '%Y%m%d' )
|
|
|
AND stat_datetime < DATE_FORMAT(#{monthFirstday}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) lastMonth ON 1=1
|
|
|
</select>
|
|
|
|
|
@@ -243,14 +276,14 @@
|
|
|
<select id="getWeekly" resultType="Long">
|
|
|
SELECT IFNULL(weekly_goal_value, 0)
|
|
|
FROM `jeecg-boot`.sys_manager_sale_value
|
|
|
- WHERE manage_id = #{userId}
|
|
|
+ WHERE user_id = #{userId}
|
|
|
AND media_id = #{mediaId}
|
|
|
AND company_id = #{companyId}
|
|
|
</select>
|
|
|
<select id="getMonthly" resultType="Long">
|
|
|
SELECT IFNULL(monthly_goal_value, 0)
|
|
|
FROM `jeecg-boot`.sys_manager_sale_value
|
|
|
- WHERE manage_id = #{userId}
|
|
|
+ WHERE user_id = #{userId}
|
|
|
AND media_id = #{mediaId}
|
|
|
AND company_id = #{companyId}
|
|
|
</select>
|
|
@@ -270,19 +303,21 @@
|
|
|
FROM
|
|
|
`jeecg-boot`.ctop_project_member t1
|
|
|
LEFT JOIN `jeecg-boot`.ctop_project t2 ON t1.project_id = t2.id
|
|
|
- WHERE t1.user_id IN
|
|
|
- <foreach collection="userIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
+ WHERE t1.project_name IS NOT NULL
|
|
|
+ AND t1.project_name != ''
|
|
|
+ <if test="userIds !=null and userIds.size()>0">
|
|
|
+ AND t1.user_id IN
|
|
|
+ <foreach collection="userIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
<if test='mediaId ==2'>
|
|
|
AND (t2.media_id = 2 or t2.media_id = 4)
|
|
|
</if>
|
|
|
<if test='mediaId ==1'>
|
|
|
AND (t2.media_id = 1 or t2.media_id = 3)
|
|
|
</if>
|
|
|
- AND t1.project_name IS NOT NULL
|
|
|
- AND t1.project_name != ''
|
|
|
)
|
|
|
GROUP BY
|
|
|
t1.account_id
|
|
@@ -316,12 +351,14 @@
|
|
|
<select id="queryKsHourList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT hour,sum(charge) as 'charge'
|
|
|
FROM application.kuaishou_account_report_hourly_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_date = DATE_FORMAT(#{statDay}, '%Y%m%d' )
|
|
|
+ WHERE stat_date = DATE_FORMAT(#{statDay}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY hour
|
|
|
ORDER BY hour
|
|
|
</select>
|
|
@@ -329,12 +366,14 @@
|
|
|
<select id="queryTtHourList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT hour,sum(cost) as 'charge'
|
|
|
FROM application.bytedance_advertiser_report_hourly_dw
|
|
|
- WHERE account_id in
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and stat_datetime = DATE_FORMAT(#{statDay}, '%Y%m%d' )
|
|
|
+ WHERE stat_datetime = DATE_FORMAT(#{statDay}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id in
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY hour
|
|
|
ORDER BY hour
|
|
|
</select>
|
|
@@ -342,7 +381,7 @@
|
|
|
|
|
|
<select id="queryTtManydaysChargeAndRoi" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
- IFNULL( this.charge, 0.00) AS 'charge',
|
|
|
+ IFNULL( this.charge, 0.00) AS 'totalCharge',
|
|
|
CONCAT( CAST( IFNULL( ROUND(( this.charge - last.charge ) / last.charge* 100,2),0) AS CHAR),'%') AS
|
|
|
'chargeRoi'
|
|
|
FROM
|
|
@@ -350,36 +389,38 @@
|
|
|
SELECT
|
|
|
IFNULL( sum(cost), 0.00 ) AS 'charge'
|
|
|
FROM
|
|
|
- application.bytedance_advertiser_report_daily_dw
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
+ application.bytedance_advertiser_report_hourly_dw
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
AND stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) this
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
IFNULL( sum(cost), 0.00 ) AS 'charge'
|
|
|
FROM
|
|
|
- application.bytedance_advertiser_report_daily_dw
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_datetime >= DATE_FORMAT( #{lastTimeStart}, '%Y%m%d' )
|
|
|
+ application.bytedance_advertiser_report_hourly_dw
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT( #{lastTimeStart}, '%Y%m%d' )
|
|
|
AND stat_datetime <= DATE_FORMAT( #{lastTimeEnd}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) last ON 1=1
|
|
|
</select>
|
|
|
|
|
|
|
|
|
<select id="queryKsManydaysChargeAndRoi" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
- IFNULL( this.charge, 0.00) AS 'charge',
|
|
|
+ IFNULL( this.charge, 0.00) AS 'totalCharge',
|
|
|
CONCAT( CAST( IFNULL( ROUND(( this.charge - last.charge ) / last.charge* 100,2),0) AS CHAR),'%') AS
|
|
|
'chargeRoi'
|
|
|
FROM
|
|
@@ -387,29 +428,31 @@
|
|
|
SELECT
|
|
|
IFNULL( sum(charge), 0.00 ) AS 'charge'
|
|
|
FROM
|
|
|
- application.kuaishou_account_report_daily_dw
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
+ application.kuaishou_account_report_hourly_dw
|
|
|
+ WHERE stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
AND stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) this
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
IFNULL( sum(charge), 0.00 ) AS 'charge'
|
|
|
FROM
|
|
|
- application.kuaishou_account_report_daily_dw
|
|
|
- WHERE
|
|
|
- account_id IN
|
|
|
- <foreach collection="accountIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_date >= DATE_FORMAT( #{lastTimeStart}, '%Y%m%d' )
|
|
|
+ application.kuaishou_account_report_hourly_dw
|
|
|
+ WHERE stat_date >= DATE_FORMAT( #{lastTimeStart}, '%Y%m%d' )
|
|
|
AND stat_date <= DATE_FORMAT( #{lastTimeEnd}, '%Y%m%d' )
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
+ AND account_id IN
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
) last ON 1=1
|
|
|
</select>
|
|
|
|
|
@@ -418,13 +461,15 @@
|
|
|
SELECT count(1)
|
|
|
FROM
|
|
|
(select 1 from application.kuaishou_account_report_hourly_dw t1
|
|
|
- where t1.project_id in
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and t1.stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
+ where t1.stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
and t1.stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and t1.project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY project_id
|
|
|
) t
|
|
|
</select>
|
|
@@ -433,13 +478,15 @@
|
|
|
SELECT count(1)
|
|
|
FROM
|
|
|
(select 1 from application.bytedance_advertiser_report_hourly_dw t1
|
|
|
- where t1.project_id in
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- and t1.stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
+ where t1.stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d')
|
|
|
and t1.stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and t1.project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY project_id
|
|
|
) t
|
|
|
</select>
|
|
@@ -450,10 +497,11 @@
|
|
|
t1.project_name as 'projectName',
|
|
|
( SELECT realname FROM `jeecg-boot`.sys_user us WHERE us.id = t1.sale_id ) AS 'saleName',
|
|
|
SUM( t1.charge ) AS 'charge',
|
|
|
- CONCAT( CAST( IFNULL( ROUND(( t1.charge - t3.charge ) / t3.charge * 100, 2 ), 0.00 ) AS CHAR ), '%' ) AS
|
|
|
+ CONCAT( CAST( IFNULL( ROUND(( SUM( t1.charge ) - t3.charge ) / t3.charge * 100, 2 ), 0.00 ) AS CHAR ), '%' ) AS
|
|
|
'chargeRoi',
|
|
|
IFNULL(t2.realCharge,0.00) AS 'realCharge',
|
|
|
- IFNULL(t2.jlCharge,0.00) AS 'jlCharge'
|
|
|
+ IFNULL(t2.jlCharge,0.00) AS 'jlCharge',
|
|
|
+ row_number() over(order by SUM( t1.charge ) desc) AS 'number'
|
|
|
FROM
|
|
|
application.kuaishou_account_report_hourly_dw t1
|
|
|
LEFT JOIN(
|
|
@@ -461,40 +509,42 @@
|
|
|
SUM(real_charged_in_yuan) as 'realCharge',
|
|
|
SUM(direct_rebate_real_charged_in_yuan) as 'jlCharge'
|
|
|
FROM application.app_kuaishou_agent_report_d
|
|
|
- WHERE
|
|
|
- project_id IN
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
+ WHERE stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
AND stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY project_id
|
|
|
)t2 ON t1.project_id = t2.project_id
|
|
|
LEFT JOIN (
|
|
|
- SELECT project_id, SUM( charge ) AS 'charge' FROM application.kuaishou_account_report_hourly_dw WHERE project_id
|
|
|
- IN
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
+ SELECT project_id, SUM( charge ) AS 'charge' FROM application.kuaishou_account_report_hourly_dw
|
|
|
+ WHERE hour <= #{hour}
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
AND stat_date >= DATE_FORMAT(DATE_ADD(#{startTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
|
AND stat_date <= DATE_FORMAT(DATE_ADD(#{endTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
|
GROUP BY project_id ) t3 ON
|
|
|
t1.project_id = t3.project_id
|
|
|
- WHERE
|
|
|
- t1.project_id IN
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
+ WHERE hour <= #{hour}
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and t1.project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
AND stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
AND stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
- GROUP BY
|
|
|
- t1.project_id
|
|
|
- ORDER BY
|
|
|
- SUM( t1.charge ) DESC
|
|
|
-
|
|
|
+ GROUP BY t1.project_id
|
|
|
</select>
|
|
|
|
|
|
|
|
@@ -504,10 +554,11 @@
|
|
|
t1.project_name as 'projectName',
|
|
|
( SELECT realname FROM `jeecg-boot`.sys_user us WHERE us.id = t1.sale_id ) AS 'saleName',
|
|
|
SUM( t1.cost ) AS 'charge',
|
|
|
- CONCAT( CAST( IFNULL( ROUND(( t1.cost - t3.charge ) / t3.charge * 100, 2 ), 0 ) AS CHAR ), '%' ) AS
|
|
|
+ CONCAT( CAST( IFNULL( ROUND(( SUM( t1.cost ) - t3.charge ) / t3.charge * 100, 2 ), 0 ) AS CHAR ), '%' ) AS
|
|
|
'chargeRoi',
|
|
|
IFNULL(t2.realCharge,0.00) AS 'realCharge',
|
|
|
- IFNULL(t2.jlCharge,0.00) AS 'jlCharge'
|
|
|
+ IFNULL(t2.jlCharge,0.00) AS 'jlCharge',
|
|
|
+ row_number() over(order by SUM( t1.cost ) desc) AS 'number'
|
|
|
FROM
|
|
|
application.bytedance_advertiser_report_hourly_dw t1
|
|
|
LEFT JOIN(
|
|
@@ -515,42 +566,42 @@
|
|
|
SUM(cash_cost) as 'realCharge',
|
|
|
SUM(grants_cost) AS 'jlCharge'
|
|
|
FROM application.app_bytedance_agent_report_d
|
|
|
- WHERE
|
|
|
- project_id IN
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
AND stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY project_id
|
|
|
)t2 ON t1.project_id = t2.project_id
|
|
|
LEFT JOIN (
|
|
|
- SELECT project_id, SUM( cost ) AS 'charge' FROM application.bytedance_advertiser_report_hourly_dw WHERE
|
|
|
- project_id
|
|
|
- IN
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND stat_datetime >= DATE_FORMAT(DATE_ADD(#{startTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
|
+ SELECT project_id, SUM( cost ) AS 'charge' FROM application.bytedance_advertiser_report_hourly_dw
|
|
|
+ WHERE stat_datetime >= DATE_FORMAT(DATE_ADD(#{startTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
|
AND stat_datetime <= DATE_FORMAT(DATE_ADD(#{endTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND hour <= #{hour}
|
|
|
GROUP BY project_id ) t3 ON
|
|
|
t1.project_id = t3.project_id
|
|
|
- WHERE
|
|
|
- t1.project_id IN
|
|
|
- <foreach collection="projectIds" item="id" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- AND t1.stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
+ WHERE t1.stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
|
AND t1.stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
- GROUP BY
|
|
|
- t1.project_id
|
|
|
- ORDER BY
|
|
|
- SUM( t1.cost ) DESC
|
|
|
-
|
|
|
+ <if test="projectIds !=null and projectIds.size()>0">
|
|
|
+ and t1.project_id in
|
|
|
+ <foreach collection="projectIds" item="id" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND hour <= #{hour}
|
|
|
+ GROUP BY t1.project_id
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
</mapper>
|