修复支付状态问题

This commit is contained in:
kate522 committed 2026-08-24 17:21:06 +08:00
1 parent 406fb8d6a6
commit 85a124b886
21 files changed
+198 -308

No files matched your search

+4 -4
View File
@@ -225,7 +225,7 @@ class Gateway {
$provider_ref = sanitize_text_field((string) ($request->get_param('order')
?: $request->get_param('out_trade_no')
?: ''));
$this->redirect_to_orders($this->local_order_number($provider_ref), 'cancelled');
$this->redirect_to_orders($this->local_order_number($provider_ref), Order::STATUS_CLOSED);
return null;
}
@@ -306,7 +306,7 @@ class Gateway {
* @param array<string,mixed>|null $order
*/
private function reconciliation_gateway(?array $order): ?GatewayInterface {
if (!is_array($order) || !in_array((string) ($order['status'] ?? ''), [Order::STATUS_CREATED, Order::STATUS_PENDING], true)) {
if (!is_array($order) || (string) ($order['status'] ?? '') !== Order::STATUS_PENDING) {
return null;
}
@@ -384,7 +384,7 @@ class Gateway {
// 幂等:仅同一交易号的重复回调可视为成功。不同交易号意味着
// 用户可能重复付款,不能静默 ACK 为已正确同步。
if (in_array($current, ['paid', 'delivered', 'completed'], true)) {
if ($current === Order::STATUS_PAID) {
$stored_transaction = sanitize_text_field((string) ($order['payment_transaction_id'] ?? ''));
if (sanitize_key((string) ($order['product_type'] ?? '')) === \AKSRT\Core\DomainModel::ORDER_PRODUCT_RECHARGE) {
if ($stored_transaction !== '' && !hash_equals($stored_transaction, $transaction_id)) {
@@ -399,7 +399,7 @@ class Gateway {
return $stored_transaction !== '' && hash_equals($stored_transaction, $transaction_id);
}
// 只允许从未支付态完成
if (!in_array($current, ['created', 'pending'], true)) {
if ($current !== Order::STATUS_PENDING) {
return false;
}