feat(pay): capability gates for transfer and withdraw
AND feature flags with user_caps balance_transfer / points_transfer / balance_withdraw on REST and user-center buttons.
This commit is contained in:
1 parent
9b98080daf
commit
c45a0ecef5
4 files changed
+21
No files matched your search
@@ -19,7 +19,11 @@ if (class_exists('AKSRT_Charge_Card')) {
|
||||
$card_pass_credits = is_array($opts['credits'] ?? null) ? $opts['credits'] : $card_pass_credits;
|
||||
}
|
||||
$all_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_all() : [];
|
||||
$points_uid = (int) ($user_id ?? get_current_user_id());
|
||||
$points_transfer_on = !empty($all_settings['points_transfer_s']);
|
||||
if ($points_transfer_on && class_exists('AKSRT_Settings_Capabilities') && !AKSRT_Settings_Capabilities::user_can('points_transfer', $points_uid)) {
|
||||
$points_transfer_on = false;
|
||||
}
|
||||
$points_buy_on = class_exists('AKSRT_Balance_Service') && AKSRT_Balance_Service::get_instance()->points_buy_enabled();
|
||||
$points_buy_view = $points_buy_on ? AKSRT_Balance_Service::get_instance()->get_points_buy_view((int) ($user_id ?? 0)) : [];
|
||||
$currency = (string) ($currency_name ?? __('积分', 'aksrt'));
|
||||
|
||||
@@ -21,10 +21,17 @@ $wallet_fmt = class_exists('AKSRT_Balance')
|
||||
$recharge = class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_payment_recharge_settings')
|
||||
? AKSRT_Settings::get_payment_recharge_settings()
|
||||
: [];
|
||||
$uid = (int) ($user_id ?? get_current_user_id());
|
||||
$transfer_on = !empty($recharge['transfer']['enabled']);
|
||||
if ($transfer_on && class_exists('AKSRT_Settings_Capabilities') && !AKSRT_Settings_Capabilities::user_can('balance_transfer', $uid)) {
|
||||
$transfer_on = false;
|
||||
}
|
||||
$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']);
|
||||
if ($withdraw_on && class_exists('AKSRT_Settings_Capabilities') && !AKSRT_Settings_Capabilities::user_can('balance_withdraw', $uid)) {
|
||||
$withdraw_on = false;
|
||||
}
|
||||
$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 = [];
|
||||
|
||||
Reference in new issue
Block a user