feat(credits): free points tasks matrix, day cap, and tasks tab

Add AKSRT_Points_Free for catalog/day-max/daily detail, wire the full
earn matrix (login, post, like, favorite, follow, comment, forum),
expose 积分任务 + 每日详情 tabs, and expand admin free-task settings.
This commit is contained in:
kate522 committed 2026-07-16 16:29:15 +08:00
1 parent 4da003663d
commit 15a883eb54
13 files changed
+728 -232

No files matched your search

+33 -9
View File
@@ -39,15 +39,39 @@ if (!function_exists('aksrt_credits_label')) {
*/
function aksrt_credits_label(string $reason): string {
$map = [
'register' => __('注册赠送', 'aksrt'),
'signin' => __('每日签到', 'aksrt'),
'comment' => __('发表评论', 'aksrt'),
'invite' => __('邀请奖励', 'aksrt'),
'invitee' => __('被邀请奖励', 'aksrt'),
'download' => __('下载消费', 'aksrt'),
'admin' => __('管理员调整', 'aksrt'),
'refund' => __('退款', 'aksrt'),
'register' => __('注册赠送', 'aksrt'),
'signin' => __('每日签到', 'aksrt'),
'comment' => __('发表评论', 'aksrt'),
'invite' => __('邀请奖励', 'aksrt'),
'invitee' => __('被邀请奖励', 'aksrt'),
'download' => __('下载消费', 'aksrt'),
'admin' => __('管理员调整', 'aksrt'),
'refund' => __('退款', 'aksrt'),
'forum_topic' => __('论坛发帖', 'aksrt'),
'forum_reply' => __('论坛回复', 'aksrt'),
'free_sign_up' => __('注册奖励', 'aksrt'),
'free_sign_in' => __('每日签到', 'aksrt'),
'free_login' => __('每日登录', 'aksrt'),
'free_followed'=> __('被关注', 'aksrt'),
'free_post_new'=> __('发布文章', 'aksrt'),
'free_post_like'=> __('文章被赞', 'aksrt'),
'free_post_favorite'=> __('文章被收藏', 'aksrt'),
'free_comment_new'=> __('发表评论', 'aksrt'),
'free_comment_like'=> __('评论被赞', 'aksrt'),
'free_bbs_posts_new'=> __('论坛发帖', 'aksrt'),
'free_bbs_reply'=> __('论坛回复', 'aksrt'),
'free_bbs_essence'=> __('帖子加精', 'aksrt'),
];
return $map[$reason] ?? $reason;
if (isset($map[$reason])) {
return $map[$reason];
}
if (str_starts_with($reason, 'free_') && class_exists('AKSRT_Points_Free')) {
$key = substr($reason, 5);
$cat = AKSRT_Points_Free::catalog();
if (isset($cat[$key][0])) {
return (string) $cat[$key][0];
}
}
return $reason;
}
}
+6
View File
@@ -775,6 +775,9 @@ if (!function_exists('aksrt_toggle_like_ajax')) :
aksrt_set_interaction_cookie(aksrt_get_interaction_cookie_name('like', $post_id), $target);
}
$count = aksrt_update_post_counter($post_id, '_aksrt_like_count', $target ? 1 : -1);
if (is_user_logged_in()) {
do_action('aksrt_post_liked', $post_id, get_current_user_id(), (bool) $target);
}
} else {
$count = aksrt_get_post_likes($post_id);
}
@@ -801,6 +804,9 @@ if (!function_exists('aksrt_toggle_favorite_ajax')) :
aksrt_set_interaction_cookie(aksrt_get_interaction_cookie_name('favorite', $post_id), $target);
}
$count = aksrt_update_post_counter($post_id, '_aksrt_favorite_count', $target ? 1 : -1);
if (is_user_logged_in()) {
do_action('aksrt_post_favorited', $post_id, get_current_user_id(), (bool) $target);
}
} else {
$count = aksrt_get_post_favorites($post_id);
}
@@ -50,6 +50,7 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
</div>
</div>
<p class="uc-balance-card__tip muted-2-color em09" data-signin-tip></p>
<button type="button" class="uc-asset-card__link muted-2-color em09" data-aksrt-asset-tab="points_free"><?php esc_html_e('做任务赚积分', 'aksrt'); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i></button>
</div>
<?php if ($points_buy_on) :
@@ -0,0 +1,95 @@
<?php
/**
* Free points tasks list + daily free detail (Zibll points free tab).
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (!class_exists('AKSRT_Points_Free') || !AKSRT_Points_Free::enabled()) {
return;
}
$user_id = (int) ($user_id ?? get_current_user_id());
$today = AKSRT_Points_Free::today_total($user_id);
$day_max = (int) AKSRT_Points_Free::settings()['day_max'];
$tasks = AKSRT_Points_Free::task_list_for_user($user_id);
$detail = AKSRT_Points_Free::date_detail($user_id);
$pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane) : 'tasks';
?>
<?php if ($pane === 'date') : ?>
<div class="uc-points-date">
<div class="flex jsb ac mb10">
<div class="font-bold"><?php esc_html_e('每日免费积分明细', 'aksrt'); ?></div>
<button type="button" class="muted-2-color" data-aksrt-asset-tab="points_free">
<?php esc_html_e('返回任务', 'aksrt'); ?><i class="fa fa-angle-right ml6 em12" aria-hidden="true"></i>
</button>
</div>
<?php if ($detail) : ?>
<?php foreach ($detail as $day => $val) : ?>
<div class="border-bottom padding-h6 flex jsb ac">
<div class="em12"><?php echo esc_html((string) $day); ?></div>
<div class="text-right shrink0 focus-color em14 font-bold">+ <?php echo esc_html((string) (int) $val); ?></div>
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="uc-transactions__empty"><p><?php esc_html_e('暂无免费积分获取明细', 'aksrt'); ?></p></div>
<?php endif; ?>
</div>
<?php else : ?>
<div class="uc-points-tasks">
<?php if ($today > 0 || $day_max > 0) : ?>
<div class="border-bottom padding-h10">
<div class="flex jsb ac">
<div class="flex1 mr20">
<div class="font-bold mb6">
<?php
printf(
/* translators: %s: points */
esc_html__('今日累计 %s', 'aksrt'),
'<span class="focus-color">+' . esc_html((string) $today) . '</span>'
);
?>
</div>
<div class="muted-2-color em09">
<?php
if ($day_max > 0) {
if ($today >= $day_max) {
printf(esc_html__('今日获取的免费积分已达到 %s,将不再获取', 'aksrt'), esc_html((string) $day_max));
} else {
printf(esc_html__('每日可免费获取 %s 积分,超过后将不再获取', 'aksrt'), esc_html((string) $day_max));
}
} else {
esc_html_e('免费积分无每日上限', 'aksrt');
}
?>
</div>
</div>
<button type="button" class="muted-2-color shrink0" data-aksrt-asset-tab="points_date">
<?php esc_html_e('每日详情', 'aksrt'); ?><i class="fa fa-angle-right ml6 em12" aria-hidden="true"></i>
</button>
</div>
</div>
<?php endif; ?>
<?php if ($tasks) : ?>
<?php foreach ($tasks as $task) : ?>
<div class="border-bottom padding-h10">
<div class="flex jsb ac">
<div class="flex1 mr20">
<div class="font-bold mb6"><?php echo esc_html((string) $task['title']); ?></div>
<div class="muted-2-color em09"><?php echo esc_html((string) $task['desc']); ?></div>
</div>
<span class="focus-color em14 shrink0">
<i class="fas fa-coins mr6 em09" aria-hidden="true"></i>+ <?php echo esc_html((string) (int) $task['points']); ?>
</span>
</div>
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="uc-transactions__empty"><p><?php esc_html_e('暂无可用积分任务', 'aksrt'); ?></p></div>
<?php endif; ?>
</div>
<?php endif; ?>
@@ -48,9 +48,10 @@ if ($show_credits) {
// Tabbed ledgers (Zibll record tabs).
if ($show_wallet || $show_credits) :
$active_record = isset($_GET['asset_tab']) ? sanitize_key(wp_unslash($_GET['asset_tab'])) : '';
if ($active_record === '' || !in_array($active_record, ['balance', 'points'], true)) {
if ($active_record === '' || !in_array($active_record, ['balance', 'points', 'points_free', 'points_date'], true)) {
$active_record = $show_wallet ? 'balance' : 'points';
}
$show_tasks = $show_credits && class_exists('AKSRT_Points_Free') && AKSRT_Points_Free::enabled();
?>
<div class="uc-asset-tabs zib-widget">
<ul class="uc-asset-tabs__nav list-inline tab-nav-theme font-bold">
@@ -64,6 +65,11 @@ if ($show_wallet || $show_credits) :
<a href="#record_tab_points" data-aksrt-asset-tab="points"><?php esc_html_e('积分记录', 'aksrt'); ?></a>
</li>
<?php endif; ?>
<?php if (!empty($show_tasks)) : ?>
<li class="<?php echo in_array($active_record, ['points_free', 'points_date'], true) ? 'active' : ''; ?>">
<a href="#record_tab_points_free" data-aksrt-asset-tab="points_free"><?php esc_html_e('积分任务', 'aksrt'); ?></a>
</li>
<?php endif; ?>
</ul>
<div class="uc-asset-tabs__content tab-content">
<?php if ($show_wallet) : ?>
@@ -100,6 +106,10 @@ if ($show_wallet || $show_credits) :
</div>
<div class="uc-transactions__amount">
<span class="uc-transactions__delta <?php echo esc_attr($delta_class); ?>"><?php echo esc_html($delta_txt); ?></span>
<span class="uc-transactions__balance"><?php printf(esc_html__('余额 %s', 'aksrt'), esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format((float) ($row['balance_after'] ?? 0)) : number_format_i18n((float) ($row['balance_after'] ?? 0), 2))); ?></span>
<?php if (!empty($row['ref_id'])) : ?>
<span class="uc-transactions__ref muted-2-color em09"><?php printf(esc_html__('单号 %s', 'aksrt'), esc_html((string) $row['ref_id'])); ?></span>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
@@ -123,6 +133,14 @@ if ($show_wallet || $show_credits) :
<?php require $dir . '/credits-transactions.php'; ?>
</div>
<?php endif; ?>
<?php if (!empty($show_tasks)) : ?>
<div class="tab-pane<?php echo $active_record === 'points_free' ? ' is-active' : ''; ?>" id="record_tab_points_free" data-aksrt-asset-pane="points_free"<?php echo $active_record === 'points_free' ? '' : ' hidden'; ?>>
<?php $points_tasks_pane = 'tasks'; require $dir . '/credits-points-tasks.php'; ?>
</div>
<div class="tab-pane<?php echo $active_record === 'points_date' ? ' is-active' : ''; ?>" id="tab_points_date" data-aksrt-asset-pane="points_date"<?php echo $active_record === 'points_date' ? '' : ' hidden'; ?>>
<?php $points_tasks_pane = 'date'; require $dir . '/credits-points-tasks.php'; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php