|
|
|
@ -15,198 +15,210 @@
|
|
|
|
|
<select id="analysisOrderSuccessRateInTypes" resultMap="successRateInTypes">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
gateway,
|
|
|
|
|
(CASE gateway
|
|
|
|
|
WHEN 0
|
|
|
|
|
THEN 'Retail-In-Store(Scan)'
|
|
|
|
|
WHEN 1
|
|
|
|
|
THEN 'Retail-In-Store(QRCode)'
|
|
|
|
|
WHEN 2
|
|
|
|
|
THEN '商户二维码(JsApi)'
|
|
|
|
|
WHEN 3
|
|
|
|
|
THEN 'Gateway QR Code'
|
|
|
|
|
WHEN 4
|
|
|
|
|
THEN 'Gateway JsApi'
|
|
|
|
|
WHEN 5
|
|
|
|
|
THEN 'Gateway Retail Api(Scan)'
|
|
|
|
|
WHEN 6
|
|
|
|
|
THEN 'Gateway Retail Api(QRCode)'
|
|
|
|
|
WHEN 7
|
|
|
|
|
THEN '商户二维码(QRCode)'
|
|
|
|
|
END) label,
|
|
|
|
|
date_format(create_time, '%Y-%m-%d') date,
|
|
|
|
|
count(order_id) total,
|
|
|
|
|
sum(if(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(if(o.status > 4, 1, 0)) success
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
WHERE date(o.create_time) >= date(#{begin}) AND date(o.create_time) <= date(#{end})
|
|
|
|
|
AND o.status > 1
|
|
|
|
|
GROUP BY date(o.create_time), o.gateway
|
|
|
|
|
) t
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
gateway,
|
|
|
|
|
(CASE gateway
|
|
|
|
|
WHEN 0
|
|
|
|
|
THEN 'Retail-In-Store(Scan)'
|
|
|
|
|
WHEN 1
|
|
|
|
|
THEN 'Retail-In-Store(QRCode)'
|
|
|
|
|
WHEN 2
|
|
|
|
|
THEN '商户二维码(JsApi)'
|
|
|
|
|
WHEN 3
|
|
|
|
|
THEN 'Gateway QR Code'
|
|
|
|
|
WHEN 4
|
|
|
|
|
THEN 'Gateway JsApi'
|
|
|
|
|
WHEN 5
|
|
|
|
|
THEN 'Gateway Retail Api(Scan)'
|
|
|
|
|
WHEN 6
|
|
|
|
|
THEN 'Gateway Retail Api(QRCode)'
|
|
|
|
|
WHEN 7
|
|
|
|
|
THEN '商户二维码(QRCode)'
|
|
|
|
|
END) label,
|
|
|
|
|
date_format(create_time, '%Y-%m-%d') date,
|
|
|
|
|
count(order_id) total,
|
|
|
|
|
sum(if(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(if(o.status > 4, 1, 0)) success
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
WHERE date(o.create_time) >= date(#{begin}) AND date(o.create_time) <= date(#{end})
|
|
|
|
|
AND o.status > 1
|
|
|
|
|
GROUP BY date(o.create_time), o.gateway
|
|
|
|
|
) t
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]]>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="analysisOrderSuccessRateOfAll" resultMap="successRateInTypes">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
-1 gateway,
|
|
|
|
|
'All' label,
|
|
|
|
|
date_format(create_time, '%Y-%m-%d') date,
|
|
|
|
|
count(order_id) total,
|
|
|
|
|
sum(if(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(if(o.status > 4, 1, 0)) success
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
WHERE date(o.create_time) >= date(#{begin}) AND date(o.create_time) <= date(#{end})
|
|
|
|
|
AND o.status > 1
|
|
|
|
|
GROUP BY date(o.create_time)
|
|
|
|
|
) t
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
-1 gateway,
|
|
|
|
|
'All' label,
|
|
|
|
|
date_format(create_time, '%Y-%m-%d') date,
|
|
|
|
|
count(order_id) total,
|
|
|
|
|
sum(if(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(if(o.status > 4, 1, 0)) success
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
WHERE date(o.create_time) >= date(#{begin}) AND date(o.create_time) <= date(#{end})
|
|
|
|
|
AND o.status > 1
|
|
|
|
|
GROUP BY date(o.create_time)
|
|
|
|
|
) t
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]]>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="analysisOrderSuccessRateDetailOfClients" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage,
|
|
|
|
|
if(t.retail_scan_total = 0, '-',
|
|
|
|
|
format(t.retail_scan_success / t.retail_scan_total * 100, 2)) retail_scan_percentage,
|
|
|
|
|
if(t.retail_qr_total = 0, '-', format(t.retail_qr_success / t.retail_qr_total * 100, 2))
|
|
|
|
|
retail_qr_percentage,
|
|
|
|
|
if(t.qrcode_jsapi_total = 0, '-', format(t.qrcode_jsapi_success / t.qrcode_jsapi_total * 100, 2))
|
|
|
|
|
qrcode_jsapi_percentage,
|
|
|
|
|
if(t.qrcode_code_total = 0, '-', format(t.qrcode_code_success / t.qrcode_code_total * 100, 2))
|
|
|
|
|
qrcode_code_percentage,
|
|
|
|
|
IF(t.gateway_code_total = 0, '-', FORMAT(t.gateway_code_success / t.gateway_code_total * 100, 2))
|
|
|
|
|
gateway_code_percentage,
|
|
|
|
|
if(t.gateway_jsapi_total = 0, '-', FORMAT(t.gateway_jsapi_success / t.gateway_jsapi_total * 100, 2))
|
|
|
|
|
gateway_jsapi_percentage,
|
|
|
|
|
if(t.retail_api_scan_total = 0, '-', FORMAT(t.retail_api_scan_success / t.retail_api_scan_total * 100, 2))
|
|
|
|
|
retail_api_scan_percentage,
|
|
|
|
|
if(t.retail_api_code_total = 0, '-', FORMAT(t.retail_api_code_success / t.retail_api_code_total * 100, 2))
|
|
|
|
|
retail_api_code_percentage
|
|
|
|
|
FROM (SELECT
|
|
|
|
|
c.client_id,
|
|
|
|
|
c.client_moniker,
|
|
|
|
|
c.short_name,
|
|
|
|
|
COUNT(order_id) total,
|
|
|
|
|
sum(IF(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(IF(o.status > 4, 1, 0)) success,
|
|
|
|
|
sum(IF(o.gateway = 0, 1, 0)) retail_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 0, 1, 0)) retail_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 0, 1, 0)) retail_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 1, 1, 0)) retail_qr_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 1, 1, 0)) retail_qr_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 1, 1, 0)) retail_qr_success,
|
|
|
|
|
sum(IF(o.gateway = 2, 1, 0)) qrcode_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 2, 1, 0)) qrcode_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 2, 1, 0)) qrcode_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 3, 1, 0)) gateway_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 3, 1, 0)) gateway_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 3, 1, 0)) gateway_code_success,
|
|
|
|
|
sum(IF(o.gateway = 4, 1, 0)) gateway_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 4, 1, 0)) gateway_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 4, 1, 0)) gateway_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 5, 1, 0)) retail_api_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 5, 1, 0)) retail_api_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 5, 1, 0)) retail_api_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 6, 1, 0)) retail_api_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 6, 1, 0)) retail_api_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 6, 1, 0)) retail_api_code_success,
|
|
|
|
|
sum(IF(o.gateway = 7, 1, 0)) qrcode_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 7, 1, 0)) qrcode_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 7, 1, 0)) qrcode_code_success,
|
|
|
|
|
sum(IF(o.gateway = 8, 1, 0)) gateway_h5_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 8, 1, 0)) gateway_h5_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 8, 1, 0)) gateway_h5_success
|
|
|
|
|
FROM sys_clients c
|
|
|
|
|
INNER JOIN pmt_orders o
|
|
|
|
|
ON o.client_id = c.client_id AND o.status > 1 AND DATE(o.create_time) = DATE(#{date})
|
|
|
|
|
WHERE c.is_valid = 1
|
|
|
|
|
GROUP BY c.client_id
|
|
|
|
|
) t
|
|
|
|
|
ORDER BY t.failed DESC
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage,
|
|
|
|
|
if(t.retail_scan_total = 0, '-',
|
|
|
|
|
format(t.retail_scan_success / t.retail_scan_total * 100, 2)) retail_scan_percentage,
|
|
|
|
|
if(t.retail_qr_total = 0, '-', format(t.retail_qr_success / t.retail_qr_total * 100, 2))
|
|
|
|
|
retail_qr_percentage,
|
|
|
|
|
if(t.qrcode_jsapi_total = 0, '-', format(t.qrcode_jsapi_success / t.qrcode_jsapi_total * 100, 2))
|
|
|
|
|
qrcode_jsapi_percentage,
|
|
|
|
|
if(t.qrcode_code_total = 0, '-', format(t.qrcode_code_success / t.qrcode_code_total * 100, 2))
|
|
|
|
|
qrcode_code_percentage,
|
|
|
|
|
IF(t.gateway_code_total = 0, '-', FORMAT(t.gateway_code_success / t.gateway_code_total * 100, 2))
|
|
|
|
|
gateway_code_percentage,
|
|
|
|
|
if(t.gateway_jsapi_total = 0, '-', FORMAT(t.gateway_jsapi_success / t.gateway_jsapi_total * 100, 2))
|
|
|
|
|
gateway_jsapi_percentage,
|
|
|
|
|
if(t.retail_api_scan_total = 0, '-', FORMAT(t.retail_api_scan_success / t.retail_api_scan_total * 100, 2))
|
|
|
|
|
retail_api_scan_percentage,
|
|
|
|
|
if(t.retail_api_code_total = 0, '-', FORMAT(t.retail_api_code_success / t.retail_api_code_total * 100, 2))
|
|
|
|
|
retail_api_code_percentage
|
|
|
|
|
FROM (SELECT
|
|
|
|
|
c.client_id,
|
|
|
|
|
c.client_moniker,
|
|
|
|
|
c.short_name,
|
|
|
|
|
COUNT(order_id) total,
|
|
|
|
|
sum(IF(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(IF(o.status > 4, 1, 0)) success,
|
|
|
|
|
sum(IF(o.gateway = 0, 1, 0)) retail_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 0, 1, 0)) retail_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 0, 1, 0)) retail_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 1, 1, 0)) retail_qr_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 1, 1, 0)) retail_qr_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 1, 1, 0)) retail_qr_success,
|
|
|
|
|
sum(IF(o.gateway = 2, 1, 0)) qrcode_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 2, 1, 0)) qrcode_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 2, 1, 0)) qrcode_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 3, 1, 0)) gateway_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 3, 1, 0)) gateway_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 3, 1, 0)) gateway_code_success,
|
|
|
|
|
sum(IF(o.gateway = 4, 1, 0)) gateway_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 4, 1, 0)) gateway_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 4, 1, 0)) gateway_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 5, 1, 0)) retail_api_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 5, 1, 0)) retail_api_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 5, 1, 0)) retail_api_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 6, 1, 0)) retail_api_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 6, 1, 0)) retail_api_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 6, 1, 0)) retail_api_code_success,
|
|
|
|
|
sum(IF(o.gateway = 7, 1, 0)) qrcode_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 7, 1, 0)) qrcode_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 7, 1, 0)) qrcode_code_success,
|
|
|
|
|
sum(IF(o.gateway = 8, 1, 0)) gateway_h5_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 8, 1, 0)) gateway_h5_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 8, 1, 0)) gateway_h5_success
|
|
|
|
|
FROM sys_clients c
|
|
|
|
|
INNER JOIN pmt_orders o
|
|
|
|
|
ON o.client_id = c.client_id AND o.status > 1 AND DATE(o.create_time) = DATE(#{date})
|
|
|
|
|
WHERE c.is_valid = 1
|
|
|
|
|
GROUP BY c.client_id
|
|
|
|
|
) t
|
|
|
|
|
ORDER BY t.failed DESC
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]]>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="analysisOrderSuccessRateDetailOfGlobal" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage,
|
|
|
|
|
if(t.retail_scan_total = 0, '-', format(t.retail_scan_success / t.retail_scan_total * 100, 2))
|
|
|
|
|
retail_scan_percentage,
|
|
|
|
|
if(t.retail_qr_total = 0, '-', format(t.retail_qr_success / t.retail_qr_total * 100, 2))
|
|
|
|
|
retail_qr_percentage,
|
|
|
|
|
if(t.qrcode_jsapi_total = 0, '-', format(t.qrcode_jsapi_success / t.qrcode_jsapi_total * 100, 2))
|
|
|
|
|
qrcode_jsapi_percentage,
|
|
|
|
|
if(t.qrcode_code_total = 0, '-', format(t.qrcode_code_success / t.qrcode_code_total * 100, 2))
|
|
|
|
|
qrcode_code_percentage,
|
|
|
|
|
IF(t.gateway_code_total = 0, '-', FORMAT(t.gateway_code_success / t.gateway_code_total * 100, 2))
|
|
|
|
|
gateway_code_percentage,
|
|
|
|
|
if(t.gateway_jsapi_total = 0, '-', FORMAT(t.gateway_jsapi_success / t.gateway_jsapi_total * 100, 2))
|
|
|
|
|
gateway_jsapi_percentage,
|
|
|
|
|
if(t.retail_api_scan_total = 0, '-', FORMAT(t.retail_api_scan_success / t.retail_api_scan_total * 100, 2))
|
|
|
|
|
retail_api_scan_percentage,
|
|
|
|
|
if(t.retail_api_code_total = 0, '-', FORMAT(t.retail_api_code_success / t.retail_api_code_total * 100, 2))
|
|
|
|
|
retail_api_code_percentage
|
|
|
|
|
FROM (SELECT
|
|
|
|
|
COUNT(order_id) total,
|
|
|
|
|
sum(IF(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(IF(o.status > 4, 1, 0)) success,
|
|
|
|
|
sum(IF(o.gateway = 0, 1, 0)) retail_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 0, 1, 0)) retail_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 0, 1, 0)) retail_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 1, 1, 0)) retail_qr_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 1, 1, 0)) retail_qr_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 1, 1, 0)) retail_qr_success,
|
|
|
|
|
sum(IF(o.gateway = 2, 1, 0)) qrcode_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 2, 1, 0)) qrcode_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 2, 1, 0)) qrcode_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 3, 1, 0)) gateway_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 3, 1, 0)) gateway_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 3, 1, 0)) gateway_code_success,
|
|
|
|
|
sum(IF(o.gateway = 4, 1, 0)) gateway_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 4, 1, 0)) gateway_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 4, 1, 0)) gateway_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 5, 1, 0)) retail_api_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 5, 1, 0)) retail_api_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 5, 1, 0)) retail_api_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 6, 1, 0)) retail_api_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 6, 1, 0)) retail_api_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 6, 1, 0)) retail_api_code_success,
|
|
|
|
|
sum(IF(o.gateway = 7, 1, 0)) qrcode_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 7, 1, 0)) qrcode_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 7, 1, 0)) qrcode_code_success
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
WHERE o.status > 1 AND DATE(o.create_time) = DATE(#{date})
|
|
|
|
|
) t
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
t.*,
|
|
|
|
|
format(t.success / t.total * 100, 2) percentage,
|
|
|
|
|
if(t.retail_scan_total = 0, '-', format(t.retail_scan_success / t.retail_scan_total * 100, 2))
|
|
|
|
|
retail_scan_percentage,
|
|
|
|
|
if(t.retail_qr_total = 0, '-', format(t.retail_qr_success / t.retail_qr_total * 100, 2))
|
|
|
|
|
retail_qr_percentage,
|
|
|
|
|
if(t.qrcode_jsapi_total = 0, '-', format(t.qrcode_jsapi_success / t.qrcode_jsapi_total * 100, 2))
|
|
|
|
|
qrcode_jsapi_percentage,
|
|
|
|
|
if(t.qrcode_code_total = 0, '-', format(t.qrcode_code_success / t.qrcode_code_total * 100, 2))
|
|
|
|
|
qrcode_code_percentage,
|
|
|
|
|
IF(t.gateway_code_total = 0, '-', FORMAT(t.gateway_code_success / t.gateway_code_total * 100, 2))
|
|
|
|
|
gateway_code_percentage,
|
|
|
|
|
if(t.gateway_jsapi_total = 0, '-', FORMAT(t.gateway_jsapi_success / t.gateway_jsapi_total * 100, 2))
|
|
|
|
|
gateway_jsapi_percentage,
|
|
|
|
|
if(t.retail_api_scan_total = 0, '-', FORMAT(t.retail_api_scan_success / t.retail_api_scan_total * 100, 2))
|
|
|
|
|
retail_api_scan_percentage,
|
|
|
|
|
if(t.retail_api_code_total = 0, '-', FORMAT(t.retail_api_code_success / t.retail_api_code_total * 100, 2))
|
|
|
|
|
retail_api_code_percentage
|
|
|
|
|
FROM (SELECT
|
|
|
|
|
COUNT(order_id) total,
|
|
|
|
|
sum(IF(o.status < 5, 1, 0)) failed,
|
|
|
|
|
sum(IF(o.status > 4, 1, 0)) success,
|
|
|
|
|
sum(IF(o.gateway = 0, 1, 0)) retail_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 0, 1, 0)) retail_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 0, 1, 0)) retail_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 1, 1, 0)) retail_qr_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 1, 1, 0)) retail_qr_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 1, 1, 0)) retail_qr_success,
|
|
|
|
|
sum(IF(o.gateway = 2, 1, 0)) qrcode_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 2, 1, 0)) qrcode_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 2, 1, 0)) qrcode_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 3, 1, 0)) gateway_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 3, 1, 0)) gateway_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 3, 1, 0)) gateway_code_success,
|
|
|
|
|
sum(IF(o.gateway = 4, 1, 0)) gateway_jsapi_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 4, 1, 0)) gateway_jsapi_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 4, 1, 0)) gateway_jsapi_success,
|
|
|
|
|
sum(IF(o.gateway = 5, 1, 0)) retail_api_scan_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 5, 1, 0)) retail_api_scan_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 5, 1, 0)) retail_api_scan_success,
|
|
|
|
|
sum(IF(o.gateway = 6, 1, 0)) retail_api_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 6, 1, 0)) retail_api_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 6, 1, 0)) retail_api_code_success,
|
|
|
|
|
sum(IF(o.gateway = 7, 1, 0)) qrcode_code_total,
|
|
|
|
|
sum(IF(o.status < 5 AND o.gateway = 7, 1, 0)) qrcode_code_failed,
|
|
|
|
|
sum(IF(o.status > 4 AND o.gateway = 7, 1, 0)) qrcode_code_success
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
WHERE o.status > 1 AND DATE(o.create_time) = DATE(#{date})
|
|
|
|
|
) t
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]]>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="listCustomersData" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT r.nickname,r.headimg,o.customer_id,sum(if(o.status='5',o.customer_payment_amount,0)) amount,
|
|
|
|
|
SELECT r.nickname,r.headimg,r.sex,o.customer_id,sum(o.customer_payment_amount) amount,
|
|
|
|
|
COUNT(DISTINCT o.order_id) orders,max(o.customer_payment_amount) max_order
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
<if test="openid_type==4">
|
|
|
|
|
LEFT JOIN sys_customer_relation r on r.globalpay_openid = o.customer_id
|
|
|
|
|
</if>
|
|
|
|
|
<if test="openid_type!=4">
|
|
|
|
|
<if test="openid_type==2">
|
|
|
|
|
LEFT JOIN sys_customer_relation_alipay r on r.alipay_uid = o.customer_id
|
|
|
|
|
</if>
|
|
|
|
|
<if test="openid_type!=4 and openid_type!=2">
|
|
|
|
|
LEFT JOIN sys_customer_relation r on r.wechat_openid = o.customer_id
|
|
|
|
|
</if>
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="openid_type==0">
|
|
|
|
@ -229,11 +241,99 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY o.customer_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="mostUseClientsByCustomer" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
select o.client_id,c.client_moniker,count(1) as orders from pmt_orders o INNER JOIN sys_clients c on
|
|
|
|
|
c.client_id=o.client_id
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="customer_id!=null">
|
|
|
|
|
and o.customer_id=#{customer_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY client_id order by orders desc limit 3;
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="mostUseIndustryByCustomer" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
select o.client_id,c.royalpayindustry,count(1) as orders from pmt_orders o INNER JOIN sys_clients c on
|
|
|
|
|
c.client_id=o.client_id
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="customer_id!=null">
|
|
|
|
|
and o.customer_id=#{customer_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY c.royalpayindustry order by orders desc limit 3;
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="mostUseAddressByCustomer" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
select o.customer_ip,count(1) as orders from pmt_orders o
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="customer_id!=null">
|
|
|
|
|
and o.customer_id=#{customer_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY substring_index(o.customer_ip,'.',2) order by orders desc limit 10;
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="mostUseAmountByCustomer" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT count(1) as orders ,substring_index((o.customer_payment_amount/100),'.',1) as amount_int from pmt_orders o
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="customer_id!=null">
|
|
|
|
|
and o.customer_id=#{customer_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY substring_index((o.customer_payment_amount/100),'.',1) order by orders desc limit 1;
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="mostUseTimesByCustomer" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT count(1) as orders ,hour(o.create_time),o.create_time from pmt_orders o
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="customer_id!=null">
|
|
|
|
|
and o.customer_id=#{customer_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY hour(o.create_time) order by orders desc limit 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="countCustomersData" resultType="int">
|
|
|
|
|
SELECT count(distinct o.customer_id)
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
@ -260,7 +360,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@ -290,7 +391,50 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="listClientsByCustomerId" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT COUNT(1) as orders,SUM(IF(t.transaction_type='Credit',t.clearing_amount,0))
|
|
|
|
|
total_amount,c.client_moniker,c.short_name,o.customer_id,c.royalpayindustry,o.customer_ip
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
INNER JOIN sys_clients c ON o.client_id=c.client_id
|
|
|
|
|
INNER JOIN pmt_transactions t ON t.order_id = o.order_id
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="customer_id!=null">
|
|
|
|
|
and o.customer_id=#{customer_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY o.client_id ORDER BY orders DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="listClientsTotalByCustomerId" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT COUNT(1) as orders,SUM(IF(t.transaction_type='Credit',t.clearing_amount,0))
|
|
|
|
|
total_amount
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
INNER JOIN sys_clients c ON o.client_id=c.client_id
|
|
|
|
|
INNER JOIN pmt_transactions t ON t.order_id = o.order_id
|
|
|
|
|
<where>
|
|
|
|
|
o.status>4
|
|
|
|
|
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and o.create_time < #{end}</if>
|
|
|
|
|
<if test="customer_id!=null">
|
|
|
|
|
and o.customer_id=#{customer_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</mapper>
|