SELECT atr.trade_time, atr.cust_id, ci.cust_num, ci.nick_name as cust_name, ci.phonenumber as mobile, co.dept_name AS org_full_name, 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=com.bonus.canteen.core.common.encrypt.SM4EncDecHandler} or ci.phonenumber = #{param.keyword,typeHandler=com.bonus.canteen.core.common.encrypt.SM4EncDecHandler} or ci.nick_name_like LIKE CONCAT('%',#{param.keyword,typeHandler=com.bonus.canteen.core.common.encrypt.CipherQueryLikeHandler},'%') ) SELECT atr.trade_time, atr.cust_id, ci.cust_num, ci.nick_name AS cust_name, ci.phonenumber AS mobile, co.dept_name AS org_full_name, 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, co.dept_name AS custOrgFullName, 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, g.dept_name AS org_full_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 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, co.dept_name AS org_full_name 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} SELECT t1.id AS tradeId, t1.trade_time, ci.cust_num, ci.nick_name AS cust_name, ci.phonenumber AS mobile, t6.dept_name AS org_full_name t4.psn_type_name, t1.amount AS withdrawAmount, t5.wallet_id AS withdrawWalletType, t5.wallet_bal AS withdrawWalletBal, t1.trade_type, t1.pay_channel, t1.pay_type, t1.withdraw_source, t1.crby, t1.crtime, t1.remark FROM acc_trade t1 LEFT JOIN sys_user ci ON t1.cust_id = ci.cust_id LEFT JOIN cust_psn_type t4 ON t4.psn_type = t1.psn_type LEFT JOIN acc_trade_wallet_detail t5 ON t1.id = t5.trade_id LEFT JOIN sys_dept t6 ON t6.dept_id = t1.org_id ORDER BY t1.trade_time desc,t1.id desc t1.trade_type = 30 and t1.id = #{param.accTradeId} and t1.trade_time = ]]> #{param.startDateTime} and t1.trade_time #{param.endDateTime} and t1.pay_channel = #{param.payChannel} and t1.crby like #{param.crBy} and t1.withdraw_source = #{param.withdrawSource} and t1.org_id in #{orgId} SELECT t1.withdraw_source, t1.pay_channel, COUNT(t1.amount) payChannelNum, SUM(t1.amount) payChannelAmount FROM acc_trade t1 GROUP BY t1.withdraw_source, t1.pay_channel ORDER BY t1.withdraw_source, t1.pay_channel t1.trade_type = #{param.tradeType} and t1.trade_time = ]]> #{param.startDateTime} and t1.trade_time #{param.endDateTime} and t1.pay_channel = #{param.payChannel} and t1.withdraw_source = #{param.withdrawSource} SELECT IFNULL( min( t4.psn_type_name ), '未分类人员' ) AS psn_type_name, min(t3.dept_name) AS org_full_name, t1.withdraw_source, t1.pay_channel, COUNT(t1.amount) AS `count`, SUM(t1.amount) AS amount FROM acc_trade t1 LEFT JOIN sys_dept t3 ON t1.org_id = t3.dept_id LEFT JOIN cust_psn_type t4 ON t4.psn_type = t1.psn_type GROUP BY t1.psn_type, t1.withdraw_source, t1.pay_channel ORDER BY t1.psn_type, t1.withdraw_source, t1.pay_channel GROUP BY t1.org_id, t1.withdraw_source, t1.pay_channel ORDER BY t1.org_id, t1.withdraw_source, t1.pay_channel WHERE t1.trade_type = #{param.tradeType} AND t1.trade_time = ]]> #{param.startDateTime} AND t1.trade_time #{param.endDateTime} AND t1.pay_channel = #{param.payChannel} AND t1.withdraw_source = #{param.withdrawSource} AND t1.psn_type in #{psnType} AND t1.org_id in #{orgId} SELECT atr.trade_time, atr.cust_id, ci.cust_num, ci.nick_name AS cust_name, ci.phonenumber AS mobile, co.dept_name AS org_full_name, atr.psn_type, cpt.psn_type_name, atr.trade_type, atwd.wallet_id, atr.amount, atwd.wallet_bal as walletBal, atr.crby, atr.id as tradeId 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 and atr.trade_type = #{param.tradeType} and atr.trade_type in #{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.id = #{param.accTradeId} AND atr.cust_id = #{param.custId} SELECT atr.trade_time, atr.cust_id, ci.cust_num, ci.nick_name AS cust_name, ci.phonenumber AS mobile, co.dept_name AS org_full_name, atr.psn_type, cpt.psn_type_name, atwd.wallet_id, atr.amount as frozenAmount, atwd.wallet_bal as walletBal, atwd.frozen_balance as walletFrozenBal, atr.crby, atr.id as tradeId 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 acc_trade_wallet_detail atwd ON atr.id = atwd.trade_id LEFT JOIN sys_dept co ON atr.org_id = co.dept_id ORDER BY atr.trade_time desc 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} SELECT atr.trade_time, atr.cust_id, ci.cust_num, ci.nick_name as cust_name, ci.phonenumber as mobile, co.dept_name as org_full_name, atr.psn_type, cpt.psn_type_name, atr.amount as rechargeAmount, atwd.wallet_bal as rechargeAfterWalletBal, atr.crby, atr.id as tradeId, atr.remark 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 = 140 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.id = #{param.accTradeId} and atr.cust_id = #{param.custId} SELECT cpt.psn_type, cpt.psn_type_name, IFNULL( t3.rechargeCount, 0 ) AS rechargeCount, IFNULL( t3.rechargeAmount, 0 ) AS rechargeAmount, 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, count(*) AS rechargeCount, SUM( t1.amount ) AS rechargeAmount, 1 AS change_flag FROM acc_trade t1 t1.trade_type = 140 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, rechargeAmount DESC, cpt.psn_type SELECT g.dept_id as org_id, g.dept_name as org_full_name, IFNULL( t3.rechargeCount, 0 ) AS rechargeCount, IFNULL( t3.rechargeAmount, 0 ) AS rechargeAmount, t3.change_flag FROM sys_dept g LEFT JOIN ( SELECT IFNULL( t1.org_id, - 1 ) AS org_id, count(*) AS rechargeCount, SUM( t1.amount ) AS rechargeAmount, 1 AS change_flag FROM acc_trade t1 t1.trade_type = 140 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,rechargeAmount DESC,g.ancestors SELECT ci.cust_id, ci.cust_num, ci.nick_name as cust_name, ci.phonenumber as mobile, co.dept_name AS custOrgFullName, IFNULL( t3.rechargeCount, 0 ) AS rechargeCount, IFNULL( t3.rechargeAmount, 0 ) AS rechargeAmount, 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, count(*) AS rechargeCount, SUM( t1.amount ) AS rechargeAmount, 1 AS change_flag FROM acc_trade t1 t1.trade_type = 140 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,rechargeAmount DESC,ci.cust_id and t1.crtime = ]]> #{param.startDateTime} and t1.crtime #{param.endDateTime} and t1.trade_time = ]]> #{param.startDateTime} and t1.trade_time #{param.endDateTime} and t1.trade_type = #{param.tradeType} and t1.pay_channel = #{param.payChannel} and t1.batch_num = #{param.batchNum} and t1.id = #{param.accTradeId} and t1.crby like #{param.crBy} and t1.trade_state in #{tradeState} and t1.pay_state in #{payState} and t1.org_id in #{orgId} and t1.cust_id = #{param.custId} SELECT t1.id tradeId, t1.crtime, t1.trade_time, ci.cust_num, ci.nick_name as cust_name, ci.phonenumber as mobile, t6.dept_name as org_full_name, t4.psn_type_name, t1.trade_type, t1.pay_channel, t1.pay_type, t1.manage_cost, t1.amount rechargeAmount, t1.actual_Amount actualAmount, t1.crby, t1.recharge_source, t1.pay_state, t1.trade_state, t1.fail_reason, t1.canteen_id, t1.machine_type, t1.machine_sn, t7.device_name, t1.batch_num, t5.canteen_name canteenName, t1.remark FROM acc_trade t1 LEFT JOIN sys_user ci ON t1.cust_id = ci.cust_id LEFT JOIN cust_psn_type t4 ON t4.psn_type = t1.psn_type LEFT JOIN alloc_canteen t5 ON t5.canteen_id = t1.canteen_id LEFT JOIN sys_dept t6 ON t6.dept_id = t1.org_id LEFT JOIN device_info t7 ON t7.device_sn = t1.machine_sn ORDER BY t1.crtime desc,t1.id desc ORDER BY t1.trade_time desc,t1.id desc and atr.trade_time = ]]> #{param.startDateTime} and atr.trade_time #{param.endDateTime} and atr.trade_type in #{tradeType} and atr.crby like #{param.crBy} and atr.org_id in #{orgId} and atr.cust_id = #{param.custId} and atr.id = #{param.accTradeId} and atr.origin_trade_id = #{param.originalRechargeId} and atr.recharge_source in #{repealSource}