进行了一些小优化
This commit is contained in:
1 parent
5549f81901
commit
75d1e6e53b
7 files changed
+52
-8
No files matched your search
@@ -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'],
|
||||
|
||||
Reference in new issue
Block a user