1. /* 日本用户概况 */
    2. SELECT U.user_id, U.email, U.telephone, FROM_UNIXTIME(U.register_time/1000+28800,('%Y-%m-%d %H:%i:%S')) AS register_time, T.total_deposit AS 'deposit',T.times_deposit AS 'times_d',T.total_withdraw AS 'withdraw', T.times_withdraw AS 'times_w', A.margin_balance/100000000 AS margin_balance,
    3. (A.margin_balance/100000000 - T.total_deposit + T.total_withdraw) AS PNL,
    4. TRADE.volume, AF.inviter, AF.`reference_code`
    5. FROM management.t_trade_user U
    6. LEFT JOIN (
    7. SELECT USER_ID, transaction_type,
    8. count(if(transaction_type='1',true,null)) as 'times_deposit',
    9. count(if(transaction_type='2',true,null)) as 'times_withdraw',
    10. SUM(IF(transaction_type='1',amount/100000000,0)) AS 'total_deposit',
    11. SUM(IF(transaction_type='2',amount/100000000,0)) AS 'total_withdraw'
    12. FROM management.t_wallet_transaction_history WHERE transaction_type IN ('1','2')
    13. GROUP BY USER_ID) AS T
    14. ON U.USER_ID = T.USER_ID
    15. LEFT JOIN `t_account` as A
    16. ON U.user_id = A.client_id
    17. LEFT JOIN (SELECT client_id, SUM(taker_fee/1e8 - ABS(maker_fee/1e8)) AS netFee, SUM(trade_volume)AS 'volume' FROM affiliate.t_daily_trade GROUP BY client_id)AS TRADE
    18. on U.user_id = TRADE.client_id
    19. LEFT JOIN affiliate.t_invitation AS AF
    20. ON U.USER_ID = AF.invitee
    21. WHERE U.user_id in (
    22. 9834944607,
    23. 6180832136,
    24. 1461494430,
    25. 2702453290,
    26. 4424682227,
    27. 1227311310,
    28. 8887717604,
    29. 6486205273,
    30. 6104428332,
    31. 1867912042,
    32. 2582376337
    33. )
    34. ORDER BY register_time DESC