Files
wordpress-theme-aksrt/inc/helpers/user-center-renderers/credits-transactions.php
T
2026-08-25 04:20:29 +08:00

71 lines
2.6 KiB
PHP

<?php
/**
* User center credits: transaction log list.
*
* Expects extracted $context vars.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
?>
<div class="uc-transactions">
<div class="uc-transactions__header">
<h3 class="uc-transactions__title">
<i class="fa fas fa-list-ul" aria-hidden="true"></i>
<?php echo esc_html(sprintf(__('%s明细', 'aksrt'), $currency_name)); ?>
</h3>
</div>
<?php
$credits_page = max(1, isset($_GET['credits_page']) ? (int) $_GET['credits_page'] : 1);
$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); ?>">
<i class="fa fas fa-<?php echo $delta >= 0 ? 'arrow-up' : 'arrow-down'; ?>" aria-hidden="true"></i>
</div>
<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>
<?php if (!empty($row['counterparty_user_id'])) : ?><div class="muted-2-color em09"><?php printf(esc_html__('对方用户 #%d', 'aksrt'), (int) $row['counterparty_user_id']); ?></div><?php endif; ?>
</div>
<div class="uc-transactions__amount">
<span class="uc-transactions__delta <?php echo esc_attr($delta_class); ?>">
<?php echo esc_html(($delta > 0 ? '+' : '') . $delta); ?>
</span>
</div>
</div>
<?php endforeach; ?>
</div>
<?php
$total_pages = (int) ceil((int) ($log['total'] ?? 0) / 10);
if ($total_pages > 1) {
aksrt_render_profile_pagination($total_pages, $credits_page, 'credits_page');
}
?>
<?php else : ?>
<div class="uc-transactions__empty">
<div class="uc-transactions__empty-icon">
<i class="fa fas fa-file-alt" aria-hidden="true"></i>
</div>
<p><?php echo esc_html(sprintf(__('还没有任何%s流水', 'aksrt'), $currency_name)); ?></p>
</div>
<?php endif; ?>
</div>