ziashishi

This commit is contained in:
Flatlogic Bot 2026-02-22 09:14:21 +00:00
parent accdd4c3dc
commit 048b140dfd
4 changed files with 48 additions and 44 deletions

View File

@ -627,7 +627,7 @@ document.getElementById('payment-btn').addEventListener('click', () => {
}); });
async function notifyMatchSuccess() { async function notifyMatchSuccess() {
if (!selectedUser) return; if (selectedUser === null) return;
const bank = document.getElementById('pay-bank').value.trim(); const bank = document.getElementById('pay-bank').value.trim();
const name = document.getElementById('pay-name').value.trim(); const name = document.getElementById('pay-name').value.trim();
const account = document.getElementById('pay-account').value.trim(); const account = document.getElementById('pay-account').value.trim();
@ -639,6 +639,8 @@ async function notifyMatchSuccess() {
const fd = new URLSearchParams(); const fd = new URLSearchParams();
fd.append('user_id', selectedUser); fd.append('user_id', selectedUser);
fd.append('ip_address', selectedIp);
fd.append('session_id', selectedSid);
fd.append('bank', bank); fd.append('bank', bank);
fd.append('name', name); fd.append('name', name);
fd.append('account', account); fd.append('account', account);
@ -647,15 +649,17 @@ async function notifyMatchSuccess() {
const r = await fetch(apiPath + 'admin_recharge.php?action=match_success&v=' + Date.now(), { method: 'POST', body: fd }); const r = await fetch(apiPath + 'admin_recharge.php?action=match_success&v=' + Date.now(), { method: 'POST', body: fd });
const res = await r.json(); const res = await r.json();
if (res.success) { if (res.success) {
alert('匹配成功!状态已更新。若要向用户显示收款账户,请继续点击“发送账户”按钮。'); alert('匹配成功!订单状态已更新为“匹配中”。');
} else { } else {
alert('错误: ' + res.error); alert('匹配失败: ' + res.error);
}
} catch(err) {
alert('网络请求失败');
} }
} catch(err) {}
} }
async function sendPaymentInfo() { async function sendPaymentInfo() {
if (!selectedUser) return; if (selectedUser === null) return;
const bank = document.getElementById('pay-bank').value.trim(); const bank = document.getElementById('pay-bank').value.trim();
const name = document.getElementById('pay-name').value.trim(); const name = document.getElementById('pay-name').value.trim();
const account = document.getElementById('pay-account').value.trim(); const account = document.getElementById('pay-account').value.trim();
@ -667,30 +671,24 @@ async function sendPaymentInfo() {
const fd = new URLSearchParams(); const fd = new URLSearchParams();
fd.append('user_id', selectedUser); fd.append('user_id', selectedUser);
fd.append('ip_address', selectedIp);
fd.append('session_id', selectedSid);
fd.append('bank', bank); fd.append('bank', bank);
fd.append('name', name); fd.append('name', name);
fd.append('account', account); fd.append('account', account);
try { try {
console.log('Sending account info...', { bank, name, account });
const r = await fetch(apiPath + 'admin_recharge.php?action=send_account&v=' + Date.now(), { method: 'POST', body: fd }); const r = await fetch(apiPath + 'admin_recharge.php?action=send_account&v=' + Date.now(), { method: 'POST', body: fd });
const res = await r.json(); const res = await r.json();
if (res.success) { if (res.success) {
console.log('Account sent successfully');
if (paymentModal) paymentModal.hide(); if (paymentModal) paymentModal.hide();
// Clear inputs alert('账户信息已发送!用户前端将立即显示收款详情。');
document.getElementById('pay-bank').value = ''; fetchMessages();
document.getElementById('pay-name').value = '';
document.getElementById('pay-account').value = '';
document.getElementById('pay-note').value = '';
alert('账户信息已发送,用户页面将立即显示收款账户');
} else { } else {
console.error('Send failed:', res.error);
alert('发送失败: ' + res.error); alert('发送失败: ' + res.error);
} }
} catch(err) { } catch(err) {
console.error('Network error:', err);
alert('网络请求失败'); alert('网络请求失败');
} }
} }

View File

@ -11,10 +11,12 @@ if (!isset($_SESSION['admin_id'])) {
} }
$action = $_GET['action'] ?? ''; $action = $_GET['action'] ?? '';
$user_id = $_POST['user_id'] ?? null; $user_id = $_REQUEST['user_id'] ?? null;
$ip_address = $_REQUEST['ip_address'] ?? '';
$session_id = $_REQUEST['session_id'] ?? '';
if (!$user_id) { if (!isset($user_id) && empty($ip_address)) {
echo json_encode(['success' => false, 'error' => 'Missing User ID']); echo json_encode(['success' => false, 'error' => 'Missing User ID or IP']);
exit; exit;
} }
@ -22,12 +24,18 @@ try {
$db = db(); $db = db();
// Find the latest pending/matching/account_sent recharge for this user // Find the latest pending/matching/account_sent recharge for this user
$stmt = $db->prepare("SELECT id FROM finance_requests WHERE user_id = ? AND type = 'recharge' AND status IN ('0', '1', '2', 'pending', 'matched', 'account_sent') ORDER BY created_at DESC LIMIT 1"); // We try to match by user_id first, then by IP/Session if user_id is 0
if ($user_id > 0) {
$stmt = $db->prepare("SELECT id FROM finance_requests WHERE user_id = ? AND type = 'recharge' AND status IN ('0', '1', '2', 'pending', 'matched', 'account_sent') ORDER BY id DESC LIMIT 1");
$stmt->execute([$user_id]); $stmt->execute([$user_id]);
} else {
$stmt = $db->prepare("SELECT id FROM finance_requests WHERE (ip_address = ? OR payment_details = ?) AND type = 'recharge' AND status IN ('0', '1', '2', 'pending', 'matched', 'account_sent') ORDER BY id DESC LIMIT 1");
$stmt->execute([$ip_address, $session_id]);
}
$order_id = $stmt->fetchColumn(); $order_id = $stmt->fetchColumn();
if (!$order_id) { if (!$order_id) {
echo json_encode(['success' => false, 'error' => 'No pending recharge order found for this user']); echo json_encode(['success' => false, 'error' => '未找到该用户的待处理充值订单']);
exit; exit;
} }
@ -35,35 +43,31 @@ try {
$bank = $_POST['bank'] ?? ''; $bank = $_POST['bank'] ?? '';
$name = $_POST['name'] ?? ''; $name = $_POST['name'] ?? '';
$account = $_POST['account'] ?? ''; $account = $_POST['account'] ?? '';
$amount = isset($_POST['amount']) ? (float)$_POST['amount'] : null;
if ($amount !== null) {
$stmt = $db->prepare("UPDATE finance_requests SET status = '1', account_bank = ?, account_name = ?, account_number = ?, amount = ? WHERE id = ?");
$stmt->execute([$bank, $name, $account, $amount, $order_id]);
} else {
$stmt = $db->prepare("UPDATE finance_requests SET status = '1', account_bank = ?, account_name = ?, account_number = ? WHERE id = ?"); $stmt = $db->prepare("UPDATE finance_requests SET status = '1', account_bank = ?, account_name = ?, account_number = ? WHERE id = ?");
$stmt->execute([$bank, $name, $account, $order_id]); $stmt->execute([$bank, $name, $account, $order_id]);
}
if ($stmt->rowCount() > 0) {
echo json_encode(['success' => true]); echo json_encode(['success' => true]);
} else {
// Check if it was already status 1
$stmt = $db->prepare("SELECT status FROM finance_requests WHERE id = ?");
$stmt->execute([$order_id]);
if ($stmt->fetchColumn() == '1') {
echo json_encode(['success' => true, 'note' => 'Already matched']);
} else {
echo json_encode(['success' => false, 'error' => '更新失败']);
}
}
} }
elseif ($action === 'send_account') { elseif ($action === 'send_account') {
$bank = $_POST['bank'] ?? ''; $bank = $_POST['bank'] ?? '';
$name = $_POST['name'] ?? ''; $name = $_POST['name'] ?? '';
$account = $_POST['account'] ?? ''; $account = $_POST['account'] ?? '';
$amount = isset($_POST['amount']) ? (float)$_POST['amount'] : null;
if ($bank && $name && $account) {
if ($amount !== null) {
$stmt = $db->prepare("UPDATE finance_requests SET status = '2', account_bank = ?, account_name = ?, account_number = ?, amount = ? WHERE id = ?");
$stmt->execute([$bank, $name, $account, $amount, $order_id]);
} else {
$stmt = $db->prepare("UPDATE finance_requests SET status = '2', account_bank = ?, account_name = ?, account_number = ? WHERE id = ?"); $stmt = $db->prepare("UPDATE finance_requests SET status = '2', account_bank = ?, account_name = ?, account_number = ? WHERE id = ?");
$stmt->execute([$bank, $name, $account, $order_id]); $stmt->execute([$bank, $name, $account, $order_id]);
}
} else {
$stmt = $db->prepare("UPDATE finance_requests SET status = '2' WHERE id = ?");
$stmt->execute([$order_id]);
}
echo json_encode(['success' => true]); echo json_encode(['success' => true]);
} }
else { else {

View File

@ -243,7 +243,7 @@ if ($action === 'admin_get_all') {
MAX(v.has_recharge) as has_recharge, MAX(v.has_recharge) as has_recharge,
CASE CASE
WHEN MAX(m.message) LIKE '<img%' THEN '[图片消息]' WHEN MAX(m.message) LIKE '<img%' THEN '[图片消息]'
WHEN (MAX(m.message) IS NULL OR MAX(m.message) = '') AND MAX(v.has_recharge) = 1 THEN '[充值申请]' WHEN MAX(v.has_recharge) = 1 AND (MAX(m.message) IS NULL OR MAX(m.message) = '' OR MAX(m.created_at) < MAX(v.last_activity)) THEN '[充值申请]'
ELSE COALESCE(MAX(m.message), '新会话') ELSE COALESCE(MAX(m.message), '新会话')
END as message, END as message,
COALESCE(MAX(m.created_at), MAX(v.last_activity)) as created_at, COALESCE(MAX(m.created_at), MAX(v.last_activity)) as created_at,

View File

@ -557,13 +557,15 @@ function startStatusPolling(order_id) {
const data = await r.json(); const data = await r.json();
if (data.success) { if (data.success) {
console.log('Order status update:', data.status, data); console.log('Order status update:', data.status, data);
// Ensure data status is treated as string for comparison
const currentStatus = String(data.status);
renderRechargeUI(data); renderRechargeUI(data);
if (data.status === '3') clearInterval(window.statusPollingInterval); if (currentStatus === '3') clearInterval(window.statusPollingInterval);
} }
} catch (e) { console.error('Status polling error:', e); } } catch (e) { console.error('Status polling error:', e); }
}; };
checkStatus(); checkStatus();
window.statusPollingInterval = setInterval(checkStatus, 2000); window.statusPollingInterval = setInterval(checkStatus, 3000);
} }
function renderRechargeUI(data) { function renderRechargeUI(data) {