|
@@ -18,395 +18,250 @@
|
|
<select id="queryAllBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="queryAllBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
SELECT e.*
|
|
SELECT e.*
|
|
from (
|
|
from (
|
|
- SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
|
|
|
|
|
|
+ SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost, (r.todayCost + r.yesterdayCost) as sumCost
|
|
|
|
+
|
|
from (
|
|
from (
|
|
- SELECT t1.advertiser_type as mediaType,
|
|
|
|
- t1.company_id as companyId,
|
|
|
|
- t1.id as advertiserId,
|
|
|
|
- t1.NAME as advertiserName,
|
|
|
|
- t2.id as projectId,
|
|
|
|
- t2.project_name as projectName,
|
|
|
|
- t2.responsible_name as operatorManger,
|
|
|
|
- t2.design_responsible_name as designManger,
|
|
|
|
|
|
+ SELECT t2.media_id as mediaType,
|
|
|
|
+ t1.company_id as companyId,
|
|
|
|
+ t1.id as advertiserId,
|
|
|
|
+ t1.NAME as advertiserName,
|
|
|
|
+ t2.id as projectId,
|
|
|
|
+ t2.project_name as projectName,
|
|
|
|
+ t2.responsible_name as operatorManger,
|
|
|
|
+ t2.design_responsible_name as designManger,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_user_allocation t3
|
|
from ctop_user_allocation t3
|
|
- where t2.id = t3.project_id) as operator,
|
|
|
|
- (SELECT realname from sys_user u WHERE u.id = t1.sale_id) as sale,
|
|
|
|
|
|
+ where t2.id = t3.project_id) as operator,
|
|
|
|
+ (SELECT realname from sys_user u WHERE u.id = t1.sale_id) as sale,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_project_member member
|
|
from ctop_project_member member
|
|
where t2.id = member.project_id
|
|
where t2.id = member.project_id
|
|
- and role_code = 'plan') as plan,
|
|
|
|
|
|
+ and role_code = 'plan') as plan,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_project_member member
|
|
from ctop_project_member member
|
|
where t2.id = member.project_id
|
|
where t2.id = member.project_id
|
|
- and role_code = 'shot') as shot,
|
|
|
|
|
|
+ and role_code = 'shot') as shot,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_project_member member
|
|
from ctop_project_member member
|
|
where t2.id = member.project_id
|
|
where t2.id = member.project_id
|
|
- and role_code = 'clip') as clip,
|
|
|
|
- case
|
|
|
|
- when
|
|
|
|
- (SELECT sum(cost)
|
|
|
|
- from ctop_bytedance_report_advertiser_daily report
|
|
|
|
- where report.advertiser_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_datetime = '${todayDate} 00:00:00') is null then 0
|
|
|
|
- else (SELECT sum(cost)
|
|
|
|
- from ctop_bytedance_report_advertiser_daily report
|
|
|
|
- where report.advertiser_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_datetime = '${todayDate} 00:00:00') END as todayCost,
|
|
|
|
- case
|
|
|
|
- when
|
|
|
|
- (SELECT sum(cost)
|
|
|
|
- from ctop_bytedance_report_advertiser_daily report
|
|
|
|
- where report.advertiser_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_datetime = '${yesterdayDate} 00:00:00') is null then 0
|
|
|
|
- else (SELECT sum(cost)
|
|
|
|
- from ctop_bytedance_report_advertiser_daily report
|
|
|
|
- where report.advertiser_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_datetime = '${yesterdayDate} 00:00:00') end as yesterdayCost
|
|
|
|
|
|
+ and role_code = 'clip') as clip,
|
|
|
|
+ IFNULL((SELECT sum(cost)
|
|
|
|
+ from ctop_bytedance_report_advertiser_daily report
|
|
|
|
+ where report.advertiser_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_datetime = '${todayDate} 00:00:00'), 0) as todayCost,
|
|
|
|
+ IFNULL((SELECT sum(cost)
|
|
|
|
+ from ctop_bytedance_report_advertiser_daily report
|
|
|
|
+ where report.advertiser_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_datetime = '${yesterdayDate} 00:00:00'), 0) as yesterdayCost
|
|
FROM ctop_advertiser t1
|
|
FROM ctop_advertiser t1
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
- where t1.advertiser_type = 1 and t2.id is not null) as r
|
|
|
|
|
|
+ where t2.media_id in(1,3)
|
|
|
|
+ and t2.id is not null) as r
|
|
|
|
|
|
UNION
|
|
UNION
|
|
|
|
|
|
- SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
|
|
|
|
|
|
+ SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost, (r.todayCost + r.yesterdayCost) as sumCost
|
|
from (
|
|
from (
|
|
- SELECT t1.advertiser_type as mediaType,
|
|
|
|
- t1.company_id as companyId,
|
|
|
|
- t1.id as advertiserId,
|
|
|
|
- t1.NAME as advertiserName,
|
|
|
|
- t2.id as projectId,
|
|
|
|
- t2.project_name as projectName,
|
|
|
|
- t2.responsible_name as operatorManger,
|
|
|
|
- t2.design_responsible_name as designManger,
|
|
|
|
|
|
+ SELECT t2.media_id as mediaType,
|
|
|
|
+ t1.company_id as companyId,
|
|
|
|
+ t1.id as advertiserId,
|
|
|
|
+ t1.NAME as advertiserName,
|
|
|
|
+ t2.id as projectId,
|
|
|
|
+ t2.project_name as projectName,
|
|
|
|
+ t2.responsible_name as operatorManger,
|
|
|
|
+ t2.design_responsible_name as designManger,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_user_allocation t3
|
|
from ctop_user_allocation t3
|
|
- where t2.id = t3.project_id) as operator,
|
|
|
|
- (SELECT realname from sys_user u WHERE u.id = t1.sale_id) as sale,
|
|
|
|
|
|
+ where t2.id = t3.project_id) as operator,
|
|
|
|
+ (SELECT realname from sys_user u WHERE u.id = t1.sale_id) as sale,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_project_member member
|
|
from ctop_project_member member
|
|
where t2.id = member.project_id
|
|
where t2.id = member.project_id
|
|
- and role_code = 'plan') as plan,
|
|
|
|
|
|
+ and role_code = 'plan') as plan,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_project_member member
|
|
from ctop_project_member member
|
|
where t2.id = member.project_id
|
|
where t2.id = member.project_id
|
|
- and role_code = 'shot') as shot,
|
|
|
|
|
|
+ and role_code = 'shot') as shot,
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
(SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
from ctop_project_member member
|
|
from ctop_project_member member
|
|
where t2.id = member.project_id
|
|
where t2.id = member.project_id
|
|
- and role_code = 'clip') as clip,
|
|
|
|
- case
|
|
|
|
- when
|
|
|
|
- (SELECT sum(charge)
|
|
|
|
- from ctop_kuaishou_report_daily_account report
|
|
|
|
- where report.account_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_date = '${todayDate}') is null then 0
|
|
|
|
- ELSE (SELECT sum(charge)
|
|
|
|
- from ctop_kuaishou_report_daily_account report
|
|
|
|
- where report.account_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_date = '${todayDate}') END as todayCost,
|
|
|
|
- case
|
|
|
|
- when
|
|
|
|
- (SELECT sum(charge)
|
|
|
|
- from ctop_kuaishou_report_daily_account report
|
|
|
|
- where report.account_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_date = '${yesterdayDate}') is null then 0
|
|
|
|
- ELSE (SELECT sum(charge)
|
|
|
|
- from ctop_kuaishou_report_daily_account report
|
|
|
|
- where report.account_id in (SELECT account_id
|
|
|
|
- from ctop_user_allocation t3
|
|
|
|
- where t2.id = t3.project_id)
|
|
|
|
- and report.stat_date = '${yesterdayDate}') end as yesterdayCost
|
|
|
|
|
|
+ and role_code = 'clip') as clip,
|
|
|
|
+ IFNULL((SELECT sum(charge)
|
|
|
|
+ from ctop_kuaishou_report_daily_account report
|
|
|
|
+ where report.account_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_date = '${todayDate}'), 0) as todayCost,
|
|
|
|
+ IFNULL((SELECT sum(charge)
|
|
|
|
+ from ctop_kuaishou_report_daily_account report
|
|
|
|
+ where report.account_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_date = '${yesterdayDate}'), 0) as yesterdayCost
|
|
FROM ctop_advertiser t1
|
|
FROM ctop_advertiser t1
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
- where t1.advertiser_type = 2 and t2.id is not null) as r
|
|
|
|
|
|
+ where t2.media_id in(2,4)
|
|
|
|
+ and t2.id is not null) as r
|
|
|
|
|
|
union
|
|
union
|
|
|
|
|
|
- SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
|
|
|
|
|
|
+ SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost, (r.todayCost + r.yesterdayCost) as sumCost
|
|
from (
|
|
from (
|
|
- SELECT '0' as mediaType,
|
|
|
|
- '-' as companyId,
|
|
|
|
- id as advertiserId,
|
|
|
|
- corporation_name as advertiserName,
|
|
|
|
- '-' as projectId,
|
|
|
|
- account_name as projectName,
|
|
|
|
- '-' as operatorManger,
|
|
|
|
- '-' as designManger,
|
|
|
|
- '-' as operator,
|
|
|
|
- '-' as sale,
|
|
|
|
- '-' as plan,
|
|
|
|
- '-' as shot,
|
|
|
|
- '-' as clip,
|
|
|
|
- case
|
|
|
|
- WHEN
|
|
|
|
- (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${todayDate}%') is null THEN 0
|
|
|
|
- ELSE (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${todayDate}%') end as todayCost,
|
|
|
|
- case
|
|
|
|
- WHEN
|
|
|
|
- (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${yesterdayDate}%') is null THEN 0
|
|
|
|
- ELSE (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${yesterdayDate}%') end as yesterdayCost
|
|
|
|
|
|
+ SELECT '- ' as mediaType,
|
|
|
|
+ '-' as companyId,
|
|
|
|
+ id as advertiserId,
|
|
|
|
+ corporation_name as advertiserName,
|
|
|
|
+ '-' as projectId,
|
|
|
|
+ account_name as projectName,
|
|
|
|
+ '-' as operatorManger,
|
|
|
|
+ '-' as designManger,
|
|
|
|
+ '-' as operator,
|
|
|
|
+ '-' as sale,
|
|
|
|
+ '-' as plan,
|
|
|
|
+ '-' as shot,
|
|
|
|
+ '-' as clip,
|
|
|
|
+ IFNULL((SELECT sum(balance)
|
|
|
|
+ from ctop_kuaishou_agent_account report
|
|
|
|
+ where report.id = t1.id
|
|
|
|
+ and report.create_time like '%${todayDate}%'), 0) as todayCost,
|
|
|
|
+ IFNULL((SELECT sum(balance)
|
|
|
|
+ from ctop_kuaishou_agent_account report
|
|
|
|
+ where report.id = t1.id
|
|
|
|
+ and report.create_time like '%${yesterdayDate}%'), 0) as yesterdayCost
|
|
from ctop_kuaishou_agent_account t1
|
|
from ctop_kuaishou_agent_account t1
|
|
where t1.create_time like '%${yesterdayDate}%'
|
|
where t1.create_time like '%${yesterdayDate}%'
|
|
GROUP by advertiserName, projectName) as r) as e
|
|
GROUP by advertiserName, projectName) as r) as e
|
|
|
|
+ ORDER BY sumCost desc
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="queryMediaReportBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="queryMediaReportBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
SELECT e.*
|
|
SELECT e.*
|
|
FROM (
|
|
FROM (
|
|
- SELECT r.*,
|
|
|
|
- (r.todayCost - r.yesterdayCost) AS diffCost
|
|
|
|
- FROM (
|
|
|
|
- SELECT t1.advertiser_type AS mediaType,
|
|
|
|
- t1.company_id as companyId,
|
|
|
|
- t1.id as advertiserId,
|
|
|
|
- t1.NAME as advertiserName,
|
|
|
|
- t2.id as projectId,
|
|
|
|
- t2.project_name AS projectName,
|
|
|
|
- t2.responsible_name AS operatorManger,
|
|
|
|
- t2.design_responsible_name AS designManger,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- ) AS operator,
|
|
|
|
- (
|
|
|
|
- SELECT realname
|
|
|
|
- FROM sys_user u
|
|
|
|
- WHERE u.id = t1.sale_id
|
|
|
|
- ) AS sale,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_project_member member
|
|
|
|
- WHERE t2.id = member.project_id
|
|
|
|
- AND role_code = 'plan'
|
|
|
|
- ) AS plan,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_project_member member
|
|
|
|
- WHERE t2.id = member.project_id
|
|
|
|
- AND role_code = 'shot'
|
|
|
|
- ) AS shot,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_project_member member
|
|
|
|
- WHERE t2.id = member.project_id
|
|
|
|
- AND role_code = 'clip'
|
|
|
|
- ) AS clip,
|
|
|
|
- CASE
|
|
|
|
- WHEN (
|
|
|
|
- SELECT sum(cost)
|
|
|
|
- FROM ctop_bytedance_report_advertiser_daily report
|
|
|
|
- WHERE report.advertiser_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_datetime = '${todayDate} 00:00:00'
|
|
|
|
- ) IS NULL THEN
|
|
|
|
- 0
|
|
|
|
- ELSE
|
|
|
|
- (
|
|
|
|
- SELECT sum(cost)
|
|
|
|
- FROM ctop_bytedance_report_advertiser_daily report
|
|
|
|
- WHERE report.advertiser_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_datetime = '${todayDate} 00:00:00'
|
|
|
|
- )
|
|
|
|
- END AS todayCost,
|
|
|
|
- CASE
|
|
|
|
- WHEN (
|
|
|
|
- SELECT sum(cost)
|
|
|
|
- FROM ctop_bytedance_report_advertiser_daily report
|
|
|
|
- WHERE report.advertiser_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_datetime = '${yesterdayDate} 00:00:00'
|
|
|
|
- ) IS NULL THEN
|
|
|
|
- 0
|
|
|
|
- ELSE
|
|
|
|
- (
|
|
|
|
- SELECT sum(cost)
|
|
|
|
- FROM ctop_bytedance_report_advertiser_daily report
|
|
|
|
- WHERE report.advertiser_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_datetime = '${yesterdayDate} 00:00:00'
|
|
|
|
- )
|
|
|
|
- END AS yesterdayCost
|
|
|
|
|
|
+ SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost, (r.todayCost + r.yesterdayCost) as sumCost
|
|
|
|
+
|
|
|
|
+ from (
|
|
|
|
+ SELECT t2.media_id as mediaType,
|
|
|
|
+ t1.company_id as companyId,
|
|
|
|
+ t1.id as advertiserId,
|
|
|
|
+ t1.NAME as advertiserName,
|
|
|
|
+ t2.id as projectId,
|
|
|
|
+ t2.project_name as projectName,
|
|
|
|
+ t2.responsible_name as operatorManger,
|
|
|
|
+ t2.design_responsible_name as designManger,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id) as operator,
|
|
|
|
+ (SELECT realname from sys_user u WHERE u.id = t1.sale_id) as sale,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_project_member member
|
|
|
|
+ where t2.id = member.project_id
|
|
|
|
+ and role_code = 'plan') as plan,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_project_member member
|
|
|
|
+ where t2.id = member.project_id
|
|
|
|
+ and role_code = 'shot') as shot,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_project_member member
|
|
|
|
+ where t2.id = member.project_id
|
|
|
|
+ and role_code = 'clip') as clip,
|
|
|
|
+ IFNULL((SELECT sum(cost)
|
|
|
|
+ from ctop_bytedance_report_advertiser_daily report
|
|
|
|
+ where report.advertiser_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_datetime = '${todayDate} 00:00:00'), 0) as todayCost,
|
|
|
|
+ IFNULL((SELECT sum(cost)
|
|
|
|
+ from ctop_bytedance_report_advertiser_daily report
|
|
|
|
+ where report.advertiser_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_datetime = '${yesterdayDate} 00:00:00'), 0) as yesterdayCost
|
|
FROM ctop_advertiser t1
|
|
FROM ctop_advertiser t1
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
- WHERE t1.advertiser_type = 1 and t2.id is not null
|
|
|
|
- ) AS r
|
|
|
|
|
|
+ where t2.media_id in(1,3)
|
|
|
|
+ and t2.id is not null) as r
|
|
|
|
+
|
|
UNION
|
|
UNION
|
|
- SELECT r.*,
|
|
|
|
- (r.todayCost - r.yesterdayCost) AS diffCost
|
|
|
|
- FROM (
|
|
|
|
- SELECT t1.advertiser_type AS mediaType,
|
|
|
|
- t1.company_id as companyId,
|
|
|
|
- t1.id as advertiserId,
|
|
|
|
- t1.NAME as advertiserName,
|
|
|
|
- t2.id as projectId,
|
|
|
|
- t2.project_name AS projectName,
|
|
|
|
- t2.responsible_name AS operatorManger,
|
|
|
|
- t2.design_responsible_name AS designManger,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- ) AS operator,
|
|
|
|
- (
|
|
|
|
- SELECT realname
|
|
|
|
- FROM sys_user u
|
|
|
|
- WHERE u.id = t1.sale_id
|
|
|
|
- ) AS sale,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_project_member member
|
|
|
|
- WHERE t2.id = member.project_id
|
|
|
|
- AND role_code = 'plan'
|
|
|
|
- ) AS plan,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_project_member member
|
|
|
|
- WHERE t2.id = member.project_id
|
|
|
|
- AND role_code = 'shot'
|
|
|
|
- ) AS shot,
|
|
|
|
- (
|
|
|
|
- SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
- FROM ctop_project_member member
|
|
|
|
- WHERE t2.id = member.project_id
|
|
|
|
- AND role_code = 'clip'
|
|
|
|
- ) AS clip,
|
|
|
|
- CASE
|
|
|
|
- WHEN (
|
|
|
|
- SELECT sum(charge)
|
|
|
|
- FROM ctop_kuaishou_report_daily_account report
|
|
|
|
- WHERE report.account_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_date = '${todayDate}'
|
|
|
|
- ) IS NULL THEN
|
|
|
|
- 0
|
|
|
|
- ELSE
|
|
|
|
- (
|
|
|
|
- SELECT sum(charge)
|
|
|
|
- FROM ctop_kuaishou_report_daily_account report
|
|
|
|
- WHERE report.account_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_date = '${todayDate}'
|
|
|
|
- )
|
|
|
|
- END AS todayCost,
|
|
|
|
- CASE
|
|
|
|
- WHEN (
|
|
|
|
- SELECT sum(charge)
|
|
|
|
- FROM ctop_kuaishou_report_daily_account report
|
|
|
|
- WHERE report.account_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_date = '${yesterdayDate}'
|
|
|
|
- ) IS NULL THEN
|
|
|
|
- 0
|
|
|
|
- ELSE
|
|
|
|
- (
|
|
|
|
- SELECT sum(charge)
|
|
|
|
- FROM ctop_kuaishou_report_daily_account report
|
|
|
|
- WHERE report.account_id IN (
|
|
|
|
- SELECT account_id
|
|
|
|
- FROM ctop_user_allocation t3
|
|
|
|
- WHERE t2.id = t3.project_id
|
|
|
|
- )
|
|
|
|
- AND report.stat_date = '${yesterdayDate}'
|
|
|
|
- )
|
|
|
|
- END AS yesterdayCost
|
|
|
|
|
|
+
|
|
|
|
+ SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost, (r.todayCost + r.yesterdayCost) as sumCost
|
|
|
|
+ from (
|
|
|
|
+ SELECT t2.media_id as mediaType,
|
|
|
|
+ t1.company_id as companyId,
|
|
|
|
+ t1.id as advertiserId,
|
|
|
|
+ t1.NAME as advertiserName,
|
|
|
|
+ t2.id as projectId,
|
|
|
|
+ t2.project_name as projectName,
|
|
|
|
+ t2.responsible_name as operatorManger,
|
|
|
|
+ t2.design_responsible_name as designManger,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id) as operator,
|
|
|
|
+ (SELECT realname from sys_user u WHERE u.id = t1.sale_id) as sale,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_project_member member
|
|
|
|
+ where t2.id = member.project_id
|
|
|
|
+ and role_code = 'plan') as plan,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_project_member member
|
|
|
|
+ where t2.id = member.project_id
|
|
|
|
+ and role_code = 'shot') as shot,
|
|
|
|
+ (SELECT GROUP_CONCAT(DISTINCT user_name)
|
|
|
|
+ from ctop_project_member member
|
|
|
|
+ where t2.id = member.project_id
|
|
|
|
+ and role_code = 'clip') as clip,
|
|
|
|
+ IFNULL((SELECT sum(charge)
|
|
|
|
+ from ctop_kuaishou_report_daily_account report
|
|
|
|
+ where report.account_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_date = '${todayDate}'), 0) as todayCost,
|
|
|
|
+ IFNULL((SELECT sum(charge)
|
|
|
|
+ from ctop_kuaishou_report_daily_account report
|
|
|
|
+ where report.account_id in (SELECT account_id
|
|
|
|
+ from ctop_user_allocation t3
|
|
|
|
+ where t2.id = t3.project_id)
|
|
|
|
+ and report.stat_date = '${yesterdayDate}'), 0) as yesterdayCost
|
|
FROM ctop_advertiser t1
|
|
FROM ctop_advertiser t1
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
LEFT JOIN ctop_project t2 ON t1.id = t2.advertiser_id
|
|
- WHERE t1.advertiser_type = 2 and t2.id is not null
|
|
|
|
- ) AS r) as e
|
|
|
|
|
|
+ where t2.media_id in(2,4)
|
|
|
|
+ and t2.id is not null) as r) as e
|
|
where companyId = ${condition}
|
|
where companyId = ${condition}
|
|
|
|
+ ORDER BY sumCost desc
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="queryAgentReportBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
<select id="queryAgentReportBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
- SELECT e.* from(
|
|
|
|
- SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost
|
|
|
|
- from (
|
|
|
|
- SELECT '0' as mediaType,
|
|
|
|
- '-' as companyId,
|
|
|
|
- id as advertiserId,
|
|
|
|
- corporation_name as advertiserName,
|
|
|
|
- '-' as projectId,
|
|
|
|
- account_name as projectName,
|
|
|
|
- '-' as operatorManger,
|
|
|
|
- '-' as designManger,
|
|
|
|
- '-' as operator,
|
|
|
|
- '-' as sale,
|
|
|
|
- '-' as plan,
|
|
|
|
- '-' as shot,
|
|
|
|
- '-' as clip,
|
|
|
|
- case
|
|
|
|
- WHEN
|
|
|
|
- (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${todayDate}%') is null THEN 0
|
|
|
|
- ELSE (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${todayDate}%') end as todayCost,
|
|
|
|
- case
|
|
|
|
- WHEN
|
|
|
|
- (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${yesterdayDate}%') is null THEN 0
|
|
|
|
- ELSE (SELECT sum(balance)
|
|
|
|
- from ctop_kuaishou_agent_account report
|
|
|
|
- where report.id = t1.id
|
|
|
|
- and report.create_time like '%${yesterdayDate}%') end as yesterdayCost
|
|
|
|
- from ctop_kuaishou_agent_account t1
|
|
|
|
- where t1.create_time like '%${yesterdayDate}%'
|
|
|
|
- GROUP by advertiserName, projectName
|
|
|
|
- )as r) as e
|
|
|
|
|
|
+ SELECT e.*
|
|
|
|
+ from (
|
|
|
|
+ SELECT r.*, (r.todayCost - r.yesterdayCost) as diffCost, (r.todayCost + r.yesterdayCost) as sumCost
|
|
|
|
+ from (
|
|
|
|
+ SELECT '-' as mediaType,
|
|
|
|
+ '-' as companyId,
|
|
|
|
+ id as advertiserId,
|
|
|
|
+ corporation_name as advertiserName,
|
|
|
|
+ '-' as projectId,
|
|
|
|
+ account_name as projectName,
|
|
|
|
+ '-' as operatorManger,
|
|
|
|
+ '-' as designManger,
|
|
|
|
+ '-' as operator,
|
|
|
|
+ '-' as sale,
|
|
|
|
+ '-' as plan,
|
|
|
|
+ '-' as shot,
|
|
|
|
+ '-' as clip,
|
|
|
|
+ IFNULL((SELECT sum(balance)
|
|
|
|
+ from ctop_kuaishou_agent_account report
|
|
|
|
+ where report.id = t1.id
|
|
|
|
+ and report.create_time like '%${todayDate}%'), 0) as todayCost,
|
|
|
|
+ IFNULL((SELECT sum(balance)
|
|
|
|
+ from ctop_kuaishou_agent_account report
|
|
|
|
+ where report.id = t1.id
|
|
|
|
+ and report.create_time like '%${yesterdayDate}%'), 0) as yesterdayCost
|
|
|
|
+ from ctop_kuaishou_agent_account t1
|
|
|
|
+ where t1.create_time like '%${yesterdayDate}%'
|
|
|
|
+ GROUP by advertiserName, projectName) as r) as e
|
|
|
|
+ ORDER BY sumCost desc
|
|
</select>
|
|
</select>
|
|
</mapper>
|
|
</mapper>
|