积分与余额账务系统硬切重构

This commit is contained in:
kate522 committed 2026-08-24 15:59:11 +08:00
1 parent ca12226b39
commit 5cae5b5c93
159 files changed
+7275 -4718

No files matched your search

+1 -3
View File
@@ -52,9 +52,7 @@ $user_credits = 0;
$user_download_count = 0;
if ($is_logged_in) {
$uid = get_current_user_id();
if (class_exists('\AKSRT\Credits\Credits')) {
$user_credits = \AKSRT\Credits\Credits::balance($uid);
}
$user_credits = \AKSRT\Ledger\LedgerService::get_instance()->balance($uid, \AKSRT\Ledger\AssetType::POINTS);
$dl_meta = get_user_meta($uid, '_aksrt_downloaded_resources', true);
$user_download_count = is_array($dl_meta) ? count($dl_meta) : 0;
}
+8 -7
View File
@@ -4,7 +4,7 @@
* Template Post Type: page
*
* 独立消息中心页面 — 两栏布局(左侧导航 + 右侧消息列表)
* 对齐 legacy msg-center:未读 / 评论 / 系统
* 展示未读、评论、资产、交易与系统通知。
*
* @package AKSRT
*/
@@ -47,12 +47,12 @@ $all_notifications = function_exists('aksrt_get_user_all_notifications')
$current_type = isset($_GET['msg_type']) ? sanitize_key(wp_unslash((string) $_GET['msg_type'])) : 'unread';
// 类型分组:对齐 legacy 主 tab 语义,同时兼容历史 type 键。
// 通知类型分组。
$type_groups = [
'unread' => null, // special: !read
'all' => null, // special: all
'comment' => ['comment_reply', 'comment_approved', 'pending_comments'],
'credits' => ['credits_added', 'credits_deducted'],
'credits' => ['asset_points_increase', 'asset_points_decrease', 'asset_balance_increase', 'asset_balance_decrease'],
'pay' => ['pay', 'order_paid', 'order_refund', 'shop_order', 'after_sale'],
'vip' => ['vip', 'pay_vip', 'vip_expire', 'vip_upgrade'],
'medal' => ['medal', 'badge', 'level_up'],
@@ -62,7 +62,6 @@ $type_groups = [
$allowed_types = array_keys($type_groups);
if (!in_array($current_type, $allowed_types, true)) {
// 兼容旧 URL:msg_type=comment_reply 等
$mapped = 'all';
foreach ($type_groups as $group => $types) {
if (is_array($types) && in_array($current_type, $types, true)) {
@@ -120,7 +119,7 @@ $nav_items = [
'unread' => __('未读消息', 'aksrt'),
'all' => __('全部消息', 'aksrt'),
'comment' => __('评论互动', 'aksrt'),
'credits' => __('积分动态', 'aksrt'),
'credits' => __('资产动态', 'aksrt'),
'pay' => __('交易通知', 'aksrt'),
'vip' => __('会员动态', 'aksrt'),
'medal' => __('徽章等级', 'aksrt'),
@@ -131,8 +130,10 @@ $nav_items = [
$icon_map = [
'comment_reply' => 'fa fas fa-comment-dots',
'comment_approved' => 'fa fas fa-check-circle',
'credits_added' => 'fa fas fa-money-bill',
'credits_deducted' => 'fa fas fa-money-bill',
'asset_points_increase' => 'fa fas fa-coins',
'asset_points_decrease' => 'fa fas fa-coins',
'asset_balance_increase' => 'fa fas fa-wallet',
'asset_balance_decrease' => 'fa fas fa-wallet',
'download_ready' => 'fa fas fa-download',
'upload_moderation' => 'fa fas fa-image',
'verify_email' => 'fa fas fa-envelope-open',
+1 -1
View File
@@ -57,7 +57,7 @@ $user_amount = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($
$cost = function_exists('aksrt_resource_download_cost') ? (int) aksrt_resource_download_cost($post_id) : 0;
$captcha_active = function_exists('aksrt_is_captcha_enabled_for') && aksrt_is_captcha_enabled_for('download');
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() && class_exists('\AKSRT\Credits\Credits') ? \AKSRT\Credits\Credits::balance(get_current_user_id()) : 0));
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() ? \AKSRT\Ledger\LedgerService::get_instance()->balance(get_current_user_id(), \AKSRT\Ledger\AssetType::POINTS) : 0));
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
$vip_url = function_exists('aksrt_get_user_center_tab_url')
? aksrt_get_user_center_tab_url('credits')
+1 -1
View File
@@ -19,7 +19,7 @@ if (empty($credits_enabled) || empty($is_own_profile)) {
?>
<div class="user-home-balance-card">
<p class="user-home-balance-card__label"><?php echo esc_html(sprintf(__('当前%s余额', 'aksrt'), $currency_name)); ?></p>
<div class="user-home-balance-card__value"><?php echo esc_html(aksrt_format_credits($credit_balance)); ?></div>
<div class="user-home-balance-card__value"><?php echo esc_html(aksrt_format_points($credit_balance)); ?></div>
<p class="user-home-balance-card__hint"><?php esc_html_e('完整账单和赚取/消费记录请在用户中心查看。', 'aksrt'); ?></p>
<a href="<?php echo esc_url(aksrt_get_user_center_url('credits')); ?>" class="btn-outline btn-sm"><?php esc_html_e('进入用户中心', 'aksrt'); ?></a>
</div>
+1 -1
View File
@@ -34,7 +34,7 @@ if (!($user instanceof WP_User) || $user->ID <= 0) {
$user_id = (int) $user->ID;
$avatar = function_exists('aksrt_get_avatar_url') ? aksrt_get_avatar_url($user_id, ['size' => 96]) : get_avatar_url($user_id, ['size' => 96]);
$home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user) : get_author_posts_url($user_id);
$credits = function_exists('aksrt_user_credits') ? (int) aksrt_user_credits($user_id) : 0;
$credits = aksrt_user_points($user_id);
$post_count = (int) count_user_posts($user_id, 'post', true);
$bio = function_exists('aksrt_get_user_description') ? aksrt_get_user_description($user_id) : (string) get_the_author_meta('description', $user_id);
$show_credits = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::credits_enabled() : true;