/user/balance/ 调整
This commit is contained in:
@@ -25,6 +25,9 @@ defined('ABSPATH') || exit;
|
||||
<?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); ?>">
|
||||
@@ -33,8 +36,8 @@ 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 (!empty($row['remark'])) : ?>
|
||||
<span class="uc-transactions__remark">(<?php echo esc_html((string) $row['remark']); ?>)</span>
|
||||
<?php if ($record_note !== '') : ?>
|
||||
<span class="uc-transactions__remark">(<?php echo esc_html($record_note); ?>)</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-transactions__time">
|
||||
@@ -46,14 +49,6 @@ defined('ABSPATH') || exit;
|
||||
<span class="uc-transactions__delta <?php echo esc_attr($delta_class); ?>">
|
||||
<?php echo esc_html(($delta > 0 ? '+' : '') . $delta); ?>
|
||||
</span>
|
||||
<span class="uc-transactions__balance">
|
||||
<?php
|
||||
/* translators: %s: balance */
|
||||
printf(esc_html__('余额 %s', 'aksrt'), esc_html((string) (int) $row['balance_after_minor']));
|
||||
?>
|
||||
</span>
|
||||
<?php if ((int) ($row['fee_minor'] ?? 0) > 0) : ?><span class="muted-2-color em09"><?php printf(esc_html__('手续费 %d', 'aksrt'), (int) $row['fee_minor']); ?></span><?php endif; ?>
|
||||
<span class="muted-2-color em09"><?php printf(esc_html__('交易 #%d', 'aksrt'), (int) $row['id']); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -82,6 +82,9 @@ if ($show_wallet || $show_credits) :
|
||||
$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'];
|
||||
?>
|
||||
<div class="uc-transactions__item">
|
||||
<div class="uc-transactions__icon <?php echo esc_attr($delta_class); ?>">
|
||||
@@ -90,20 +93,14 @@ if ($show_wallet || $show_credits) :
|
||||
<div class="uc-transactions__info">
|
||||
<div class="uc-transactions__reason">
|
||||
<?php echo esc_html(aksrt_asset_reason_label((string) $row['reason'])); ?>
|
||||
<?php if (!empty($row['remark'])) : ?>
|
||||
<span class="uc-transactions__remark">(<?php echo esc_html((string) $row['remark']); ?>)</span>
|
||||
<?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>
|
||||
<div class="uc-transactions__amount">
|
||||
<span class="uc-transactions__delta <?php echo esc_attr($delta_class); ?>"><?php echo esc_html($delta_txt); ?></span>
|
||||
<span class="uc-transactions__balance"><?php printf(esc_html__('余额 %s', 'aksrt'), esc_html(\AKSRT\Ledger\AssetAmount::from_minor(\AKSRT\Ledger\AssetType::BALANCE, (int) ($row['balance_after_minor'] ?? 0))->formatted())); ?></span>
|
||||
<?php if ((int) ($row['fee_minor'] ?? 0) > 0) : ?><span class="muted-2-color em09"><?php printf(esc_html__('手续费 %s', 'aksrt'), esc_html(\AKSRT\Ledger\AssetAmount::from_minor(\AKSRT\Ledger\AssetType::BALANCE, (int) $row['fee_minor'])->formatted())); ?></span><?php endif; ?>
|
||||
<span class="muted-2-color em09"><?php printf(esc_html__('交易 #%d', 'aksrt'), (int) $row['id']); ?></span>
|
||||
<?php if (!empty($row['ref_id'])) : ?>
|
||||
<span class="uc-transactions__ref muted-2-color em09"><?php printf(esc_html__('单号 %s', 'aksrt'), esc_html((string) $row['ref_id'])); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -77,6 +77,14 @@ test('user asset submissions send idempotency keys', () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('profile asset records show order references and only the changed amount', () => {
|
||||
for (const file of ['profile-credits.php', 'credits-transactions.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.doesNotMatch(source, /uc-transactions__balance|交易 #%d|\$row\['fee_minor'\]|\$row\['ref_id'\]/)
|
||||
}
|
||||
})
|
||||
|
||||
test('core asset paths never use floating-point money helpers', () => {
|
||||
const files = [
|
||||
'src/Ledger/AssetAmount.php',
|
||||
|
||||
Reference in New Issue
Block a user