修复两个问题
This commit is contained in:
1 parent
58f3f42bf8
commit
406fb8d6a6
4 files changed
+63
-11
No files matched your search
@@ -386,6 +386,16 @@ class Gateway {
|
||||
// 用户可能重复付款,不能静默 ACK 为已正确同步。
|
||||
if (in_array($current, ['paid', 'delivered', 'completed'], true)) {
|
||||
$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)) {
|
||||
return false;
|
||||
}
|
||||
return $repo->update_status($order_number, Order::STATUS_PAID, [
|
||||
'payment_method' => $gateway_id,
|
||||
'payment_transaction_id' => $transaction_id,
|
||||
'note' => __('支付网关回调补充确认到账。', 'aksrt'),
|
||||
]);
|
||||
}
|
||||
return $stored_transaction !== '' && hash_equals($stored_transaction, $transaction_id);
|
||||
}
|
||||
// 只允许从未支付态完成
|
||||
|
||||
@@ -244,7 +244,7 @@ trait OrderRepositoryCore {
|
||||
public function expire_pending_orders(?int $user_id = null): int {
|
||||
global $wpdb;
|
||||
|
||||
$where = "status IN ('created', 'pending') AND expires_at IS NOT NULL AND expires_at <> '' AND expires_at <= %s";
|
||||
$where = "status IN ('created', 'pending') AND expires_at IS NOT NULL AND expires_at <= %s";
|
||||
$params = [gmdate('Y-m-d H:i:s')];
|
||||
if ($user_id !== null && $user_id > 0) {
|
||||
$where .= ' AND user_id = %d';
|
||||
@@ -298,7 +298,10 @@ trait OrderRepositoryCore {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
$new_status === \AKSRT\Core\DomainModel::ORDER_STATUS_PAID
|
||||
in_array($new_status, [
|
||||
\AKSRT\Core\DomainModel::ORDER_STATUS_PAID,
|
||||
\AKSRT\Core\DomainModel::ORDER_STATUS_COMPLETED,
|
||||
], true)
|
||||
&& sanitize_key((string) ($preflight['product_type'] ?? '')) === \AKSRT\Core\DomainModel::ORDER_PRODUCT_RECHARGE
|
||||
&& class_exists('\AKSRT\Credits\BalanceService')
|
||||
) {
|
||||
@@ -579,7 +582,7 @@ trait OrderRepositoryCore {
|
||||
// Prefer cancelled_at when set; fall back to created_at for older rows.
|
||||
$sql = "DELETE FROM {$table}
|
||||
WHERE status IN ('cancelled', 'expired')
|
||||
AND COALESCE(NULLIF(cancelled_at, ''), created_at) < %s";
|
||||
AND COALESCE(cancelled_at, created_at) < %s";
|
||||
$deleted = $wpdb->query($wpdb->prepare($sql, $cutoff));
|
||||
return $deleted === false ? 0 : (int) $deleted;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user