fix(payment): normalize revenue currency filters

This commit is contained in:
2026-08-07 12:53:57 +08:00
parent 50ac2119f1
commit c16add0807
+9 -6
View File
@@ -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;
}