refactor(referral): prune dead code and formalize ops list header

- remove unused AuthReader::invitation_mode and ReferralAttribution
  helpers (get_or_create_code / validate_ref); contract test now
  asserts the canonical invit_code_s reader in CreditsRuntime
- drop legacy aksrt_invite table from uninstall cleanup list
- track referral code creation time (aksrt_referral_code_created)
  and surface it in the referral ops REST list
- formalize ops list headers (归属用户/推广码/启用状态/推广用户数/
  有效付费用户数/创建时间) and right-align count columns
This commit is contained in:
2026-09-19 12:54:22 +08:00
parent b375fcc55c
commit ae626ba1c8
5 changed files with 23 additions and 32 deletions
+13 -11
View File
@@ -31,7 +31,7 @@ trait UsersMenusReferral {
<option value="disabled"><?php esc_html_e('已禁用', 'aksrt'); ?></option>
<option value="missing"><?php esc_html_e('未生成', 'aksrt'); ?></option>
</select>
<input type="search" id="aksrt-ref-search" placeholder="<?php esc_attr_e('搜索用户或 Ref 码', 'aksrt'); ?>">
<input type="search" id="aksrt-ref-search" placeholder="<?php esc_attr_e('搜索归属用户或推广码', 'aksrt'); ?>">
<button type="button" class="button" id="aksrt-ref-filter"><?php esc_html_e('筛选', 'aksrt'); ?></button>
</div>
</div>
@@ -39,14 +39,15 @@ trait UsersMenusReferral {
<div id="aksrt-ref-notice" role="status" aria-live="polite"></div>
<table class="wp-list-table widefat fixed striped">
<thead><tr>
<th><?php esc_html_e('用户', 'aksrt'); ?></th>
<th><?php esc_html_e('Ref 推广码', 'aksrt'); ?></th>
<th><?php esc_html_e('状态', 'aksrt'); ?></th>
<th><?php esc_html_e('绑定用户', 'aksrt'); ?></th>
<th><?php esc_html_e('有效付费用户', 'aksrt'); ?></th>
<th><?php esc_html_e('归属用户', 'aksrt'); ?></th>
<th><?php esc_html_e('推广码', 'aksrt'); ?></th>
<th><?php esc_html_e('启用状态', 'aksrt'); ?></th>
<th style="text-align:right;"><?php esc_html_e('推广用户数', 'aksrt'); ?></th>
<th style="text-align:right;"><?php esc_html_e('有效付费用户数', 'aksrt'); ?></th>
<th><?php esc_html_e('创建时间', 'aksrt'); ?></th>
<th><?php esc_html_e('操作', 'aksrt'); ?></th>
</tr></thead>
<tbody id="aksrt-ref-rows"><tr><td colspan="6"><?php esc_html_e('正在加载…', 'aksrt'); ?></td></tr></tbody>
<tbody id="aksrt-ref-rows"><tr><td colspan="7"><?php esc_html_e('正在加载…', 'aksrt'); ?></td></tr></tbody>
</table>
<div class="tablenav bottom"><div class="tablenav-pages" id="aksrt-ref-pages"></div></div>
</div>
@@ -102,7 +103,7 @@ trait UsersMenusReferral {
const load = async (page = 1) => {
currentPage = page;
setNotice('');
rows.innerHTML = '<tr><td colspan="6"><?php echo esc_js(__('正在加载…', 'aksrt')); ?></td></tr>';
rows.innerHTML = '<tr><td colspan="7"><?php echo esc_js(__('正在加载…', 'aksrt')); ?></td></tr>';
const url = new URL(endpoint);
url.searchParams.set('page', String(page));
url.searchParams.set('per_page', '20');
@@ -115,10 +116,11 @@ trait UsersMenusReferral {
<td><strong>${escapeHtml(item.user.name)}</strong><br><small>${escapeHtml(item.user.login)} · #${Number(item.user.id)}</small></td>
<td>${item.ref ? `<code>${escapeHtml(item.ref)}</code>` : '—'}</td>
<td>${escapeHtml({active:'<?php echo esc_js(__('已启用', 'aksrt')); ?>',disabled:'<?php echo esc_js(__('已禁用', 'aksrt')); ?>',missing:'<?php echo esc_js(__('未生成', 'aksrt')); ?>'}[item.status] || item.status)}</td>
<td>${Number(item.bound_count || 0)}</td>
<td>${Number(item.effective_payers || 0)}</td>
<td style="text-align:right;">${Number(item.bound_count || 0)}</td>
<td style="text-align:right;">${Number(item.effective_payers || 0)}</td>
<td>${item.created_at ? escapeHtml(item.created_at) : '—'}</td>
<td>${actionButton(item)}</td>
</tr>`).join('') : '<tr><td colspan="6"><?php echo esc_js(__('没有符合条件的用户', 'aksrt')); ?></td></tr>';
</tr>`).join('') : '<tr><td colspan="7"><?php echo esc_js(__('没有符合条件的用户', 'aksrt')); ?></td></tr>';
pages.innerHTML = Array.from({length: Number(data.max_pages || 1)}, (_, index) => {
const number = index + 1;
return `<button type="button" class="button ${number === Number(data.page) ? 'button-primary' : ''}" data-ref-page="${number}">${number}</button>`;