进行了一些小优化

This commit is contained in:
2026-08-25 05:59:50 +08:00
parent 5549f81901
commit 75d1e6e53b
7 changed files with 52 additions and 8 deletions
+6 -2
View File
@@ -42,6 +42,7 @@ final class LedgerQuery {
$entry_table = \AKSRT\Core\DBMigrator::table('asset_entry');
$transaction_table = \AKSRT\Core\DBMigrator::table('asset_transaction');
$flow_table = \AKSRT\Core\DBMigrator::table('financial_flow');
$where = ['1=1'];
$params = [];
if ($user_id > 0) {
@@ -107,8 +108,10 @@ final class LedgerQuery {
$entry_params[] = $asset;
}
$rows = $wpdb->get_results($wpdb->prepare(
"SELECT e.*, t.operation_key, t.reason, t.ref_type, t.ref_key, t.actor_user_id, t.metadata, t.created_at transaction_created_at
FROM {$entry_table} e INNER JOIN {$transaction_table} t ON t.id = e.transaction_id
"SELECT e.*, t.operation_key, t.reason, t.ref_type, t.ref_key, t.actor_user_id, t.metadata, t.created_at transaction_created_at, f.withdrawal_number
FROM {$entry_table} e
INNER JOIN {$transaction_table} t ON t.id = e.transaction_id
LEFT JOIN {$flow_table} f ON f.ledger_transaction_id = t.id
WHERE " . implode(' AND ', $entry_where) . ' ORDER BY e.transaction_id DESC, e.line_no ASC',
$entry_params
), ARRAY_A);
@@ -123,6 +126,7 @@ final class LedgerQuery {
'reason' => (string) $row['reason'],
'ref_type' => (string) ($row['ref_type'] ?? ''),
'ref_key' => (string) ($row['ref_key'] ?? ''),
'withdrawal_number' => (string) ($row['withdrawal_number'] ?? ''),
'actor_user_id' => (int) ($row['actor_user_id'] ?? 0),
'metadata' => json_decode((string) ($row['metadata'] ?? ''), true) ?: [],
'created_at' => (string) $row['transaction_created_at'],
+4 -1
View File
@@ -669,7 +669,10 @@ class Withdrawal {
$row['amount'] = $this->database_balance_decimal((string) ($row['amount'] ?? '0'));
$row['fee_rate'] = (int) ($meta['fee_rate'] ?? 0);
$display = (string) ($meta['account'] ?? $row['account_info'] ?? '');
$row['display_account'] = strlen($display) > 4 ? substr($display, 0, 2) . str_repeat('*', max(2, strlen($display) - 4)) . substr($display, -2) : '****';
$display_length = mb_strlen($display, 'UTF-8');
$row['display_account'] = $display_length > 4
? mb_substr($display, 0, 2, 'UTF-8') . str_repeat('*', max(2, $display_length - 4)) . mb_substr($display, -2, null, 'UTF-8')
: '****';
$row['source'] = (string) ($meta['source'] ?? 'balance');
return $row;
}