Merge pull request 'fix(payment): align plate-follow cash preview with wallet balance' (#290) from worktree-fix-balance-chain into main

Reviewed-on: CYL/wordpress-theme-aksrt#290
This commit is contained in:
kate522 committed 2026-07-25 13:15:07 +08:00
commit 85ade059a2
2 files changed
+9 -11

No files matched your search

+2 -3
View File
@@ -86,9 +86,8 @@ if (!function_exists('aksrt_list_cash_payment_methods')) {
: ['alipay', 'wechatpay', 'paypal', 'stripe']; : ['alipay', 'wechatpay', 'paypal', 'stripe'];
if (!class_exists('\AKSRT\Payment\Gateway')) { if (!class_exists('\AKSRT\Payment\Gateway')) {
return $logged_in // No gateway manager → no real methods (avoid dead balance/alipay stubs).
? [['id' => 'balance', 'name' => __('站内余额', 'aksrt')]] return [];
: [['id' => 'alipay', 'name' => __('支付宝', 'aksrt')]];
} }
$methods = []; $methods = [];
+7 -8
View File
@@ -188,16 +188,14 @@ class PlateFollowPay {
} }
$has_followed = $this->user_has_followed($uid, $plate_id); $has_followed = $this->user_has_followed($uid, $plate_id);
$balance = 0; $wallet_balance = 0.0;
if ($uid > 0 && class_exists('\AKSRT\Credits\Credits')) { if ($uid > 0 && class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled()) {
$balance = (int) \AKSRT\Credits\Credits::balance($uid); $wallet_balance = (float) \AKSRT\Credits\Balance::balance($uid);
} }
$methods = function_exists('aksrt_list_cash_payment_methods') $methods = function_exists('aksrt_list_cash_payment_methods')
? aksrt_list_cash_payment_methods($uid > 0) ? aksrt_list_cash_payment_methods($uid > 0)
: ($uid > 0 : [];
? [['id' => 'balance', 'name' => __('站内余额', 'aksrt')]]
: [['id' => 'alipay', 'name' => __('支付宝', 'aksrt')]]);
$coupon_allowed = $this->is_coupon_allowed($plate_id); $coupon_allowed = $this->is_coupon_allowed($plate_id);
$coupon_error = ''; $coupon_error = '';
@@ -258,8 +256,9 @@ class PlateFollowPay {
'need_vip' => false, 'need_vip' => false,
'need_purchase' => !$has_followed && !$is_free, 'need_purchase' => !$has_followed && !$is_free,
'logged_in' => $uid > 0, 'logged_in' => $uid > 0,
'balance' => $balance, 'balance' => $wallet_balance,
'balance_enough' => true, 'wallet_balance' => $wallet_balance,
'balance_enough' => $is_free || ($wallet_balance + 0.0001 >= (float) $payable),
'payment_methods' => $methods, 'payment_methods' => $methods,
'login_url' => wp_login_url(get_permalink($post)), 'login_url' => wp_login_url(get_permalink($post)),
'vip_url' => home_url('/'), 'vip_url' => home_url('/'),