SELECT U.user_id, U.country_id AS ‘国家’, U.language AS ‘语言’, U.email, U.telephone, T.withdrawing AS ‘提币申请’, T.withdraw_fee AS ‘手续费’,
A.margin_balance/1e8 AS ‘保证金余额’, T.times_deposit AS ‘充次数’, T.times_withdraw AS ‘提次数’, T.total_deposit AS ‘总充值’, T.total_withdraw AS ‘总提现’,
from_unixtime(T.first_deposit/1000+28800,’%Y-%m-%d’) AS ‘首充时间’,
from_unixtime(T.last_deposit/1000+28800,’%Y-%m-%d’) AS ‘最后时间’,
from_unixtime(T.first_withdraw/1000+28800,’%Y-%m-%d’) AS ‘首提时间’,
from_unixtime(T.last_withdraw/1000+28800,’%Y-%m-%d’) AS ‘最后时间’, B.total_bonus AS ‘总赠金’,TS.transfer_in AS ‘转入’,TS.transfer_out AS ‘转出’, TS.transfer_in - TS.transfer_out AS ‘净转’
FROM management.t_trade_user AS U
LEFT JOIN clear.t_account AS A ON A.client_id = U.user_id
LEFT JOIN (
SELECT USER_ID, transaction_status,
IF(transaction_status=’0’,amount/1e8,NULL) AS ‘withdrawing’,
IF(transaction_status=’0’,withdraw_fee/1e8,NULL) AS ‘withdraw_fee’,
COUNT(IF(transaction_status=’5’,true,NULL)) AS ‘times_deposit’,
COUNT(IF(transaction_status=’7’,true,NULL)) AS ‘times_withdraw’,
SUM(IF(transaction_status=’5’,amount/1e8,0)) AS ‘total_deposit’,
SUM(IF(transaction_status=’7’,amount/1e8,0)) AS ‘total_withdraw’,
MIN(IF(transaction_status=’5’,operate_time,NULL)) AS ‘first_deposit’,
MAX(IF(transaction_status=’5’,operate_time,NULL)) AS ‘last_deposit’,
MIN(IF(transaction_status=’7’,operate_time,NULL)) AS ‘first_withdraw’,
MAX(IF(transaction_status=’7’,operate_time,NULL)) AS ‘last_withdraw’
FROM management.t_wallet_transaction_history WHERE transaction_status IN (‘0’,’5’,’7’)
GROUP BY USER_ID) AS T
ON U.USER_ID = T.USER_ID
LEFT JOIN (SELECT SUM(amount/1e8)AS total_bonus, in_client_id FROM management.t_donation_transfer WHERE transfer_status = 7 GROUP BY in_client_id) AS B
ON B.in_client_id = U.USER_ID
LEFT JOIN (SELECT transfer_out_client_id, transfer_in_client_id,
SUM(IF(transfer_out_client_id=’$user_id’, transfer/1e8,NULL)) AS ‘transfer_out’,
SUM(IF(transfer_in_client_id=’$user_id’, transfer/1e8,NULL)) AS ‘transfer_in’,
‘$user_id’ AS USER_ID
from management.t_verify_transfer
WHERE transfer_out_client_id =’$user_id’ OR transfer_in_client_id = ‘$user_id’ AND transfer_status=’7’ )AS TS
ON TS.USER_ID = U.USER_ID
where T.USER_ID in (‘2582376337’,
‘4346609449’,
‘9673736522’,
‘4509346201’,
‘3151316749’,
‘1707734135’,
‘3852812845’,
‘2739097878’,
‘3012458049’,
‘1966208647’,
‘4572456134’,
‘5254102423’,
‘5158724612’,
‘6436230460’,
‘5426535200’,
‘3310260678’,
‘4071583311’,
‘9741869472’,
‘1867912042’,
‘2702453290’,
‘5305451442’,
‘3984817929’,
‘2832154241’,
‘4890769184’,
‘1784862406’,
‘1437922885’,
‘4283505917’,
‘3401386969’,
‘1082365856’,
‘1453246070’,
‘6486205273’,
‘9522369046’,
‘1025790174’,
‘4424682227’,
‘1461494430’,
‘9215440022’,
‘9179629609’,
‘7822394615’,
‘1583019548’,
‘2764431012’,
‘3631571641’
)
