积分与余额账务系统硬切重构

This commit is contained in:
kate522 committed 2026-08-24 15:59:11 +08:00
1 parent ca12226b39
commit 5cae5b5c93
159 files changed
+7275 -4718

No files matched your search

@@ -7,7 +7,7 @@
defined('ABSPATH') || exit;
$balance = (float) ($credit_balance ?? 0.0);
$balance = max(0, (int) ($credit_balance ?? 0));
$credits_enabled = !empty($credits_enabled);
if (!$credits_enabled) {
return;
@@ -26,7 +26,8 @@ if ($points_transfer_on && class_exists('\AKSRT\Settings\Capabilities') && !\AKS
}
$points_transfer_min = max(1, (int) ($all_settings['points_transfer_min'] ?? 1));
$points_exchange = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_recharge_settings()['points_exchange'] ?? [] : [];
$points_exchange_on = !empty($points_exchange['enabled']) && class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
$recharge = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_recharge_settings() : [];
$points_exchange_on = !empty($points_exchange['enabled']) && !empty($recharge['enabled']);
$currency = (string) ($currency_name ?? __('积分', 'aksrt'));
?>
<div class="uc-asset-card uc-asset-card--points">
@@ -45,7 +46,7 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
</div>
<div class="uc-asset-card__body flex jsb ac">
<div class="uc-asset-card__amount c-green">
<span class="uc-asset-card__value font-bold"><?php echo esc_html(function_exists('aksrt_format_credits') ? aksrt_format_credits((int) $balance) : (string) (int) $balance); ?></span>
<span class="uc-asset-card__value font-bold"><?php echo esc_html(aksrt_format_points($balance)); ?></span>
</div>
<div class="uc-asset-card__actions flex0">
<?php if ($points_transfer_on) : ?>
@@ -74,7 +75,7 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
<?php endif; ?>
<form data-aksrt-points-exchange-form>
<label class="muted-color em09"><?php esc_html_e('兑换余额', 'aksrt'); ?></label>
<input type="number" class="uc-card-pass__input" name="amount" min="1" step="1" inputmode="numeric" data-aksrt-points-exchange-amount data-aksrt-points-exchange-rate="<?php echo esc_attr((string) $pb_rate); ?>">
<input type="number" class="uc-card-pass__input" name="amount" min="0.01" step="0.01" inputmode="decimal" data-aksrt-points-exchange-amount data-aksrt-points-exchange-rate="<?php echo esc_attr((string) $pb_rate); ?>">
<p class="muted-2-color em09 mt6"><?php printf(esc_html__('1 余额 = %d 积分;单笔至少 %d 积分,每日最多 %d 积分。', 'aksrt'), $pb_rate, $pb_min_points, $pb_daily_max_points); ?></p>
<p class="muted-2-color em09 mt6" data-aksrt-points-exchange-preview></p>
<button type="submit" class="but jb-blue btn-block mt10"><?php esc_html_e('立即购买', 'aksrt'); ?></button>
@@ -18,16 +18,12 @@ defined('ABSPATH') || exit;
</div>
<?php
$credits_page = max(1, isset($_GET['credits_page']) ? (int) $_GET['credits_page'] : 1);
if (class_exists('\AKSRT\Credits\Credits')) {
$log = \AKSRT\Credits\Credits::get_log(['user_id' => $user_id, 'page' => $credits_page, 'per_page' => 10]);
} else {
$log = ['items' => [], 'total' => 0];
}
$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'];
$delta = (int) $row['delta_minor'];
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
?>
<div class="uc-transactions__item">
@@ -36,7 +32,7 @@ defined('ABSPATH') || exit;
</div>
<div class="uc-transactions__info">
<div class="uc-transactions__reason">
<?php echo esc_html(aksrt_credits_label((string) $row['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 endif; ?>
@@ -44,6 +40,7 @@ defined('ABSPATH') || exit;
<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); ?>">
@@ -52,9 +49,11 @@ defined('ABSPATH') || exit;
<span class="uc-transactions__balance">
<?php
/* translators: %s: balance */
printf(esc_html__('余额 %s', 'aksrt'), esc_html((string) (int) $row['balance_after']));
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; ?>
@@ -13,10 +13,15 @@ if (empty($balance_enabled)) {
return;
}
$wallet = (float) ($wallet_balance ?? 0.0);
$wallet_fmt = class_exists('\AKSRT\Credits\Balance')
? \AKSRT\Credits\Balance::format($wallet)
: number_format_i18n($wallet, 2);
$normalize_balance = static function ($value): \AKSRT\Ledger\AssetAmount {
try {
return \AKSRT\Ledger\AssetAmount::balance(is_string($value) ? $value : '');
} catch (\InvalidArgumentException $e) {
return \AKSRT\Ledger\AssetAmount::balance('0');
}
};
$wallet = $normalize_balance($wallet_balance ?? '0');
$wallet_fmt = $wallet->formatted();
$recharge = class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_payment_recharge_settings')
? \AKSRT\Settings\Settings::get_payment_recharge_settings()
@@ -32,9 +37,9 @@ if ($withdraw_on && class_exists('\AKSRT\Settings\Capabilities') && !\AKSRT\Sett
$withdraw_on = false;
}
$withdraw_settings = class_exists('\\AKSRT\\Settings\\Settings') ? \AKSRT\Settings\Settings::get_withdrawal_settings() : [];
$withdraw_min = max(0, (float) ($withdraw_settings['min_amount'] ?? 50));
$withdraw_usage = ['remaining_count' => 0, 'remaining_amount' => 0];
$withdraw_pending_hold = 0.0;
$withdraw_min = $normalize_balance($withdraw_settings['min_amount'] ?? '50')->decimal();
$withdraw_usage = ['remaining_count' => 0, 'remaining_amount' => '0.00'];
$withdraw_pending_hold = '0.00';
$withdraw_history = [];
if ($withdraw_on && class_exists('\AKSRT\Payment\Withdrawal')) {
$wd_svc = \AKSRT\Payment\Withdrawal::get_instance();
@@ -42,7 +47,7 @@ if ($withdraw_on && class_exists('\AKSRT\Payment\Withdrawal')) {
$withdraw_history = $wd_svc->get_user_withdrawals((int) ($user_id ?? 0), ['limit' => 30]);
$withdraw_usage = $wd_svc->daily_usage((int) ($user_id ?? 0), $withdraw_settings);
}
$withdraw_processing = $withdraw_pending_hold > 0;
$withdraw_processing = $normalize_balance($withdraw_pending_hold)->minor() > 0;
$card_pass_balance = ['enabled' => false, 'desc' => '', 'only_password' => true];
if (class_exists('\AKSRT\Payment\ChargeCard')) {
$opts = \AKSRT\Payment\ChargeCard::get_instance()->get_public_options();
@@ -90,7 +95,7 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
</div>
<?php if ($withdraw_on) : ?>
<div class="uc-asset-card__foot muted-2-color em09 mt6">
<span><?php printf(esc_html__('冻结中 %s', 'aksrt'), esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format((float) $withdraw_pending_hold) : number_format_i18n((float) $withdraw_pending_hold, 2))); ?></span>
<span><?php printf(esc_html__('冻结中 %s', 'aksrt'), esc_html($normalize_balance($withdraw_pending_hold)->formatted())); ?></span>
</div>
<?php endif; ?>
</div>
@@ -128,13 +133,17 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<?php if ($packages) : ?>
<div class="muted-color mb6"><?php esc_html_e('请选择充值金额', 'aksrt'); ?></div>
<div class="uc-charge-packages">
<?php foreach ($packages as $idx => $pkg) : ?>
<?php foreach ($packages as $idx => $pkg) :
$package_credit = $normalize_balance($pkg['price'] ?? '');
$package_pay = $normalize_balance($pkg['pay_price'] ?? '');
$package_saving_minor = max(0, $package_credit->minor() - $package_pay->minor());
?>
<label class="uc-charge-package<?php echo $idx === 0 ? ' is-active' : ''; ?>">
<input type="radio" name="balance_package" value="<?php echo esc_attr((string) $pkg['key']); ?>" <?php checked($idx === 0); ?>>
<div class="uc-charge-package__credit"><span class="px12">¥</span><?php echo esc_html((string) $pkg['price']); ?></div>
<div class="uc-charge-package__pay c-red"><span class="px12">¥</span><?php echo esc_html((string) $pkg['pay_price']); ?>
<?php if ((float) $pkg['pay_price'] < (float) $pkg['price']) : ?>
<span class="ml6 c-yellow smail"><?php printf(esc_html__('省%s', 'aksrt'), esc_html((string) ((float) $pkg['price'] - (float) $pkg['pay_price']))); ?></span>
<?php if ($package_saving_minor > 0) : ?>
<span class="ml6 c-yellow smail"><?php printf(esc_html__('省%s', 'aksrt'), esc_html(\AKSRT\Ledger\AssetAmount::decimal_from_minor($package_saving_minor))); ?></span>
<?php endif; ?>
</div>
<?php if (!empty($pkg['tag'])) : ?>
@@ -195,19 +204,19 @@ endif; ?>
<?php if (!empty($withdraw_history)) : ?>
<?php foreach ($withdraw_history as $wd) :
$st = sanitize_key((string) ($wd['status'] ?? ''));
$gross = (float) ($wd['gross_amount'] ?? $wd['amount'] ?? 0);
$net = (float) ($wd['amount'] ?? 0);
$gross = $normalize_balance($wd['gross_amount'] ?? $wd['amount'] ?? '0');
$net = $normalize_balance($wd['amount'] ?? '0');
$st_class = $st === 'rejected' ? 'c-red' : ($st === 'completed' ? 'c-green' : 'c-blue');
?>
<div class="uc-withdraw-history__item border-bottom padding-h10">
<div class="flex jsb ac">
<span class="badg badg-sm <?php echo esc_attr($st_class); ?>"><?php echo esc_html($status_labels[$st] ?? $st); ?></span>
<b class="em12"><?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($gross) : number_format_i18n($gross, 2)); ?></b>
<b class="em12"><?php echo esc_html($gross->formatted()); ?></b>
</div>
<div class="muted-2-color em09 mt6">
<?php echo esc_html((string) ($wd['created_at'] ?? '')); ?>
<?php if (abs($gross - $net) > 0.001) : ?>
· <?php printf(esc_html__('到账 %s', 'aksrt'), esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($net) : number_format_i18n($net, 2))); ?>
<?php if ($gross->minor() !== $net->minor()) : ?>
· <?php printf(esc_html__('到账 %s', 'aksrt'), esc_html($net->formatted())); ?>
<?php endif; ?>
</div>
<?php if (!empty($wd['note'])) : ?>
@@ -233,16 +242,14 @@ endif; ?>
</div>
<?php
$wallet_page = max(1, isset($_GET['wallet_page']) ? (int) $_GET['wallet_page'] : 1);
$wlog = class_exists('\AKSRT\Credits\Balance')
? \AKSRT\Credits\Balance::get_log(['user_id' => (int) $user_id, 'page' => $wallet_page, 'per_page' => 10])
: ['items' => [], 'total' => 0];
$wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history(['user_id' => (int) $user_id, 'asset' => 'balance', 'page' => $wallet_page, 'per_page' => 10]);
if (!empty($wlog['items'])) :
?>
<div class="uc-transactions__list">
<?php foreach ($wlog['items'] as $row) :
$delta = (float) $row['delta'];
$delta = (int) $row['delta_minor'];
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
$delta_txt = ($delta > 0 ? '+' : '') . (class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($delta) : number_format_i18n($delta, 2));
$delta_txt = ($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); ?>">
@@ -250,7 +257,7 @@ endif; ?>
</div>
<div class="uc-transactions__info">
<div class="uc-transactions__reason">
<?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::reason_label((string) $row['reason']) : (string) $row['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 endif; ?>
@@ -263,7 +270,7 @@ endif; ?>
<?php
printf(
esc_html__('余额 %s', 'aksrt'),
esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format((float) $row['balance_after']) : number_format_i18n((float) $row['balance_after'], 2))
esc_html(\AKSRT\Ledger\AssetAmount::from_minor(\AKSRT\Ledger\AssetType::BALANCE, (int) $row['balance_after_minor'])->formatted())
);
?>
</span>
@@ -39,7 +39,14 @@ $page_url = static function (int $target_page) use ($base_url): string {
);
};
$format = static function ($amount, string $unit): string {
return number_format_i18n((float) $amount, $unit === 'points' ? 0 : 2);
if ($unit === 'points') {
return aksrt_format_points(max(0, (int) $amount));
}
try {
return \AKSRT\Ledger\AssetAmount::balance(is_string($amount) ? $amount : '')->formatted();
} catch (\InvalidArgumentException $e) {
return '0.00';
}
};
$note = trim((string) ($settings['note'] ?? ''));
if ($note === '') {
@@ -77,17 +77,15 @@ if ($show_wallet || $show_credits) :
// Render only the ledger portion by reusing balance log markup.
$user_id = (int) ($user_id ?? 0);
$wallet_page = max(1, isset($_GET['wallet_page']) ? (int) $_GET['wallet_page'] : 1);
$wlog = class_exists('\AKSRT\Credits\Balance')
? \AKSRT\Credits\Balance::get_log(['user_id' => $user_id, 'page' => $wallet_page, 'per_page' => 10])
: ['items' => [], 'total' => 0];
$wlog = \AKSRT\Ledger\LedgerQuery::get_instance()->history(['user_id' => $user_id, 'asset' => 'balance', 'page' => $wallet_page, 'per_page' => 10]);
?>
<div class="uc-transactions uc-transactions--wallet">
<?php if (!empty($wlog['items'])) : ?>
<div class="uc-transactions__list">
<?php foreach ($wlog['items'] as $row) :
$delta = (float) $row['delta'];
$delta = (int) $row['delta_minor'];
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
$delta_txt = ($delta > 0 ? '+' : '') . (class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($delta) : number_format_i18n($delta, 2));
$delta_txt = ($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); ?>">
@@ -95,7 +93,7 @@ if ($show_wallet || $show_credits) :
</div>
<div class="uc-transactions__info">
<div class="uc-transactions__reason">
<?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::reason_label((string) $row['reason']) : (string) $row['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 endif; ?>
@@ -104,7 +102,9 @@ if ($show_wallet || $show_credits) :
</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(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format((float) ($row['balance_after'] ?? 0)) : number_format_i18n((float) ($row['balance_after'] ?? 0), 2))); ?></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; ?>
@@ -111,9 +111,16 @@ $tabs = [
<?php foreach ($orders as $order) :
$number = (string) ($order['order_number'] ?? '');
$actions = (array) ($order['allowed_actions'] ?? []);
$amount = !empty($order['is_points'])
? esc_html((string) ($order['currency_symbol'] ?? __('积分', 'aksrt')) . ' ' . (string) (int) round((float) ($order['amount'] ?? 0)))
: '¥' . esc_html(number_format((float) ($order['amount'] ?? 0), 2));
if (!empty($order['is_points'])) {
$amount = esc_html((string) ($order['currency_symbol'] ?? __('积分', 'aksrt')) . ' ' . (string) max(0, (int) ($order['amount'] ?? 0)));
} else {
try {
$order_amount = \AKSRT\Ledger\AssetAmount::balance(is_string($order['amount'] ?? null) ? $order['amount'] : '')->formatted();
} catch (\InvalidArgumentException $e) {
$order_amount = '0.00';
}
$amount = '¥' . esc_html($order_amount);
}
?>
<article class="aksrt-orders-page__card" data-aksrt-order-card="<?php echo esc_attr($number); ?>" data-order-status="<?php echo esc_attr((string) ($order['status_group'] ?? '')); ?>">
<div class="aksrt-orders-page__card-rail"><span><?php echo esc_html((string) ($order['product_type_label'] ?? '')); ?></span><time><?php echo esc_html((string) ($order['created_at'] ?? '')); ?></time><span class="aksrt-orders-page__card-status is-<?php echo esc_attr((string) ($order['status_group'] ?? '')); ?>"><?php echo esc_html((string) ($order['status_label'] ?? '')); ?></span></div>
@@ -21,22 +21,34 @@ $affiliate_on = !empty($affiliate['enabled']);
$withdrawal = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_withdrawal_settings()
: [];
$withdraw_on = $affiliate_on
&& class_exists('\AKSRT\Credits\Balance')
&& \AKSRT\Credits\Balance::enabled();
$recharge = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_recharge_settings() : [];
$withdraw_on = $affiliate_on && !empty($recharge['enabled']);
if ($withdraw_on && class_exists('\AKSRT\Settings\Capabilities') && !\AKSRT\Settings\Capabilities::user_can('balance_withdraw', $user_id)) {
$withdraw_on = false;
}
$withdraw_min = max(1, (float) ($withdrawal['min_amount'] ?? 50));
$normalize_balance = static function ($value): \AKSRT\Ledger\AssetAmount {
try {
return \AKSRT\Ledger\AssetAmount::balance(is_string($value) ? $value : '');
} catch (\InvalidArgumentException $e) {
return \AKSRT\Ledger\AssetAmount::balance('0');
}
};
$signed_balance_minor = static function ($value) use ($normalize_balance): int {
$value = is_string($value) ? trim($value) : '';
$negative = str_starts_with($value, '-');
$amount = $normalize_balance($negative ? substr($value, 1) : $value)->minor();
return $negative ? -$amount : $amount;
};
$withdraw_min = $normalize_balance($withdrawal['min_amount'] ?? '50')->decimal();
$commission_stats = class_exists('\AKSRT\Payment\CommissionLedger')
? \AKSRT\Payment\CommissionLedger::get_instance()->overview($user_id)
: ['total' => 0, 'pending' => 0, 'settled' => 0, 'wallet' => 0];
$pending_commission = (float) ($commission_stats['pending'] ?? 0);
$pending_commission = $normalize_balance($commission_stats['pending'] ?? '0')->decimal();
$vip_ratios = [];
$commission_ratio = class_exists('\AKSRT\Settings\Settings')
? (float) \AKSRT\Settings\Settings::affiliate_ratio_for_user($user_id)
: 0.0;
? (int) \AKSRT\Settings\Settings::affiliate_ratio_for_user($user_id)
: 0;
$details_text = trim((string) ($affiliate['promotion_text'] ?? ''));
if ($details_text === '') {
$details_text = __('好友通过推广链接完成符合条件的订单后,系统会按当前佣金比例记录返佣,结算后进入可提现余额。', 'aksrt');
@@ -56,8 +68,8 @@ $base_url = function_exists('aksrt_get_user_center_tab_url')
$reward_url = static function (string $tab, array $extra = []) use ($base_url): string {
return add_query_arg(array_merge(['reward_tab' => $tab], $extra), $base_url);
};
$format_amount = static function ($amount): string {
return number_format_i18n((float) $amount, 2);
$format_amount = static function ($amount) use ($normalize_balance): string {
return $normalize_balance($amount)->formatted();
};
$commission_page = max(1, (int) ($revenue_request['commission_page'] ?? ($_GET['commission_page'] ?? 1)));
@@ -151,7 +163,11 @@ $status_labels = [
$source_user = !empty($item['source_user_id']) ? get_userdata((int) $item['source_user_id']) : null;
$source_name = $source_user instanceof WP_User ? $source_user->display_name : __('推广用户', 'aksrt');
?>
<article class="uc-commission-row"><span class="uc-commission-row__icon"><i class="fa fas fa-file-alt" aria-hidden="true"></i></span><div class="uc-commission-row__main"><strong><?php echo esc_html($source_name); ?></strong><span><?php printf(esc_html__('订单 %s', 'aksrt'), esc_html((string) ($item['order_number'] ?? '-'))); ?></span><time><?php echo esc_html((string) ($item['created_at'] ?? '')); ?></time></div><div class="uc-commission-row__value"><strong><?php echo esc_html($format_amount((float) ($item['original_amount'] ?? 0) + (float) ($item['adjustment_total'] ?? 0))); ?></strong><span class="is-<?php echo esc_attr($status); ?>"><?php echo esc_html($status_labels[$status] ?? $status); ?></span></div></article>
<?php
$commission_minor = $signed_balance_minor($item['original_amount'] ?? '0') + $signed_balance_minor($item['adjustment_total'] ?? '0');
$commission_amount = \AKSRT\Ledger\AssetAmount::decimal_from_minor(max(0, $commission_minor));
?>
<article class="uc-commission-row"><span class="uc-commission-row__icon"><i class="fa fas fa-file-alt" aria-hidden="true"></i></span><div class="uc-commission-row__main"><strong><?php echo esc_html($source_name); ?></strong><span><?php printf(esc_html__('订单 %s', 'aksrt'), esc_html((string) ($item['order_number'] ?? '-'))); ?></span><time><?php echo esc_html((string) ($item['created_at'] ?? '')); ?></time></div><div class="uc-commission-row__value"><strong><?php echo esc_html($format_amount($commission_amount)); ?></strong><span class="is-<?php echo esc_attr($status); ?>"><?php echo esc_html($status_labels[$status] ?? $status); ?></span></div></article>
<?php endforeach; ?>
</div>
<?php if ($commission_total_pages > 1) : ?><nav class="uc-reward-pagination" aria-label="<?php esc_attr_e('佣金明细分页', 'aksrt'); ?>"><?php for ($i = 1; $i <= $commission_total_pages; $i++) : ?><a class="<?php echo $i === $commission_page ? 'is-active' : ''; ?>" href="<?php echo esc_url($reward_url('orders', ['commission_page' => $i])); ?>"><?php echo esc_html((string) $i); ?></a><?php endfor; ?></nav><?php endif; ?>
@@ -14,15 +14,19 @@ if (!$show_wallet && !$show_credits) {
}
$assets_url = aksrt_get_user_center_tab_url('credits');
$wallet = (float) ($wallet_balance ?? 0);
$points = (float) ($credit_balance ?? 0);
try {
$wallet = \AKSRT\Ledger\AssetAmount::balance(is_string($wallet_balance ?? null) ? $wallet_balance : '')->formatted();
} catch (\InvalidArgumentException $e) {
$wallet = '0.00';
}
$points = max(0, (int) ($credit_balance ?? 0));
?>
<div class="uc-sidebar__pair uc-sidebar__pair--assets">
<?php if ($show_wallet) : ?>
<a class="uc-summary-card uc-summary-card--wallet" href="<?php echo esc_url($assets_url); ?>" data-tab="credits">
<span class="uc-summary-card__head"><?php esc_html_e('账户余额', 'aksrt'); ?><i class="fa fas fa-angle-right" aria-hidden="true"></i></span>
<span class="uc-summary-card__body">
<strong><?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($wallet) : number_format_i18n($wallet, 2)); ?></strong>
<strong><?php echo esc_html($wallet); ?></strong>
<i class="fa fas fa-money-bill" aria-hidden="true"></i>
</span>
</a>
@@ -31,7 +35,7 @@ $points = (float) ($credit_balance ?? 0);
<a class="uc-summary-card uc-summary-card--points" href="<?php echo esc_url($assets_url); ?>" data-tab="credits">
<span class="uc-summary-card__head"><?php echo esc_html((string) ($currency_name ?? __('积分', 'aksrt'))); ?><i class="fa fas fa-angle-right" aria-hidden="true"></i></span>
<span class="uc-summary-card__body">
<strong><?php echo esc_html(function_exists('aksrt_format_credits') ? aksrt_format_credits((int) $points) : number_format_i18n((int) $points)); ?></strong>
<strong><?php echo esc_html(aksrt_format_points($points)); ?></strong>
<i class="fa fas fa-money-bill" aria-hidden="true"></i>
</span>
</a>
@@ -6,8 +6,12 @@ if (!empty($GLOBALS['aksrt_withdraw_modal_rendered'])) {
return;
}
$GLOBALS['aksrt_withdraw_modal_rendered'] = true;
$withdraw_min = max(0, (float) ($withdraw_min ?? 50));
$withdraw_usage = is_array($withdraw_usage ?? null) ? $withdraw_usage : ['remaining_count' => 0, 'remaining_amount' => 0];
try {
$withdraw_min = \AKSRT\Ledger\AssetAmount::balance(is_string($withdraw_min ?? null) ? $withdraw_min : '')->decimal();
} catch (\InvalidArgumentException $e) {
$withdraw_min = '0.00';
}
$withdraw_usage = is_array($withdraw_usage ?? null) ? $withdraw_usage : ['remaining_count' => 0, 'remaining_amount' => '0.00'];
$withdraw_fee_rate = (int) ($withdraw_settings['service_charge_rate'] ?? 5);
$withdraw_channels = array_values(array_intersect(['alipay', 'wechat'], (array) ($withdraw_settings['payout_channels'] ?? ['alipay', 'wechat'])));
if (!$withdraw_channels) {
@@ -21,8 +25,8 @@ if (!$withdraw_channels) {
<h3 class="uc-modal__title"><?php esc_html_e('余额提现', 'aksrt'); ?></h3>
<form data-aksrt-withdraw-form>
<label class="muted-color em09"><?php esc_html_e('提现金额', 'aksrt'); ?></label>
<input type="number" class="uc-card-pass__input" name="amount" min="<?php echo esc_attr((string) $withdraw_min); ?>" max="<?php echo esc_attr((string) ($withdraw_usage['remaining_amount'] ?? 0)); ?>" step="1" inputmode="numeric" data-aksrt-withdraw-amount data-withdraw-min="<?php echo esc_attr((string) $withdraw_min); ?>" data-withdraw-remaining-amount="<?php echo esc_attr((string) ($withdraw_usage['remaining_amount'] ?? 0)); ?>" data-withdraw-remaining-count="<?php echo esc_attr((string) ($withdraw_usage['remaining_count'] ?? 0)); ?>">
<p class="muted-2-color em09 mt6"><?php printf(esc_html__('最低提现%s 元,今日可提现%d次,提现手续费率%d%%', 'aksrt'), esc_html((string) $withdraw_min), (int) ($withdraw_usage['remaining_count'] ?? 0), $withdraw_fee_rate); ?></p>
<input type="number" class="uc-card-pass__input" name="amount" min="<?php echo esc_attr($withdraw_min); ?>" max="<?php echo esc_attr((string) ($withdraw_usage['remaining_amount'] ?? '0.00')); ?>" step="0.01" inputmode="decimal" data-aksrt-withdraw-amount data-withdraw-min="<?php echo esc_attr($withdraw_min); ?>" data-withdraw-remaining-amount="<?php echo esc_attr((string) ($withdraw_usage['remaining_amount'] ?? '0.00')); ?>" data-withdraw-remaining-count="<?php echo esc_attr((string) ($withdraw_usage['remaining_count'] ?? 0)); ?>">
<p class="muted-2-color em09 mt6"><?php printf(esc_html__('最低提现%s 元,今日可提现%d次,提现手续费率%d%%', 'aksrt'), esc_html($withdraw_min), (int) ($withdraw_usage['remaining_count'] ?? 0), $withdraw_fee_rate); ?></p>
<label class="muted-color em09 mt10"><?php esc_html_e('收款方式', 'aksrt'); ?></label>
<select class="uc-card-pass__input" name="method" data-aksrt-withdraw-method>
<?php foreach ($withdraw_channels as $channel) : ?>