fix(frontend): 用户中心余额与积分记录不再拼接括号内容

记录行只保留中文变动原因、时间与变动额,移除名称后的(引用键/备注/提现单号)拼接。

同步清理该改动产生的死代码:$record_note 计算块、.uc-transactions__remark 样式、LedgerQuery 中已无消费者的 financial_flow LEFT JOIN 与 withdrawal_number 字段,以及 credits-wallet.php 里恒为 true 的 $skip_wallet_ledger 双路分支。
This commit is contained in:
2026-09-19 11:46:01 +08:00
parent 0d617d88c9
commit 32e76b440f
8 changed files with 16 additions and 47 deletions
@@ -526,12 +526,6 @@ body.uc-modal-open {
line-height: 1.4;
}
.uc-transactions__remark {
font-size: 12px;
color: var(--color-ink-4);
margin-left: 4px;
}
.uc-transactions__time {
font-size: 12px;
color: var(--color-ink-4);
@@ -21,16 +21,13 @@ defined('ABSPATH') || exit;
$credits_page = ($asset_request['asset'] ?? '') === 'points'
? max(1, (int) ($asset_request['page'] ?? 1))
: 1;
$log = \AKSRT\Ledger\LedgerQuery::get_instance()->history(['user_id' => $user_id, 'asset' => 'points', 'page' => $credits_page, 'per_page' => 10]);
$log = \AKSRT\Ledger\LedgerQuery::get_instance()->history(['user_id' => $user_id, 'asset' => 'points', 'page' => $credits_page, 'per_page' => 10]);
if (!empty($log['items'])) :
?>
<div class="uc-transactions__list">
<?php foreach ($log['items'] as $row) :
$delta = (int) $row['delta_minor'];
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
$record_note = (string) $row['reason'] === 'points_exchange'
? (string) $row['ref_key']
: (string) $row['remark'];
?>
<div class="uc-transactions__item">
<div class="uc-transactions__icon <?php echo esc_attr($delta_class); ?>">
@@ -39,9 +36,6 @@ defined('ABSPATH') || exit;
<div class="uc-transactions__info">
<div class="uc-transactions__reason">
<?php echo esc_html(aksrt_asset_reason_label((string) $row['reason'])); ?>
<?php if ($record_note !== '') : ?>
<span class="uc-transactions__remark">(<?php echo esc_html($record_note); ?>)</span>
<?php endif; ?>
</div>
<div class="uc-transactions__time">
<?php echo esc_html(get_date_from_gmt((string) $row['created_at'], 'Y-m-d H:i')); ?>
@@ -33,12 +33,6 @@ $wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history([
$delta = (int) $row['delta_minor'];
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
$delta_txt = ($delta > 0 ? '+' : '-') . \AKSRT\Ledger\AssetAmount::from_minor(\AKSRT\Ledger\AssetType::BALANCE, abs($delta))->formatted();
$record_note = (string) $row['reason'] === 'points_exchange'
? (string) $row['ref_key']
: (string) ($row['remark'] ?? '');
if (in_array((string) $row['reason'], ['withdraw_hold', 'withdraw_refund'], true)) {
$record_note = (string) ($row['withdrawal_number'] ?? '');
}
?>
<div class="uc-transactions__item">
<div class="uc-transactions__icon <?php echo esc_attr($delta_class); ?>">
@@ -47,9 +41,6 @@ $wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history([
<div class="uc-transactions__info">
<div class="uc-transactions__reason">
<?php echo esc_html(aksrt_asset_reason_label((string) $row['reason'])); ?>
<?php if ($record_note !== '') : ?>
<span class="uc-transactions__remark">(<?php echo esc_html($record_note); ?>)</span>
<?php endif; ?>
</div>
<div class="uc-transactions__time"><?php echo esc_html(get_date_from_gmt((string) $row['created_at'], 'Y-m-d H:i')); ?></div>
</div>
@@ -243,7 +243,3 @@ endif; ?>
</div>
</div>
<?php endif; ?>
<?php if (empty($skip_wallet_ledger)) : ?>
<?php require __DIR__ . '/credits-wallet-ledger.php'; ?>
<?php endif; ?>
@@ -22,11 +22,7 @@ if ($show_wallet || $show_credits) :
<div class="uc-assets-row<?php echo ($show_wallet && $show_credits) ? ' uc-assets-row--dual' : ''; ?>">
<?php if ($show_wallet) : ?>
<div class="uc-assets-col">
<?php
// Ledger moved to tab section below.
$skip_wallet_ledger = true;
require $dir . '/credits-wallet.php';
?>
<?php require $dir . '/credits-wallet.php'; ?>
</div>
<?php endif; ?>
<?php if ($show_credits) : ?>
+1 -4
View File
@@ -42,7 +42,6 @@ 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) {
@@ -108,10 +107,9 @@ 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, f.withdrawal_number
"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
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);
@@ -126,7 +124,6 @@ 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'],
@@ -78,10 +78,12 @@ test('user asset submissions send idempotency keys', () => {
}
})
test('profile asset records show order references and only the changed amount', () => {
test('profile asset records show only the reason label and the changed amount', () => {
for (const file of ['credits-transactions.php', 'credits-wallet-ledger.php']) {
const source = fs.readFileSync(path.join(root, 'inc', 'helpers', 'user-center-renderers', file), 'utf8')
assert.match(source, /\$record_note\s*=\s*\(string\) \$row\['reason'\] === 'points_exchange'[\s\S]*?\(string\) \$row\['ref_key'\]/)
assert.match(source, /aksrt_asset_reason_label\(\(string\) \$row\['reason'\]\)/)
// 记录名称后不再拼接(引用键 / 备注 / 提现单号)。
assert.doesNotMatch(source, /\$record_note|uc-transactions__remark|\$row\['ref_key'\]|\$row\['remark'\]|withdrawal_number/)
assert.doesNotMatch(source, /uc-transactions__balance|交易 #%d|\$row\['fee_minor'\]|\$row\['ref_id'\]/)
}
})
@@ -63,19 +63,18 @@ test('native and front-end surfaces expose immutable business numbers', () => {
assert.match(read('assets/js/order-center.js'), /\["流水号", order\.order_number\]/)
assert.doesNotMatch(read('assets/js/order-center.js'), /flow_number|账本流水号/)
assert.doesNotMatch(read('src/Payment/UserOrders.php'), /\$view\['flow_number'\]/)
assert.match(read('inc/helpers/user-center-renderers/credits-wallet-ledger.php'), /withdrawal_number/)
})
test('balance history renders withdrawal numbers from the committed flow', () => {
test('ledger history carries no financial flow coupling', () => {
const query = read('src/Ledger/LedgerQuery.php')
const profile = read('inc/helpers/user-center-renderers/credits-wallet-ledger.php')
const wallet = read('inc/helpers/user-center-renderers/credits-wallet.php') + read('inc/helpers/user-center-renderers/credits-wallet-ledger.php')
assert.match(query, /LEFT JOIN \{\$flow_table\} f ON f\.ledger_transaction_id = t\.id/)
assert.match(query, /'withdrawal_number'\s*=>\s*\(string\)/)
for (const source of [profile, wallet]) {
assert.match(source, /\['withdraw_hold', 'withdraw_refund'\]/)
assert.match(source, /\$row\['withdrawal_number'\]/)
}
const records = [
read('inc/helpers/user-center-renderers/credits-transactions.php'),
read('inc/helpers/user-center-renderers/credits-wallet-ledger.php'),
].join('\n')
// 前台余额/积分记录只展示中文变动原因与变动额:提现单号既不查询也不下发,
// 账本历史不再为了它 LEFT JOIN financial_flow。
assert.doesNotMatch(query, /financial_flow|withdrawal_number/)
assert.doesNotMatch(records, /\$row\['ref_key'\]|\$row\['remark'\]|withdrawal_number|uc-transactions__remark/)
})
test('user withdrawal history uses one paginated ten-item endpoint', () => {