From 50ac2119f1530fd79d1251255535c381f5fcf092 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Aug 2026 12:48:27 +0800 Subject: [PATCH 1/2] fix(payment): constrain creator income counts --- src/Payment/Revenue.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Payment/Revenue.php b/src/Payment/Revenue.php index 20ab8dd2..8a8a3ab7 100644 --- a/src/Payment/Revenue.php +++ b/src/Payment/Revenue.php @@ -406,7 +406,8 @@ class Revenue { } } $where_sql = $where ? 'WHERE ' . implode(' AND ', $where) : ''; - $total = (int) ($params ? $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$this->table()} {$where_sql}", $params)) : $wpdb->get_var("SELECT COUNT(*) FROM {$this->table()}")); + $count_sql = "SELECT COUNT(*) FROM {$this->table()} {$where_sql}"; + $total = (int) ($params ? $wpdb->get_var($wpdb->prepare($count_sql, $params)) : $wpdb->get_var($count_sql)); $items_params = array_merge($params, [$limit, $offset]); $items = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->table()} {$where_sql} ORDER BY created_at DESC LIMIT %d OFFSET %d", $items_params), ARRAY_A); return ['items' => $items ?: [], 'total' => $total, 'page' => (int) floor($offset / $limit) + 1, 'max_pages' => (int) ceil(max(1, $total) / $limit)]; From c16add08076edb27c91cf5a686cab549be85e368 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Aug 2026 12:53:57 +0800 Subject: [PATCH 2/2] fix(payment): normalize revenue currency filters --- src/Payment/Revenue.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Payment/Revenue.php b/src/Payment/Revenue.php index 8a8a3ab7..f575e10e 100644 --- a/src/Payment/Revenue.php +++ b/src/Payment/Revenue.php @@ -283,8 +283,9 @@ class Revenue { $where[] = 'status = %s'; $params[] = $status; } - $currency = sanitize_key((string) ($args['currency'] ?? '')); - if (in_array($currency, ['CNY', 'points'], true)) { + $currency = strtolower(sanitize_key((string) ($args['currency'] ?? ''))); + if (in_array($currency, ['cny', 'points'], true)) { + $currency = $currency === 'points' ? 'points' : 'CNY'; $where[] = 'currency = %s'; $params[] = $currency; } @@ -317,8 +318,9 @@ class Revenue { $where = 'author_id = %d'; $params = [$user_id]; - $currency = sanitize_key((string) ($args['currency'] ?? '')); - if (in_array($currency, ['CNY', 'points'], true)) { + $currency = strtolower(sanitize_key((string) ($args['currency'] ?? ''))); + if (in_array($currency, ['cny', 'points'], true)) { + $currency = $currency === 'points' ? 'points' : 'CNY'; $where .= ' AND currency = %s'; $params[] = $currency; } @@ -388,8 +390,9 @@ class Revenue { $where[] = 'post_id = %d'; $params[] = $post_id; } - $currency = sanitize_key((string) ($args['currency'] ?? '')); - if (in_array($currency, ['CNY', 'points'], true)) { + $currency = strtolower(sanitize_key((string) ($args['currency'] ?? ''))); + if (in_array($currency, ['cny', 'points'], true)) { + $currency = $currency === 'points' ? 'points' : 'CNY'; $where[] = 'currency = %s'; $params[] = $currency; }