修复两个问题

This commit is contained in:
2026-08-24 16:52:26 +08:00
parent 58f3f42bf8
commit 406fb8d6a6
4 changed files with 63 additions and 11 deletions
+6 -3
View File
@@ -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;
}