From cb949f5b16e0b7b143da36baac7e79490563d06c Mon Sep 17 00:00:00 2001 From: ypsdf1 Date: Wed, 15 Jul 2026 19:48:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=94=AF=E4=BB=98=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=A0=B8=E5=BF=83=E9=97=AE=E9=A2=98v2\n\n-=20poller?= =?UTF-8?q?=5Fonline.php:=20=E6=B7=BB=E5=8A=A0=E5=85=A8=E5=B1=80=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8D=95=E8=8E=B7=EF=BC=8C=E9=98=B2=E6=AD=A2500?= =?UTF-8?q?=E9=94=99=E8=AF=AF\n-=20pay.php:=20queryOrder=E8=BF=94=E5=9B=9E?= =?UTF-8?q?created=5Fat=EF=BC=8CsyncPoller=20action=E5=8D=A0=E4=BD=8D\n-?= =?UTF-8?q?=20player.php:=20=E7=BB=AD=E6=94=AF=E4=BB=98=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E6=B7=BB=E5=8A=A05=E5=88=86=E9=92=9F=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=A3=80=E6=9F=A5\n-=20=E8=A7=A3=E5=86=B3:\n=20=201.=20Java?= =?UTF-8?q?=E8=BD=AE=E8=AF=A2500=E9=94=99=E8=AF=AF\n=20=202.=20=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=B6=85=E6=97=B65=E5=88=86=E9=92=9F\n=20=203.=20?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E8=BF=87=E6=9C=9F=E8=AE=A2=E5=8D=95=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=B8=85=E9=99=A4\n=20=204.=20=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E6=8C=89=E9=92=AE=E9=94=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/pay.php | 4 ++++ api/poller_online.php | 22 ++++++++++++++++------ player.php | 12 ++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/api/pay.php b/api/pay.php index 06ebd14..ea53561 100644 --- a/api/pay.php +++ b/api/pay.php @@ -524,6 +524,7 @@ function queryOrder($token) { 'money' => $row['money'], 'bonds' => (int)$row['bond_amount'], 'paid_at' => $row['paid_at'], + 'created_at' => $row['created_at'], ], $message); } @@ -542,6 +543,9 @@ try { case 'pay_redirect': handlePayRedirect(); // 内部已 exit break; + case 'sync_poller': + syncPoller(getParam('token')); + break; case 'query_order': queryOrder(getParam('token')); break; diff --git a/api/poller_online.php b/api/poller_online.php index 6a5baa7..4b66ca6 100644 --- a/api/poller_online.php +++ b/api/poller_online.php @@ -85,11 +85,16 @@ function getSQLite() { function getPlatformDB() { static $pdo = null; if ($pdo === null) { - $dsn = "mysql:host={$GLOBALS['PLATFORM_DB_HOST']};dbname={$GLOBALS['PLATFORM_DB_NAME']};charset=utf8mb4"; - $pdo = new PDO($dsn, $GLOBALS['PLATFORM_DB_USER'], $GLOBALS['PLATFORM_DB_PASS'], [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_TIMEOUT => 5, - ]); + try { + $dsn = "mysql:host={$GLOBALS['PLATFORM_DB_HOST']};dbname={$GLOBALS['PLATFORM_DB_NAME']};charset=utf8mb4"; + $pdo = new PDO($dsn, $GLOBALS['PLATFORM_DB_USER'], $GLOBALS['PLATFORM_DB_PASS'], [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_TIMEOUT => 5, + ]); + } catch (Exception $e) { + debugLog("Platform DB connection failed", ['error' => $e->getMessage()]); + throw $e; // re-throw to be caught by pollPaidOrders + } } return $pdo; } @@ -267,5 +272,10 @@ function markNotified($pdo, $tradeNo) { // 不在此处自动执行补单(由调用方自行决定何时触发)。 if (!defined('POLLER_NO_AUTO_RUN')) { header('Content-Type: application/json; charset=utf-8'); - pollPaidOrders(); + try { + pollPaidOrders(); + } catch (\Throwable $e) { + debugLog('[poller_online] 未捕获异常', ['error' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]); + echo json_encode(['error' => 'uncaught_exception', 'detail' => $e->getMessage()]); + } } diff --git a/player.php b/player.php index 542c46a..6eae0b6 100644 --- a/player.php +++ b/player.php @@ -1113,6 +1113,17 @@ if ($currentVersion !== $BUILD_VERSION) { btn.textContent = '✅ 支付完成'; btn.onclick = null; } else if (res.data.status === 'created') { + // 检查订单是否已过期(5分钟) + const nowSec = Math.floor(Date.now() / 1000); + const createdAt = res.data.created_at || 0; + if (createdAt && (nowSec - createdAt) > 300) { + // 已过期:清除本地记录,重置按钮 + localStorage.removeItem('sdf1_last_recharge_no'); + st.innerHTML = '订单已过期(超过5分钟),请重新下单。'; + btn.disabled = false; + btn.textContent = '🅰️ 支付宝支付 ¥0.01'; + btn.onclick = startRecharge; + } else { // 未支付:显示继续支付 btn.textContent = '🔄 继续支付 ¥' + (res.data.money || '0.01'); btn.onclick = async function() { @@ -1140,6 +1151,7 @@ if ($currentVersion !== $BUILD_VERSION) { }; st.innerHTML = '⚠️ 您有一笔未完成的订单,点此继续支付'; document.getElementById('rechargeQueryBtn').style.display = 'block'; + } } // 如果是 expired 或其他状态,不处理,保持默认按钮 }