再次
This commit is contained in:
parent
b50700161d
commit
eefde1d921
@ -238,9 +238,11 @@ $requests = $stmt->fetchAll();
|
||||
<?php if ($r['status'] === '0' || $r['status'] === 'pending'): ?>
|
||||
<span class="badge bg-secondary">待匹配</span>
|
||||
<?php elseif ($r['status'] === 'matched' || $r['status'] === '1'): ?>
|
||||
<span class="badge bg-info">匹配成功</span>
|
||||
<?php elseif ($r['status'] === 'account_sent' || $r['status'] === '2' || $r['status'] === 'finished'): ?>
|
||||
<span class="badge bg-primary">已完成转账</span>
|
||||
<span class="badge bg-info">匹配成功/待发账号</span>
|
||||
<?php elseif ($r['status'] === 'account_sent' || $r['status'] === '2'): ?>
|
||||
<span class="badge bg-warning text-dark">已发账号/待转账</span>
|
||||
<?php elseif ($r['status'] === 'finished'): ?>
|
||||
<span class="badge bg-primary">用户已转账/待审核</span>
|
||||
<?php elseif ($r['status'] === '3'): ?>
|
||||
<span class="badge bg-success">已通过</span>
|
||||
<?php elseif ($r['status'] === '4'): ?>
|
||||
@ -255,7 +257,7 @@ $requests = $stmt->fetchAll();
|
||||
<?php else: ?>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<?php if ($r['status'] == '0' || $r['status'] == 'pending'): ?>
|
||||
<button type="button" class="btn btn-primary" onclick="showMatchModal(<?= $r['id'] ?>, '<?= htmlspecialchars($r['payment_method'] ?? '') ?>')">
|
||||
<button type="button" class="btn btn-primary" onclick="submitMatchOnly(<?= $r['id'] ?>)">
|
||||
匹配成功
|
||||
</button>
|
||||
<?php elseif ($r['status'] == '1' || $r['status'] == 'matched'): ?>
|
||||
@ -291,37 +293,6 @@ $requests = $stmt->fetchAll();
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Match Modal -->
|
||||
<div class="modal fade" id="matchModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">匹配收款账户</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="match_id">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">银行/机构</label>
|
||||
<input type="text" id="match_bank" class="form-control" placeholder="例如:中国工商银行">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">收款人姓名</label>
|
||||
<input type="text" id="match_name" class="form-control" placeholder="例如:张三">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">收款账号</label>
|
||||
<input type="text" id="match_account" class="form-control" placeholder="例如:6222020100001234567">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="submitMatch()">确认匹配</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Send Modal -->
|
||||
<div class="modal fade" id="sendModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
@ -420,10 +391,13 @@ $requests = $stmt->fetchAll();
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showMatchModal(id, method) {
|
||||
document.getElementById('match_id').value = id;
|
||||
// Default values if needed
|
||||
new bootstrap.Modal(document.getElementById('matchModal')).show();
|
||||
async function submitMatchOnly(id) {
|
||||
if(!confirm('确定标记为匹配成功吗?')) return;
|
||||
const formData = new FormData();
|
||||
formData.append('id', id);
|
||||
const resp = await fetch('../api/admin_recharge.php?action=match_success', { method: 'POST', body: formData });
|
||||
const data = await resp.json();
|
||||
if(data.success) location.reload(); else alert(data.error || '操作失败');
|
||||
}
|
||||
|
||||
function showSendModal(id, bank, name, account) {
|
||||
@ -434,11 +408,12 @@ function showSendModal(id, bank, name, account) {
|
||||
new bootstrap.Modal(document.getElementById('sendModal')).show();
|
||||
}
|
||||
|
||||
async function submitMatch() {
|
||||
const id = document.getElementById('match_id').value;
|
||||
const bank = document.getElementById('match_bank').value;
|
||||
const name = document.getElementById('match_name').value;
|
||||
const account = document.getElementById('match_account').value;
|
||||
async function submitSend() {
|
||||
const id = document.getElementById('send_id').value;
|
||||
const bank = document.getElementById('send_bank').value;
|
||||
const name = document.getElementById('send_name').value;
|
||||
const account = document.getElementById('send_account').value;
|
||||
const note = document.getElementById('send_note').value;
|
||||
|
||||
if(!bank || !name || !account) return alert('请完整填写信息');
|
||||
|
||||
@ -447,12 +422,22 @@ async function submitMatch() {
|
||||
formData.append('bank', bank);
|
||||
formData.append('name', name);
|
||||
formData.append('account', account);
|
||||
formData.append('note', note);
|
||||
|
||||
const resp = await fetch('../api/admin_recharge.php?action=match_success', { method: 'POST', body: formData });
|
||||
const resp = await fetch('../api/admin_recharge.php?action=send_account', { method: 'POST', body: formData });
|
||||
const data = await resp.json();
|
||||
if(data.success) location.reload(); else alert(data.error || '操作失败');
|
||||
}
|
||||
|
||||
|
||||
function showSendModal(id, bank, name, account) {
|
||||
document.getElementById('send_id').value = id;
|
||||
document.getElementById('send_bank').value = bank;
|
||||
document.getElementById('send_name').value = name;
|
||||
document.getElementById('send_account').value = account;
|
||||
new bootstrap.Modal(document.getElementById('sendModal')).show();
|
||||
}
|
||||
|
||||
async function submitSend() {
|
||||
const id = document.getElementById('send_id').value;
|
||||
const bank = document.getElementById('send_bank').value;
|
||||
@ -460,6 +445,8 @@ async function submitSend() {
|
||||
const account = document.getElementById('send_account').value;
|
||||
const note = document.getElementById('send_note').value;
|
||||
|
||||
if(!bank || !name || !account) return alert('请完整填写信息');
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('id', id);
|
||||
formData.append('bank', bank);
|
||||
|
||||
@ -43,12 +43,8 @@ try {
|
||||
}
|
||||
|
||||
if ($action === 'match_success') {
|
||||
$bank = $_POST['bank'] ?? '';
|
||||
$name = $_POST['name'] ?? '';
|
||||
$account = $_POST['account'] ?? '';
|
||||
|
||||
$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 = $db->prepare("UPDATE finance_requests SET status = '1', updated_at = NOW() WHERE id = ?");
|
||||
$stmt->execute([$order_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
}
|
||||
@ -58,7 +54,7 @@ try {
|
||||
$account = $_POST['account'] ?? '';
|
||||
$note = $_POST['note'] ?? '';
|
||||
|
||||
$stmt = $db->prepare("UPDATE finance_requests SET status = '2', account_bank = ?, account_name = ?, account_number = ?, payment_details = ? WHERE id = ?");
|
||||
$stmt = $db->prepare("UPDATE finance_requests SET status = '2', account_bank = ?, account_name = ?, account_number = ?, payment_details = ?, updated_at = NOW() WHERE id = ?");
|
||||
$stmt->execute([$bank, $name, $account, $note, $order_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
14
recharge.php
14
recharge.php
@ -556,11 +556,19 @@ function startStatusPolling(order_id) {
|
||||
const r = await fetch(apiPath + `recharge_status.php?id=${order_id}&v=${Date.now()}`);
|
||||
const data = await r.json();
|
||||
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);
|
||||
if (currentStatus === 'completed' || currentStatus === '3' || currentStatus === 'rejected' || currentStatus === '4') clearInterval(window.statusPollingInterval);
|
||||
|
||||
// Only re-render if status has changed to avoid UI flickering
|
||||
if (window.lastRechargeStatus !== currentStatus) {
|
||||
window.lastRechargeStatus = currentStatus;
|
||||
renderRechargeUI(data);
|
||||
}
|
||||
|
||||
if (currentStatus === 'completed' || currentStatus === '3' || currentStatus === 'rejected' || currentStatus === '4') {
|
||||
clearInterval(window.statusPollingInterval);
|
||||
}
|
||||
}
|
||||
} catch (e) { console.error('Status polling error:', e); }
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user