fix(pay): refund wallet on withdraw reject and show pending history

Close the freeze/refund loop when admin rejects a balance withdrawal,
block concurrent open applications, and surface processing state plus
server-rendered withdraw history on the wallet card.
This commit is contained in:
kate522 committed 2026-07-16 16:28:56 +08:00
1 parent d57fc6f934
commit 4da003663d
6 files changed
+514 -136

No files matched your search

@@ -26,6 +26,14 @@ $exchange_on = !empty($recharge['exchange']['enabled']);
$all_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_all() : [];
$withdraw_on = !empty($all_settings['pay_balance_withdraw_s']);
$withdraw_min = max(1, (float) ($all_settings['pay_balance_withdraw_lowest_money'] ?? $all_settings['pay_rebate_withdraw_lowest_money'] ?? 50));
$withdraw_pending_hold = 0.0;
$withdraw_history = [];
if ($withdraw_on && class_exists('AKSRT_Withdrawal')) {
$wd_svc = AKSRT_Withdrawal::get_instance();
$withdraw_pending_hold = $wd_svc->sum_pending_hold((int) ($user_id ?? 0));
$withdraw_history = $wd_svc->get_user_withdrawals((int) ($user_id ?? 0), ['limit' => 30]);
}
$withdraw_processing = $withdraw_pending_hold > 0;
$card_pass_balance = ['enabled' => false, 'desc' => '', 'only_password' => true];
if (class_exists('AKSRT_Charge_Card')) {
$opts = AKSRT_Charge_Card::get_instance()->get_public_options();
@@ -49,6 +57,12 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<div class="uc-asset-card__title">
<i class="fas fa-wallet em12 mr6" aria-hidden="true"></i><?php esc_html_e('余额', 'aksrt'); ?>
</div>
<?php if ($withdraw_on) : ?>
<button type="button" class="uc-asset-card__head-action muted-color px12" data-aksrt-withdraw-history-open>
<?php echo $withdraw_processing ? esc_html__('提现处理中', 'aksrt') : esc_html__('提现记录', 'aksrt'); ?>
<i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
</button>
<?php endif; ?>
</div>
<div class="uc-asset-card__body flex jsb ac">
<div class="uc-asset-card__amount c-blue-2">
@@ -60,7 +74,11 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<button type="button" class="but c-blue-2 mr6 hollow" data-aksrt-transfer-open="balance"><?php esc_html_e('转账', 'aksrt'); ?></button>
<?php endif; ?>
<?php if ($withdraw_on) : ?>
<button type="button" class="but c-blue-2 mr6 hollow" data-aksrt-withdraw-open><?php esc_html_e('提现', 'aksrt'); ?></button>
<?php if ($withdraw_processing) : ?>
<button type="button" class="but c-blue-2 mr6 hollow" data-aksrt-withdraw-history-open><?php esc_html_e('提现处理中', 'aksrt'); ?></button>
<?php else : ?>
<button type="button" class="but c-blue-2 mr6 hollow" data-aksrt-withdraw-open><?php esc_html_e('提现', 'aksrt'); ?></button>
<?php endif; ?>
<?php endif; ?>
<button type="button" class="but b-blue-2" data-aksrt-charge-open><?php esc_html_e('充值', 'aksrt'); ?></button>
</div>
@@ -74,6 +92,12 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
</button>
<?php endif; ?>
<?php if ($withdraw_on) : ?>
<div class="uc-asset-card__foot muted-2-color em09 flex jsb ac mt6">
<span><?php printf(esc_html__('处理中冻结 %s', 'aksrt'), esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format((float) $withdraw_pending_hold) : number_format_i18n((float) $withdraw_pending_hold, 2))); ?></span>
<button type="button" class="muted-color" data-aksrt-withdraw-history-open><?php esc_html_e('提现记录', 'aksrt'); ?></button>
</div>
<?php endif; ?>
</div>
<?php if (!empty($card_pass_balance['enabled'])) : ?>
@@ -231,6 +255,53 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
</div>
<?php endif; ?>
<?php if ($withdraw_on) :
$status_labels = [
'pending' => __('待处理', 'aksrt'),
'approved' => __('已通过', 'aksrt'),
'processing' => __('处理中', 'aksrt'),
'completed' => __('已完成', 'aksrt'),
'rejected' => __('已拒绝', 'aksrt'),
];
?>
<div class="uc-modal" id="aksrt-withdraw-history-modal" hidden data-aksrt-withdraw-history-modal>
<div class="uc-modal__overlay" data-aksrt-withdraw-history-close></div>
<div class="uc-modal__dialog" role="dialog" aria-modal="true">
<button type="button" class="uc-modal__close" data-aksrt-withdraw-history-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
<h3 class="uc-modal__title"><i class="fas fa-file-invoice-dollar mr6" aria-hidden="true"></i><?php esc_html_e('提现记录', 'aksrt'); ?></h3>
<div class="uc-withdraw-history">
<?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);
$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_Balance') ? AKSRT_Balance::format($gross) : number_format_i18n($gross, 2)); ?></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_Balance') ? AKSRT_Balance::format($net) : number_format_i18n($net, 2))); ?>
<?php endif; ?>
</div>
<?php if (!empty($wd['note'])) : ?>
<div class="muted-2-color em09 mt3"><?php echo esc_html((string) $wd['note']); ?></div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="uc-transactions__empty"><p><?php esc_html_e('暂无提现记录', 'aksrt'); ?></p></div>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if (empty($skip_wallet_ledger)) : ?>
<div class="uc-transactions uc-transactions--wallet">
<div class="uc-transactions__header">