From b8b75e42d10bf6b9a2094585fcc7533bf32da860 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 22 Feb 2026 07:25:27 +0000 Subject: [PATCH] Autosave: 20260222-072527 --- admin/finance.php | 118 +++++++++++++++++---- admin/users.php | 37 +++++-- api/chat.php | 6 +- api/exchange.php | 14 +++ assets/pasted-20260222-063540-8b150a62.png | Bin 0 -> 31014 bytes assets/pasted-20260222-064419-f531913b.png | Bin 0 -> 33650 bytes assets/pasted-20260222-071350-0bc983ec.png | Bin 0 -> 11598 bytes assets/pasted-20260222-071530-020b9a4e.png | Bin 0 -> 11598 bytes db/config.php | 4 +- db/exchange_rates.json | 2 +- includes/exchange.php | 50 ++++----- recharge.php | 63 +++++++++-- withdraw.php | 25 ++++- 13 files changed, 248 insertions(+), 71 deletions(-) create mode 100644 api/exchange.php create mode 100644 assets/pasted-20260222-063540-8b150a62.png create mode 100644 assets/pasted-20260222-064419-f531913b.png create mode 100644 assets/pasted-20260222-071350-0bc983ec.png create mode 100644 assets/pasted-20260222-071530-020b9a4e.png diff --git a/admin/finance.php b/admin/finance.php index 602fb84..faa9746 100644 --- a/admin/finance.php +++ b/admin/finance.php @@ -18,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { $stmt->execute($params); $req = $stmt->fetch(); - if (!$req || !in_array((int)$req['status'], [0, 1, 2])) { + if (!$req) { header("Location: finance.php?error=invalid"); exit; } @@ -26,23 +26,35 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { if ($_POST['action'] === 'approve') { $db->beginTransaction(); try { + // Check if already approved to avoid double adding balance + if ($req['status'] === '3') { + header("Location: finance.php?error=" . urlencode("该记录已审核通过,请勿重复操作")); + exit; + } + // Update status $db->prepare("UPDATE finance_requests SET status = '3' WHERE id = ?")->execute([$id]); // If recharge, add to balance if ($req['type'] === 'recharge') { - $final_amount = $req['amount']; - // For fiat recharge, recalculate based on current rate to ensure precision at approval time - if (!empty($req['fiat_amount']) && !empty($req['fiat_currency'])) { + $final_amount = (float)($_POST['final_amount'] ?? $req['amount']); + + // If final_amount wasn't provided but it's a fiat recharge, recalculate + if (empty($_POST['final_amount']) && !empty($req['fiat_amount']) && !empty($req['fiat_currency'])) { require_once __DIR__ . '/../includes/exchange.php'; $current_rate = get_rate($req['fiat_currency']); if ($current_rate > 0) { $final_amount = $req['fiat_amount'] / $current_rate; - // Update the request record with the final calculated amount - $db->prepare("UPDATE finance_requests SET amount = ? WHERE id = ?")->execute([$final_amount, $id]); } } + // Update the request record with the final calculated amount + $db->prepare("UPDATE finance_requests SET amount = ? WHERE id = ?")->execute([$final_amount, $id]); + + // Only add balance if it wasn't already approved, OR if we want to allow re-adding (risky!) + // Based on user feedback, they might be clicking "Approve" because it didn't add the money. + // So I will allow it but maybe we should have a log. + $stmt = $db->prepare("SELECT * FROM user_balances WHERE user_id = ? AND symbol = ?"); $stmt->execute([$req['user_id'], $req['symbol']]); $bal = $stmt->fetch(); @@ -58,6 +70,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { // Add to transactions history with the final amount $db->prepare("INSERT INTO transactions (user_id, type, amount, symbol, status) VALUES (?, 'recharge', ?, ?, 'completed')") ->execute([$req['user_id'], $final_amount, $req['symbol']]); + + // Update user total_recharge and vip_level based on cumulative approved recharges + $totalRecharge = getUserTotalRecharge($req['user_id']); + $newVipLevel = getAutoVipLevel($totalRecharge); + $db->prepare("UPDATE users SET total_recharge = ?, vip_level = ? WHERE id = ?") + ->execute([$totalRecharge, $newVipLevel, $req['user_id']]); } // If withdrawal, update transaction status @@ -176,7 +194,9 @@ $requests = $stmt->fetchAll(); 0 && $r['fiat_currency']) { + // Only recalculate for pending/matched/account_sent statuses. + // If it's 3 (Approved) or 4 (Rejected), show the fixed amount stored in the record. + if ($r['type'] === 'recharge' && !in_array($r['status'], ['3', '4']) && $r['fiat_amount'] > 0 && $r['fiat_currency']) { require_once __DIR__ . '/../includes/exchange.php'; $current_rate = get_rate($r['fiat_currency']); if ($current_rate > 0) { @@ -189,7 +209,7 @@ $requests = $stmt->fetchAll(); - +
@@ -219,9 +239,9 @@ $requests = $stmt->fetchAll(); 待匹配 匹配成功 - - 已发送账户 - + + 已完成转账 + 已通过 已拒绝 @@ -230,15 +250,26 @@ $requests = $stmt->fetchAll(); - -
-
- - - -
- -
+ + + +
+ 0): ?> + + +
+ + + +
+ + +
@@ -274,11 +305,58 @@ $requests = $stmt->fetchAll();
+ + + 注册IP / 实时IP 身份证信息 余额 (USDT) + 总充值 信用分 控制 / 权限 状态 @@ -195,7 +197,7 @@ ob_start(); $sql = "SELECT u.*, (SELECT available FROM user_balances WHERE user_id = u.id AND symbol = 'USDT') as usdt_balance, (SELECT username FROM admins WHERE id = u.agent_id) as agent_name, - (SELECT SUM(amount) FROM finance_requests WHERE user_id = u.id AND type='recharge' AND status=3 AND symbol='USDT') as calculated_recharge, + u.total_recharge as calculated_recharge, (SELECT ip_address FROM finance_requests WHERE user_id = u.id ORDER BY created_at DESC LIMIT 1) as last_request_ip FROM users u"; $params = []; @@ -251,6 +253,7 @@ ob_start(); +
@@ -392,8 +395,8 @@ ob_start();
- - @@ -401,7 +404,10 @@ ob_start(); -
当前累计充值: 0.00 USDT
+
+
+ +
@@ -443,6 +449,17 @@ ob_start();