feat(user-center): show cash and points income on sidebar creator card
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
293e1121c5
commit
72e55d95fd
1 file changed
+7
-40
@@ -25,52 +25,19 @@ if ($creation_url !== '') {
|
||||
$income_stats = $user_id > 0 && class_exists('\AKSRT\Payment\Revenue')
|
||||
? (array) (\AKSRT\Payment\Revenue::get_instance()->get_user_income_view($user_id)['stats'] ?? [])
|
||||
: [];
|
||||
$today_income = (float) ($income_stats['today']['CNY'] ?? 0);
|
||||
if ($today_income > 0) {
|
||||
$income_label = __('今日收入', 'aksrt');
|
||||
$income_value = aksrt_cut_count($today_income);
|
||||
} else {
|
||||
$income_label = __('收入', 'aksrt');
|
||||
$income_value = aksrt_cut_count((float) ($income_stats['total']['CNY'] ?? 0));
|
||||
}
|
||||
|
||||
// Reference zibpay_get_user_income_post_count(): the author's published paid posts.
|
||||
$product_count = 0;
|
||||
if ($user_id > 0) {
|
||||
$product_query = new WP_Query([
|
||||
'post_type' => ['post', 'page'],
|
||||
'post_status' => 'publish',
|
||||
'author' => $user_id,
|
||||
'posts_per_page' => 1,
|
||||
'fields' => 'ids',
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'meta_query' => [
|
||||
[
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_TYPE_KEY,
|
||||
'value' => \AKSRT\Core\DomainModel::PAY_TYPE_NO,
|
||||
'compare' => '!=',
|
||||
],
|
||||
[
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
|
||||
'value' => 0,
|
||||
'compare' => '>',
|
||||
'type' => 'DECIMAL(10,2)',
|
||||
],
|
||||
],
|
||||
]);
|
||||
$product_count = (int) $product_query->found_posts;
|
||||
}
|
||||
// 累计收益(pending + settled),现金与积分分开统计。
|
||||
$cash_income = (float) ($income_stats['total']['CNY'] ?? 0);
|
||||
$points_income = (int) ($income_stats['total']['points'] ?? 0);
|
||||
|
||||
$centers[] = [
|
||||
'url' => $creation_url,
|
||||
'tab' => 'creator',
|
||||
'icon' => aksrt_icon_markup('zibsvg-merchant-color', 'mr6'),
|
||||
'title' => __('创作中心', 'aksrt'),
|
||||
'first' => aksrt_cut_count($product_count),
|
||||
'first_l' => __('商品', 'aksrt'),
|
||||
'second' => $income_value,
|
||||
'second_l' => $income_label,
|
||||
'first' => aksrt_cut_count($cash_income),
|
||||
'first_l' => __('现金收益', 'aksrt'),
|
||||
'second' => aksrt_cut_count($points_income),
|
||||
'second_l' => __('积分收益', 'aksrt'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user