SELECT atr.trade_time,
atr.cust_id,
ci.cust_num,
ci.nick_name as cust_name,
ci.phonenumber as mobile,
atr.psn_type,
cpt.psn_type_name,
atr.crby,
atr.id as tradeId,
atr.trade_state,
atr.batch_num,
atr.remark,
atr.amount as rechargeAmount,
atwd.wallet_bal as rechargeAfterWalletBal,
atwd.validate_time
FROM
acc_trade atr
LEFT JOIN sys_user ci ON ci.cust_id = atr.cust_id
LEFT JOIN cust_psn_type cpt ON cpt.psn_type = atr.psn_type
LEFT JOIN sys_dept co ON co.dept_id = atr.org_id
LEFT JOIN acc_trade_wallet_detail atwd ON atr.id = atwd.trade_id
ORDER BY atr.trade_time desc,atr.id desc
atr.trade_type = 20 and atr.pay_state = 3
and atr.id = #{param.accTradeId}
and atr.trade_time = ]]> #{param.startDateTime}
and atr.trade_time #{param.endDateTime}
and atr.crby like #{param.crBy}
and atr.batch_num = #{param.batchNum}
and atr.org_id in
#{orgId}
and atr.cust_id = #{param.custId}
and (ci.cust_num LIKE CONCAT('%', #{param.keyword},'%')
or ci.nick_name = #{param.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.phonenumber = #{param.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.nick_name_like LIKE CONCAT('%',#{param.keyword,typeHandler=net.xnzn.core.common.encrypt.CipherQueryLikeHandler},'%')
)
SELECT atr.trade_time,
atr.cust_id,
ci.cust_num,
ci.nick_name AS cust_name,
ci.phonenumber AS mobile,
atr.psn_type,
cpt.psn_type_name,
atr.amount as clearAmount,
atwd.wallet_bal as clearAfterWalletBal,
atr.crby,
atr.id as tradeId
FROM
acc_trade atr
LEFT JOIN sys_user ci ON ci.cust_id = atr.cust_id
LEFT JOIN sys_dept co ON co.dept_id = atr.org_id
LEFT JOIN cust_psn_type cpt ON cpt.psn_type = atr.psn_type
LEFT JOIN acc_trade_wallet_detail atwd ON atr.id = atwd.trade_id
ORDER BY atr.trade_time desc,atr.id desc
atr.trade_type = 100 and atr.pay_state = 3
and atr.trade_time = ]]> #{param.startDateTime}
and atr.trade_time #{param.endDateTime}
and atr.crby like #{param.crBy}
and atr.batch_num = #{param.batchNum}
and atr.org_id in
#{orgId}
and atr.cust_id = #{param.custId}
and atr.id = #{param.accTradeId}
SELECT
ci.cust_id,
ci.cust_num,
ci.nick_name as cust_name,
ci.phonenumber as mobile,
IFNULL(t3.count,0) AS `times`,
IFNULL(t3.amount,0) AS `amount`,
IFNULL(t3.clearTimes,0) AS clearTimes,
IFNULL(t3.clearAmount,0) AS clearAmount,
IFNULL(t3.revocationTimes,0) AS revocationTimes,
IFNULL(t3.revocationAmount,0) AS revocationAmount,
IFNULL(t3.amount,0) + IFNULL(t3.clearAmount,0) + IFNULL(t3.revocationAmount,0) AS totalAmount,
t3.change_flag
FROM
sys_user ci
INNER JOIN acc_info ai on ci.cust_id = ai.cust_id
LEFT JOIN sys_dept co ON ci.dept_id = co.dept_id
LEFT JOIN
(
SELECT
t1.cust_id,
SUM( CASE WHEN t1.trade_type = 20 THEN 1 ELSE 0 END ) AS `count`,
SUM( CASE WHEN t1.trade_type = 20 THEN t1.amount ELSE 0 END ) AS `amount`,
SUM( CASE WHEN t1.trade_type = 50 THEN 1 ELSE 0 END ) AS revocationTimes,
SUM( CASE WHEN t1.trade_type = 50 THEN - t1.amount ELSE 0 END ) AS revocationAmount,
SUM( CASE WHEN t1.trade_type = 100 THEN 1 ELSE 0 END ) AS clearTimes,
SUM( CASE WHEN t1.trade_type = 100 THEN - t1.amount ELSE 0 END ) AS clearAmount,
1 AS change_flag
FROM
acc_trade t1
t1.trade_type IN (20,50,100)
and t1.trade_time = ]]> #{param.startDateTime}
and t1.trade_time #{param.endDateTime}
GROUP BY t1.cust_id
) t3 ON t3.cust_id = ci.cust_id
and ci.dept_id in
#{orgId}
ORDER BY change_flag IS NULL,amount DESC,ci.cust_id
SELECT
cpt.psn_type,
cpt.psn_type_name,
IFNULL(t3.count,0) AS `times`,
IFNULL(t3.amount,0) AS `amount`,
IFNULL(t3.clearTimes,0) AS clearTimes,
IFNULL(t3.clearAmount,0) AS clearAmount,
IFNULL(t3.revocationTimes,0) AS revocationTimes,
IFNULL(t3.revocationAmount,0) AS revocationAmount,
IFNULL(t3.amount,0) + IFNULL(t3.clearAmount,0) + IFNULL(t3.revocationAmount,0) AS totalAmount,
t3.change_flag
FROM
(SELECT psn_type_name, psn_type FROM cust_psn_type UNION ALL SELECT '—' AS psn_type_name, - 1 AS psn_type) cpt
LEFT JOIN
(
SELECT
IFNULL( t1.psn_type, - 1 ) AS psn_type,
SUM( CASE WHEN t1.trade_type = 20 THEN 1 ELSE 0 END ) AS `count`,
SUM( CASE WHEN t1.trade_type = 20 THEN t1.amount ELSE 0 END ) AS `amount`,
SUM( CASE WHEN t1.trade_type = 50 THEN 1 ELSE 0 END ) AS revocationTimes,
SUM( CASE WHEN t1.trade_type = 50 THEN - t1.amount ELSE 0 END ) AS revocationAmount,
SUM( CASE WHEN t1.trade_type = 100 THEN 1 ELSE 0 END ) AS clearTimes,
SUM( CASE WHEN t1.trade_type = 100 THEN - t1.amount ELSE 0 END ) AS clearAmount,
1 AS change_flag
FROM
acc_trade t1
t1.trade_type IN (20,50,100)
and t1.trade_time = ]]> #{param.startDateTime}
and t1.trade_time #{param.endDateTime}
GROUP BY t1.psn_type
) t3 ON t3.psn_type = cpt.psn_type
and cpt.psn_type in
#{psnType}
ORDER BY change_flag IS NULL, amount DESC, cpt.psn_type
SELECT
g.dept_id as org_id,
IFNULL(t3.count,0) AS `times`,
IFNULL(t3.amount,0) AS `amount`,
IFNULL(t3.clearTimes,0) AS clearTimes,
IFNULL(t3.clearAmount,0) AS clearAmount,
IFNULL(t3.revocationTimes,0) AS revocationTimes,
IFNULL(t3.revocationAmount,0) AS revocationAmount,
IFNULL(t3.amount,0) + IFNULL(t3.clearAmount,0) + IFNULL(t3.revocationAmount,0) AS totalAmount,
t3.change_flag
FROM
sys_dept g
LEFT JOIN (
SELECT
IFNULL( t1.org_id, - 1 ) AS org_id,
SUM( CASE WHEN t1.trade_type = 20 THEN 1 ELSE 0 END ) AS `count`,
SUM( CASE WHEN t1.trade_type = 20 THEN t1.amount ELSE 0 END ) AS `amount`,
SUM( CASE WHEN t1.trade_type = 50 THEN 1 ELSE 0 END ) AS revocationTimes,
SUM( CASE WHEN t1.trade_type = 50 THEN - t1.amount ELSE 0 END ) AS revocationAmount,
SUM( CASE WHEN t1.trade_type = 100 THEN 1 ELSE 0 END ) AS clearTimes,
SUM( CASE WHEN t1.trade_type = 100 THEN - t1.amount ELSE 0 END ) AS clearAmount,
1 AS change_flag
FROM
acc_trade t1
t1.trade_type IN ( 20, 50, 100 )
and t1.trade_time = ]]> #{param.startDateTime}
and t1.trade_time #{param.endDateTime}
GROUP BY t1.org_id
) t3 ON t3.org_id = g.dept_id
and g.dept_id in
#{orgId}
ORDER BY change_flag IS NULL,amount DESC,g.ancestors
SELECT atr.trade_time,
atr.cust_id,
ci.cust_num,
ci.nick_name AS cust_name,
ci.phonenumber AS mobile,
atr.psn_type,
cpt.psn_type_name,
atwd.amount as repealAmount,
atwd.wallet_bal as repealAfterWalletBal,
atr.crby,
atr.id as tradeId
FROM
acc_trade atr
LEFT JOIN sys_user ci ON ci.cust_id = atr.cust_id
LEFT JOIN sys_dept co ON co.dept_id = atr.org_id
LEFT JOIN cust_psn_type cpt ON cpt.psn_type = atr.psn_type
LEFT JOIN acc_trade_wallet_detail atwd ON atr.id = atwd.trade_id
ORDER BY atr.trade_time desc,atr.id desc
atr.pay_state = 3
and atwd.wallet_id = #{param.walletId}
and atr.trade_type = #{param.tradeType}
and atr.trade_time = ]]> #{param.startDateTime}
and atr.trade_time #{param.endDateTime}
and atr.crby like #{param.crBy}
and atr.org_id in
#{orgId}
and atr.cust_id = #{param.custId}
and atr.id = #{param.accTradeId}