diff --git a/pom.xml b/pom.xml
index 62377ab20..ebcbbb303 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
UTF-8
1.1.2
- 1.0.43
+ 1.0.44
diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml
index 673aae015..3f0bcb658 100644
--- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml
+++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml
@@ -553,43 +553,89 @@
fbc.bd_name,
fbc.bd_group,
fbc.bd_type,
- count( * ) clients_month
+ sum( a.proportion ) clients_month
FROM
- sys_clients sc
- INNER JOIN sys_client_bd d ON sc.client_id = d.client_id
- INNER JOIN financial_bd_config c ON d.bd_id = c.manager_id
- INNER JOIN financial_bd_config fbc ON fbc.manager_id = c.bd_group
+ sys_client_bd a
+ INNER JOIN (
+ SELECT
+ bd_id,
+ max( create_time ) create_time
+ FROM
+ sys_client_bd
WHERE
- sc.org_id = 1
- AND sc.create_time >= #{start_date_month}
- AND d.is_valid = 1
- AND c.bd_group IS NOT NULL
- AND d.start_date <= now( ) AND d.is_valid = 1 AND ( d.end_date IS NULL OR d.end_date > now( )
+ client_id IN (
+ SELECT
+ client_id
+ FROM
+ sys_clients c
+ WHERE
+ c.approve_time >= #{start_date_month}
+ AND c.approve_time <= #{end_date}
+ AND c.is_valid = 1
+ AND c.approve_result = 1
+ AND c.org_id = 1
+ )
+ AND start_date <= #{end_date} AND is_valid = 1 AND ( end_date > #{start_date_month}
+ OR end_date IS NULL
)
GROUP BY
- fbc.bd_type
+ bd_id,
+ client_id
+ ) b ON a.bd_id = b.bd_id
+ AND a.create_time = b.create_time
+ INNER JOIN financial_bd_config c ON a.bd_id = c.manager_id
+ INNER JOIN financial_bd_config fbc ON fbc.manager_id = c.bd_group
+ WHERE
+ a.is_valid = 1
+ GROUP BY
+ fbc.bd_group
+ ORDER BY
+ clients_month DESC
) t1
LEFT JOIN (
SELECT
- count( * ) clients_yesterday,
- fbc.bd_group
+ fbc.bd_name,
+ fbc.bd_group,
+ fbc.bd_type,
+ sum( a.proportion ) clients_yesterday
FROM
- sys_clients sc
- INNER JOIN sys_client_bd d ON sc.client_id = d.client_id
- INNER JOIN financial_bd_config c ON d.bd_id = c.manager_id
- INNER JOIN financial_bd_config fbc ON fbc.manager_id = c.bd_group
+ sys_client_bd a
+ INNER JOIN (
+ SELECT
+ bd_id,
+ max( create_time ) create_time
+ FROM
+ sys_client_bd
+ WHERE
+ client_id IN (
+ SELECT
+ client_id
+ FROM
+ sys_clients c
WHERE
- sc.org_id = 1
- AND sc.create_time >= #{start_date}
- AND sc.create_time < #{end_date}
- AND d.is_valid = 1
- AND d.start_date <= now( ) AND d.is_valid = 1 AND ( d.end_date IS NULL OR d.end_date > now( )
+ c.approve_time >= #{start_date}
+ AND c.approve_time < #{end_date}
+ AND c.is_valid = 1
+ AND c.approve_result = 1
+ AND c.org_id = 1
+ )
+ AND start_date <= #{end_date} AND is_valid = 1 AND ( end_date > #{start_date}
+ OR end_date IS NULL
)
GROUP BY
- fbc.bd_type
- ) t2 ON t1.bd_group = t2.bd_group
+ bd_id,
+ client_id
+ ) b ON a.bd_id = b.bd_id
+ AND a.create_time = b.create_time
+ INNER JOIN financial_bd_config c ON a.bd_id = c.manager_id
+ INNER JOIN financial_bd_config fbc ON fbc.manager_id = c.bd_group
WHERE
- t1.bd_type IN ( 1, 2, 6, 7 )
+ a.is_valid = 1
+ GROUP BY
+ fbc.bd_group
+ ORDER BY
+ clients_yesterday DESC
+ ) t2 ON t1.bd_group = t2.bd_group