fix(payment): wire balance wallet end-to-end when pay_balance_s is on

Opening 余额功能 alone now enables cash-wallet pay (unless 余额支付 is explicitly off). Drop points-as-balance fallback, stop fake method injection, expose real wallet in cashiers, and honor auto_to_balance on recharge fulfill.
This commit is contained in:
2026-07-25 12:46:38 +08:00
parent c85774f9a0
commit 3267bee71e
12 changed files with 109 additions and 105 deletions
+29 -12
View File
@@ -548,18 +548,35 @@
}
body += '</div>';
}
let methodHtml = '';
methods.forEach(function (m, idx) {
const id = escapeAttr(m.id || '');
const name = escapeHtml(m.name || id);
methodHtml += '<label class="aksrt-cashier__method"><input type="radio" name="aksrt_pay_method" value="' + id + '"' + (idx === 0 ? ' checked' : '') + '> <span>' + name + '</span></label>';
});
if (methodHtml) {
body += '<div class="aksrt-cashier__methods"><div class="aksrt-cashier__methods-title">' + tt('pay_method', '支付方式') + '</div>' + methodHtml + '</div>';
}
body += '<div class="aksrt-dl-modal__actions">';
body += '<button type="button" class="btn-primary aksrt-dl-modal__download" data-aksrt-pay-submit data-mode="cash" data-price-type="' + escapeAttr(priceType) + '">' + tt('pay_now', '立即支付') + ' ' + amountLabel + '</button>';
body += '</div>';
const walletBal = typeof preview.wallet_balance === 'number'
? preview.wallet_balance
: (typeof preview.balance === 'number' ? preview.balance : 0);
const hasBalanceMethod = methods.some(function (m) { return (m && m.id) === 'balance'; });
if (hasBalanceMethod) {
body += '<div class="aksrt-cashier__box"><div class="aksrt-cashier__row"><span>' + tt('my_wallet', '我的余额') + '</span><b class="is-ok">¥' + Number(walletBal).toFixed(2) + '</b></div></div>';
if (preview.balance_enough === false) {
body += '<div class="aksrt-cashier__warn">' + tt('wallet_short', '余额不足,请先充值或选择其他支付方式') + '</div>';
if (preview.credits_url) {
body += '<div class="aksrt-dl-modal__actions"><a class="btn-sm" href="' + escapeAttr(preview.credits_url) + '">' + tt('go_recharge', '去充值') + '</a></div>';
}
}
}
let methodHtml = '';
methods.forEach(function (m, idx) {
const id = escapeAttr(m.id || '');
const name = escapeHtml(m.name || id);
methodHtml += '<label class="aksrt-cashier__method"><input type="radio" name="aksrt_pay_method" value="' + id + '"' + (idx === 0 ? ' checked' : '') + '> <span>' + name + '</span></label>';
});
if (methodHtml) {
body += '<div class="aksrt-cashier__methods"><div class="aksrt-cashier__methods-title">' + tt('pay_method', '支付方式') + '</div>' + methodHtml + '</div>';
} else {
body += '<div class="aksrt-cashier__warn">' + tt('no_pay_method', '暂无可用支付方式,请联系站长配置收款接口') + '</div>';
}
body += '<div class="aksrt-dl-modal__actions">';
if (methodHtml) {
body += '<button type="button" class="btn-primary aksrt-dl-modal__download" data-aksrt-pay-submit data-mode="cash" data-price-type="' + escapeAttr(priceType) + '">' + tt('pay_now', '立即支付') + ' ' + amountLabel + '</button>';
}
body += '</div>';
}
open('<h3 class="aksrt-dl-modal__title">' + tt('confirm_buy', '确认购买') + '</h3>' + body, returnFocusEl);