feat(users): normalize center routes and withdrawal limits
This commit is contained in:
1 parent
9004f7093f
commit
dacd0095bf
24 files changed
+326
-174
No files matched your search
@@ -106,13 +106,7 @@ if (!function_exists('aksrt_get_user_center_tab_url')) {
|
||||
if ('invite' === $tab || 'promotion' === $tab) {
|
||||
$tab = 'revenue';
|
||||
}
|
||||
$url = remove_query_arg([
|
||||
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
|
||||
'post_status', 'creator_page', 'creator_status', 'saved', 'profile_error',
|
||||
'order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'income_currency', 'income_status', 'income_page', 'section',
|
||||
], aksrt_get_user_center_url());
|
||||
|
||||
return add_query_arg('tab', $tab, $url);
|
||||
return aksrt_get_user_center_url($tab);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +276,10 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
|
||||
$default = in_array('vip', $keys, true)
|
||||
? 'vip'
|
||||
: (in_array('profile', $keys, true) ? 'profile' : ($keys[0] ?? 'profile'));
|
||||
$active = isset($_GET['tab']) ? sanitize_key(wp_unslash($_GET['tab'])) : $default;
|
||||
$active = (string) get_query_var('aksrt_user_center_tab') ?: $default;
|
||||
if ($active === 'balance') {
|
||||
$active = 'credits';
|
||||
}
|
||||
if ('signin' === $active || 'assets' === $active) {
|
||||
$active = 'credits';
|
||||
} elseif ('invite' === $active || 'promotion' === $active) {
|
||||
|
||||
@@ -32,13 +32,16 @@ $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_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_history = [];
|
||||
if ($withdraw_on && class_exists('\AKSRT\Payment\Withdrawal')) {
|
||||
$wd_svc = \AKSRT\Payment\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_usage = $wd_svc->daily_usage((int) ($user_id ?? 0), $withdraw_settings);
|
||||
}
|
||||
$withdraw_processing = $withdraw_pending_hold > 0;
|
||||
$card_pass_balance = ['enabled' => false, 'desc' => '', 'only_password' => true];
|
||||
@@ -66,7 +69,7 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
|
||||
</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'); ?>
|
||||
<?php esc_html_e('提现记录', 'aksrt'); ?>
|
||||
<i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
@@ -81,11 +84,7 @@ $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) : ?>
|
||||
<?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; ?>
|
||||
<button type="button" class="but c-blue-2 mr6 hollow" data-aksrt-withdraw-open><?php esc_html_e('提现', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="but b-blue-2" data-aksrt-charge-open><?php esc_html_e('充值', 'aksrt'); ?></button>
|
||||
</div>
|
||||
@@ -100,9 +99,8 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($withdraw_on) : ?>
|
||||
<div class="uc-asset-card__foot muted-2-color em09 flex jsb ac mt6">
|
||||
<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>
|
||||
<button type="button" class="muted-color" data-aksrt-withdraw-history-open><?php esc_html_e('提现记录', 'aksrt'); ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Shared balance withdrawal modal.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
/** Shared balance withdrawal modal. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!empty($GLOBALS['aksrt_withdraw_modal_rendered'])) {
|
||||
return;
|
||||
}
|
||||
$GLOBALS['aksrt_withdraw_modal_rendered'] = true;
|
||||
|
||||
$withdraw_min = max(1, (float) ($withdraw_min ?? 50));
|
||||
$wallet_fmt = (string) ($wallet_fmt ?? '0.00');
|
||||
$withdraw_min = max(0, (float) ($withdraw_min ?? 50));
|
||||
$withdraw_usage = is_array($withdraw_usage ?? null) ? $withdraw_usage : ['remaining_count' => 0, 'remaining_amount' => 0];
|
||||
$withdraw_fee_rate = (int) ($withdraw_settings['service_charge_rate'] ?? 5);
|
||||
?>
|
||||
<div class="uc-modal" id="aksrt-withdraw-modal" hidden data-aksrt-withdraw-modal>
|
||||
<div class="uc-modal__overlay" data-aksrt-withdraw-close></div>
|
||||
@@ -22,16 +17,16 @@ $wallet_fmt = (string) ($wallet_fmt ?? '0.00');
|
||||
<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); ?>" step="0.01" data-aksrt-withdraw-amount>
|
||||
<p class="muted-2-color em09 mt6"><?php printf(esc_html__('最低提现 %s 元,当前余额 %s', 'aksrt'), esc_html((string) $withdraw_min), esc_html($wallet_fmt)); ?></p>
|
||||
<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>
|
||||
<label class="muted-color em09 mt10"><?php esc_html_e('收款方式', 'aksrt'); ?></label>
|
||||
<select class="uc-card-pass__input" name="method" data-aksrt-withdraw-method>
|
||||
<option value="alipay"><?php esc_html_e('支付宝', 'aksrt'); ?></option>
|
||||
<option value="wechat"><?php esc_html_e('微信', 'aksrt'); ?></option>
|
||||
<option value="bank"><?php esc_html_e('银行卡', 'aksrt'); ?></option>
|
||||
</select>
|
||||
<label class="muted-color em09 mt10"><?php esc_html_e('收款账号信息', 'aksrt'); ?></label>
|
||||
<textarea class="uc-card-pass__input" name="account" rows="3" data-aksrt-withdraw-account placeholder="<?php esc_attr_e('姓名 + 账号 / 卡号', 'aksrt'); ?>"></textarea>
|
||||
<label class="muted-color em09 mt10"><?php esc_html_e('收款账户信息', 'aksrt'); ?></label>
|
||||
<textarea class="uc-card-pass__input" name="account" rows="3" data-aksrt-withdraw-account placeholder="<?php esc_attr_e('姓名 + 账户 / 卡号', 'aksrt'); ?>"></textarea>
|
||||
<p class="uc-modal__tip" data-aksrt-withdraw-tip></p>
|
||||
<button type="submit" class="but jb-blue btn-block" data-aksrt-withdraw-submit><?php esc_html_e('提交申请', 'aksrt'); ?></button>
|
||||
</form>
|
||||
|
||||
Reference in new issue
Block a user