prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user['id']]);
$userData = $stmt->fetch();
// Get balances
$stmt = db()->prepare("SELECT * FROM user_balances WHERE user_id = ?");
$stmt->execute([$user['id']]);
$userBalances = $stmt->fetchAll();
$balancesBySymbol = [];
foreach ($userBalances as $ub) {
$balancesBySymbol[$ub['symbol']] = $ub;
}
// Calculate total balance in USDT
$totalBalanceUsdt = 0;
foreach ($userBalances as $ub) {
$totalBalanceUsdt += ($ub['available'] + $ub['frozen']) * getCoinPrice($ub['symbol']);
}
$displayCoins = ['BTC', 'ETH', 'USDT', 'LTC', 'BNB', 'SOL', 'TRX', 'XRP'];
$balances = [];
foreach ($displayCoins as $symbol) {
$balances[] = [
'symbol' => $symbol,
'available' => $balancesBySymbol[$symbol]['available'] ?? 0,
'frozen' => $balancesBySymbol[$symbol]['frozen'] ?? 0,
];
}
// Add any other coins user might have that are not in displayCoins
foreach ($userBalances as $ub) {
if (!in_array($ub['symbol'], $displayCoins)) {
$balances[] = $ub;
}
}
function getCoinPrice($symbol) {
$prices = [
'BTC' => 65432.10,
'ETH' => 3542.50,
'USDT' => 1.00,
'BNB' => 612.30,
'SOL' => 145.20,
'LTC' => 85.40,
'TRX' => 0.12,
'XRP' => 0.62,
'ADA' => 0.45,
'DOGE' => 0.16,
'DOT' => 7.20,
'MATIC' => 0.72,
];
return $prices[strtoupper($symbol)] ?? 1.00;
}
function getVipLevel($totalRecharge) {
if ($totalRecharge >= 10000000) return 7;
if ($totalRecharge >= 5000000) return 6;
if ($totalRecharge >= 1000000) return 5;
if ($totalRecharge >= 500000) return 4;
if ($totalRecharge >= 100000) return 3;
if ($totalRecharge >= 50000) return 2;
if ($totalRecharge >= 10001) return 1;
return 0;
}
$vipLevel = getVipLevel($userData['total_recharge'] ?? 0);
// Fetch transactions
$stmt = db()->prepare("SELECT * FROM transactions WHERE user_id = ? ORDER BY created_at DESC LIMIT 50");
$stmt->execute([$user['id']]);
$transactions = $stmt->fetchAll();
// Fetch orders to sync if needed, or just show transactions which should cover most balance changes
// For a complete "order history", we might want a separate tab, but user asked for "recharge, withdrawal, and order records" to be synced here.
$kycStatusText = [
0 => __('unverified'),
1 => __('pending'),
2 => __('verified'),
3 => __('rejected')
];
$kycStatusColor = [
0 => 'text-white-50',
1 => 'text-warning',
2 => 'text-success',
3 => 'text-danger'
];
?>
= strtoupper(substr($userData['username'], 0, 1)) ?>
= htmlspecialchars($userData['username']) ?>
= __('balance') ?>:
(USDT)
≈ = number_format($totalBalanceUsdt, 2) ?>
| = __('coin') ?> |
= __('available_balance') ?> |
= __('frozen') ?> |
= __('converted_to') ?> |
= __('operation') ?> |
= $b['symbol'] ?>
|
= number_format($b['available'], 4) ?>
|
= number_format($b['frozen'], 4) ?>
|
≈ = number_format(($b['available'] + $b['frozen']) * getCoinPrice($b['symbol']), 2) ?>
|
= __('trade') ?>
|
= __('asset_records') ?>
| = __('type') ?> |
= __('amount') ?> |
= __('status') ?> |
= __('time') ?> |
|
= __('no_records_found') ?>
|
|
= $typeName ?>
|
= $prefix . number_format($t['amount'], 4) ?>
= $t['symbol'] ?>
|
= $statusText ?>
|
= date('Y-m-d H:i', strtotime($t['created_at'])) ?>
|