diff --git a/admin/orders.php b/admin/orders.php
index 9f3ac75..137e202 100644
--- a/admin/orders.php
+++ b/admin/orders.php
@@ -25,14 +25,33 @@ if (isset($_POST['action'])) {
$order = $orderStmt->fetch();
if ($order) {
$credit_amount = $order['usdt_amount'] > 0 ? $order['usdt_amount'] : $order['amount'];
- $pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$credit_amount, $order['user_id']]);
- $pdo->prepare("UPDATE $table SET status = 'completed' WHERE id = ?")->execute([$id]);
- $msg = "您的充值 " . $credit_amount . " USDT 已确认到账。";
- $pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], $msg]);
+ $pdo->beginTransaction();
+ try {
+ $pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$credit_amount, $order['user_id']]);
+ $pdo->prepare("UPDATE $table SET status = 'completed' WHERE id = ?")->execute([$id]);
+
+ // 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 已确认到账。";
+ $pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'admin', ?)")->execute([$order['user_id'], $msg]);
+
+ $pdo->commit();
+ } catch (Exception $e) {
+ $pdo->rollBack();
+ }
}
} elseif ($_POST['action'] == 'reject') {
$pdo->prepare("UPDATE $table SET status = 'rejected' WHERE id = ?")->execute([$id]);
+
+ $orderStmt = $pdo->prepare("SELECT user_id FROM $table WHERE id = ?");
+ $orderStmt->execute([$id]);
+ $order = $orderStmt->fetch();
+ 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%"]);
+ }
}
}
@@ -54,30 +73,30 @@ $pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE stat
充值管理 - NovaEx 管理后台
-
-
返回
-
充值申请管理
+
充值申请管理
@@ -124,7 +142,7 @@ $pending_orders_count = $pdo->query("SELECT COUNT(*) FROM fiat_orders WHERE stat
diff --git a/admin/users.php b/admin/users.php
index 1b0d2a5..70a15eb 100644
--- a/admin/users.php
+++ b/admin/users.php
@@ -19,27 +19,45 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action'])) {
} elseif ($action == 'update_user') {
$id = $_POST['id'];
$username = $_POST['username'];
- $balance = $_POST['balance'];
+ $new_balance = (float)$_POST['balance'];
$credit_score = $_POST['credit_score'];
$win_loss = $_POST['win_loss_control'];
$status = $_POST['status'];
+ // Fetch old balance to log if changed
+ $old_user = $pdo->prepare("SELECT balance FROM users WHERE id = ?");
+ $old_user->execute([$id]);
+ $old_balance = (float)$old_user->fetchColumn();
+
$sql = "UPDATE users SET username = ?, balance = ?, credit_score = ?, win_loss_control = ?, status = ? WHERE id = ?";
- $params = [$username, $balance, $credit_score, $win_loss, $status, $id];
+ $params = [$username, $new_balance, $credit_score, $win_loss, $status, $id];
if (!empty($_POST['password'])) {
$sql = "UPDATE users SET username = ?, balance = ?, credit_score = ?, win_loss_control = ?, status = ?, password = ? WHERE id = ?";
- $params = [$username, $balance, $credit_score, $win_loss, $status, password_hash($_POST['password'], PASSWORD_DEFAULT), $id];
+ $params = [$username, $new_balance, $credit_score, $win_loss, $status, password_hash($_POST['password'], PASSWORD_DEFAULT), $id];
}
$pdo->prepare($sql)->execute($params);
+
+ if ($new_balance != $old_balance) {
+ $diff = $new_balance - $old_balance;
+ $pdo->prepare("INSERT INTO transactions (user_id, type, amount, currency, status, description) VALUES (?, 'admin_adjust', ?, 'USDT', 'completed', ?)")->execute([
+ $id, $diff, "管理员手动修改余额 (Balance adjusted by admin)"
+ ]);
+ }
} elseif ($action == 'adjust_balance') {
$id = $_POST['id'];
$type = $_POST['adjustment_type'];
$amount = (float)$_POST['amount'];
if ($type == 'up') {
$pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?")->execute([$amount, $id]);
+ $pdo->prepare("INSERT INTO transactions (user_id, type, amount, currency, status, description) VALUES (?, 'admin_adjust', ?, 'USDT', 'completed', ?)")->execute([
+ $id, $amount, "管理员增加余额 (Credit by admin)"
+ ]);
} else {
$pdo->prepare("UPDATE users SET balance = balance - ? WHERE id = ?")->execute([$amount, $id]);
+ $pdo->prepare("INSERT INTO transactions (user_id, type, amount, currency, status, description) VALUES (?, 'admin_adjust', ?, 'USDT', 'completed', ?)")->execute([
+ $id, -$amount, "管理员扣除余额 (Debit by admin)"
+ ]);
}
} elseif ($action == 'toggle_status') {
$id = $_POST['id'];
@@ -72,22 +90,18 @@ $pending_kyc = $pdo->query("SELECT COUNT(*) FROM users WHERE kyc_status = 1")->f
.menu-item { padding: 12px 15px; color: #474d57; text-decoration: none; display: flex; align-items: center; gap: 12px; border-radius: 8px; margin-bottom: 8px; transition: 0.2s; }
.menu-item:hover, .menu-item.active { background: #f5f5f5; color: var(--primary); font-weight: bold; }
.badge { background: #f6465d; color: white; border-radius: 10px; padding: 2px 8px; font-size: 0.7rem; margin-left: auto; }
-
.card { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.table { width: 100%; border-collapse: collapse; margin-top: 1.5rem; }
.table th, .table td { padding: 15px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table th { background: #f9fafb; color: #707a8a; font-weight: 600; text-transform: uppercase; font-size: 0.75rem; }
-
.btn { padding: 8px 16px; border-radius: 6px; font-size: 0.85rem; border: none; cursor: pointer; font-weight: 500; transition: 0.2s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn-primary { background: var(--primary); color: black; }
.btn-danger { background: #f6465d; color: white; }
.btn-info { background: #2f80ed; color: white; }
.btn-success { background: #00c087; color: white; }
-
.status-badge { padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; }
.status-active { background: #e6fcf5; color: #00c087; }
.status-disabled { background: #fff5f5; color: #f6465d; }
-
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-content { background: white; width: 550px; padding: 30px; border-radius: 16px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.form-group { margin-bottom: 20px; }
@@ -286,7 +300,6 @@ $pending_kyc = $pdo->query("SELECT COUNT(*) FROM users WHERE kyc_status = 1")->f