Autosave: 20260214-023012

This commit is contained in:
Flatlogic Bot 2026-02-14 02:30:12 +00:00
parent 1fcaec3d09
commit 868df18001
13 changed files with 1173 additions and 635 deletions

View File

@ -5,39 +5,84 @@ require_once '../includes/currency_helper.php';
$pdo = db();
$user_id = $_GET['user_id'] ?? null;
if (!$user_id) die("User ID required");
if (!$user_id) die("需要用户 ID");
// Mark as read
// 标记为已读
$pdo->prepare("UPDATE messages SET is_read = 1 WHERE user_id = ? AND sender = 'user'")->execute([$user_id]);
// Handle Message Sending
// 处理消息发送
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['message'])) {
$msg = $_POST['message'];
$pdo->prepare("INSERT INTO messages (user_id, sender, message, type) VALUES (?, 'admin', ?, 'text')")->execute([$user_id, $msg]);
exit;
}
// Handle Recharge Actions
// 处理充值/提现操作
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action'])) {
$oid = $_POST['order_id'];
if ($_POST['action'] == 'match') {
if ($_POST['action'] == 'match_deposit') {
$bank = $_POST['bank_name'] ?? '';
$name = $_POST['account_name'] ?? '';
$number = $_POST['account_number'] ?? '';
$remarks = $_POST['remarks'] ?? '';
$info = "🏦 银行名称:$bank\n👤 收款姓名:$name\n💳 收款账号:$number\n📝 备注说明:$remarks";
$pdo->prepare("UPDATE fiat_orders SET status = 'matched', bank_account_info = ? WHERE id = ?")->execute([$info, $oid]);
// 发送消息给用户
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, $info]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, "✅ 匹配成功!收款账户已下发。"]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, "✅ 匹配成功!收款账户已下发,请在转账后上传凭证。"]);
echo "<script>parent.location.reload();</script>";
exit;
} elseif ($_POST['action'] == 'send_withdraw_format') {
$format = "📋 请提供以下提现收款信息:\n\n1. 银行/钱包名称:\n2. 收款人姓名:\n3. 账号/地址:\n4. 支行/网络:";
$pdo->prepare("UPDATE fiat_orders SET status = 'matched', bank_account_info = ? WHERE id = ?")->execute([$format, $oid]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, $format]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, "✅ 请按上述格式回复您的收款详情。"]);
echo "<script>parent.location.reload();</script>";
exit;
} elseif ($_POST['action'] == 'complete') {
$stmt = $pdo->prepare("SELECT amount, currency FROM fiat_orders WHERE id = ?");
$stmt = $pdo->prepare("SELECT order_type, usdt_amount, currency FROM fiat_orders WHERE id = ?");
$stmt->execute([$oid]);
$order = $stmt->fetch();
$pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$order['amount'], $user_id]);
$pdo->prepare("UPDATE fiat_orders SET status = 'completed' WHERE id = ?")->execute([$oid]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, "🎉 充值已确认到账!"]);
$pdo->beginTransaction();
try {
if ($order['order_type'] === 'deposit') {
// 充值:增加余额
$pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$order['usdt_amount'], $user_id]);
$msg = "🎉 您的充值已确认到账!";
} else {
// 提现:余额已在发起时扣除,这里仅标记完成
$msg = "🎉 您的提现申请已处理完成,请查收!";
}
$pdo->prepare("UPDATE fiat_orders SET status = 'completed' WHERE id = ?")->execute([$oid]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, $msg]);
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
die($e->getMessage());
}
echo "<script>parent.location.reload();</script>";
exit;
} elseif ($_POST['action'] == 'reject') {
$pdo->prepare("UPDATE fiat_orders SET status = 'rejected' WHERE id = ?")->execute([$oid]);
$stmt = $pdo->prepare("SELECT order_type, usdt_amount FROM fiat_orders WHERE id = ?");
$stmt->execute([$oid]);
$order = $stmt->fetch();
$pdo->beginTransaction();
try {
if ($order['order_type'] === 'withdrawal') {
// 提现拒绝:退还余额
$pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$order['usdt_amount'], $user_id]);
}
$pdo->prepare("UPDATE fiat_orders SET status = 'rejected' WHERE id = ?")->execute([$oid]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$user_id, "❌ 您的申请已被拒绝,如有疑问请咨询客服。"]);
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
die($e->getMessage());
}
echo "<script>parent.location.reload();</script>";
exit;
}
}
@ -45,7 +90,7 @@ $user = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$user->execute([$user_id]);
$userData = $user->fetch();
$orders = $pdo->prepare("SELECT * FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'submitting', 'matched') ORDER BY id DESC");
$orders = $pdo->prepare("SELECT * FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'matched', 'paid') ORDER BY id DESC");
$orders->execute([$user_id]);
$pending_orders = $orders->fetchAll();
?>
@ -55,82 +100,123 @@ $pending_orders = $orders->fetchAll();
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
body { margin: 0; font-family: sans-serif; background: #0B0E11; color: white; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.chat-header { padding: 10px 15px; background: #1E2329; border-bottom: 1px solid #2B3139; display: flex; justify-content: space-between; font-size: 13px; }
#chat-box { flex: 1; padding: 15px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; scroll-behavior: smooth; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.msg.admin { align-self: flex-end; background: #f0b90b; color: black; border-bottom-right-radius: 2px; }
.msg.user { align-self: flex-start; background: #2B3139; color: #EAECEF; border-bottom-left-radius: 2px; }
.input-area { padding: 12px; background: #1E2329; border-top: 1px solid #2B3139; display: flex; gap: 10px; }
input { flex: 1; background: #0B0E11; border: 1px solid #2B3139; color: white; padding: 10px; border-radius: 6px; outline: none; }
button { background: #f0b90b; border: none; color: black; padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; }
.order-card { background: #161A1E; border: 1px solid #2B3139; padding: 12px; border-radius: 10px; margin: 10px; font-size: 12px; }
body { margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #0B0E11; color: white; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.chat-header { padding: 12px 20px; background: #1E2329; border-bottom: 1px solid #2B3139; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
#chat-box { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; scroll-behavior: smooth; background: #0b0e11; }
.msg { max-width: 80%; padding: 12px 16px; border-radius: 16px; font-size: 13.5px; line-height: 1.6; position: relative; }
.msg.admin { align-self: flex-end; background: #f0b90b; color: black; border-bottom-right-radius: 4px; }
.msg.user { align-self: flex-start; background: #2B3139; color: #EAECEF; border-bottom-left-radius: 4px; border: 1px solid #3b424d; }
.msg-time { font-size: 10px; opacity: 0.5; margin-top: 5px; display: block; text-align: right; }
.input-area { padding: 15px 20px; background: #1E2329; border-top: 1px solid #2B3139; display: flex; gap: 12px; align-items: center; }
input[type="text"] { flex: 1; background: #0B0E11; border: 1px solid #2B3139; color: white; padding: 12px 15px; border-radius: 10px; outline: none; transition: 0.3s; }
input[type="text"]:focus { border-color: #f0b90b; }
button { background: #f0b90b; border: none; color: black; padding: 10px 20px; border-radius: 10px; cursor: pointer; font-weight: bold; transition: 0.3s; }
button:hover { background: #fcd535; }
.order-panel { background: #1E2329; border-bottom: 1px solid #2B3139; padding: 15px; max-height: 250px; overflow-y: auto; }
.order-card { background: #2B3139; border: 1px solid #3b424d; padding: 15px; border-radius: 12px; margin-bottom: 10px; }
.order-card input { background: #0B0E11; border: 1px solid #3b424d; color: white; padding: 8px; border-radius: 6px; font-size: 12px; margin-bottom: 5px; width: 100%; box-sizing: border-box; }
.status-tag { padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: bold; text-transform: uppercase; }
.status-matching { background: rgba(240, 185, 11, 0.2); color: #f0b90b; }
.status-matched { background: rgba(0, 192, 135, 0.2); color: #00c087; }
.status-paid { background: rgba(14, 203, 129, 0.2); color: #0ecb81; }
</style>
</head>
<body>
<div class="chat-header">
<span><b><?php echo htmlspecialchars($userData['username'] ?? ''); ?></b> (UID: <?php echo $userData['uid'] ?? ''; ?>)</span>
<span>Balance: <?php echo number_format($userData['balance'] ?? 0, 2); ?> USDT</span>
<span><i class="fas fa-user-circle"></i> <b><?php echo htmlspecialchars($userData['username'] ?? ''); ?></b> (UID: <?php echo $userData['uid'] ?? ''; ?>)</span>
<span style="color: #00c087; font-weight: bold;">余额: <?php echo number_format($userData['balance'] ?? 0, 2); ?> USDT</span>
</div>
<div style="flex: 1; display: flex; flex-direction: column; overflow: hidden;">
<?php if ($pending_orders): ?>
<div style="background: #1E2329; border-bottom: 1px solid #2B3139; max-height: 200px; overflow-y: auto;">
<div class="order-panel">
<div style="font-size: 11px; color: #848E9C; margin-bottom: 10px; font-weight: bold;">待处理申请 (ACTIVE REQUESTS)</div>
<?php foreach($pending_orders as $o):
// Determine the display text for the order type
$orderTypeDisplay = '';
if ($o['order_type'] === 'deposit') {
$orderTypeDisplay = '充值';
} elseif ($o['order_type'] === 'withdrawal') {
$orderTypeDisplay = '提现';
}
// Determine the display text for the status
$statusDisplay = '';
if ($o['status'] === 'matching') {
$statusDisplay = '待受理';
} elseif ($o['status'] === 'matched') {
$statusDisplay = '已下发/待确认';
} elseif ($o['status'] === 'paid') {
$statusDisplay = '待审核';
}
?>
<div class="order-card">
<div style="display:flex; justify-content: space-between; margin-bottom:8px;">
<b style="color:#f0b90b;"><?php echo $o['amount']; ?> <?php echo $o['currency']; ?></b>
<span style="opacity:0.6;"><?php echo $o['status']; ?></span>
<div style="display:flex; justify-content: space-between; align-items: center; margin-bottom: 12px;">
<div>
<span style="font-weight: 800; color: #f0b90b; font-size: 14px;"><?php echo $orderTypeDisplay; ?>: <?php echo $o['amount']; ?> <?php echo $o['currency']; ?></span>
<span style="color: #848E9C; font-size: 12px; margin-left: 10px;"> <?php echo number_format($o['usdt_amount'], 2); ?> USDT</span>
</div>
<span class="status-tag status-<?php echo $o['status']; ?>"><?php echo $statusDisplay; ?></span>
</div>
<?php if($o['status'] == 'matching'): ?>
<form method="POST" style="display:grid; grid-template-columns: 1fr 1fr; gap:5px;">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="match">
<input type="text" name="bank_name" placeholder="Bank" required>
<input type="text" name="account_name" placeholder="Name" required>
<input type="text" name="account_number" placeholder="Number" required style="grid-column: span 2;">
<button type="submit" style="grid-column: span 2;">Match Account</button>
</form>
<?php else:
?>
<div style="display:flex; gap:10px; align-items:center;">
<?php if($o['proof_image']): ?>
<a href="../<?php echo $o['proof_image']; ?>" target="_blank" style="color:#00c087;">View Proof</a>
<?php endif;
?>
<form method="POST" style="flex:1; display:flex; gap:5px;">
<?php if($o['order_type'] == 'deposit'): ?>
<form method="POST">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="match_deposit">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px;">
<input type="text" name="bank_name" placeholder="银行名称" required>
<input type="text" name="account_name" placeholder="收款姓名" required>
<input type="text" name="account_number" placeholder="收款账号 / IBAN" required style="grid-column: span 2;">
<input type="text" name="remarks" placeholder="备注说明 (可选)" style="grid-column: span 2;">
<button type="submit" style="grid-column: span 2; background: #00c087; color: white;">下发收款账户</button>
</div>
</form>
<?php else: ?>
<form method="POST">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="send_withdraw_format">
<button type="submit" style="width: 100%; background: #4facfe; color: white;">发送提现信息格式模板</button>
</form>
<?php endif; ?>
<?php else: ?>
<div style="display: flex; gap: 10px;">
<form method="POST" style="flex: 1;">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="complete">
<button type="submit" style="flex:1; background:#00c087; color:white;">Approve</button>
<button type="submit" style="width: 100%; background: #00c087; color: white;">同意 (Approve)</button>
</form>
<form method="POST" style="flex:1;">
<form method="POST" style="flex: 1;">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="reject">
<button type="submit" style="flex:1; background:#f6465d; color:white;">Reject</button>
<button type="submit" style="width: 100%; background: #f6465d; color: white;">拒绝 (Reject)</button>
</form>
</div>
<?php endif;
?>
<?php endif; ?>
</div>
<?php endforeach;
?>
<?php endforeach; ?>
</div>
<?php endif;
?>
<?php endif; ?>
<div id="chat-box"></div>
</div>
<form class="input-area" id="msg-form">
<input type="text" id="msg-input" placeholder="Type a message..." autocomplete="off">
<input type="text" id="msg-input" placeholder="输入消息..." autocomplete="off">
<button type="submit"><i class="fas fa-paper-plane"></i></button>
</form>
<audio id="notif-sound" src="https://assets.mixkit.co/active_storage/sfx/2354/2354-preview.mp3" preload="auto"></audio>
<script>
const chatBox = document.getElementById('chat-box');
const msgInput = document.getElementById('msg-input');
const notifSound = document.getElementById('notif-sound');
let lastMsgId = 0;
async function loadMessages() {
try {
@ -138,7 +224,13 @@ $pending_orders = $orders->fetchAll();
const res = await resp.json();
if (res.success) {
let html = '';
let hasNewUserMsg = false;
res.data.forEach(m => {
if (m.id > lastMsgId) {
if (m.sender === 'user' && lastMsgId > 0) hasNewUserMsg = true;
lastMsgId = m.id;
}
const isUser = m.sender === 'user';
html += `
<div class="msg ${m.sender}">
${m.type === 'image' ? `<img src="../${m.message}" style="max-width:100%; border-radius:8px; cursor:pointer;" onclick="window.open(this.src)">` : m.message.replace(/\n/g, '<br>')}
@ -146,7 +238,12 @@ $pending_orders = $orders->fetchAll();
</div>
`;
});
const isAtBottom = chatBox.scrollHeight - chatBox.scrollTop <= chatBox.clientHeight + 50;
if (hasNewUserMsg) {
try { notifSound.play(); } catch(e) {}
}
const isAtBottom = chatBox.scrollHeight - chatBox.scrollTop <= chatBox.clientHeight + 100;
chatBox.innerHTML = html;
if (isAtBottom) chatBox.scrollTop = chatBox.scrollHeight;
}
@ -165,7 +262,7 @@ $pending_orders = $orders->fetchAll();
};
loadMessages();
setInterval(loadMessages, 2000);
setInterval(loadMessages, 3000);
</script>
</body>
</html>

View File

@ -16,7 +16,7 @@ if (isset($_POST['action'])) {
$orderStmt->execute([$id]);
$order = $orderStmt->fetch();
if ($order) {
$msg = "您的充值订单 #$id 匹配成功。请刷新支付页面查看收款账户详情并按要求完成转账";
$msg = "📢 您的充值订单 #$id 匹配成功.\n收款账户信息:\n$info\n请按要求完成转账并上传凭证";
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], $msg]);
}
} elseif ($_POST['action'] == 'complete') {
@ -24,7 +24,7 @@ if (isset($_POST['action'])) {
$orderStmt->execute([$id]);
$order = $orderStmt->fetch();
if ($order) {
$credit_amount = $order['usdt_amount'] > 0 ? $order['usdt_amount'] : $order['amount'];
$credit_amount = $order['usdt_amount'];
$pdo->beginTransaction();
try {
@ -34,7 +34,7 @@ if (isset($_POST['action'])) {
// Update transaction status
$pdo->prepare("UPDATE transactions SET status = 'completed' WHERE user_id = ? AND type = 'deposit' AND description LIKE ?")->execute([$order['user_id'], "%#$id%"]);
$msg = "您的充值 " . $credit_amount . " USDT 已确认到账。";
$msg = "🎉 您的充值 " . $credit_amount . " USDT 已确认到账。";
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], $msg]);
$pdo->commit();
@ -51,22 +51,15 @@ if (isset($_POST['action'])) {
if ($order) {
// Update transaction status
$pdo->prepare("UPDATE transactions SET status = 'rejected' WHERE user_id = ? AND type = 'deposit' AND description LIKE ?")->execute([$order['user_id'], "%#$id%"]);
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], "❌ 您的充值申请 #$id 已被拒绝,请咨询客服。"]);
}
}
}
$all_deposits = $pdo->query("SELECT o.*, u.username, u.uid FROM fiat_orders o JOIN users u ON o.user_id = u.id ORDER BY o.id DESC")->fetchAll();
usort($all_deposits, function($a, $b) {
$priority = ['matching' => 3, 'submitting' => 2, 'pending' => 2, 'matched' => 1, 'completed' => 0];
$pA = $priority[$a['status']] ?? 0;
$pB = $priority[$b['status']] ?? 0;
if ($pA != $pB) return $pB - $pA;
return $b['id'] - $a['id'];
});
$all_deposits = $pdo->query("SELECT o.*, u.username, u.uid FROM fiat_orders o JOIN users u ON o.user_id = u.id WHERE o.order_type = 'deposit' ORDER BY o.id DESC")->fetchAll();
$unread_msgs = $pdo->query("SELECT COUNT(*) FROM messages WHERE sender = 'user' AND is_read = 0")->fetchColumn();
$pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE status IN ('matching', 'submitting')")->fetchColumn();
$pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE status IN ('matching', 'paid')")->fetchColumn();
?>
<!DOCTYPE html>
<html lang="zh-CN">
@ -87,9 +80,10 @@ $pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE stat
.table th, .table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.status-badge { padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; }
.matching { background: rgba(255, 60, 0, 0.2); color: #ff3c00; border: 1px solid #ff3c00; }
.submitting { background: rgba(0, 192, 135, 0.2); color: #00c087; border: 1px solid #00c087; }
.paid { background: rgba(0, 192, 135, 0.2); color: #00c087; border: 1px solid #00c087; }
.matched { background: rgba(55, 122, 255, 0.1); color: #377aff; }
.completed { background: rgba(0, 192, 135, 0.1); color: #00c087; opacity: 0.6; }
.rejected { background: rgba(246, 70, 93, 0.1); color: #f6465d; }
.btn-primary { background: var(--primary); color: black; border: none; padding: 8px 15px; border-radius: 6px; font-weight: bold; cursor: pointer; }
</style>
</head>
@ -122,7 +116,8 @@ $pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE stat
</tr>
</thead>
<tbody>
<?php foreach($all_deposits as $o): ?>
<?php foreach($all_deposits as $o):
?>
<tr>
<td>#<?php echo $o['id']; ?></td>
<td><?php echo htmlspecialchars($o['username']); ?> (UID: <?php echo $o['uid']; ?>)</td>
@ -130,34 +125,57 @@ $pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE stat
<td><b><?php echo number_format($o['amount'], 2); ?></b></td>
<td><b style="color: #00c087"><?php echo number_format($o['usdt_amount'], 2); ?></b></td>
<td>
<?php if($o['proof_image']): ?>
<?php if($o['proof_image']):
?>
<a href="../<?php echo $o['proof_image']; ?>" target="_blank" style="color: #00c087; font-weight: bold;"><i class="fas fa-image"></i> 查看凭证</a>
<?php else: ?>
<?php else:
?>
<span style="color: #555;">未上传</span>
<?php endif; ?>
<?php endif;
?>
</td>
<td><span class="status-badge <?php echo $o['status']; ?>"><?php echo strtoupper($o['status']); ?></span></td>
<td><span class="status-badge <?php echo $o['status']; ?>">
<?php
if ($o['status'] === 'matching') echo '待受理';
elseif ($o['status'] === 'matched') echo '已分配账户';
elseif ($o['status'] === 'paid') echo '待审核凭证';
elseif ($o['status'] === 'completed') echo '已完成';
elseif ($o['status'] === 'rejected') echo '已拒绝';
else echo strtoupper($o['status']);
?>
</span></td>
<td>
<?php if($o['status'] == 'matching'): ?>
<?php if($o['status'] == 'matching'):
?>
<form method="POST" style="display: flex; gap: 5px;">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="match">
<input type="text" name="account_info" placeholder="收款账户信息" required style="padding: 8px; border: 1px solid var(--border); border-radius: 4px;">
<button type="submit" class="btn-primary" style="background: #ff3c00; color: white;">分配账户</button>
</form>
<?php elseif($o['status'] == 'submitting' || $o['status'] == 'matched'): ?>
<form method="POST">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="complete">
<button type="submit" class="btn-primary" style="background: #00c087; color: white;">确认入金</button>
</form>
<?php endif; ?>
<?php elseif($o['status'] == 'paid' || $o['status'] == 'matched'):
?>
<div style="display: flex; gap: 5px;">
<form method="POST">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="complete">
<button type="submit" class="btn-primary" style="background: #00c087; color: white;">确认入金</button>
</form>
<form method="POST">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="reject">
<button type="submit" class="btn-primary" style="background: #f6465d; color: white;">驳回</button>
</form>
</div>
<?php endif;
?>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach;
?>
</tbody>
</table>
</div>
</div>
</body>
</html>
</html>

View File

@ -9,70 +9,60 @@ $error_msg = "";
// Handle Actions
if (isset($_POST['action'])) {
$id = $_POST['order_id'];
$table = 'fiat_orders';
if ($_POST['action'] == 'complete') {
$pdo->prepare("UPDATE orders SET status = 'completed' WHERE id = ?")->execute([$id]);
$pdo->prepare("UPDATE $table SET status = 'completed' WHERE id = ?")->execute([$id]);
$orderStmt = $pdo->prepare("SELECT user_id, amount, currency, type FROM orders WHERE id = ?");
$orderStmt = $pdo->prepare("SELECT user_id, usdt_amount FROM $table WHERE id = ?");
$orderStmt->execute([$id]);
$order = $orderStmt->fetch();
if ($order) {
// Update transaction status
$pdo->prepare("UPDATE transactions SET status = 'completed' WHERE user_id = ? AND type = 'withdraw' AND description LIKE ?")->execute([$order['user_id'], "%#$id%"]);
$pdo->prepare("UPDATE transactions SET status = 'completed' WHERE user_id = ? AND type = 'withdrawal' AND description LIKE ?")->execute([$order['user_id'], "%#$id%"]);
$msg = "您的提现 " . $order['amount'] . " USDT 已汇出,请查收。";
$msg = "🎉 您的提现 " . $order['usdt_amount'] . " USDT 已汇出,请查收。";
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], $msg]);
}
$success_msg = "确认成功,提现已处理。";
} elseif ($_POST['action'] == 'reject') {
$remark = !empty($_POST['remark']) ? $_POST['remark'] : '违反规定';
$remark = !empty($_POST['remark']) ? $_POST['remark'] : '审核不通过';
$orderStmt = $pdo->prepare("SELECT user_id, amount FROM orders WHERE id = ?");
$orderStmt = $pdo->prepare("SELECT user_id, usdt_amount FROM $table WHERE id = ?");
$orderStmt->execute([$id]);
$order = $orderStmt->fetch();
if ($order) {
$pdo->beginTransaction();
try {
// Return balance
$pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$order['amount'], $order['user_id']]);
$pdo->prepare("UPDATE orders SET status = 'rejected' WHERE id = ?")->execute([$id]);
// 退还余额
$pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$order['usdt_amount'], $order['user_id']]);
$pdo->prepare("UPDATE $table SET status = 'rejected' WHERE id = ?")->execute([$id]);
// Log return to transactions
// 记录退还到交易记录
$pdo->prepare("INSERT INTO transactions (user_id, type, amount, currency, status, description) VALUES (?, 'withdraw_return', ?, 'USDT', 'completed', ?)")->execute([
$order['user_id'], $order['amount'], "Withdrawal #$id Rejected: $remark"
$order['user_id'], $order['usdt_amount'], "提现申请 #$id 被拒绝退回: $remark"
]);
// Update original transaction status
$pdo->prepare("UPDATE transactions SET status = 'rejected' WHERE user_id = ? AND type = 'withdraw' AND description LIKE ?")->execute([$order['user_id'], "%#$id%"]);
// 更新原交易状态
$pdo->prepare("UPDATE transactions SET status = 'rejected' WHERE user_id = ? AND type = 'withdrawal' AND description LIKE ?")->execute([$order['user_id'], "%#$id%"]);
$msg = "您的提现申请 #$id 已被拒绝,资金已退回您的余额。原因: " . $remark;
$msg = "您的提现申请 #$id 已被拒绝,资金已退回。原因: " . $remark;
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], $msg]);
$pdo->commit();
$success_msg = "拒绝成功";
$success_msg = "已成功驳回提现申请。";
} catch (Exception $e) {
$pdo->rollBack();
$error_msg = "操作失败: " . $e->getMessage();
}
} else {
$error_msg = "订单不存在。";
}
} elseif ($_POST['action'] == 'send_format') {
$orderStmt = $pdo->prepare("SELECT user_id FROM orders WHERE id = ?");
$orderStmt->execute([$id]);
$order = $orderStmt->fetch();
if ($order) {
$format = "【出款格式】\n提现单号: #$id\n请确认您的收货地址及相关信息准确无误。管理员正在进行最后审核。";
$pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], $format]);
$success_msg = "出款格式已发送。";
}
}
}
$withdrawals = $pdo->query("SELECT o.*, u.username, u.uid FROM orders o JOIN users u ON o.user_id = u.id WHERE o.type IN ('usdt', 'fiat') ORDER BY o.id DESC")->fetchAll();
$withdrawals = $pdo->query("SELECT o.*, u.username, u.uid FROM fiat_orders o JOIN users u ON o.user_id = u.id WHERE o.order_type = 'withdrawal' ORDER BY o.id DESC")->fetchAll();
$unread_msgs = $pdo->query("SELECT COUNT(*) FROM messages WHERE sender = 'user' AND is_read = 0")->fetchColumn();
$pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE status IN ('matching', 'submitting')")->fetchColumn();
$pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE status IN ('matching', 'paid')")->fetchColumn();
$pending_kyc = $pdo->query("SELECT COUNT(*) FROM users WHERE kyc_status = 1")->fetchColumn();
?>
@ -97,7 +87,8 @@ $pending_kyc = $pdo->query("SELECT COUNT(*) FROM users WHERE kyc_status = 1")->f
.table th { background: #fafafa; color: #707a8a; font-weight: 600; }
.status-badge { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; }
.pending { background: #fff9e6; color: #f0b90b; }
.matching { background: rgba(255, 60, 0, 0.2); color: #ff3c00; border: 1px solid #ff3c00; }
.paid { background: rgba(0, 192, 135, 0.2); color: #00c087; border: 1px solid #00c087; }
.completed { background: #e6fff1; color: #03ad5d; }
.rejected { background: #fff1f0; color: #f6465d; }
@ -108,7 +99,6 @@ $pending_kyc = $pdo->query("SELECT COUNT(*) FROM users WHERE kyc_status = 1")->f
.btn { padding: 8px 15px; border: none; border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: 0.2s; }
.btn-success { background: #03ad5d; color: white; }
.btn-danger { background: #f6465d; color: white; }
.btn-info { background: #4facfe; color: white; }
.btn:hover { opacity: 0.9; }
input[type="text"] { padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; outline: none; width: 120px; }
@ -151,55 +141,55 @@ $pending_kyc = $pdo->query("SELECT COUNT(*) FROM users WHERE kyc_status = 1")->f
<tr>
<th>ID</th>
<th>用户</th>
<th>金额 (USDT)</th>
<th>类型</th>
<th>详情</th>
<th>提现币种</th>
<th>金额</th>
<th>折算 USDT</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($withdrawals as $o):
?>
<?php foreach($withdrawals as $o): ?>
<tr>
<td>#<?php echo $o['id']; ?></td>
<td><b><?php echo htmlspecialchars($o['username']); ?></b> (<?php echo $o['uid']; ?>)</td>
<td><b><?php echo htmlspecialchars($o['username']); ?></b> (UID: <?php echo $o['uid']; ?>)</td>
<td><span style="color: #007bff; font-weight: bold;"><?php echo strtoupper($o['currency']); ?></span></td>
<td><?php echo number_format($o['amount'], 2); ?></td>
<td><?php echo strtoupper($o['type']); ?></td>
<td><small><?php echo htmlspecialchars($o['account_info'] ?? ''); ?></small></td>
<td><span class="status-badge <?php echo $o['status']; ?>"><?php echo strtoupper($o['status']); ?></span></td>
<td><b style="color: #00c087"><?php echo number_format($o['usdt_amount'], 2); ?></b></td>
<td><span class="status-badge <?php echo $o['status']; ?>">
<?php
if ($o['status'] === 'matching') echo '待受理';
elseif ($o['status'] === 'matched') echo '已下发模板';
elseif ($o['status'] === 'paid') echo '待处理出款';
elseif ($o['status'] === 'completed') echo '已完成';
elseif ($o['status'] === 'rejected') echo '已拒绝';
else echo strtoupper($o['status']);
?>
</span></td>
<td>
<?php if($o['status'] == 'pending'): ?>
<?php if($o['status'] == 'paid' || $o['status'] == 'matched'): ?>
<div style="display: flex; gap: 8px;">
<form method="POST" style="margin: 0;">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="send_format">
<button type="submit" class="btn btn-info">发格式</button>
</form>
<form method="POST" style="margin: 0;">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="complete">
<button type="submit" class="btn btn-success" onclick="return confirm('确认汇出?')">汇出</button>
<button type="submit" class="btn btn-success" onclick="return confirm('确认已完成出款?')">确认完成</button>
</form>
<form method="POST" style="margin: 0; display: flex; gap: 3px;">
<input type="hidden" name="order_id" value="<?php echo $o['id']; ?>">
<input type="hidden" name="action" value="reject">
<input type="text" name="remark" placeholder="原因" required>
<input type="text" name="remark" placeholder="驳回原因" required>
<button type="submit" class="btn btn-danger">驳回</button>
</form>
</div>
<?php else:
?>
<?php else: ?>
--
<?php endif;
?>
<?php endif; ?>
</td>
</tr>
<?php endforeach;
?>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
</html>

View File

@ -1,26 +1,24 @@
<?php
require_once '../db/config.php';
session_start();
require_once '../db/config.php';
header('Content-Type: application/json');
if (!isset($_SESSION['user_id'])) {
echo json_encode(['status' => 'unauthorized']);
echo json_encode(['success' => false, 'error' => 'Unauthorized']);
exit;
}
$user_id = $_SESSION['user_id'];
$pdo = db();
$stmt = $pdo->prepare("SELECT status, bank_account_info FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'matched', 'submitting') ORDER BY id DESC LIMIT 1");
// Check for active orders (including 'paid' which means waiting for admin approval)
$stmt = $pdo->prepare("SELECT id, order_type, status, bank_account_info FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'matched', 'paid') ORDER BY id DESC LIMIT 1");
$stmt->execute([$user_id]);
$order = $stmt->fetch();
if ($order) {
echo json_encode([
'status' => $order['status'],
'account_info' => $order['bank_account_info']
]);
echo json_encode(['success' => true, 'order' => $order]);
} else {
echo json_encode(['status' => 'none']);
echo json_encode(['success' => true, 'order' => null]);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

210
chat.php
View File

@ -13,18 +13,32 @@ $stmt = $pdo->prepare("SELECT uid, username FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
// Get user IP
$user_ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$user_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
// Check if there's an active deposit/withdrawal process
$stmt = $pdo->prepare("SELECT * FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'matched', 'paid') ORDER BY id DESC LIMIT 1");
$stmt->execute([$user_id]);
$active_order = $stmt->fetch();
$is_locked = (bool)$active_order;
// Action to complete transfer/submission
if (isset($_GET['action']) && $_GET['action'] === 'complete_order' && $active_order) {
$stmt = $pdo->prepare("UPDATE fiat_orders SET status = 'paid' WHERE id = ?");
$stmt->execute([$active_order['id']]);
$type_text = ($active_order['order_type'] === 'deposit') ? "充值" : "提现";
$msg = "✅ 用户已点击确认,$type_text 申请等待审核中。";
$stmt = $pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'user', ?)");
$stmt->execute([$user_id, $msg]);
header("Location: chat.php");
exit;
}
// Fetch greeting message
$stmt = $pdo->prepare("SELECT value FROM settings WHERE name = 'chat_greeting'");
$stmt->execute();
$greeting = $stmt->fetchColumn() ?: 'Hello! Welcome to NovaEx official support. How can we help you today?';
$greeting = $stmt->fetchColumn() ?: '您好!欢迎咨询 NovaEx 官方客服,请问有什么可以帮您?如果是充值咨询,请提供您的充值金额和币种。';
// Handle POST request via AJAX
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
$msg = trim($_POST['message']);
if ($msg !== '') {
@ -43,48 +57,104 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
#chat-box { flex: 1; overflow-y: auto; padding: 25px; display: flex; flex-direction: column; gap: 20px; background: #161a1e; scroll-behavior: smooth; }
.msg-container { display: flex; flex-direction: column; transition: all 0.3s ease; }
.msg-content { max-width: 75%; padding: 12px 18px; border-radius: 18px; font-size: 14px; line-height: 1.6; }
.msg-content { max-width: 75%; padding: 12px 18px; border-radius: 18px; font-size: 14px; line-height: 1.6; position: relative; }
.locked-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.locked-modal { background: #1e2329; width: 90%; max-width: 500px; border-radius: 24px; padding: 40px; text-align: center; border: 1px solid var(--primary-color); }
.account-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 450px; background: #1e2329; border-radius: 24px; border: 1px solid var(--primary-color); z-index: 10001; padding: 30px; box-shadow: 0 20px 50px rgba(0,0,0,0.8); display: none; }
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 10000; display: none; }
.status-bar { background: rgba(240,185,11,0.1); border: 1px solid var(--primary-color); padding: 15px 25px; border-radius: 12px; margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; color: var(--primary-color); }
#image-upload-btn:hover { background: #3b424d !important; color: #fcd535 !important; }
#image-upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }
</style>
<div id="chat-container" class="container" style="max-width: 850px; margin: 30px auto; padding: 0; height: 75vh;">
<div id="chat-card" class="card" style="background: #1e2329; border: 1px solid #2b3139; border-radius: 20px; display: flex; flex-direction: column; height: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.3);">
<!-- Account Details Modal -->
<div id="acc-backdrop" class="modal-backdrop"></div>
<div id="acc-modal" class="account-modal">
<div style="text-align: center; margin-bottom: 25px;">
<div style="width: 60px; height: 60px; background: rgba(240,185,11,0.1); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--primary-color); margin: 0 auto 15px; font-size: 24px;">
<i class="fas fa-university"></i>
</div>
<h3 style="margin: 0; color: white;" id="modal-title">账户已匹配</h3>
<p style="color: var(--text-muted); font-size: 14px; margin-top: 5px;" id="modal-tip">请按照下方账户信息完成操作。</p>
</div>
<div id="acc-info" style="background: #161a1e; padding: 20px; border-radius: 16px; color: white; font-size: 14px; line-height: 2; border: 1px solid #2b3139; margin-bottom: 25px;">
<!-- Filled by JS -->
</div>
<button onclick="closeAccModal()" class="btn-primary" style="width: 100%; padding: 15px; border-radius: 12px; font-weight: 800;">确认</button>
</div>
<div id="chat-container" class="container" style="max-width: 850px; margin: 30px auto; padding: 0; height: calc(100vh - 200px); min-height: 500px;">
<?php if ($is_locked): ?>
<div class="status-bar">
<div style="display: flex; align-items: center; gap: 15px;">
<i class="fas fa-lock"></i>
<div>
<div style="font-size: 14px; font-weight: 800;"><?php echo ($active_order['order_type'] === 'deposit') ? '充值进行中' : '提现申请中'; ?></div>
<div style="font-size: 12px; opacity: 0.8;"><?php
if ($active_order['status'] === 'matching') echo '等待客服响应...';
elseif ($active_order['status'] === 'matched') echo ($active_order['order_type'] === 'deposit') ? '请按要求转账并上传凭证' : '请提供您的收款信息';
elseif ($active_order['status'] === 'paid') echo '正在审核凭证,请稍候...';
?></div>
</div>
</div>
<div style="display: flex; gap: 10px;">
<?php if ($active_order['status'] === 'matched' && $active_order['order_type'] === 'deposit'): ?>
<button onclick="showCurrentAccInfo()" class="btn-primary" style="padding: 8px 15px; font-size: 12px; border-radius: 8px; background: #2b3139; color: white; border: 1px solid #3b424d;">
查看账户
</button>
<?php endif; ?>
<?php if ($active_order['status'] === 'matched'): ?>
<button onclick="window.location.href='?action=complete_order'" class="btn-primary" style="padding: 8px 15px; font-size: 12px; border-radius: 8px;">
<?php echo ($active_order['order_type'] === 'deposit') ? '完成转账' : '确认发送'; ?>
</button>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div id="chat-card" class="card" style="background: #1e2329; border: 1px solid #2b3139; border-radius: 20px; display: flex; flex-direction: column; height: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.3); overflow: hidden;">
<!-- Header -->
<div style="padding: 20px 25px; border-bottom: 1px solid #2b3139; display: flex; align-items: center; justify-content: space-between;">
<div style="padding: 20px 25px; border-bottom: 1px solid #2b3139; display: flex; align-items: center; justify-content: space-between; background: #1e2329;">
<div style="display: flex; align-items: center; gap: 15px;">
<div style="width: 45px; height: 45px; background: #f0b90b; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: black;">
<i class="fas fa-headset fa-lg"></i>
</div>
<div>
<h3 style="margin: 0; font-size: 18px; color: white;">NovaEx Support</h3>
<h3 style="margin: 0; font-size: 18px; color: white;">官方客服中心</h3>
<div style="display: flex; align-items: center; gap: 5px; font-size: 12px; color: #00c087;">
<span style="width: 8px; height: 8px; background: #00c087; border-radius: 50%; display: inline-block;"></span> Online
<span style="width: 8px; height: 8px; background: #00c087; border-radius: 50%; display: inline-block;"></span> 24/7 全天候在线
</div>
</div>
</div>
<div style="text-align: right; font-size: 12px; color: #848e9c;">
<div>UID: <?php echo $user['uid']; ?></div>
<div>IP: <?php echo $user_ip; ?></div>
<a href="index.php" style="color: var(--primary-color); text-decoration: none; display: <?php echo $is_locked ? 'none' : 'block'; ?>; margin-top: 5px;"><i class="fas fa-times"></i> 退出</a>
</div>
</div>
<!-- Chat Body -->
<div id="chat-box">
<!-- Messages loaded via JS -->
<div style="text-align: center; color: #848e9c; padding: 20px;">Connecting to support...</div>
<div style="text-align: center; color: #848e9c; padding: 20px;">正在连接客服...</div>
</div>
<!-- Input Area -->
<div style="padding: 20px; background: #1e2329; border-top: 1px solid #2b3139;">
<form id="chat-form" style="display: flex; gap: 12px; align-items: center;">
<button type="button" onclick="document.getElementById('image-input').click()" style="background: #2b3139; border: 1px solid #3b424d; color: #f0b90b; width: 45px; height: 45px; border-radius: 12px; cursor: pointer;">
<button type="button" id="image-upload-btn" onclick="document.getElementById('image-input').click()" style="background: #2b3139; border: 1px solid #3b424d; color: #f0b90b; width: 45px; height: 45px; border-radius: 12px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.2s;">
<i class="fas fa-plus"></i>
</button>
<input type="file" id="image-input" accept="image/*" style="display: none;" onchange="uploadImage(this)">
<input type="text" id="chat-input" placeholder="Type a message..."
<input type="text" id="chat-input" placeholder="请输入消息..."
style="flex: 1; background: #161a1e; border: 1px solid #2b3139; border-radius: 12px; padding: 14px 20px; color: white; outline: none; font-size: 14px;" autocomplete="off">
<button type="submit" style="background: #f0b90b; border: none; color: black; width: 50px; height: 50px; border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;">
<button type="submit" style="background: #f0b90b; border: none; color: black; width: 50px; height: 50px; border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
<i class="fas fa-paper-plane fa-lg"></i>
</button>
</form>
@ -92,11 +162,31 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
</div>
</div>
<?php if ($is_locked): ?>
<script>
// Prevent leaving the page
window.onbeforeunload = function() {
return "您的充值/提现流程尚未完成,请勿离开此页面。";
};
// Hide navigation elements
document.querySelector('nav')?.style.display = 'none';
document.querySelector('footer')?.style.display = 'none';
// Prevent back navigation
history.pushState(null, null, location.href);
window.onpopstate = function() {
history.pushState(null, null, location.href);
};
</script>
<?php endif; ?>
<script>
const chatBox = document.getElementById('chat-box');
const chatForm = document.getElementById('chat-form');
const chatInput = document.getElementById('chat-input');
let lastMsgId = 0;
const uploadBtn = document.getElementById('image-upload-btn');
let lastStatus = '<?php echo $active_order['status'] ?? ''; ?>';
let currentBankAccountInfo = `<?php echo addslashes($active_order['bank_account_info'] ?? ''); ?>`;
const greeting = `<?php echo addslashes($greeting); ?>`;
async function loadMessages() {
@ -111,7 +201,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
<div class="msg-content" style="background: #2b3139; color: white; border-bottom-left-radius: 4px; border: 1px solid #3b424d;">
${greeting.replace(/\n/g, '<br>')}
</div>
<span style="font-size: 10px; color: #5e6673; margin-top: 6px;">Support Bot</span>
<span style="font-size: 10px; color: #5e6673; margin-top: 6px;">系统助手</span>
</div>
`;
} else {
@ -119,9 +209,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
newMessages.forEach(m => {
const isUser = m.sender === 'user';
html += `
<div class="msg-container" style="align-items: ${isUser ? 'flex-end' : 'flex-start'};
">
<div class="msg-content" style="${isUser ? 'background: #f0b90b; color: black; border-bottom-right-radius: 4px;' : 'background: #2b3139; color: white; border-bottom-left-radius: 4px; border: 1px solid #3b424d;'}">
<div class="msg-container" style="align-items: ${isUser ? 'flex-end' : 'flex-start'};">
<div class="msg-content" style="${isUser ? 'background: #f0b90b; color: black; border-bottom-right-radius: 4px;' : 'background: #2b3139; color: white; border-bottom-left-radius: 4px; border: 1px solid #3b424d;'} ">
${m.type === 'image' ? `<img src="${m.message}" style="max-width:100%; border-radius:8px; cursor:pointer;" onclick="window.open(this.src)">` : m.message.replace(/\n/g, '<br>')}
</div>
<span style="font-size: 10px; color: #5e6673; margin-top: 6px;">${new Date(m.created_at).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}</span>
@ -137,6 +226,51 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
} catch (e) {}
}
async function checkOrderStatus() {
try {
const resp = await fetch('api/check_order_status.php');
const res = await resp.json();
if (res.success && res.order) {
currentBankAccountInfo = res.order.bank_account_info;
if (res.order.status !== lastStatus) {
if (res.order.status === 'matched') {
// Only show modal for DEPOSIT
if (res.order.order_type === 'deposit') {
showAccModal('账户已匹配', '请按照下方账户信息完成转账,并务必上传截图凭证。', res.order.bank_account_info);
}
} else if (res.order.status === 'completed' || res.order.status === 'rejected') {
alert(res.order.status === 'completed' ? "业务处理成功!" : "业务被拒绝,请联系客服了解详情。");
window.onbeforeunload = null;
location.href = 'profile.php';
}
lastStatus = res.order.status;
}
} else if (res.success && !res.order && lastStatus !== '') {
// Order disappeared or completed
window.onbeforeunload = null;
location.href = 'profile.php';
}
} catch (e) {}
}
function showAccModal(title, tip, info) {
if (!info) return;
document.getElementById('modal-title').innerText = title;
document.getElementById('modal-tip').innerText = tip;
document.getElementById('acc-info').innerHTML = info.replace(/\n/g, '<br>');
document.getElementById('acc-backdrop').style.display = 'block';
document.getElementById('acc-modal').style.display = 'block';
}
function showCurrentAccInfo() {
showAccModal('收款账户信息', '请核对以下转账信息。', currentBankAccountInfo);
}
function closeAccModal() {
document.getElementById('acc-backdrop').style.display = 'none';
document.getElementById('acc-modal').style.display = 'none';
}
chatForm.onsubmit = async (e) => {
e.preventDefault();
const msg = chatInput.value.trim();
@ -154,11 +288,37 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
if (!input.files || !input.files[0]) return;
const formData = new FormData();
formData.append('image', input.files[0]);
fetch('api/upload_chat_image.php', { method: 'POST', body: formData }).then(() => loadMessages());
uploadBtn.disabled = true;
uploadBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
fetch('api/upload_chat_image.php', { method: 'POST', body: formData })
.then(res => res.json())
.then(res => {
if (res.success) {
loadMessages();
} else {
alert(res.error || '上传失败');
}
})
.finally(() => {
uploadBtn.disabled = false;
uploadBtn.innerHTML = '<i class="fas fa-plus"></i>';
input.value = ''; // Reset input
});
}
// Show modal on load if matched and deposit
window.onload = () => {
const orderType = '<?php echo $active_order['order_type'] ?? ''; ?>';
if (lastStatus === 'matched' && orderType === 'deposit' && currentBankAccountInfo) {
showAccModal('账户已匹配', '请按照下方账户信息完成转账,并务必上传截图凭证。', currentBankAccountInfo);
}
};
loadMessages();
setInterval(loadMessages, 2000);
setInterval(loadMessages, 3000);
setInterval(checkOrderStatus, 3000);
</script>
<?php include 'footer.php'; ?>

View File

@ -27,13 +27,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
<style>
body { margin: 0; padding: 0; font-family: 'Inter', sans-serif; background: #161a1e; color: white; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
#chat-box { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; }
.msg.user { align-self: flex-end; background: #4facfe; color: white; border-bottom-right-radius: 2px; }
.msg.admin { align-self: flex-start; background: #2b3139; color: #EAECEF; border-bottom-left-radius: 2px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #f0b90b; color: black; border-bottom-right-radius: 2px; }
.msg.admin { align-self: flex-start; background: #2b3139; color: #EAECEF; border-bottom-left-radius: 2px; border: 1px solid #3b424d; }
.msg-time { font-size: 10px; opacity: 0.5; margin-top: 4px; display: block; }
.chat-input-area { padding: 12px; background: #1e2329; border-top: 1px solid #2b3139; display: flex; gap: 10px; }
input { flex: 1; background: #0b0e11; border: 1px solid #2b3139; border-radius: 8px; padding: 10px 12px; color: white; outline: none; }
button { background: #4facfe; border: none; width: 40px; height: 40px; border-radius: 8px; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chat-input-area { padding: 12px; background: #1e2329; border-top: 1px solid #2b3139; display: flex; gap: 10px; align-items: center; }
input[type="text"] { flex: 1; background: #0b0e11; border: 1px solid #2b3139; border-radius: 8px; padding: 10px 12px; color: white; outline: none; }
.icon-btn { background: #2b3139; border: 1px solid #3b424d; width: 40px; height: 40px; border-radius: 8px; color: #f0b90b; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.icon-btn:hover { background: #3b424d; }
.send-btn { background: #f0b90b; border: none; width: 40px; height: 40px; border-radius: 8px; color: black; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#chat-box::-webkit-scrollbar { width: 4px; }
#chat-box::-webkit-scrollbar-thumb { background: #2b3139; border-radius: 10px; }
img.chat-img { max-width: 100%; border-radius: 8px; margin-top: 5px; cursor: pointer; }
</style>
</head>
<body>
@ -41,13 +46,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
<div id="chat-box"></div>
<form id="chat-form" class="chat-input-area">
<button type="button" class="icon-btn" id="upload-btn" onclick="document.getElementById('image-input').click()">
<i class="fas fa-plus"></i>
</button>
<input type="file" id="image-input" accept="image/*" style="display: none;" onchange="uploadImage(this)>
<input type="text" id="msg-input" placeholder="Type a message..." autocomplete="off">
<button type="submit"><i class="fas fa-paper-plane"></i></button>
<button type="submit" class="send-btn"><i class="fas fa-paper-plane"></i></button>
</form>
<script>
const chatBox = document.getElementById('chat-box');
const msgInput = document.getElementById('msg-input');
const uploadBtn = document.getElementById('upload-btn');
async function loadMessages() {
try {
@ -56,14 +67,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
if (res.success) {
let html = '';
res.data.forEach(m => {
const content = m.type === 'image'
? `<img src="${m.message}" class="chat-img" onclick="window.open(this.src)">`
: m.message.replace(/\n/g, '<br>');
html += `
<div class="msg ${m.sender}">
${m.message.replace(/\n/g, '<br>')}
${content}
<span class="msg-time">${new Date(m.created_at).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}</span>
</div>
`;
});
const isAtBottom = chatBox.scrollHeight - chatBox.scrollTop <= chatBox.clientHeight + 50;
const isAtBottom = chatBox.scrollHeight - chatBox.scrollTop <= chatBox.clientHeight + 100;
chatBox.innerHTML = html;
if (isAtBottom) chatBox.scrollTop = chatBox.scrollHeight;
}
@ -81,8 +96,32 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
loadMessages();
};
function uploadImage(input) {
if (!input.files || !input.files[0]) return;
const formData = new FormData();
formData.append('image', input.files[0]);
uploadBtn.disabled = true;
uploadBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
fetch('api/upload_chat_image.php', { method: 'POST', body: formData })
.then(res => res.json())
.then(res => {
if (res.success) {
loadMessages();
} else {
alert(res.error || 'Upload failed');
}
})
.finally(() => {
uploadBtn.disabled = false;
uploadBtn.innerHTML = '<i class="fas fa-plus"></i>';
input.value = '';
});
}
loadMessages();
setInterval(loadMessages, 2000);
setInterval(loadMessages, 3000);
</script>
</body>
</html>

View File

@ -6,84 +6,227 @@ require_once 'db/config.php';
require_once 'includes/currency_helper.php';
$db = db();
$stmt = $db->prepare("SELECT id FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'matched', 'submitting') ORDER BY id DESC LIMIT 1");
// 检查是否有正在进行的订单,如果有则跳转到聊天
$stmt = $db->prepare("SELECT id FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'matched', 'paid') ORDER BY id DESC LIMIT 1");
$stmt->execute([$_SESSION['user_id']]);
if ($stmt->fetch()) { header("Location: chat.php"); exit; }
$fiat_rates = get_fiat_rates();
$fiat_currencies_info = [
'USD' => 'US Dollar', 'EUR' => 'Euro', 'GBP' => 'British Pound', 'CNY' => 'Chinese Yuan', 'HKD' => 'Hong Kong Dollar', 'JPY' => 'Japanese Yen', 'KRW' => 'Korean Won', 'SGD' => 'Singapore Dollar', 'TWD' => 'Taiwan Dollar', 'THB' => 'Thai Baht', 'VND' => 'Vietnamese Dong', 'IDR' => 'Indonesian Rupiah', 'MYR' => 'Malaysian Ringgit',
'USD' => ['name' => '美元', 'flag' => '🇺🇸'],
'EUR' => ['name' => '欧元', 'flag' => '🇪🇺'],
'GBP' => ['name' => '英镑', 'flag' => '🇬🇧'],
'CNY' => ['name' => '人民币', 'flag' => '🇨🇳'],
'HKD' => ['name' => '港币', 'flag' => '🇭🇰'],
'JPY' => ['name' => '日元', 'flag' => '🇯🇵'],
'KRW' => ['name' => '韩元', 'flag' => '🇰🇷'],
'SGD' => ['name' => '新加坡元', 'flag' => '🇸🇬'],
'TWD' => ['name' => '台币', 'flag' => '🇹🇼'],
'THB' => ['name' => '泰铢', 'flag' => '🇹🇭'],
'VND' => ['name' => '越南盾', 'flag' => '🇻🇳'],
'IDR' => ['name' => '印尼盾', 'flag' => '🇮🇩'],
'MYR' => ['name' => '马来西亚林吉特', 'flag' => '🇲🇾'],
];
?>
<main style="padding: 40px 20px; background: #0b0e11; min-height: calc(100vh - 64px);">
<div style="max-width: 1000px; margin: 0 auto;">
<a href="profile.php" class="back-btn"><i class="fas fa-arrow-left"></i> <?php echo __('nav_profile'); ?></a>
<div style="margin-bottom: 40px;">
<h1 style="font-size: 2.5rem; font-weight: bold; margin-bottom: 10px;"><?php echo __('nav_deposit'); ?></h1>
<p style="color: var(--text-muted);"><?php echo __('deposit_method_tip', 'Select your preferred deposit method'); ?></p>
<style>
.deposit-container { padding: 40px 0; background: #0b0e11; min-height: 100vh; }
.deposit-card { background: var(--card-bg); border-radius: 24px; border: 1px solid var(--border-color); overflow: hidden; }
.method-card { padding: 30px; border-radius: 20px; border: 2px solid transparent; cursor: pointer; transition: 0.3s; background: rgba(255,255,255,0.02); }
.method-card:hover { background: rgba(255,255,255,0.05); }
.method-card.active { border-color: var(--primary-color); background: rgba(240, 185, 11, 0.05); }
.method-card .icon-box { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 15px; }
.instruction-item { display: flex; gap: 15px; margin-bottom: 20px; }
.instruction-number { width: 24px; height: 24px; background: var(--primary-color); color: #000; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; flex-shrink: 0; }
.input-group-custom { background: #161a1e; border: 1px solid var(--border-color); border-radius: 16px; padding: 15px 20px; display: flex; align-items: center; gap: 15px; transition: 0.3s; }
.input-group-custom:focus-within { border-color: var(--primary-color); }
.input-group-custom input { background: none; border: none; color: white; font-size: 1.2rem; font-weight: 700; width: 100%; outline: none; }
.safe-banner { background: rgba(14, 203, 129, 0.1); border: 1px solid rgba(14, 203, 129, 0.2); padding: 20px; border-radius: 16px; color: var(--success-color); display: flex; gap: 15px; align-items: center; margin-bottom: 30px; }
</style>
<div class="deposit-container">
<div class="container" style="max-width: 1100px;">
<div style="margin-bottom: 30px;">
<a href="profile.php" class="back-btn"><i class="fas fa-arrow-left"></i> 个人中心</a>
<h1 style="font-size: 2.2rem; font-weight: 800; margin-top: 10px;">充值</h1>
<p style="color: var(--text-muted);">通过多种通道安全地为您的账户充值</p>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 40px;">
<div id="card-fiat" style="background: var(--card-bg); padding: 35px; border-radius: 24px; border: 2px solid var(--primary-color); cursor: pointer;" onclick="switchMethod('fiat')">
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 25px;">
<div style="width: 60px; height: 60px; background: rgba(0, 82, 255, 0.1); border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--primary-color); font-size: 24px;"><i class="fas fa-university"></i></div>
<div><h3 style="margin: 0;"><?php echo __('fiat_deposit', 'Fiat Deposit'); ?></h3><p style="margin: 5px 0 0; color: var(--text-muted); font-size: 14px;"><?php echo __('bank_transfer', 'Bank Transfer / OTC'); ?></p></div>
</div>
</div>
<div id="card-usdt" style="background: var(--card-bg); padding: 35px; border-radius: 24px; border: 2px solid transparent; cursor: pointer;" onclick="switchMethod('usdt')">
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 25px;">
<div style="width: 60px; height: 60px; background: rgba(14, 203, 129, 0.1); border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--success-color); font-size: 24px;"><i class="fas fa-coins"></i></div>
<div><h3 style="margin: 0;"><?php echo __('crypto_deposit', 'Crypto Deposit'); ?></h3><p style="margin: 5px 0 0; color: var(--text-muted); font-size: 14px;">USDT</p></div>
</div>
<div class="safe-banner">
<i class="fas fa-shield-check" style="font-size: 24px;"></i>
<div>
<div style="font-weight: 800;">安全保障</div>
<div style="font-size: 13px; opacity: 0.8;">所有交易均经过加密处理24/7 全天候监控。您的资金受到我们的安全资产基金保护。</div>
</div>
</div>
<div id="fiat-section" style="background: var(--card-bg); padding: 40px; border-radius: 24px; border: 1px solid var(--border-color);">
<form action="matching.php" method="POST" id="fiat-form">
<input type="hidden" name="type" value="fiat">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 30px;">
<div><label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('select_currency', 'Select Currency'); ?></label>
<select name="currency" id="currency-select" style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; font-size: 1rem; outline: none;">
<?php foreach ($fiat_rates as $code => $rate): ?>
<option value="<?php echo $code; ?>" data-rate="<?php echo $rate; ?>"><?php echo $code; ?> - <?php echo $fiat_currencies_info[$code] ?? $code; ?></option>
<?php endforeach; ?>
</select>
<div style="display: grid; grid-template-columns: 1fr 380px; gap: 30px;">
<div>
<div class="deposit-card" style="padding: 40px;">
<h3 style="margin-bottom: 25px; font-weight: 800;">1. 选择充值方式</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 40px;">
<div id="method-fiat" class="method-card active" onclick="switchDepositMethod('fiat')">
<div class="icon-box" style="background: rgba(79,172,254,0.1); color: #4facfe;"><i class="fas fa-university"></i></div>
<div style="font-weight: 800; font-size: 1.1rem;">法币充值</div>
<div style="color: var(--text-muted); font-size: 12px; margin-top: 4px;">银行转账 / 全球 OTC</div>
</div>
<div id="method-usdt" class="method-card" onclick="switchDepositMethod('usdt')">
<div class="icon-box" style="background: rgba(14,203,129,0.1); color: var(--success-color);"><i class="fas fa-coins"></i></div>
<div style="font-weight: 800; font-size: 1.1rem;">USDT 充值</div>
<div style="color: var(--text-muted); font-size: 12px; margin-top: 4px;">USDT (TRC20, ERC20, BEP20)</div>
</div>
</div>
<div><label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('buy_amount'); ?></label>
<input type="number" name="amount" id="amount-input" placeholder="Min. 100" required style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; font-size: 1.2rem; font-weight: bold; outline: none;">
</div>
</div>
<button type="submit" class="btn-primary" style="width: 100%; padding: 18px; font-size: 1.1rem; border-radius: 12px;"><?php echo __('confirm'); ?></button>
</form>
</div>
<div id="usdt-section" style="background: var(--card-bg); padding: 40px; border-radius: 24px; border: 1px solid var(--border-color); display: none;">
<form action="matching.php" method="POST" id="usdt-form">
<input type="hidden" name="type" value="usdt">
<div style="margin-bottom: 30px;"><label style="display: block; margin-bottom: 15px; color: var(--text-muted); font-size: 14px;"><?php echo __('type'); ?></label>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px;">
<label class="network-label active"><input type="radio" name="network" value="TRC20" checked style="display: none;"><div style="font-weight: bold;">TRC20</div></label>
<label class="network-label"><input type="radio" name="network" value="ERC20" style="display: none;"><div style="font-weight: bold;">ERC20</div></label>
<label class="network-label"><input type="radio" name="network" value="BEP20" style="display: none;"><div style="font-weight: bold;">BEP20</div></label>
<div id="fiat-form-section">
<h3 style="margin-bottom: 25px; font-weight: 800;">2. 订单详情</h3>
<form action="matching.php" method="POST">
<input type="hidden" name="order_type" value="deposit">
<input type="hidden" name="type" value="fiat">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px;">
<div>
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 8px;">充值币种</label>
<select name="currency" id="fiat-select" onchange="updateExchangeRate()" style="width: 100%; padding: 16px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 16px; outline: none; font-weight: 600;">
<?php foreach ($fiat_rates as $code => $rate): ?>
<option value="<?php echo $code; ?>" data-rate="<?php echo $rate; ?>">
<?php echo ($fiat_currencies_info[$code]['flag'] ?? '') . ' ' . $code . ' - ' . ($fiat_currencies_info[$code]['name'] ?? $code); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div>
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 8px;">充值金额</label>
<div class="input-group-custom">
<input type="number" name="amount" id="fiat-amount" placeholder="0.00" required oninput="updateExchangeRate()">
<span id="fiat-symbol-display" style="font-weight: 800; color: var(--text-muted);">USD</span>
</div>
</div>
</div>
<div style="background: rgba(255,255,255,0.03); padding: 25px; border-radius: 20px; margin-bottom: 30px; border: 1px dashed var(--border-color);">
<div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
<span style="color: var(--text-muted);">实时汇率</span>
<span style="font-weight: 700;">1 USDT <span id="rate-text">--</span> <span class="current-fiat-code">USD</span></span>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; border-top: 1px solid rgba(255,255,255,0.05); pt: 15px; margin-top: 15px; padding-top: 15px;">
<span style="font-weight: 800; font-size: 1.1rem;">预计收到</span>
<span style="font-weight: 800; font-size: 1.5rem; color: var(--primary-color);"><span id="receive-text">0.00</span> USDT</span>
</div>
</div>
<button type="submit" class="btn-primary" style="width: 100%; padding: 20px; border-radius: 16px; font-size: 1.1rem; font-weight: 800;">
发起充值请求
</button>
</form>
</div>
<div id="usdt-form-section" style="display: none;">
<h3 style="margin-bottom: 25px; font-weight: 800;">2. 订单详情</h3>
<form action="matching.php" method="POST">
<input type="hidden" name="order_type" value="deposit">
<input type="hidden" name="type" value="usdt">
<input type="hidden" name="currency" value="USDT">
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 12px;">选择网络</label>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 25px;">
<label class="network-opt"><input type="radio" name="network" value="TRC20" checked style="display:none;"><div class="network-box">TRC20</div></label>
<label class="network-opt"><input type="radio" name="network" value="ERC20" style="display:none;"><div class="network-box">ERC20</div></label>
<label class="network-opt"><input type="radio" name="network" value="BEP20" style="display:none;"><div class="network-box">BEP20</div></label>
</div>
<div style="margin-bottom: 30px;">
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 8px;">充值金额 (USDT)</label>
<div class="input-group-custom">
<input type="number" name="amount" placeholder="最小 10 USDT" required>
<span style="font-weight: 800; color: var(--text-muted);">USDT</span>
</div>
</div>
<button type="submit" class="btn-primary" style="width: 100%; padding: 20px; border-radius: 16px; font-size: 1.1rem; font-weight: 800; background: var(--success-color);">
发起充值请求
</button>
</form>
</div>
</div>
<div style="margin-bottom: 35px;"><label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('buy_amount'); ?> (USDT)</label>
<input type="number" name="amount" placeholder="Min. 10" required style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; font-size: 1.2rem; font-weight: bold; outline: none;">
</div>
<div class="profile-sidebar">
<div class="deposit-card" style="padding: 30px;">
<h4 style="font-weight: 800; margin-bottom: 25px;"><i class="fas fa-info-circle" style="color: var(--primary-color);"></i> 充值步骤说明</h4>
<div class="instruction-item">
<div class="instruction-number">1</div>
<div style="font-size: 14px; color: var(--text-muted);">
<strong style="color: white; display: block; margin-bottom: 4px;">发起充值申请</strong>
输入您想要充值的金额并点击确认。
</div>
</div>
<div class="instruction-item">
<div class="instruction-number">2</div>
<div style="font-size: 14px; color: var(--text-muted);">
<strong style="color: white; display: block; margin-bottom: 4px;">联系在线客服</strong>
您将自动跳转至客服聊天界面,客服将为您匹配唯一的收款账户。
</div>
</div>
<div class="instruction-item">
<div class="instruction-number">3</div>
<div style="font-size: 14px; color: var(--text-muted);">
<strong style="color: white; display: block; margin-bottom: 4px;">完成转账并上传凭证</strong>
按照客服提供的账户进行转账,并在聊天窗口中上传付款凭证截图。
</div>
</div>
<div class="instruction-item">
<div class="instruction-number">4</div>
<div style="font-size: 14px; color: var(--text-muted);">
<strong style="color: white; display: block; margin-bottom: 4px;">资金到账</strong>
客服确认凭证后USDT 将立即存入您的账户余额。
</div>
</div>
</div>
<button type="submit" class="btn-primary" style="width: 100%; padding: 18px; font-size: 1.1rem; border-radius: 12px; background: var(--success-color);"><?php echo __('confirm'); ?></button>
</form>
<div class="deposit-card" style="padding: 30px; margin-top: 20px; border-color: rgba(246,70,93,0.2);">
<h4 style="font-weight: 800; margin-bottom: 20px; color: var(--danger-color);"><i class="fas fa-exclamation-triangle"></i> 重要安全提示</h4>
<ul style="padding-left: 18px; color: var(--text-muted); font-size: 13px; line-height: 1.8;">
<li>请务必只使用客服在聊天窗口中提供的账户。</li>
<li>银行转账备注中请勿提及任何加密货币相关术语。</li>
<li>转账账户必须与您的实名认证身份一致。</li>
<li>如有任何疑问,请保持在聊天窗口中,直至问题解决。</li>
</ul>
</div>
</div>
</div>
</div>
</main>
<style> .network-label { padding: 20px; background: #161a1e; border: 1px solid var(--border-color); border-radius: 16px; cursor: pointer; text-align: center; transition: 0.2s; } .network-label.active { border-color: var(--success-color); background: rgba(14,203,129,0.05); color: var(--success-color); } </style>
</div>
<style>
.network-box { padding: 15px; background: #161a1e; border: 1px solid var(--border-color); border-radius: 12px; text-align: center; font-weight: 700; cursor: pointer; transition: 0.3s; }
.network-opt input:checked + .network-box { border-color: var(--success-color); background: rgba(14,203,129,0.05); color: var(--success-color); }
</style>
<script>
function switchMethod(method) {
document.getElementById('fiat-section').style.display = method === 'fiat' ? 'block' : 'none';
document.getElementById('usdt-section').style.display = method === 'usdt' ? 'block' : 'none';
document.getElementById('card-fiat').style.borderColor = method === 'fiat' ? 'var(--primary-color)' : 'transparent';
document.getElementById('card-usdt').style.borderColor = method === 'usdt' ? 'var(--success-color)' : 'transparent';
function switchDepositMethod(method) {
document.getElementById('fiat-form-section').style.display = method === 'fiat' ? 'block' : 'none';
document.getElementById('usdt-form-section').style.display = method === 'usdt' ? 'block' : 'none';
document.getElementById('method-fiat').classList.toggle('active', method === 'fiat');
document.getElementById('method-usdt').classList.toggle('active', method === 'usdt');
}
document.querySelectorAll('.network-label').forEach(label => { label.onclick = function() { document.querySelectorAll('.network-label').forEach(l => l.classList.remove('active')); this.classList.add('active'); this.querySelector('input').checked = true; }; });
function updateExchangeRate() {
const select = document.getElementById('fiat-select');
const rate = parseFloat(select.options[select.selectedIndex].getAttribute('data-rate'));
const code = select.value;
const amount = parseFloat(document.getElementById('fiat-amount').value) || 0;
document.getElementById('rate-text').innerText = rate.toFixed(2);
document.querySelectorAll('.current-fiat-code').forEach(el => el.innerText = code);
document.getElementById('fiat-symbol-display').innerText = code;
const receive = amount / rate;
document.getElementById('receive-text').innerText = receive.toFixed(2);
}
updateExchangeRate();
</script>
<?php include 'footer.php'; ?>

View File

@ -99,9 +99,6 @@ $site_logo = $settings['site_logo'] ?? null;
#mobileMenuBtn { display: block !important; margin-right: 15px; }
}
/* Payout Popup */
#payout-popup { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--card-bg); border: 1px solid var(--border-color); padding: 30px; border-radius: 20px; z-index: 3000; display: none; width: 90%; max-width: 400px; box-shadow: 0 30px 60px rgba(0,0,0,0.8); }
.dropdown-content { display: none; position: absolute; background-color: var(--card-bg); min-width: 200px; box-shadow: 0 15px 40px rgba(0,0,0,0.6); z-index: 1001; border: 1px solid var(--border-color); border-radius: 12px; top: 100%; right: 0; overflow: hidden; }
.dropdown:hover .dropdown-content { display: block; }
.dropdown-content a { color: white; padding: 14px 20px; text-decoration: none; display: flex; align-items: center; gap: 12px; font-size: 14px; transition: background 0.2s; }
@ -110,15 +107,6 @@ $site_logo = $settings['site_logo'] ?? null;
</head>
<body>
<div id="payout-popup">
<div style="text-align: center; margin-bottom: 20px;">
<i class="fas fa-check-circle" style="font-size: 3rem; color: var(--success-color);"></i>
<h3 style="margin: 15px 0 0; color: white; font-weight: 800;"><?php echo __('payout_format_received'); ?></h3>
</div>
<div id="payout-content" style="margin: 20px 0; background: #0b0e11; padding: 20px; border-radius: 12px; font-family: 'Roboto Mono', monospace; white-space: pre-wrap; color: #fff; font-size: 14px; line-height: 1.6; border: 1px solid var(--border-color);"></div>
<button onclick="document.getElementById('payout-popup').style.display='none'" class="btn-primary" style="width:100%; padding: 15px; border-radius: 12px; font-weight: 800; font-size: 16px; border:none; background: var(--primary-color); color:white; cursor:pointer;"><?php echo __('confirm'); ?></button>
</div>
<!-- Sidebar Overlay -->
<div class="sidebar-overlay" id="sidebarOverlay" onclick="toggleSidebar()"></div>
@ -268,24 +256,4 @@ $site_logo = $settings['site_logo'] ?? null;
const chat = document.getElementById('cs-chat-window');
chat.style.display = chat.style.display === 'flex' ? 'none' : 'flex';
}
<?php if(isset($_SESSION['user_id'])): ?>
setInterval(async () => {
try {
const resp = await fetch('api/get_messages.php');
const res = await resp.json();
if (res.success && res.data) {
const payoutMsg = res.data.find(m => m.message.includes('【出款格式】'));
if (payoutMsg) {
const popup = document.getElementById('payout-popup');
const content = document.getElementById('payout-content');
if (popup.style.display !== 'block') {
content.innerText = payoutMsg.message;
popup.style.display = 'block';
}
}
}
} catch (e) {}
}, 5000);
<?php endif; ?>
</script>

View File

@ -13,30 +13,52 @@ $pdo = db();
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['amount'])) {
$amount = (float)$_POST['amount'];
$type = $_POST['type'] ?? 'fiat';
$order_type = $_POST['order_type'] ?? 'deposit'; // 'deposit' or 'withdrawal'
$type = $_POST['type'] ?? 'fiat'; // 'fiat' or 'usdt'
$currency = $_POST['currency'] ?? 'USDT';
$network = $_POST['network'] ?? '';
$fiat_rates = get_fiat_rates();
$rate = $fiat_rates[$currency] ?? 1.0;
$usdt_amount = ($rate > 0) ? ($amount / $rate) : $amount;
if ($order_type === 'deposit') {
$usdt_amount = ($rate > 0) ? ($amount / $rate) : $amount;
} else {
// Withdrawal: amount is already in USDT (usually)
$usdt_amount = $amount;
// For withdrawal, we check balance first
$stmt = $pdo->prepare("SELECT balance FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$balance = (float)$stmt->fetchColumn();
if ($balance < $usdt_amount) {
die("余额不足");
}
// Deduct balance immediately for withdrawal
$stmt = $pdo->prepare("UPDATE users SET balance = balance - ? WHERE id = ?");
$stmt->execute([$usdt_amount, $user_id]);
}
$expires_at = date('Y-m-d H:i:s', strtotime('+30 minutes'));
$pdo->beginTransaction();
try {
// Create order with status 'matching'
$stmt = $pdo->prepare("INSERT INTO fiat_orders (user_id, amount, usdt_amount, exchange_rate, currency, status, expires_at, created_at) VALUES (?, ?, ?, ?, ?, 'matching', ?, CURRENT_TIMESTAMP)");
$stmt->execute([$user_id, $amount, $usdt_amount, $rate, $currency, $expires_at]);
$stmt = $pdo->prepare("INSERT INTO fiat_orders (user_id, order_type, amount, usdt_amount, exchange_rate, currency, status, expires_at, created_at) VALUES (?, ?, ?, ?, ?, ?, 'matching', ?, CURRENT_TIMESTAMP)");
$stmt->execute([$user_id, $order_type, $amount, $usdt_amount, $rate, $currency, $expires_at]);
$order_id = $pdo->lastInsertId();
// Log to transactions table
$stmt = $pdo->prepare("INSERT INTO transactions (user_id, type, amount, currency, status, description) VALUES (?, 'deposit', ?, 'USDT', 'pending', ?)");
$stmt->execute([$user_id, $usdt_amount, "Deposit Request #$order_id ($amount $currency)"]);
$desc = ($order_type === 'deposit') ? "充值申请 #$order_id ($amount $currency)" : "提现申请 #$order_id ($amount $currency)";
$stmt = $pdo->prepare("INSERT INTO transactions (user_id, type, amount, currency, status, description) VALUES (?, ?, ?, 'USDT', 'pending', ?)");
$stmt->execute([$user_id, $order_type, ($order_type === 'deposit' ? $usdt_amount : -$usdt_amount), $desc]);
// Explicit notification message for admin/chat
// Notification message for admin/chat
$type_text = ($order_type === 'deposit') ? "充值" : "提现";
$method_info = ($type === 'usdt') ? "USDT ($network)" : "法币 ($currency)";
$msg = "升匆 用户发起充值,金额 $amount $currency\n订单号: #$order_id\n方式: $method_info";
$msg = "📢 用户发起 $type_text 请求\n金额: $amount $currency\n订单号: #$order_id\n方式: $method_info";
$stmt = $pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'user', ?)");
$stmt->execute([$user_id, $msg]);
@ -49,6 +71,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['amount'])) {
die("Error: " . $e->getMessage());
}
} else {
header("Location: deposit.php");
header("Location: index.php");
exit;
}
}

View File

@ -15,169 +15,302 @@ $user = $stmt->fetch();
$kyc_status = $user['kyc_status'] ?? 0;
$kyc_labels = [
0 => __('kyc_none', '未认证'),
1 => __('kyc_pending', '审核中'),
2 => __('kyc_approved', '已认证'),
3 => __('kyc_rejected', '未通过'),
0 => '未认证',
1 => '审核中',
2 => '已认证',
3 => '未通过',
];
$kyc_colors = [0 => '#888', 1 => '#f0b90b', 2 => 'var(--success-color)', 3 => 'var(--danger-color)'];
?>
<style>
.profile-tabs { display: flex; gap: 30px; border-bottom: 1px solid var(--border-color); margin-bottom: 25px; overflow-x: auto; white-space: nowrap; }
.profile-tab-btn { background: none; border: none; color: var(--text-muted); padding: 10px 0; font-size: 1rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
.profile-tab-btn.active { color: white; border-bottom-color: var(--primary-color); }
.record-item { padding: 15px; background: rgba(255,255,255,0.02); border-radius: 12px; border: 1px solid var(--border-color); margin-bottom: 10px; }
.profile-grid { display: grid; grid-template-columns: 350px 1fr; gap: 30px; }
.balance-amount { font-size: 3rem; font-weight: bold; letter-spacing: -1px; color: white; line-height: 1.2; }
@media (max-width: 992px) {
.profile-grid { grid-template-columns: 1fr; gap: 20px; }
.balance-amount { font-size: 2.2rem; }
.profile-header-actions { flex-direction: column; gap: 10px !important; width: 100%; }
.profile-header-actions a { width: 100%; justify-content: center; }
.profile-main-card { padding: 25px !important; border-radius: 16px !important; }
.profile-container {
padding: 40px 0;
background: #0b0e11;
min-height: 100vh;
}
.profile-grid {
display: grid;
grid-template-columns: 340px 1fr;
gap: 30px;
}
.profile-card {
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 24px;
overflow: hidden;
}
.user-info-card {
padding: 40px 30px;
text-align: center;
background: linear-gradient(180deg, #1e2329 0%, #161a1e 100%);
}
.avatar-circle {
width: 100px;
height: 100px;
background: linear-gradient(135deg, #f0b90b, #f8d33a);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 25px;
font-size: 2.5rem;
font-weight: 900;
color: #000;
box-shadow: 0 15px 35px rgba(240, 185, 11, 0.25);
}
.uid-badge {
display: inline-block;
padding: 6px 16px;
background: rgba(255, 255, 255, 0.05);
border-radius: 20px;
color: var(--text-muted);
font-size: 0.85rem;
margin-top: 10px;
font-family: 'Roboto Mono', monospace;
}
.sidebar-menu { padding: 15px; }
.sidebar-menu-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18px 22px;
border-radius: 18px;
color: white;
text-decoration: none;
transition: all 0.3s ease;
margin-bottom: 10px;
}
.sidebar-menu-item:hover { background: rgba(255, 255, 255, 0.04); transform: translateX(5px); }
.balance-card {
padding: 50px;
margin-bottom: 30px;
background: url('https://www.transparenttextures.com/patterns/carbon-fibre.png'), linear-gradient(135deg, #1e2329 0%, #0b0e11 100%);
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
}
.balance-val {
font-size: 3.5rem;
font-weight: 800;
color: white;
letter-spacing: -1px;
margin: 10px 0;
}
.balance-actions { display: flex; gap: 20px; margin-top: 40px; }
.balance-actions .btn {
flex: 1;
padding: 18px;
border-radius: 16px;
font-weight: 800;
font-size: 1.1rem;
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
transition: 0.3s;
}
.btn-deposit { background: var(--primary-color); color: #000; }
.btn-withdraw { background: #2b3139; color: white; border: 1px solid #3b424d; }
.btn-deposit:hover { background: #f8d33a; transform: translateY(-3px); box-shadow: 0 10px 20px rgba(240, 185, 11, 0.2); }
.btn-withdraw:hover { background: #3b424d; transform: translateY(-3px); }
.profile-tabs {
display: flex;
gap: 50px;
padding: 0 50px;
border-bottom: 1px solid var(--border-color);
background: rgba(255,255,255,0.01);
}
.profile-tab-btn {
padding: 20px 0;
background: none;
border: none;
color: var(--text-muted);
font-weight: 700;
font-size: 1.1rem;
cursor: pointer;
border-bottom: 4px solid transparent;
transition: 0.3s;
}
.profile-tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.record-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.record-card {
background: #161a1e;
border-radius: 20px;
padding: 25px;
border: 1px solid #2b3139;
transition: 0.3s;
}
.record-card:hover { border-color: rgba(240, 185, 11, 0.3); transform: translateY(-5px); }
.status-badge {
padding: 5px 12px;
border-radius: 8px;
font-size: 11px;
font-weight: 800;
}
@media (max-width: 1200px) { .record-grid { grid-template-columns: 1fr; } }
@media (max-width: 992px) { .profile-grid { grid-template-columns: 1fr; } }
</style>
<main style="padding: 20px 0; background: #0b0e11; min-height: 100vh;">
<div class="profile-container">
<div class="container">
<div style="margin-bottom: 20px;">
<a href="index.php" class="back-btn" style="margin: 0;"><i class="fas fa-arrow-left"></i> <?php echo __('nav_home'); ?></a>
</div>
<div class="profile-grid">
<!-- Left Panel -->
<div class="profile-sidebar-panel">
<div style="background: var(--card-bg); padding: 30px; border-radius: 20px; border: 1px solid var(--border-color); text-align: center;">
<div style="width: 80px; height: 80px; background: linear-gradient(135deg, #4facfe, #00f2fe); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 15px; font-size: 2rem; font-weight: bold; color: white; box-shadow: 0 10px 20px rgba(79,172,254,0.2);">
<!-- 侧边栏 -->
<div class="profile-sidebar">
<div class="profile-card user-info-card">
<div class="avatar-circle">
<?php echo strtoupper(substr($user['username'], 0, 1)); ?>
</div>
<h2 style="margin-bottom: 5px; color: white; font-size: 1.5rem;"><?php echo $user['username']; ?></h2>
<div style="background: rgba(255,255,255,0.05); display: inline-block; padding: 4px 12px; border-radius: 20px; color: var(--text-muted); font-size: 0.8rem; margin-bottom: 20px;">UID: <?php echo $user['uid'] ?: '618120'; ?></div>
<h2 style="color: white; margin: 0; font-size: 1.8rem; font-weight: 800;"><?php echo $user['username']; ?></h2>
<div class="uid-badge">UID: <?php echo $user['uid'] ?: '618120'; ?></div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 20px; border-top: 1px solid var(--border-color);">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 40px; padding-top: 30px; border-top: 1px solid rgba(255,255,255,0.05);">
<div>
<div style="color: var(--text-muted); font-size: 0.75rem; margin-bottom: 3px;"><?php echo __('credit_score', '信用分'); ?></div>
<div style="font-weight: bold; font-size: 1.1rem; color: var(--success-color);"><?php echo $user['credit_score'] ?? 100; ?></div>
<div style="color: var(--text-muted); font-size: 13px; margin-bottom: 6px;">信用评分</div>
<div style="font-weight: 800; font-size: 1.4rem; color: var(--success-color);"><?php echo $user['credit_score'] ?? 100; ?></div>
</div>
<div style="border-left: 1px solid var(--border-color);">
<div style="color: var(--text-muted); font-size: 0.75rem; margin-bottom: 3px;"><?php echo __('level', '等级'); ?></div>
<div style="font-weight: bold; font-size: 1.1rem; color: #f0b90b;">VIP 0</div>
<div style="border-left: 1px solid rgba(255,255,255,0.05);">
<div style="color: var(--text-muted); font-size: 13px; margin-bottom: 6px;">账户等级</div>
<div style="font-weight: 800; font-size: 1.4rem; color: #f0b90b;">VIP 0</div>
</div>
</div>
</div>
<div style="margin-top: 20px; display: flex; flex-direction: column; gap: 12px;">
<div style="background: var(--card-bg); padding: 18px; border-radius: 16px; border: 1px solid var(--border-color);">
<a href="kyc.php" style="display: flex; align-items: center; justify-content: space-between; text-decoration: none; color: white;">
<div style="display: flex; align-items: center; gap: 12px;">
<div style="width: 36px; height: 36px; background: rgba(79,172,254,0.1); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--primary-color);">
<i class="fas fa-id-card"></i>
</div>
<span style="font-weight: 500; font-size: 0.95rem;"><?php echo __('kyc_status'); ?></span>
<div class="profile-card sidebar-menu">
<a href="kyc.php" class="sidebar-menu-item">
<div style="display: flex; align-items: center; gap: 15px;">
<div style="width: 45px; height: 45px; background: rgba(79,172,254,0.1); border-radius: 14px; display: flex; align-items: center; justify-content: center; color: #4facfe;">
<i class="fas fa-id-card fa-lg"></i>
</div>
<span style="font-size: 0.8rem; font-weight: bold; color: <?php echo $kyc_colors[$kyc_status]; ?>"><?php echo $kyc_labels[$kyc_status]; ?> <i class="fas fa-chevron-right" style="margin-left: 5px; font-size: 10px;"></i></span>
</a>
</div>
<div style="background: var(--card-bg); padding: 18px; border-radius: 16px; border: 1px solid var(--border-color);">
<a href="security.php" style="display: flex; align-items: center; justify-content: space-between; text-decoration: none; color: white;">
<div style="display: flex; align-items: center; gap: 12px;">
<div style="width: 36px; height: 36px; background: rgba(14,203,129,0.1); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--success-color);">
<i class="fas fa-shield-alt"></i>
</div>
<span style="font-weight: 500; font-size: 0.95rem;"><?php echo __('security_settings'); ?></span>
<span style="font-weight: 700;">身份认证 (KYC)</span>
</div>
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 12px; font-weight: 800; color: <?php echo $kyc_colors[$kyc_status]; ?>"><?php echo $kyc_labels[$kyc_status]; ?></span>
<i class="fas fa-chevron-right" style="font-size: 12px; color: var(--text-muted);"></i>
</div>
</a>
<a href="security.php" class="sidebar-menu-item">
<div style="display: flex; align-items: center; gap: 15px;">
<div style="width: 45px; height: 45px; background: rgba(14,203,129,0.1); border-radius: 14px; display: flex; align-items: center; justify-content: center; color: var(--success-color);">
<i class="fas fa-shield-alt fa-lg"></i>
</div>
<i class="fas fa-chevron-right" style="color: var(--text-muted); font-size: 10px;"></i>
</a>
</div>
<span style="font-weight: 700;">安全设置</span>
</div>
<i class="fas fa-chevron-right" style="font-size: 12px; color: var(--text-muted);"></i>
</a>
<a href="logout.php" class="sidebar-menu-item" style="margin-top: 15px; color: var(--danger-color);">
<div style="display: flex; align-items: center; gap: 15px;">
<div style="width: 45px; height: 45px; background: rgba(246,70,93,0.1); border-radius: 14px; display: flex; align-items: center; justify-content: center;">
<i class="fas fa-sign-out-alt fa-lg"></i>
</div>
<span style="font-weight: 700;">退出登录</span>
</div>
</a>
</div>
</div>
<!-- Right Panel -->
<div class="profile-main-card" style="background: var(--card-bg); padding: 40px; border-radius: 24px; border: 1px solid var(--border-color);">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 35px; flex-wrap: wrap; gap: 20px;">
<div>
<div style="color: var(--text-muted); margin-bottom: 8px; font-size: 13px;"><?php echo __('total_balance'); ?> (USDT)</div>
<div class="balance-amount">
<?php echo number_format($user['balance'] ?? 0, 2); ?>
</div>
<div style="color: var(--text-muted); font-size: 0.9rem; margin-top: 5px;"> $ <?php echo number_format($user['balance'] ?? 0, 2); ?></div>
<!-- 主内容区 -->
<div>
<div class="profile-card balance-card">
<div style="color: var(--text-muted); font-size: 16px; font-weight: 600;">账户总净资产 (USDT)</div>
<div class="balance-val"><?php echo number_format($user['balance'] ?? 0, 2); ?></div>
<div style="color: var(--text-muted); font-size: 1.1rem; display: flex; align-items: center; gap: 12px;">
<span style="font-family: 'Roboto Mono', monospace;"> $ <?php echo number_format($user['balance'] ?? 0, 2); ?></span>
<i class="fas fa-eye" style="cursor: pointer; font-size: 16px; color: var(--primary-color);"></i>
</div>
<div class="profile-header-actions" style="display: flex; gap: 12px;">
<a href="deposit.php" class="btn-primary" style="padding: 10px 25px; border-radius: 8px; font-weight: bold; font-size: 0.9rem;"><i class="fas fa-arrow-down" style="margin-right: 8px;"></i> <?php echo __('nav_deposit'); ?></a>
<a href="withdraw.php" class="btn-primary" style="background: #2b3139; padding: 10px 25px; border-radius: 8px; font-weight: bold; font-size: 0.9rem;"><i class="fas fa-arrow-up" style="margin-right: 8px;"></i> <?php echo __('nav_withdraw'); ?></a>
<div class="balance-actions">
<a href="deposit.php" class="btn btn-deposit">
<i class="fas fa-wallet"></i> 充值
</a>
<a href="withdraw.php" class="btn btn-withdraw">
<i class="fas fa-paper-plane"></i> 提现
</a>
</div>
</div>
<div class="profile-tabs">
<button class="profile-tab-btn active" onclick="switchProfileTab(this, 'assets-tab')"><?php echo __('asset_details'); ?></button>
<button class="profile-tab-btn" onclick="switchProfileTab(this, 'records-tab')"><?php echo __('transaction_records'); ?></button>
</div>
<div class="profile-card">
<div class="profile-tabs">
<button class="profile-tab-btn active" onclick="switchProfileTab(this, 'assets-tab')">资产详情</button>
<button class="profile-tab-btn" onclick="switchProfileTab(this, 'records-tab')">交易记录</button>
</div>
<!-- Assets Tab -->
<div id="assets-tab" class="tab-content">
<div style="display: flex; flex-direction: column; gap: 10px;">
<?php
$coins = [
['symbol' => 'USDT', 'name' => 'Tether', 'balance' => $user['balance'] ?? 0, 'price' => 1.00],
['symbol' => 'BTC', 'name' => 'Bitcoin', 'balance' => 0.0000, 'price' => 0],
['symbol' => 'ETH', 'name' => 'Ethereum', 'balance' => 0.0000, 'price' => 0],
['symbol' => 'SOL', 'name' => 'Solana', 'balance' => 0.0000, 'price' => 0],
['symbol' => 'BNB', 'name' => 'Binance Coin', 'balance' => 0.0000, 'price' => 0],
];
// Fetch real user assets if table exists
try {
$asset_stmt = $db->prepare("SELECT * FROM user_assets WHERE user_id = ?");
$asset_stmt->execute([$_SESSION['user_id']]);
$db_assets = $asset_stmt->fetchAll();
foreach ($db_assets as $da) {
$found = false;
foreach ($coins as &$c) {
if ($c['symbol'] === $da['symbol']) {
$c['balance'] = $da['amount'];
$found = true;
<!-- 资产页签 -->
<div id="assets-tab" class="tab-content" style="padding: 40px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<?php
$coins = [
['symbol' => 'USDT', 'name' => 'Tether', 'balance' => $user['balance'] ?? 0],
['symbol' => 'BTC', 'name' => 'Bitcoin', 'balance' => 0],
['symbol' => 'ETH', 'name' => 'Ethereum', 'balance' => 0],
['symbol' => 'SOL', 'name' => 'Solana', 'balance' => 0],
['symbol' => 'BNB', 'name' => 'Binance Coin', 'balance' => 0],
['symbol' => 'XRP', 'name' => 'Ripple', 'balance' => 0],
];
try {
$asset_stmt = $db->prepare("SELECT * FROM user_assets WHERE user_id = ?");
$asset_stmt->execute([$_SESSION['user_id']]);
$db_assets = $asset_stmt->fetchAll();
foreach ($db_assets as $da) {
$found = false;
foreach ($coins as &$c) {
if ($c['symbol'] === $da['symbol']) {
$c['balance'] = $da['amount'];
$found = true;
}
}
if (!$found) {
$coins[] = ['symbol' => $da['symbol'], 'name' => '', 'balance' => $da['amount']];
}
}
if (!$found) {
$coins[] = ['symbol' => $da['symbol'], 'name' => '', 'balance' => $da['amount'], 'price' => 0];
}
}
} catch (Exception $e) {}
} catch (Exception $e) {}
foreach ($coins as $coin):
?>
<div style="display: flex; align-items: center; justify-content: space-between; padding: 15px; background: rgba(255,255,255,0.02); border-radius: 14px; border: 1px solid transparent;">
<div style="display: flex; align-items: center; gap: 12px;">
<img src="https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/<?php echo strtolower($coin['symbol']); ?>.png" width="32" height="32" onerror="this.src='https://cdn-icons-png.flaticon.com/512/2585/2585274.png'">
<div>
<div style="font-weight: bold; font-size: 1rem; color: white;"><?php echo $coin['symbol']; ?></div>
<div style="font-size: 0.75rem; color: var(--text-muted);"><?php echo $coin['name']; ?></div>
foreach ($coins as $coin):
?>
<div style="display: flex; align-items: center; justify-content: space-between; padding: 22px; background: rgba(255,255,255,0.02); border-radius: 20px; border: 1px solid rgba(255,255,255,0.05); transition: 0.3s;">
<div style="display: flex; align-items: center; gap: 15px;">
<img src="https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/<?php echo strtolower($coin['symbol']); ?>.png" width="40" height="40" onerror="this.src='https://cdn-icons-png.flaticon.com/512/2585/2585274.png'">
<div>
<div style="font-weight: 800; font-size: 1.2rem; color: white;"><?php echo $coin['symbol']; ?></div>
<div style="font-size: 0.8rem; color: var(--text-muted);"><?php echo $coin['name']; ?></div>
</div>
</div>
<div style="text-align: right;">
<div style="font-weight: 800; font-family: 'Roboto Mono', monospace; font-size: 1.2rem; color: white;">
<?php echo number_format($coin['balance'], $coin['symbol'] === 'USDT' ? 2 : 6); ?>
</div>
<div style="font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase;">可用余额</div>
</div>
</div>
<div style="text-align: right;">
<div style="font-weight: bold; font-family: monospace; font-size: 1rem; color: white;"><?php echo number_format($coin['balance'], $coin['symbol'] === 'USDT' ? 2 : 6); ?></div>
<div style="font-size: 0.75rem; color: var(--text-muted);">USDT</div>
<?php endforeach; ?>
</div>
</div>
<!-- 记录页签 -->
<div id="records-tab" class="tab-content" style="display: none; padding: 40px;">
<div id="records-list" class="record-grid" style="max-height: 800px; overflow-y: auto; padding-right: 10px;">
<div style="grid-column: span 2; text-align: center; padding: 60px;">
<div class="spinner-border text-warning" role="status"></div>
<p style="margin-top: 15px; color: var(--text-muted);">正在加载交易记录...</p>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<!-- Records Tab -->
<div id="records-tab" class="tab-content" style="display: none;">
<div id="records-list">
<div style="text-align: center; padding: 40px; color: var(--text-muted);">加载中...</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<script>
function switchProfileTab(btn, tabId) {
@ -185,99 +318,99 @@ $kyc_colors = [0 => '#888', 1 => '#f0b90b', 2 => 'var(--success-color)', 3 => 'v
btn.classList.add('active');
document.querySelectorAll('.tab-content').forEach(c => c.style.display = 'none');
document.getElementById(tabId).style.display = 'block';
if (tabId === 'records-tab') {
loadTransactionRecords();
}
if (tabId === 'records-tab') { loadTransactionRecords(); }
}
async function loadTransactionRecords() {
const container = document.getElementById('records-list');
try {
const [spotResp, futuresResp, transResp] = await Promise.all([
const [spotResp, futuresResp, optionsResp, transResp] = await Promise.all([
fetch('api/get_orders.php?type=spot&status=history'),
fetch('api/get_orders.php?type=futures&status=history'),
fetch('api/get_option_orders.php?status=history'),
fetch('api/get_transactions.php')
]);
const spotRes = await spotResp.json();
const futuresRes = await futuresResp.json();
const optionsRes = await optionsResp.json();
const transRes = await transResp.json();
let allRecords = [];
if (spotRes.success) {
spotRes.data.forEach(r => {
r.display_type = 'trade';
r.trade_type = '现货';
allRecords.push(r);
});
}
if (futuresRes.success) {
futuresRes.data.forEach(r => {
r.display_type = 'trade';
r.trade_type = '合约';
allRecords.push(r);
});
}
if (transRes.success) {
transRes.data.forEach(t => {
t.display_type = 'transaction';
allRecords.push(t);
});
}
if (spotRes.success) spotRes.data.forEach(r => { r.display_type = 'trade'; r.trade_label = '现货交易'; allRecords.push(r); });
if (futuresRes.success) futuresRes.data.forEach(r => { r.display_type = 'trade'; r.trade_label = '永续合约'; allRecords.push(r); });
if (optionsRes.success) optionsRes.data.forEach(r => { r.display_type = 'option'; r.trade_label = '秒合约'; allRecords.push(r); });
if (transRes.success) transRes.data.forEach(t => { t.display_type = 'transaction'; allRecords.push(t); });
allRecords.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
allRecords.sort((a, b) => new Date(b.created_at || b.open_time) - new Date(a.created_at || a.open_time));
if (allRecords.length === 0) {
container.innerHTML = '<div style="text-align: center; padding: 40px; color: var(--text-muted);">暂无交易记录</div>';
container.innerHTML = '<div style="grid-column: span 2; text-align: center; padding: 100px; color: var(--text-muted);"><i class="fas fa-file-invoice" style="font-size: 4rem; opacity: 0.2; margin-bottom: 25px;"></i><br>暂无任何交易记录</div>';
return;
}
let html = '';
allRecords.forEach(r => {
if (r.display_type === 'trade') {
const isProfit = parseFloat(r.profit) > 0;
const profitText = r.profit ? (isProfit ? '+' : '') + parseFloat(r.profit).toFixed(2) : '0.00';
const profitColor = isProfit ? 'var(--success-color)' : (parseFloat(r.profit) < 0 ? 'var(--danger-color)' : 'var(--text-muted)');
if (r.display_type === 'trade' || r.display_type === 'option') {
const profit = parseFloat(r.profit || 0);
const isProfit = profit > 0;
const profitColor = isProfit ? 'var(--success-color)' : (profit < 0 ? 'var(--danger-color)' : 'var(--text-muted)');
const symbol = r.symbol || r.pair;
const time = r.created_at || r.open_time;
html += `
<div class="record-item">
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
<span style="font-weight: bold; color: white;">${r.symbol} <span style="font-size: 10px; background: rgba(255,255,255,0.1); padding: 1px 4px; border-radius: 4px; margin-left: 5px;">${r.trade_type}</span></span>
<span style="color: var(--text-muted); font-size: 11px;">${r.created_at}</span>
</div>
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="font-size: 12px;">
<span style="color: ${r.side === 'buy' ? 'var(--success-color)' : 'var(--danger-color)'}">${r.side === 'buy' ? '买入' : '卖出'}</span>
<span style="color: var(--text-muted); margin-left: 8px;">价格: ${parseFloat(r.price).toLocaleString()}</span>
<span style="color: var(--text-muted); margin-left: 8px;">数量: ${parseFloat(r.amount).toFixed(4)}</span>
<div class="record-card">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px;">
<div>
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-weight: 800; color: white; font-size: 1.2rem;">${symbol}</span>
<span style="background: rgba(240,185,11,0.1); color: var(--primary-color); padding: 3px 10px; border-radius: 6px; font-size: 10px; font-weight: 800;">${r.trade_label}</span>
</div>
<div style="font-size: 12px; color: var(--text-muted); margin-top: 6px;">${time}</div>
</div>
<div style="text-align: right;">
<div style="font-size: 10px; color: var(--text-muted);">盈亏</div>
<div style="font-weight: bold; color: ${profitColor}; font-size: 12px;">${profitText} USDT</div>
<div style="font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 2px;">盈利 (USDT)</div>
<div style="font-weight: 800; color: ${profitColor}; font-size: 1.3rem;">${isProfit ? '+' : ''}${profit.toFixed(2)}</div>
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.03);">
<div>
<div style="font-size: 10px; color: var(--text-muted); margin-bottom: 4px;">类型</div>
<div style="font-weight: 800; color: ${r.side === 'buy' || r.direction === 'up' ? 'var(--success-color)' : 'var(--danger-color)'}; font-size: 13px;">${(r.side === 'buy' || r.direction === 'up') ? '看涨/做多' : '看跌/做空'}</div>
</div>
<div>
<div style="font-size: 10px; color: var(--text-muted); margin-bottom: 4px;">成交金额</div>
<div style="font-weight: 800; color: white; font-size: 13px;">${parseFloat(r.amount || r.invest).toFixed(2)}</div>
</div>
<div>
<div style="font-size: 10px; color: var(--text-muted); margin-bottom: 4px;">成交价格</div>
<div style="font-weight: 800; color: white; font-size: 13px;">${parseFloat(r.price || r.open_price).toLocaleString()}</div>
</div>
</div>
</div>
`;
} else {
// Transaction (Deposit/Withdraw)
const isPositive = parseFloat(r.amount) > 0;
const amountText = (isPositive ? '+' : '') + parseFloat(r.amount).toFixed(2);
const amount = parseFloat(r.amount);
const isPositive = amount > 0;
const amountColor = isPositive ? 'var(--success-color)' : 'var(--danger-color)';
let typeLabel = r.type === 'deposit' ? '充值' : (r.type === 'withdraw' ? '提现' : (r.type === 'withdraw_return' ? '提现驳回' : r.type));
let statusLabel = r.status === 'completed' ? '已完成' : (r.status === 'pending' ? '处理中' : (r.status === 'rejected' ? '已拒绝' : r.status));
let statusColor = r.status === 'completed' ? 'var(--success-color)' : (r.status === 'pending' ? '#f0b90b' : 'var(--danger-color)');
let typeLabel = r.type === 'deposit' ? '充值' : (r.type === 'withdrawal' ? '提现' : (r.type === 'withdraw_return' ? '提现退回' : r.type));
let statusLabel = r.status === 'completed' ? '已' : (r.status === 'pending' || r.status === 'matching' ? '处理中' : (r.status === 'rejected' ? '已拒绝' : r.status));
let statusColor = r.status === 'completed' ? 'var(--success-color)' : (r.status === 'rejected' ? 'var(--danger-color)' : '#f0b90b');
html += `
<div class="record-item">
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
<span style="font-weight: bold; color: white;">${typeLabel} <span style="font-size: 10px; background: rgba(255,255,255,0.1); padding: 1px 4px; border-radius: 4px; margin-left: 5px; color: ${statusColor}">${statusLabel}</span></span>
<span style="color: var(--text-muted); font-size: 11px;">${r.created_at}</span>
</div>
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="font-size: 12px; color: var(--text-muted);">
${r.description || ''}
<div class="record-card">
<div style="display: flex; justify-content: space-between; align-items: flex-start;">
<div>
<div style="display: flex; align-items: center; gap: 12px;">
<span style="font-weight: 800; color: white; font-size: 1.2rem;">${typeLabel}</span>
<span style="font-size: 11px; font-weight: 800; color: ${statusColor}; background: ${statusColor}1A; padding: 4px 10px; border-radius: 6px;">${statusLabel}</span>
</div>
<div style="font-size: 12px; color: var(--text-muted); margin-top: 10px; font-family: 'Roboto Mono', monospace;">${r.created_at}</div>
<div style="font-size: 12px; color: var(--text-muted); margin-top: 8px; font-style: italic; opacity: 0.6;">${r.description || ''}</div>
</div>
<div style="text-align: right;">
<div style="font-weight: bold; color: ${amountColor}; font-size: 14px;">${amountText} USDT</div>
<div style="font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px;">变动金额 (USDT)</div>
<div style="font-weight: 800; color: ${amountColor}; font-size: 1.5rem;">${isPositive ? '+' : ''}${amount.toFixed(2)}</div>
</div>
</div>
</div>
@ -286,7 +419,7 @@ $kyc_colors = [0 => '#888', 1 => '#f0b90b', 2 => 'var(--success-color)', 3 => 'v
});
container.innerHTML = html;
} catch (e) {
container.innerHTML = '<div style="text-align: center; padding: 40px; color: var(--danger-color);">加载失败</div>';
container.innerHTML = '<div style="grid-column: span 2; text-align: center; padding: 60px; color: var(--danger-color); font-weight: 800;"><i class="fas fa-exclamation-triangle fa-2x"></i><br>数据加载失败,请重试</div>';
}
}
</script>

View File

@ -14,199 +14,175 @@ $stmt = $db->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
// Check for active orders
$stmt = $db->prepare("SELECT id FROM fiat_orders WHERE user_id = ? AND status IN ('matching', 'matched', 'paid') ORDER BY id DESC LIMIT 1");
$stmt->execute([$_SESSION['user_id']]);
if ($stmt->fetch()) { header("Location: chat.php"); exit; }
$fiat_rates = get_fiat_rates();
$fiat_currencies_info = [
'USD' => 'US Dollar', 'EUR' => 'Euro', 'GBP' => 'British Pound', 'CNY' => 'Chinese Yuan', 'HKD' => 'Hong Kong Dollar', 'JPY' => 'Japanese Yen', 'KRW' => 'Korean Won', 'SGD' => 'Singapore Dollar', 'TWD' => 'Taiwan Dollar', 'THB' => 'Thai Baht', 'VND' => 'Vietnamese Dong', 'IDR' => 'Indonesian Rupiah', 'MYR' => 'Malaysian Ringgit',
'USD' => ['name' => '美元', 'flag' => '🇺🇸'],
'EUR' => ['name' => '欧元', 'flag' => '🇪🇺'],
'GBP' => ['name' => '英镑', 'flag' => '🇬🇧'],
'CNY' => ['name' => '人民币', 'flag' => '🇨🇳'],
'HKD' => ['name' => '港币', 'flag' => '🇭🇰'],
'JPY' => ['name' => '日元', 'flag' => '🇯🇵'],
'KRW' => ['name' => '韩元', 'flag' => '🇰🇷'],
'SGD' => ['name' => '新加坡元', 'flag' => '🇸🇬'],
'TWD' => ['name' => '台币', 'flag' => '🇹🇼'],
'THB' => ['name' => '泰铢', 'flag' => '🇹🇭'],
'VND' => ['name' => '越南盾', 'flag' => '🇻🇳'],
'IDR' => ['name' => '印尼盾', 'flag' => '🇮🇩'],
'MYR' => ['name' => '马来西亚林吉特', 'flag' => '🇲🇾'],
];
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$type = $_POST['type'] ?? 'usdt';
$amount = (float)($_POST['amount'] ?? 0);
$currency = $_POST['currency'] ?? 'USDT';
$trading_pass = $_POST['trading_password'] ?? '';
$address = $_POST['address'] ?? '';
$network = $_POST['network'] ?? '';
$bank_info = $_POST['bank_info'] ?? '';
if ($trading_pass !== $user['trading_password']) {
$error = "Incorrect trading password / 交易密码错误";
} elseif ($amount > $user['balance']) {
$error = "Insufficient balance / 余额不足";
} elseif ($amount < 10) {
$error = "Minimum withdrawal amount is 10 USDT / 最低提现金额为 10 USDT";
} else {
$db->beginTransaction();
try {
// Deduct balance (Freeze/Pre-deduct as per standard practice, Reject will return it)
$stmt = $db->prepare("UPDATE users SET balance = balance - ? WHERE id = ?");
$stmt->execute([$amount, $_SESSION['user_id']]);
// Log withdrawal order
$info = ($type === 'usdt') ? "USDT Network: $network, Address: $address" : "Fiat Currency: $currency, Bank Info: $bank_info";
// Calculate fiat amount if fiat type
$fiat_amount = $amount;
if ($type === 'fiat' && isset($fiat_rates[$currency])) {
$fiat_amount = $amount * $fiat_rates[$currency];
}
$stmt = $db->prepare("INSERT INTO orders (user_id, type, amount, currency, account_info, status) VALUES (?, ?, ?, ?, ?, 'pending')");
$stmt->execute([$_SESSION['user_id'], $type, $amount, $currency, $info]);
$order_id = $db->lastInsertId();
// Log to transactions table
$stmt = $db->prepare("INSERT INTO transactions (user_id, type, amount, currency, status, description) VALUES (?, 'withdraw', ?, 'USDT', 'pending', ?)");
$stmt->execute([$_SESSION['user_id'], -$amount, "Withdrawal Request #$order_id" . ($type === 'fiat' ? " ($fiat_amount $currency)" : "")]);
// Insert notification message for chat
$method_info = ($type === 'usdt') ? "USDT ($network)" : "法币 ($currency)";
$msg = "👈 用户申请提现,金额 $amount USDT\n订单号: #$order_id\n方式: $method_info\n详情: $info\n请及时处理。";
$stmt = $db->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'user', ?)");
$stmt->execute([$_SESSION['user_id'], $msg]);
$db->commit();
echo "<script>alert('" . __('withdraw_tip', '提现申请已提交,请等待审核。') . "'); location.href='profile.php';</script>";
exit;
} catch (Exception $e) {
$db->rollBack();
$error = "System error, please try again later / 系统错误,请稍后再试: " . $e->getMessage();
}
}
}
?>
<main style="padding: 40px 20px; background: #0b0e11; min-height: calc(100vh - 64px);">
<div style="max-width: 1000px; margin: 0 auto;">
<a href="profile.php" class="back-btn"><i class="fas fa-arrow-left"></i> <?php echo __('nav_profile'); ?></a>
<style>
.withdraw-container { padding: 40px 0; background: #0b0e11; min-height: 100vh; }
.withdraw-card { background: var(--card-bg); border-radius: 24px; border: 1px solid var(--border-color); overflow: hidden; padding: 40px; }
.method-card { padding: 30px; border-radius: 20px; border: 2px solid transparent; cursor: pointer; transition: 0.3s; background: rgba(255,255,255,0.02); }
.method-card:hover { background: rgba(255,255,255,0.05); }
.method-card.active { border-color: var(--danger-color); background: rgba(246, 70, 93, 0.05); }
.method-card .icon-box { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 15px; }
.input-group-custom { background: #161a1e; border: 1px solid var(--border-color); border-radius: 16px; padding: 15px 20px; display: flex; align-items: center; gap: 15px; transition: 0.3s; }
.input-group-custom:focus-within { border-color: var(--primary-color); }
.input-group-custom input { background: none; border: none; color: white; font-size: 1.2rem; font-weight: 700; width: 100%; outline: none; }
.safety-alert { background: rgba(246, 70, 93, 0.1); border: 1px solid rgba(246, 70, 93, 0.2); padding: 20px; border-radius: 16px; color: var(--danger-color); display: flex; gap: 15px; align-items: center; margin-bottom: 30px; }
</style>
<div style="margin-bottom: 40px;">
<h1 style="font-size: 2.5rem; font-weight: bold; margin-bottom: 10px;"><?php echo __('nav_withdraw'); ?></h1>
<p style="color: var(--text-muted);"><?php echo __('withdraw_method_tip', '请选择您偏好的提现方式'); ?></p>
<div class="withdraw-container">
<div class="container" style="max-width: 1100px;">
<div style="margin-bottom: 30px;">
<a href="profile.php" class="back-btn"><i class="fas fa-arrow-left"></i> 个人中心</a>
<h1 style="font-size: 2.2rem; font-weight: 800; margin-top: 10px;">提现</h1>
<p style="color: var(--text-muted);">安全地将您的资产提取至个人账户</p>
</div>
<?php if($error): ?>
<div style="background: rgba(246,70,93,0.1); color: var(--danger-color); padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid var(--danger-color);">
<i class="fas fa-exclamation-circle"></i> <?php echo $error; ?>
<div class="safety-alert">
<i class="fas fa-exclamation-circle" style="font-size: 24px;"></i>
<div style="font-weight: 700;"><?php echo $error; ?></div>
</div>
<?php endif; ?>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 40px;">
<div id="card-fiat" style="background: var(--card-bg); padding: 35px; border-radius: 24px; border: 2px solid transparent; cursor: pointer;" onclick="switchMethod('fiat')">
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 25px;">
<div style="width: 60px; height: 60px; background: rgba(0, 82, 255, 0.1); border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--primary-color); font-size: 24px;">
<i class="fas fa-university"></i>
</div>
<div>
<h3 style="margin: 0;"><?php echo __('fiat_withdraw', '法币提现'); ?></h3>
<p style="margin: 5px 0 0; color: var(--text-muted); font-size: 14px;"><?php echo __('bank_transfer', '银行转账 / OTC'); ?></p>
</div>
</div>
</div>
<div id="card-usdt" style="background: var(--card-bg); padding: 35px; border-radius: 24px; border: 2px solid var(--success-color); cursor: pointer;" onclick="switchMethod('usdt')">
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 25px;">
<div style="width: 60px; height: 60px; background: rgba(14, 203, 129, 0.1); border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--success-color); font-size: 24px;">
<i class="fas fa-coins"></i>
</div>
<div>
<h3 style="margin: 0;"><?php echo __('crypto_withdraw', '数字货币提现'); ?></h3>
<p style="margin: 5px 0 0; color: var(--text-muted); font-size: 14px;">Blockchain Transfer</p>
</div>
</div>
</div>
</div>
<div style="background: var(--card-bg); padding: 40px; border-radius: 24px; border: 1px solid var(--border-color);">
<form method="POST" id="withdraw-form">
<input type="hidden" name="type" id="withdraw-type" value="usdt">
<div id="fiat-options" style="display: none; margin-bottom: 25px;">
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('select_currency', '选择币种'); ?></label>
<select name="currency" id="fiat-currency" onchange="updateFiatEquivalent()" style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; font-size: 1rem; outline: none;">
<?php foreach ($fiat_rates as $code => $rate): ?>
<option value="<?php echo $code; ?>" data-rate="<?php echo $rate; ?>"><?php echo $code; ?> - <?php echo $fiat_currencies_info[$code] ?? $code; ?></option>
<?php endforeach; ?>
</select>
</div>
<div style="margin-bottom: 25px; background: rgba(0, 82, 255, 0.05); padding: 15px; border-radius: 12px; border: 1px dashed var(--primary-color);">
<div style="display: flex; justify-content: space-between; align-items: center;">
<span style="font-size: 13px; color: var(--text-muted);"><?php echo __('exchange_rate', '当前汇率'); ?></span>
<span style="font-weight: bold; color: var(--primary-color);">1 USDT <span id="current-rate-val">--</span> <span id="current-rate-code">--</span></span>
<div style="display: grid; grid-template-columns: 1fr 380px; gap: 30px;">
<div>
<div class="withdraw-card">
<h3 style="margin-bottom: 25px; font-weight: 800;">1. 选择提现方式</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 40px;">
<div id="method-fiat" class="method-card" onclick="switchWithdrawMethod('fiat')">
<div class="icon-box" style="background: rgba(79,172,254,0.1); color: #4facfe;"><i class="fas fa-university"></i></div>
<div style="font-weight: 800; font-size: 1.1rem;">法币提现</div>
<div style="color: var(--text-muted); font-size: 12px; margin-top: 4px;">银行转账 / 全球 OTC</div>
</div>
<div id="method-usdt" class="method-card active" onclick="switchWithdrawMethod('usdt')">
<div class="icon-box" style="background: rgba(14,203,129,0.1); color: var(--success-color);"><i class="fas fa-coins"></i></div>
<div style="font-weight: 800; font-size: 1.1rem;">USDT 提现</div>
<div style="color: var(--text-muted); font-size: 12px; margin-top: 4px;">USDT 区块链转账</div>
</div>
</div>
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('bank_info', '银行账户信息'); ?></label>
<textarea name="bank_info" placeholder="<?php echo __('bank_info_placeholder', '请输入姓名、银行名称、账号等信息'); ?>" style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; outline: none; min-height: 100px;"></textarea>
<form action="matching.php" method="POST" id="withdraw-form">
<input type="hidden" name="order_type" value="withdrawal">
<input type="hidden" name="type" id="withdraw-type" value="usdt">
<h3 style="margin-bottom: 25px; font-weight: 800;">2. 提现详情</h3>
<!-- Fiat Options -->
<div id="fiat-options" style="display: none;">
<div style="margin-bottom: 25px;">
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 8px;">接收币种</label>
<select name="currency" id="fiat-currency" onchange="updateWithdrawRate()" style="width: 100%; padding: 16px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 16px; outline: none; font-weight: 600;">
<?php foreach ($fiat_rates as $code => $rate): ?>
<option value="<?php echo $code; ?>" data-rate="<?php echo $rate; ?>">
<?php echo ($fiat_currencies_info[$code]['flag'] ?? '') . ' ' . $code . ' - ' . ($fiat_currencies_info[$code]['name'] ?? $code); ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<!-- USDT Options -->
<div id="usdt-options">
<div style="margin-bottom: 25px;">
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 8px;">网络</label>
<select name="network" style="width: 100%; padding: 16px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 16px; outline: none; font-weight: 600;">
<option value="TRC20">USDT - TRC20 (快速 & 低手续费)</option>
<option value="ERC20">USDT - ERC20</option>
<option value="BEP20">USDT - BEP20 (BSC)</option>
</select>
</div>
</div>
<!-- Amount & Password -->
<div style="margin-bottom: 25px;">
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 8px;">提现金额 (USDT)</label>
<div class="input-group-custom">
<input type="number" name="amount" id="amount-input" oninput="updateWithdrawRate()" placeholder="最小 10.00" step="0.01" required>
<span onclick="document.getElementById('amount-input').value = '<?php echo $user['balance']; ?>'; updateWithdrawRate();" style="color: var(--primary-color); font-weight: 800; cursor: pointer; white-space: nowrap;">全部</span>
</div>
<div style="display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px;">
<span style="color: var(--text-muted);">可用余额: <strong style="color: white;"><?php echo number_format($user['balance'], 2); ?> USDT</strong></span>
<span id="fiat-equiv-display" style="color: var(--success-color); font-weight: 800; display: none;"> <span id="fiat-val">0.00</span> <span id="fiat-code">USD</span></span>
</div>
</div>
<div style="margin-bottom: 35px;">
<label style="display: block; color: var(--text-muted); font-size: 13px; margin-bottom: 8px;">交易密码</label>
<div class="input-group-custom">
<input type="password" name="trading_password" placeholder="6 位安全密码" required style="letter-spacing: 5px;">
</div>
</div>
<button type="submit" class="btn-primary" style="width: 100%; padding: 20px; border-radius: 16px; font-size: 1.1rem; font-weight: 800; background: var(--danger-color);">
发起提现请求
</button>
</form>
</div>
</div>
<div class="profile-sidebar">
<div class="withdraw-card" style="padding: 30px;">
<h4 style="font-weight: 800; margin-bottom: 25px;"><i class="fas fa-shield-check" style="color: var(--success-color);"></i> 提现安全说明</h4>
<div style="font-size: 13px; color: var(--text-muted); line-height: 1.8;">
<p style="margin-bottom: 15px;">为了您的账户安全,提现申请将由人工审核,您将跳转至在线客服界面完成后续步骤。</p>
<p style="margin-bottom: 15px;">发起申请后,请按照客服要求提供您的收款账户信息。</p>
<div style="background: rgba(255, 255, 255, 0.03); padding: 15px; border-radius: 12px; border-left: 3px solid var(--primary-color);">
请确保您的收款账户信息 100% 正确。资金一旦发出,将无法追回。
</div>
</div>
</div>
<div id="usdt-options" style="margin-bottom: 25px;">
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;">Select Network</label>
<select name="network" style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; outline: none;">
<option value="TRC20">USDT - TRC20 (Recommended)</option>
<option value="ERC20">USDT - ERC20</option>
<option value="BEP20">USDT - BEP20 (BSC)</option>
</select>
</div>
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('withdraw_address'); ?></label>
<input type="text" name="address" placeholder="Paste your USDT wallet address" style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; outline: none;">
<div class="withdraw-card" style="padding: 30px; margin-top: 20px;">
<h4 style="font-weight: 800; margin-bottom: 20px;"><i class="fas fa-history"></i> 帮助与支持</h4>
<div style="font-size: 13px; color: var(--text-muted);">
提现过程中遇到问题?联系我们的 24/7 在线客服。
<div style="margin-top: 20px;">
<a href="chat.php" class="btn" style="width: 100%; background: #2b3139; color: white; border-radius: 10px; padding: 10px;">联系客服</a>
</div>
</div>
</div>
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('withdraw_amount'); ?> (USDT)</label>
<div style="position: relative;">
<input type="number" name="amount" id="amount-input" oninput="updateFiatEquivalent()" placeholder="<?php echo __('min_withdraw'); ?>: 10" step="0.01" required style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; font-size: 1.2rem; font-weight: bold; outline: none;">
<span onclick="document.getElementById('amount-input').value = '<?php echo $user['balance']; ?>'; updateFiatEquivalent();" style="position: absolute; right: 20px; top: 50%; transform: translateY(-50%); color: var(--primary-color); font-weight: bold; cursor: pointer; font-size: 14px;"><?php echo __('withdraw_all'); ?></span>
</div>
<div id="fiat-equivalent" style="margin-top: 10px; font-size: 14px; color: var(--success-color); font-weight: bold; display: none;">
<span id="fiat-val">0.00</span> <span id="fiat-code">USD</span>
</div>
<div style="margin-top: 10px; font-size: 13px; color: var(--text-muted);">
<?php echo __('available'); ?>: <span style="color: white; font-weight: bold;"><?php echo number_format($user['balance'], 2); ?> USDT</span>
</div>
</div>
<div style="margin-bottom: 35px;">
<label style="display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 14px;"><?php echo __('fund_password'); ?></label>
<input type="password" name="trading_password" placeholder="Enter 6-digit trading password" required style="width: 100%; padding: 15px; background: #161a1e; border: 1px solid var(--border-color); color: white; border-radius: 12px; outline: none;">
</div>
<button type="submit" class="btn-primary" style="width: 100%; padding: 18px; font-size: 1.1rem; border-radius: 12px; background: var(--danger-color);">
<?php echo __('withdraw_submit'); ?>
</button>
</form>
</div>
</div>
</div>
</main>
</div>
<script>
function switchMethod(method) {
if(method === 'fiat') {
document.getElementById('fiat-options').style.display = 'block';
document.getElementById('usdt-options').style.display = 'none';
document.getElementById('card-fiat').style.borderColor = 'var(--primary-color)';
document.getElementById('card-usdt').style.borderColor = 'transparent';
document.getElementById('withdraw-type').value = 'fiat';
document.getElementById('fiat-equivalent').style.display = 'block';
} else {
document.getElementById('fiat-options').style.display = 'none';
document.getElementById('usdt-options').style.display = 'block';
document.getElementById('card-fiat').style.borderColor = 'transparent';
document.getElementById('card-usdt').style.borderColor = 'var(--success-color)';
document.getElementById('withdraw-type').value = 'usdt';
document.getElementById('fiat-equivalent').style.display = 'none';
}
updateFiatEquivalent();
function switchWithdrawMethod(method) {
document.getElementById('fiat-options').style.display = method === 'fiat' ? 'block' : 'none';
document.getElementById('usdt-options').style.display = method === 'usdt' ? 'block' : 'none';
document.getElementById('method-fiat').classList.toggle('active', method === 'fiat');
document.getElementById('method-usdt').classList.toggle('active', method === 'usdt');
document.getElementById('withdraw-type').value = method;
document.getElementById('fiat-equiv-display').style.display = method === 'fiat' ? 'block' : 'none';
updateWithdrawRate();
}
function updateFiatEquivalent() {
function updateWithdrawRate() {
const amount = parseFloat(document.getElementById('amount-input').value) || 0;
const select = document.getElementById('fiat-currency');
const rate = parseFloat(select.options[select.selectedIndex].getAttribute('data-rate'));
@ -214,15 +190,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
document.getElementById('fiat-val').innerText = (amount * rate).toFixed(2);
document.getElementById('fiat-code').innerText = code;
const rateVal = document.getElementById('current-rate-val');
if(rateVal) rateVal.innerText = rate.toFixed(4);
const rateCode = document.getElementById('current-rate-code');
if(rateCode) rateCode.innerText = code;
}
// Initialize rate display
updateFiatEquivalent();
updateWithdrawRate();
</script>
<?php include 'footer.php'; ?>