feat(users): merge promotion into revenue center
This commit is contained in:
1 parent
156060d2ec
commit
49c12b761f
20 files changed
+369
-413
No files matched your search
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* User center revenue invitation section.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
?>
|
||||
<section class="uc-promotion-panel" aria-labelledby="uc-promotion-title" data-aksrt-invite>
|
||||
<header class="uc-promotion-panel__header">
|
||||
<span class="uc-promotion-panel__icon"><i class="fas fa-user-plus" aria-hidden="true"></i></span>
|
||||
<div>
|
||||
<p class="uc-promotion-panel__eyebrow"><?php esc_html_e('邀请与奖励', 'aksrt'); ?></p>
|
||||
<h3 id="uc-promotion-title"><?php esc_html_e('推广奖励', 'aksrt'); ?></h3>
|
||||
</div>
|
||||
</header>
|
||||
<p class="uc-promotion-panel__intro"><?php esc_html_e('分享专属链接,邀请好友完成注册与验证后即可获得奖励。', 'aksrt'); ?></p>
|
||||
<p class="uc-promotion-panel__status" data-invite-status role="status" aria-live="polite"><?php esc_html_e('正在加载推广数据…', 'aksrt'); ?></p>
|
||||
<section class="uc-promotion-section uc-promotion-section--stats" aria-labelledby="uc-promotion-stats-title"><div class="uc-promotion-section__header"><h4 id="uc-promotion-stats-title"><?php esc_html_e('推广成果', 'aksrt'); ?></h4><p><?php esc_html_e('实时汇总你的邀请进度', 'aksrt'); ?></p></div><div class="uc-promotion-stats" data-invite-stats aria-live="polite"><div class="uc-promotion-stat"><span><?php esc_html_e('已注册', 'aksrt'); ?></span><strong data-stat="registered">—</strong><small><?php esc_html_e('通过链接完成注册', 'aksrt'); ?></small></div><div class="uc-promotion-stat"><span><?php esc_html_e('已验证', 'aksrt'); ?></span><strong data-stat="verified">—</strong><small><?php esc_html_e('已完成邮箱验证', 'aksrt'); ?></small></div><div class="uc-promotion-stat"><span><?php esc_html_e('已奖励', 'aksrt'); ?></span><strong data-stat="rewarded">—</strong><small><?php esc_html_e('奖励已发放', 'aksrt'); ?></small></div></div></section>
|
||||
<section class="uc-promotion-section uc-promotion-section--share" aria-labelledby="uc-promotion-share-title"><div class="uc-promotion-section__header"><h4 id="uc-promotion-share-title"><?php esc_html_e('分享专属链接', 'aksrt'); ?></h4><p><?php esc_html_e('好友通过此链接注册,邀请关系会自动记录。', 'aksrt'); ?></p></div><div class="uc-promotion-share"><div class="uc-promotion-code"><span><?php esc_html_e('我的邀请码', 'aksrt'); ?></span><strong data-invite-code>—</strong></div><label class="screen-reader-text" for="aksrt-invite-link"><?php esc_html_e('推广链接', 'aksrt'); ?></label><div class="uc-promotion-link-row"><input id="aksrt-invite-link" type="text" class="uc-promotion-link" data-invite-link readonly value=""><button type="button" class="btn-primary btn-sm uc-promotion-copy" data-invite-copy disabled><i class="fas fa-copy" aria-hidden="true"></i><span><?php esc_html_e('复制链接', 'aksrt'); ?></span></button></div><p class="uc-promotion-copy-feedback" data-invite-copy-feedback role="status" aria-live="polite"></p></div></section>
|
||||
<section class="uc-promotion-section uc-promotion-section--reward" aria-labelledby="uc-promotion-reward-title"><div class="uc-promotion-section__header"><h4 id="uc-promotion-reward-title"><?php esc_html_e('奖励说明', 'aksrt'); ?></h4></div><p><?php echo esc_html(sprintf(__('邀请好友完成注册与邮箱验证后,双方将按站点规则获得%s奖励。', 'aksrt'), (string) ($currency_name ?? __('积分', 'aksrt')))); ?></p></section>
|
||||
<section class="uc-promotion-section uc-promotion-section--records" aria-labelledby="uc-promotion-records-title"><div class="uc-promotion-section__header uc-promotion-records__header"><div><h4 id="uc-promotion-records-title"><?php esc_html_e('邀请记录', 'aksrt'); ?></h4><p><?php esc_html_e('查看最近邀请好友的状态', 'aksrt'); ?></p></div><span data-invite-total><?php esc_html_e('加载中…', 'aksrt'); ?></span></div><div class="uc-promotion-record-list is-loading" data-invite-list aria-live="polite"><div class="uc-promotion-record-empty"><?php esc_html_e('正在加载邀请记录…', 'aksrt'); ?></div></div></section>
|
||||
</section>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User center promotion panel.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
?>
|
||||
<section class="uc-promotion-panel" aria-labelledby="uc-promotion-title" data-aksrt-invite>
|
||||
<header class="uc-promotion-panel__header">
|
||||
<span class="uc-promotion-panel__icon"><i class="fas fa-user-plus" aria-hidden="true"></i></span>
|
||||
<div>
|
||||
<p class="uc-promotion-panel__eyebrow"><?php esc_html_e('邀请与奖励', 'aksrt'); ?></p>
|
||||
<h2 id="uc-promotion-title"><?php esc_html_e('推广中心', 'aksrt'); ?></h2>
|
||||
</div>
|
||||
</header>
|
||||
<p class="uc-promotion-panel__intro"><?php esc_html_e('分享专属链接,邀请好友完成注册与验证后即可获得奖励。', 'aksrt'); ?></p>
|
||||
|
||||
<div class="uc-promotion-panel__status" data-invite-status role="status" aria-live="polite">
|
||||
<?php esc_html_e('正在加载推广数据…', 'aksrt'); ?>
|
||||
</div>
|
||||
|
||||
<section class="uc-promotion-section uc-promotion-section--stats" aria-labelledby="uc-promotion-stats-title">
|
||||
<div class="uc-promotion-section__header">
|
||||
<h3 id="uc-promotion-stats-title"><?php esc_html_e('推广成果', 'aksrt'); ?></h3>
|
||||
<p><?php esc_html_e('实时汇总你的邀请进度', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<div class="uc-promotion-stats" data-invite-stats aria-live="polite">
|
||||
<div class="uc-promotion-stat">
|
||||
<span><?php esc_html_e('已注册', 'aksrt'); ?></span>
|
||||
<strong data-stat="registered">—</strong>
|
||||
<small><?php esc_html_e('通过链接完成注册', 'aksrt'); ?></small>
|
||||
</div>
|
||||
<div class="uc-promotion-stat">
|
||||
<span><?php esc_html_e('已验证', 'aksrt'); ?></span>
|
||||
<strong data-stat="verified">—</strong>
|
||||
<small><?php esc_html_e('已完成邮箱验证', 'aksrt'); ?></small>
|
||||
</div>
|
||||
<div class="uc-promotion-stat">
|
||||
<span><?php esc_html_e('已奖励', 'aksrt'); ?></span>
|
||||
<strong data-stat="rewarded">—</strong>
|
||||
<small><?php esc_html_e('奖励已发放', 'aksrt'); ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="uc-promotion-section uc-promotion-section--share" aria-labelledby="uc-promotion-share-title">
|
||||
<div class="uc-promotion-section__header">
|
||||
<h3 id="uc-promotion-share-title"><?php esc_html_e('分享专属链接', 'aksrt'); ?></h3>
|
||||
<p><?php esc_html_e('好友通过此链接注册,邀请关系会自动记录。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<div class="uc-promotion-share">
|
||||
<div class="uc-promotion-code">
|
||||
<span><?php esc_html_e('我的邀请码', 'aksrt'); ?></span>
|
||||
<strong data-invite-code>—</strong>
|
||||
</div>
|
||||
<label class="screen-reader-text" for="aksrt-invite-link"><?php esc_html_e('推广链接', 'aksrt'); ?></label>
|
||||
<div class="uc-promotion-link-row">
|
||||
<input id="aksrt-invite-link" type="text" class="uc-promotion-link" data-invite-link readonly value="">
|
||||
<button type="button" class="btn-primary btn-sm uc-promotion-copy" data-invite-copy disabled>
|
||||
<i class="fas fa-copy" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('复制链接', 'aksrt'); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="uc-promotion-copy-feedback" data-invite-copy-feedback role="status" aria-live="polite"></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="uc-promotion-section uc-promotion-section--reward" aria-labelledby="uc-promotion-reward-title">
|
||||
<div class="uc-promotion-section__header">
|
||||
<h3 id="uc-promotion-reward-title"><?php esc_html_e('奖励说明', 'aksrt'); ?></h3>
|
||||
</div>
|
||||
<p><?php echo esc_html(sprintf(__('邀请好友完成注册与邮箱验证后,双方将按站点规则获得%s奖励。', 'aksrt'), (string) ($currency_name ?? __('积分', 'aksrt')))); ?></p>
|
||||
</section>
|
||||
|
||||
<section class="uc-promotion-section uc-promotion-section--records" aria-labelledby="uc-promotion-records-title">
|
||||
<div class="uc-promotion-section__header uc-promotion-records__header">
|
||||
<div>
|
||||
<h3 id="uc-promotion-records-title"><?php esc_html_e('邀请记录', 'aksrt'); ?></h3>
|
||||
<p><?php esc_html_e('查看最近邀请好友的状态', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<span data-invite-total><?php esc_html_e('加载中…', 'aksrt'); ?></span>
|
||||
</div>
|
||||
<div class="uc-promotion-record-list is-loading" data-invite-list aria-live="polite">
|
||||
<div class="uc-promotion-record-empty"><?php esc_html_e('正在加载邀请记录…', 'aksrt'); ?></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* User center revenue panel.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
||||
if ($user_id <= 0) {
|
||||
echo '<div class="uc-panel-empty muted-2-color">' . esc_html__('请先登录', 'aksrt') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
$show_revenue_section = !empty($context['show_revenue_section']);
|
||||
$show_invite_section = !empty($context['show_invite_section']);
|
||||
$revenue_view = function_exists('aksrt_get_revenue_page_view')
|
||||
? aksrt_get_revenue_page_view($user_id)
|
||||
: ['balance' => 0, 'total_earned' => 0, 'total_withdrawn' => 0, 'records' => []];
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_withdrawal_settings() : [];
|
||||
$min_amount = (float) ($settings['min_amount'] ?? 50);
|
||||
$fee_rate = (float) ($settings['service_charge_rate'] ?? 0);
|
||||
$withdraw_text = (string) ($settings['text'] ?? '');
|
||||
$withdrawals = class_exists('\AKSRT\Payment\Withdrawal')
|
||||
? \AKSRT\Payment\Withdrawal::get_instance()->get_user_withdrawals($user_id, ['limit' => 20])
|
||||
: [];
|
||||
$records = (array) ($revenue_view['records'] ?? []);
|
||||
$page = max(1, isset($_GET['rev_page']) ? (int) $_GET['rev_page'] : 1);
|
||||
$per_page = 20;
|
||||
$total_pages = max(1, (int) ceil(max(1, count($records)) / $per_page));
|
||||
$paged_records = array_slice($records, ($page - 1) * $per_page, $per_page);
|
||||
$revenue_url = static function (int $target_page): string {
|
||||
$url = function_exists('aksrt_get_user_center_tab_url') ? aksrt_get_user_center_tab_url('revenue') : home_url('/profile/?tab=revenue');
|
||||
return $target_page > 1 ? add_query_arg('rev_page', $target_page, $url) : $url;
|
||||
};
|
||||
?>
|
||||
<div class="aksrt-revenue-page uc-revenue-panel" data-aksrt-revenue-page data-min-amount="<?php echo esc_attr((string) $min_amount); ?>" data-fee-rate="<?php echo esc_attr((string) $fee_rate); ?>">
|
||||
<header class="uc-revenue-panel__header">
|
||||
<p><?php esc_html_e('账户收益', 'aksrt'); ?></p>
|
||||
<h2><?php esc_html_e('收益中心', 'aksrt'); ?></h2>
|
||||
<span><?php esc_html_e('查看分成明细、余额与邀请奖励。', 'aksrt'); ?></span>
|
||||
</header>
|
||||
|
||||
<?php if ($show_revenue_section) : ?>
|
||||
<div class="aksrt-revenue-page__stats" aria-label="<?php esc_attr_e('收益概览', 'aksrt'); ?>">
|
||||
<div class="aksrt-revenue-page__stat-card"><div class="aksrt-revenue-page__stat-icon"><i class="fas fa-wallet" aria-hidden="true"></i></div><div class="aksrt-revenue-page__stat-info"><strong class="aksrt-revenue-page__stat-value" data-aksrt-revenue-balance>¥<?php echo esc_html(number_format_i18n((float) ($revenue_view['balance'] ?? 0), 2)); ?></strong><span class="aksrt-revenue-page__stat-label"><?php esc_html_e('可提现余额', 'aksrt'); ?></span></div></div>
|
||||
<div class="aksrt-revenue-page__stat-card"><div class="aksrt-revenue-page__stat-icon"><i class="fas fa-chart-line" aria-hidden="true"></i></div><div class="aksrt-revenue-page__stat-info"><strong class="aksrt-revenue-page__stat-value">¥<?php echo esc_html(number_format_i18n((float) ($revenue_view['total_earned'] ?? 0), 2)); ?></strong><span class="aksrt-revenue-page__stat-label"><?php esc_html_e('累计收益', 'aksrt'); ?></span></div></div>
|
||||
<div class="aksrt-revenue-page__stat-card"><div class="aksrt-revenue-page__stat-icon"><i class="fas fa-money-check-alt" aria-hidden="true"></i></div><div class="aksrt-revenue-page__stat-info"><strong class="aksrt-revenue-page__stat-value">¥<?php echo esc_html(number_format_i18n((float) ($revenue_view['total_withdrawn'] ?? 0), 2)); ?></strong><span class="aksrt-revenue-page__stat-label"><?php esc_html_e('已提现', 'aksrt'); ?></span></div></div>
|
||||
</div>
|
||||
<div class="aksrt-revenue-page__layout">
|
||||
<section class="aksrt-revenue-page__panel"><h3><?php esc_html_e('申请提现', 'aksrt'); ?></h3><?php if ($withdraw_text !== '') : ?><div class="aksrt-revenue-page__note"><?php echo wp_kses_post(wpautop($withdraw_text)); ?></div><?php endif; ?><form class="aksrt-revenue-page__withdraw-form" data-aksrt-withdraw-form><label><span><?php esc_html_e('提现金额', 'aksrt'); ?></span><input type="number" name="amount" min="<?php echo esc_attr((string) $min_amount); ?>" step="0.01" required></label><label><span><?php esc_html_e('提现方式', 'aksrt'); ?></span><select name="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><label><span><?php esc_html_e('收款账户信息', 'aksrt'); ?></span><textarea name="account_info" rows="3" required></textarea></label><p class="aksrt-revenue-page__fee-hint"><?php printf(esc_html__('手续费 %s%%', 'aksrt'), esc_html((string) $fee_rate)); ?></p><button type="submit" class="btn-primary"><?php esc_html_e('提交提现申请', 'aksrt'); ?></button><p class="aksrt-revenue-page__form-msg" data-aksrt-withdraw-msg hidden></p></form></section>
|
||||
<section class="aksrt-revenue-page__panel"><h3><?php esc_html_e('提现记录', 'aksrt'); ?></h3><div class="aksrt-revenue-page__list" data-aksrt-withdraw-list><?php if ($withdrawals) : foreach ($withdrawals as $withdrawal) : ?><div class="aksrt-revenue-page__item"><div><strong>¥<?php echo esc_html(number_format_i18n((float) ($withdrawal['amount'] ?? 0), 2)); ?></strong><span><?php echo esc_html((string) ($withdrawal['method'] ?? '')); ?></span></div><div><span><?php echo esc_html((string) ($withdrawal['status'] ?? '')); ?></span><time><?php echo esc_html((string) ($withdrawal['created_at'] ?? '')); ?></time></div></div><?php endforeach; else : ?><p class="aksrt-revenue-page__empty"><?php esc_html_e('暂无提现记录', 'aksrt'); ?></p><?php endif; ?></div></section>
|
||||
</div>
|
||||
<section class="aksrt-revenue-page__section"><h3><?php esc_html_e('收益明细', 'aksrt'); ?></h3><?php if ($paged_records) : ?><div class="aksrt-revenue-page__list"><?php foreach ($paged_records as $record) : ?><div class="aksrt-revenue-page__item"><div><strong><?php echo esc_html((string) ($record['title'] ?? '')); ?></strong><time><?php echo esc_html((string) ($record['created_at'] ?? '')); ?></time></div><span class="<?php echo ($record['type'] ?? '') === 'withdrawal' ? 'is-out' : 'is-in'; ?>"><?php echo ($record['type'] ?? '') === 'withdrawal' ? '-' : '+'; ?>¥<?php echo esc_html(number_format_i18n((float) ($record['amount'] ?? 0), 2)); ?></span></div><?php endforeach; ?></div><?php if ($total_pages > 1) : ?><nav class="aksrt-revenue-page__pagination" aria-label="<?php esc_attr_e('收益分页', 'aksrt'); ?>"><?php for ($index = 1; $index <= $total_pages; $index++) : ?><a class="aksrt-revenue-page__page-chip<?php echo $index === $page ? ' is-active' : ''; ?>" href="<?php echo esc_url($revenue_url($index)); ?>"><?php echo esc_html((string) $index); ?></a><?php endfor; ?></nav><?php endif; ?><?php else : ?><p class="aksrt-revenue-page__empty"><?php esc_html_e('暂无收益明细', 'aksrt'); ?></p><?php endif; ?></section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($show_invite_section) : require __DIR__ . '/profile-invite.php'; endif; ?>
|
||||
</div>
|
||||
@@ -26,9 +26,9 @@ if ($creation_url === '' && $revenue_url === '') {
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($revenue_url !== '') : ?>
|
||||
<a class="uc-center-card uc-center-card--promotion" href="<?php echo esc_url($revenue_url); ?>">
|
||||
<a class="uc-center-card uc-center-card--revenue" href="<?php echo esc_url($revenue_url); ?>">
|
||||
<span class="uc-center-card__icon"><i class="fas fa-chart-line" aria-hidden="true"></i></span>
|
||||
<span><strong><?php esc_html_e('收益中心', 'aksrt'); ?></strong><small><?php esc_html_e('返佣与收益', 'aksrt'); ?></small></span>
|
||||
<span><strong><?php esc_html_e('收益中心', 'aksrt'); ?></strong><small><?php esc_html_e('邀请、返佣与收益', 'aksrt'); ?></small></span>
|
||||
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -11,7 +11,6 @@ $level_url = isset($dashboard_tabs['level'])
|
||||
? aksrt_get_user_center_tab_url('level')
|
||||
: '';
|
||||
$auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : '';
|
||||
$promotion_url = isset($dashboard_tabs['promotion']) ? aksrt_get_user_center_tab_url('promotion') : '';
|
||||
$orders_available = isset($dashboard_tabs['orders']);
|
||||
$orders_url = $orders_available ? (string) ($orders_url ?? '') : '';
|
||||
|
||||
@@ -29,13 +28,6 @@ $services = array_values(array_filter([
|
||||
'url' => $auth_url,
|
||||
'tab' => 'auth',
|
||||
],
|
||||
[
|
||||
'label' => __('推广中心', 'aksrt'),
|
||||
'icon' => 'user-plus',
|
||||
'tone' => 'promotion',
|
||||
'url' => $promotion_url,
|
||||
'tab' => 'promotion',
|
||||
],
|
||||
[
|
||||
'label' => __('我的订单', 'aksrt'),
|
||||
'icon' => 'receipt',
|
||||
|
||||
Reference in new issue
Block a user