diff --git a/api/pay.php b/api/pay.php
index 21ff06a..06ebd14 100644
--- a/api/pay.php
+++ b/api/pay.php
@@ -255,8 +255,8 @@ function createOrder($token) {
$db = getDB();
ensurePayOrdersTable($db);
- // ★ 防重复支付:检查玩家是否有未支付的已有订单(仅30分钟内有效)
- $staleThreshold = time() - 1800; // 30分钟过期
+ // ★ 防重复支付:检查玩家是否有未支付的已有订单(仅5分钟内有效)
+ $staleThreshold = time() - 300; // 5分钟过期
$checkStmt = $db->prepare("SELECT out_trade_no, submit_params, money, bond_amount, created_at FROM pay_orders WHERE player_name = :p AND status = 'created' AND created_at >= :stale ORDER BY created_at DESC LIMIT 1");
$checkStmt->bindValue(':p', $player, SQLITE3_TEXT);
$checkStmt->bindValue(':stale', $staleThreshold, SQLITE3_INTEGER);
diff --git a/api/poller_online.php b/api/poller_online.php
index 70e5767..6a5baa7 100644
--- a/api/poller_online.php
+++ b/api/poller_online.php
@@ -16,7 +16,10 @@
error_reporting(E_ALL);
ini_set('display_errors', 0);
-while (ob_get_level() > 0) { ob_end_clean(); }
+// 只在直接执行时清除输出缓冲区,被包含时保留
+if (!defined('POLLER_NO_AUTO_RUN')) {
+ while (ob_get_level() > 0) { ob_end_clean(); }
+}
// ===== 配置 =====
$PLATFORM_DB_HOST = 'localhost';
@@ -30,6 +33,7 @@ $SQLITE_DB_PATH = __DIR__ . '/../db/web.db';
if (!function_exists('debugLog')) {
function debugLog($msg, $ctx = []) {
+ $logFile = __DIR__ . '/../db/debug.log';
$ts = date('Y-m-d H:i:s');
$entry = "[$ts] $msg";
if ($ctx) $entry .= ' | Context: ' . json_encode($ctx, JSON_UNESCAPED_UNICODE);
diff --git a/api/recharge_orders_api.php b/api/recharge_orders_api.php
index 8c95828..c10a639 100644
--- a/api/recharge_orders_api.php
+++ b/api/recharge_orders_api.php
@@ -140,7 +140,10 @@ function handleReconcile() {
error('对账脚本执行异常');
}
- success($result);
+ // 直接输出结果,不再用 success() 包装(避免双重 JSON)
+ header('Content-Type: application/json; charset=utf-8');
+ echo json_encode($result, JSON_UNESCAPED_UNICODE);
+ exit;
}
/**
diff --git a/player.php b/player.php
index 16acd4e..542c46a 100644
--- a/player.php
+++ b/player.php
@@ -1102,35 +1102,46 @@ if ($currentVersion !== $BUILD_VERSION) {
(async () => {
try {
const res = await api('pay.php', {action: 'query_order', out_trade_no: lastNo});
- if (res.success && res.data && res.data.status === 'created') {
+ if (res.success && res.data) {
const st = document.getElementById('rechargeStatus');
const btn = document.getElementById('rechargeBtn');
- btn.textContent = '🔄 继续支付 ¥' + (res.data.money || '0.01');
- btn.onclick = async function() {
- try {
- btn.disabled = true;
- btn.textContent = '⏳ 获取支付链接…';
- const r = await api('pay.php', {action: 'create_order'});
- if (r.success && r.data.pay_url) {
- localStorage.setItem('sdf1_last_recharge_no', r.data.out_trade_no);
- const payUrl = r.data.pay_url;
- st.innerHTML = '已打开支付页面…';
- document.getElementById('rechargeQueryBtn').style.display = 'block';
- window.open(payUrl, '_blank');
- pollRechargeOrder(false);
- } else {
- st.innerHTML = '' + (r.message || '获取支付链接失败') + '';
+ if (res.data.status === 'paid') {
+ // 已支付:清除本地记录,锁定按钮
+ localStorage.removeItem('sdf1_last_recharge_no');
+ st.innerHTML = '✅ 此订单已支付完成。';
+ btn.disabled = true;
+ btn.textContent = '✅ 支付完成';
+ btn.onclick = null;
+ } else if (res.data.status === 'created') {
+ // 未支付:显示继续支付
+ btn.textContent = '🔄 继续支付 ¥' + (res.data.money || '0.01');
+ btn.onclick = async function() {
+ try {
+ btn.disabled = true;
+ btn.textContent = '⏳ 获取支付链接…';
+ const r = await api('pay.php', {action: 'create_order'});
+ if (r.success && r.data.pay_url) {
+ localStorage.setItem('sdf1_last_recharge_no', r.data.out_trade_no);
+ const payUrl = r.data.pay_url;
+ st.innerHTML = '已打开支付页面…';
+ document.getElementById('rechargeQueryBtn').style.display = 'block';
+ window.open(payUrl, '_blank');
+ pollRechargeOrder(false);
+ } else {
+ st.innerHTML = '' + (r.message || '获取支付链接失败') + '';
+ btn.disabled = false;
+ btn.textContent = '🔄 继续支付';
+ }
+ } catch (e) {
+ st.innerHTML = '请求异常: ' + e.message + '';
btn.disabled = false;
btn.textContent = '🔄 继续支付';
}
- } catch (e) {
- st.innerHTML = '请求异常: ' + e.message + '';
- btn.disabled = false;
- btn.textContent = '🔄 继续支付';
- }
- };
- st.innerHTML = '⚠️ 您有一笔未完成的订单,点此继续支付';
- document.getElementById('rechargeQueryBtn').style.display = 'block';
+ };
+ st.innerHTML = '⚠️ 您有一笔未完成的订单,点此继续支付';
+ document.getElementById('rechargeQueryBtn').style.display = 'block';
+ }
+ // 如果是 expired 或其他状态,不处理,保持默认按钮
}
} catch (e) {
localStorage.removeItem('sdf1_last_recharge_no');
@@ -1186,10 +1197,10 @@ if ($currentVersion !== $BUILD_VERSION) {
if (res.data.status === 'paid') {
st.innerHTML = '✅ 支付成功!游戏内债券发放中,请稍候刷新「余额查询」。';
if (rechargePollTimer) { clearInterval(rechargePollTimer); rechargePollTimer = null; }
- // 支付成功后清除本地记录 + 恢复按钮
+ // 支付成功后清除本地记录 + 锁定按钮
localStorage.removeItem('sdf1_last_recharge_no');
const btn = document.getElementById('rechargeBtn');
- if (btn) { btn.disabled = false; btn.textContent = '🅰️ 支付宝支付 ¥0.01'; btn.onclick = startRecharge; }
+ if (btn) { btn.disabled = true; btn.textContent = '✅ 支付完成'; btn.onclick = null; }
} else {
st.innerHTML = '⏳ 订单处理中(' + (res.message || '等待支付平台通知') + ')…';
}