feat(payment): rebuild order details and asset records
This commit is contained in:
1 parent
476e2f961d
commit
7b55cfb190
57 files changed
+2080
-1294
No files matched your search
@@ -13,12 +13,9 @@ $asset_request = is_array($asset_request ?? null) ? $asset_request : [];
|
||||
$wallet_page = ($asset_request['asset'] ?? '') === 'balance'
|
||||
? max(1, (int) ($asset_request['page'] ?? 1))
|
||||
: 1;
|
||||
$wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history([
|
||||
'user_id' => (int) ($user_id ?? 0),
|
||||
'asset' => 'balance',
|
||||
'page' => $wallet_page,
|
||||
'per_page' => 10,
|
||||
]);
|
||||
$history = get_user_meta((int) ($user_id ?? 0), 'balance_record', true);
|
||||
$history = is_array($history) ? array_slice($history, 0, 50) : [];
|
||||
$items = array_slice($history, ($wallet_page - 1) * 10, 10);
|
||||
?>
|
||||
<div class="uc-transactions uc-transactions--wallet">
|
||||
<div class="uc-transactions__header">
|
||||
@@ -27,12 +24,14 @@ $wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history([
|
||||
<?php esc_html_e('余额记录', 'aksrt'); ?>
|
||||
</h3>
|
||||
</div>
|
||||
<?php if (!empty($wlog['items'])) : ?>
|
||||
<?php if ($items) : ?>
|
||||
<div class="uc-transactions__list">
|
||||
<?php foreach ($wlog['items'] as $row) :
|
||||
$delta = (int) $row['delta_minor'];
|
||||
<?php foreach ($items as $row) :
|
||||
$raw_delta = (string) ($row['value'] ?? '0');
|
||||
try { $delta_minor = \AKSRT\Ledger\AssetAmount::balance($raw_delta)->minor(); } catch (\InvalidArgumentException $e) { $delta_minor = 0; }
|
||||
$delta = $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();
|
||||
$delta_txt = ($delta > 0 ? '+' : ($delta < 0 ? '-' : '')) . \AKSRT\Ledger\AssetAmount::from_minor(\AKSRT\Ledger\AssetType::BALANCE, abs($delta))->formatted();
|
||||
?>
|
||||
<div class="uc-transactions__item">
|
||||
<div class="uc-transactions__icon <?php echo esc_attr($delta_class); ?>">
|
||||
@@ -40,9 +39,10 @@ $wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history([
|
||||
</div>
|
||||
<div class="uc-transactions__info">
|
||||
<div class="uc-transactions__reason">
|
||||
<?php echo esc_html(aksrt_asset_reason_label((string) $row['reason'])); ?>
|
||||
<?php echo esc_html((string) ($row['desc'] ?? '') !== '' ? (string) $row['desc'] : aksrt_asset_reason_label((string) ($row['type'] ?? ''))); ?>
|
||||
</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 class="uc-transactions__time"><?php echo esc_html((string) ($row['time'] ?? '')); ?></div>
|
||||
<?php if (!empty($row['order_num'])) : ?><div class="muted-2-color em09"><?php echo esc_html__('订单号:', 'aksrt') . esc_html((string) $row['order_num']); ?></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_txt); ?></span>
|
||||
@@ -51,7 +51,7 @@ $wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history([
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
$total_pages = (int) ceil((int) ($wlog['total'] ?? 0) / 10);
|
||||
$total_pages = (int) ceil(count($history) / 10);
|
||||
if ($total_pages > 1 && function_exists('aksrt_render_asset_pagination')) {
|
||||
aksrt_render_asset_pagination($total_pages, $wallet_page, 'balance');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user