|
@@ -34,48 +34,69 @@
|
|
where manage_id = #{userId}
|
|
where manage_id = #{userId}
|
|
</select>
|
|
</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 id="querySalesDirectorAccountIds" resultType="Long">
|
|
|
|
+ SELECT
|
|
|
|
+ account_id
|
|
|
|
+ FROM
|
|
|
|
+ `jeecg-boot`.ctop_user_allocation
|
|
|
|
+ WHERE
|
|
|
|
+ project_id IN (
|
|
|
|
+ SELECT DISTINCT
|
|
|
|
+ id
|
|
|
|
+ FROM `jeecg-boot`.ctop_project
|
|
|
|
+ WHERE company_id = #{companyId}
|
|
<if test='mediaId ==2'>
|
|
<if test='mediaId ==2'>
|
|
AND (media_id = 2 or media_id = 4)
|
|
AND (media_id = 2 or media_id = 4)
|
|
</if>
|
|
</if>
|
|
<if test='mediaId ==1'>
|
|
<if test='mediaId ==1'>
|
|
AND (media_id = 1 or media_id = 3)
|
|
AND (media_id = 1 or media_id = 3)
|
|
</if>
|
|
</if>
|
|
- and t1.account_status = 0
|
|
|
|
- GROUP BY t1.account_id
|
|
|
|
|
|
+ <if test="userIds !=null and userIds.size()>0">
|
|
|
|
+ AND sale_id IN
|
|
|
|
+ <foreach collection="userIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ )
|
|
|
|
+ GROUP BY
|
|
|
|
+ account_id
|
|
</select>
|
|
</select>
|
|
|
|
|
|
-
|
|
|
|
<select id="queryKsTodayCharge" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="queryKsTodayCharge" resultType="com.alibaba.fastjson.JSONObject">
|
|
SELECT IFNULL(t.charge, 0.00) as 'totalCharge', CONCAT(
|
|
SELECT IFNULL(t.charge, 0.00) as 'totalCharge', CONCAT(
|
|
CAST(IFNULL(ROUND((t.charge - y.charge) / y.charge * 100, 2), 0) as CHAR), '%') as 'chargeRoi'
|
|
CAST(IFNULL(ROUND((t.charge - y.charge) / y.charge * 100, 2), 0) as CHAR), '%') as 'chargeRoi'
|
|
FROM (
|
|
FROM (
|
|
SELECT sum(charge) as 'charge'
|
|
SELECT sum(charge) as 'charge'
|
|
FROM application.kuaishou_account_report_hourly_dw
|
|
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 company_id = #{companyId}
|
|
|
|
+ and stat_date = DATE_FORMAT(#{statDay}, '%Y%m%d')
|
|
|
|
+ <if test="hour !=null">
|
|
|
|
+ AND hour <= #{hour}
|
|
|
|
+ </if>
|
|
|
|
+ </where>
|
|
) t
|
|
) t
|
|
LEFT JOIN
|
|
LEFT JOIN
|
|
(
|
|
(
|
|
SELECT sum(charge) as 'charge'
|
|
SELECT sum(charge) as 'charge'
|
|
FROM application.kuaishou_account_report_hourly_dw
|
|
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')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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">
|
|
<if test="hour !=null">
|
|
AND hour <= #{hour}
|
|
AND hour <= #{hour}
|
|
</if>
|
|
</if>
|
|
@@ -88,12 +109,16 @@
|
|
FROM (
|
|
FROM (
|
|
SELECT sum(cost) as 'charge'
|
|
SELECT sum(cost) as 'charge'
|
|
FROM application.bytedance_advertiser_report_hourly_dw
|
|
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')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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">
|
|
<if test="hour !=null">
|
|
AND hour <= #{hour}
|
|
AND hour <= #{hour}
|
|
</if>
|
|
</if>
|
|
@@ -102,12 +127,14 @@
|
|
(
|
|
(
|
|
SELECT sum(cost) as 'charge'
|
|
SELECT sum(cost) as 'charge'
|
|
FROM application.bytedance_advertiser_report_hourly_dw
|
|
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">
|
|
<if test="hour !=null">
|
|
AND hour <= #{hour}
|
|
AND hour <= #{hour}
|
|
</if>
|
|
</if>
|
|
@@ -116,54 +143,68 @@
|
|
|
|
|
|
<select id="queryTtManydaysTotalCharge" resultType="String">
|
|
<select id="queryTtManydaysTotalCharge" resultType="String">
|
|
SELECT IFNULL(sum(cost), 0.00)
|
|
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')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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>
|
|
|
|
|
|
<select id="queryTtManydaysCharge" resultType="com.alibaba.fastjson.JSONObject">
|
|
<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'
|
|
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')
|
|
and stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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
|
|
GROUP BY stat_datetime
|
|
order by stat_datetime
|
|
order by stat_datetime
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="queryKsManydaysCharge" resultType="com.alibaba.fastjson.JSONObject">
|
|
<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'
|
|
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')
|
|
and stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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
|
|
GROUP BY stat_date
|
|
order by stat_date
|
|
order by stat_date
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="queryKsManydaysTotalCharge" resultType="String">
|
|
<select id="queryKsManydaysTotalCharge" resultType="String">
|
|
SELECT IFNULL(sum(charge), 0.00)
|
|
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')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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>
|
|
|
|
|
|
<select id="queryKsRealCharged" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="queryKsRealCharged" resultType="com.alibaba.fastjson.JSONObject">
|
|
@@ -177,28 +218,33 @@
|
|
IFNULL( sum( real_charged_in_yuan ), 0.00 ) AS 'realCharged'
|
|
IFNULL( sum( real_charged_in_yuan ), 0.00 ) AS 'realCharged'
|
|
FROM
|
|
FROM
|
|
application.app_kuaishou_agent_report_d
|
|
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' )
|
|
AND stat_date <= DATE_FORMAT( #{statDay}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
|
+ AND account_id IN
|
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
) thisMonth
|
|
) thisMonth
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
IFNULL( sum( real_charged_in_yuan ), 0.00 ) AS 'realCharged'
|
|
IFNULL( sum( real_charged_in_yuan ), 0.00 ) AS 'realCharged'
|
|
FROM
|
|
FROM
|
|
application.app_kuaishou_agent_report_d
|
|
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' )
|
|
AND stat_date < DATE_FORMAT(#{monthFirstday}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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
|
|
) lastMonth ON 1=1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
@@ -213,28 +259,32 @@
|
|
IFNULL( sum( cash_cost ), 0.00 ) AS 'realCharged'
|
|
IFNULL( sum( cash_cost ), 0.00 ) AS 'realCharged'
|
|
FROM
|
|
FROM
|
|
application.app_bytedance_agent_report_d
|
|
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' )
|
|
AND stat_datetime <= DATE_FORMAT( #{statDay}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
|
+ AND
|
|
|
|
+ account_id IN
|
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
) thisMonth
|
|
) thisMonth
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
IFNULL( sum( cash_cost ), 0.00 ) AS 'realCharged'
|
|
IFNULL( sum( cash_cost ), 0.00 ) AS 'realCharged'
|
|
FROM
|
|
FROM
|
|
application.app_bytedance_agent_report_d
|
|
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' )
|
|
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
|
|
) lastMonth ON 1=1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
@@ -254,38 +304,6 @@
|
|
AND company_id = #{companyId}
|
|
AND company_id = #{companyId}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
- <select id="querySalesDirectorAccountIds" 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
|
|
|
|
- t1.account_status = 0
|
|
|
|
- AND t2.company_id = #{companyId}
|
|
|
|
- AND project_id IN (
|
|
|
|
- SELECT DISTINCT
|
|
|
|
- t1.project_id AS projectId
|
|
|
|
- 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>
|
|
|
|
- <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
|
|
|
|
- </select>
|
|
|
|
|
|
|
|
<select id="querySalesDirectorProjectIds" resultType="Long">
|
|
<select id="querySalesDirectorProjectIds" resultType="Long">
|
|
SELECT DISTINCT
|
|
SELECT DISTINCT
|
|
@@ -315,12 +333,15 @@
|
|
<select id="queryKsHourList" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="queryKsHourList" resultType="com.alibaba.fastjson.JSONObject">
|
|
SELECT hour,sum(charge) as 'charge'
|
|
SELECT hour,sum(charge) as 'charge'
|
|
FROM application.kuaishou_account_report_hourly_dw
|
|
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' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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
|
|
GROUP BY hour
|
|
ORDER BY hour
|
|
ORDER BY hour
|
|
</select>
|
|
</select>
|
|
@@ -328,12 +349,15 @@
|
|
<select id="queryTtHourList" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="queryTtHourList" resultType="com.alibaba.fastjson.JSONObject">
|
|
SELECT hour,sum(cost) as 'charge'
|
|
SELECT hour,sum(cost) as 'charge'
|
|
FROM application.bytedance_advertiser_report_hourly_dw
|
|
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' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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
|
|
GROUP BY hour
|
|
ORDER BY hour
|
|
ORDER BY hour
|
|
</select>
|
|
</select>
|
|
@@ -349,29 +373,33 @@
|
|
SELECT
|
|
SELECT
|
|
IFNULL( sum(cost), 0.00 ) AS 'charge'
|
|
IFNULL( sum(cost), 0.00 ) AS 'charge'
|
|
FROM
|
|
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' )
|
|
AND stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
|
+ AND account_id IN
|
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
) this
|
|
) this
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
IFNULL( sum(cost), 0.00 ) AS 'charge'
|
|
IFNULL( sum(cost), 0.00 ) AS 'charge'
|
|
FROM
|
|
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' )
|
|
AND stat_datetime <= DATE_FORMAT( #{lastTimeEnd}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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
|
|
) last ON 1=1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
@@ -386,29 +414,33 @@
|
|
SELECT
|
|
SELECT
|
|
IFNULL( sum(charge), 0.00 ) AS 'charge'
|
|
IFNULL( sum(charge), 0.00 ) AS 'charge'
|
|
FROM
|
|
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' )
|
|
AND stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
|
+ AND account_id IN
|
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
) this
|
|
) this
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
IFNULL( sum(charge), 0.00 ) AS 'charge'
|
|
IFNULL( sum(charge), 0.00 ) AS 'charge'
|
|
FROM
|
|
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' )
|
|
AND stat_date <= DATE_FORMAT( #{lastTimeEnd}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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
|
|
) last ON 1=1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
@@ -417,13 +449,16 @@
|
|
SELECT count(1)
|
|
SELECT count(1)
|
|
FROM
|
|
FROM
|
|
(select 1 from application.kuaishou_account_report_hourly_dw t1
|
|
(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')
|
|
and t1.stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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 project_id
|
|
GROUP BY project_id
|
|
) t
|
|
) t
|
|
</select>
|
|
</select>
|
|
@@ -432,13 +467,16 @@
|
|
SELECT count(1)
|
|
SELECT count(1)
|
|
FROM
|
|
FROM
|
|
(select 1 from application.bytedance_advertiser_report_hourly_dw t1
|
|
(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')
|
|
and t1.stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d')
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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 project_id
|
|
GROUP BY project_id
|
|
) t
|
|
) t
|
|
</select>
|
|
</select>
|
|
@@ -447,7 +485,7 @@
|
|
SELECT
|
|
SELECT
|
|
t1.project_id as 'projectId',
|
|
t1.project_id as 'projectId',
|
|
t1.project_name as 'projectName',
|
|
t1.project_name as 'projectName',
|
|
- ( SELECT realname FROM `jeecg-boot`.sys_user us WHERE us.id = t1.sale_id ) AS 'saleName',
|
|
|
|
|
|
+ t4.realname AS 'saleName',
|
|
SUM( t1.charge ) AS 'charge',
|
|
SUM( t1.charge ) AS 'charge',
|
|
CONCAT( CAST( IFNULL( ROUND(( SUM( 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',
|
|
'chargeRoi',
|
|
@@ -461,37 +499,44 @@
|
|
SUM(real_charged_in_yuan) as 'realCharge',
|
|
SUM(real_charged_in_yuan) as 'realCharge',
|
|
SUM(direct_rebate_real_charged_in_yuan) as 'jlCharge'
|
|
SUM(direct_rebate_real_charged_in_yuan) as 'jlCharge'
|
|
FROM application.app_kuaishou_agent_report_d
|
|
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' )
|
|
AND stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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 project_id
|
|
GROUP BY project_id
|
|
)t2 ON t1.project_id = t2.project_id
|
|
)t2 ON t1.project_id = t2.project_id
|
|
LEFT JOIN (
|
|
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}
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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(DATE_ADD(#{startTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
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' )
|
|
AND stat_date <= DATE_FORMAT(DATE_ADD(#{endTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
- 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>
|
|
|
|
|
|
+ GROUP BY project_id ) t3 ON t1.project_id = t3.project_id
|
|
|
|
+ left join(select id,realname from `jeecg-boot`.sys_user )t4 on t1.sale_id=t4.id
|
|
|
|
+ WHERE hour <= #{hour}
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
|
+ and t1.account_id IN
|
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
AND stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
AND stat_date >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
AND stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
AND stat_date <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
- AND hour <= #{hour}
|
|
|
|
GROUP BY t1.project_id
|
|
GROUP BY t1.project_id
|
|
</select>
|
|
</select>
|
|
|
|
|
|
@@ -500,7 +545,7 @@
|
|
SELECT
|
|
SELECT
|
|
t1.project_id as 'projectId',
|
|
t1.project_id as 'projectId',
|
|
t1.project_name as 'projectName',
|
|
t1.project_name as 'projectName',
|
|
- ( SELECT realname FROM `jeecg-boot`.sys_user us WHERE us.id = t1.sale_id ) AS 'saleName',
|
|
|
|
|
|
+ t4.realname AS 'saleName',
|
|
SUM( t1.cost ) AS 'charge',
|
|
SUM( t1.cost ) AS 'charge',
|
|
CONCAT( CAST( IFNULL( ROUND(( SUM( 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',
|
|
'chargeRoi',
|
|
@@ -514,40 +559,45 @@
|
|
SUM(cash_cost) as 'realCharge',
|
|
SUM(cash_cost) as 'realCharge',
|
|
SUM(grants_cost) AS 'jlCharge'
|
|
SUM(grants_cost) AS 'jlCharge'
|
|
FROM application.app_bytedance_agent_report_d
|
|
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' )
|
|
AND stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <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 project_id
|
|
GROUP BY project_id
|
|
)t2 ON t1.project_id = t2.project_id
|
|
)t2 ON t1.project_id = t2.project_id
|
|
LEFT JOIN (
|
|
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' )
|
|
AND stat_datetime <= DATE_FORMAT(DATE_ADD(#{endTime}, INTERVAL - ${days} DAY ), '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
|
+ and account_id IN
|
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
AND hour <= #{hour}
|
|
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' )
|
|
|
|
|
|
+ GROUP BY project_id ) t3 ON t1.project_id = t3.project_id
|
|
|
|
+ left join(select id,realname from `jeecg-boot`.sys_user )t4 on t1.sale_id=t4.id
|
|
|
|
+ WHERE t1.stat_datetime >= DATE_FORMAT(#{startTime}, '%Y%m%d' )
|
|
AND t1.stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
AND t1.stat_datetime <= DATE_FORMAT(#{endTime}, '%Y%m%d' )
|
|
|
|
+ and company_id = #{companyId}
|
|
|
|
+ <if test="accountIds !=null and accountIds.size()>0">
|
|
|
|
+ and account_id IN
|
|
|
|
+ <foreach collection="accountIds" item="id" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
AND hour <= #{hour}
|
|
AND hour <= #{hour}
|
|
GROUP BY t1.project_id
|
|
GROUP BY t1.project_id
|
|
</select>
|
|
</select>
|
|
|
|
|
|
-
|
|
|
|
</mapper>
|
|
</mapper>
|