diff --git a/src/Admin/Native/UsersMenusReferral.php b/src/Admin/Native/UsersMenusReferral.php
index a3d15617..4e767e49 100644
--- a/src/Admin/Native/UsersMenusReferral.php
+++ b/src/Admin/Native/UsersMenusReferral.php
@@ -31,7 +31,7 @@ trait UsersMenusReferral {
-
+
@@ -39,14 +39,15 @@ trait UsersMenusReferral {
- |
- |
- |
- |
- |
+ |
+ |
+ |
+ |
+ |
+ |
|
- |
+ |
@@ -102,7 +103,7 @@ trait UsersMenusReferral {
const load = async (page = 1) => {
currentPage = page;
setNotice('');
- rows.innerHTML = ' |
';
+ rows.innerHTML = ' |
';
const url = new URL(endpoint);
url.searchParams.set('page', String(page));
url.searchParams.set('per_page', '20');
@@ -115,10 +116,11 @@ trait UsersMenusReferral {
${escapeHtml(item.user.name)} ${escapeHtml(item.user.login)} · #${Number(item.user.id)} |
${item.ref ? `${escapeHtml(item.ref)}` : '—'} |
${escapeHtml({active:'',disabled:'',missing:''}[item.status] || item.status)} |
- ${Number(item.bound_count || 0)} |
- ${Number(item.effective_payers || 0)} |
+ ${Number(item.bound_count || 0)} |
+ ${Number(item.effective_payers || 0)} |
+ ${item.created_at ? escapeHtml(item.created_at) : '—'} |
${actionButton(item)} |
- `).join('') : ' |
';
+ `).join('') : ' |
';
pages.innerHTML = Array.from({length: Number(data.max_pages || 1)}, (_, index) => {
const number = index + 1;
return ``;
diff --git a/src/Payment/ReferralAttribution.php b/src/Payment/ReferralAttribution.php
index 1027356b..994952a9 100644
--- a/src/Payment/ReferralAttribution.php
+++ b/src/Payment/ReferralAttribution.php
@@ -14,6 +14,8 @@ final class ReferralAttribution {
private const COOKIE = 'aksrt_referral';
private const META_CODE = 'aksrt_referral_code';
private const META_STATUS = 'aksrt_referral_code_status';
+ /** 推广码生成时间(新生成的码才有;历史码为空,后台列表显示 —)。 */
+ private const META_CREATED = 'aksrt_referral_code_created';
private const STATUS_ACTIVE = 'active';
private const STATUS_DISABLED = 'disabled';
@@ -258,14 +260,6 @@ final class ReferralAttribution {
];
}
- public function get_or_create_code(int $user_id): string {
- return (string) ($this->create_link($user_id)['ref'] ?? '');
- }
-
- public function validate_ref(string $ref): bool {
- return $this->resolve_promoter($ref) > 0;
- }
-
public function resolve(int $user_id = 0): int {
$user_id = $user_id > 0 ? $user_id : get_current_user_id();
if ($user_id <= 0) {
@@ -482,9 +476,10 @@ final class ReferralAttribution {
$where_sql = implode(' AND ', $where);
$joins = $wpdb->prepare(
- "LEFT JOIN {$wpdb->usermeta} code ON code.user_id=u.ID AND code.meta_key=%s LEFT JOIN {$wpdb->usermeta} state ON state.user_id=u.ID AND state.meta_key=%s",
+ "LEFT JOIN {$wpdb->usermeta} code ON code.user_id=u.ID AND code.meta_key=%s LEFT JOIN {$wpdb->usermeta} state ON state.user_id=u.ID AND state.meta_key=%s LEFT JOIN {$wpdb->usermeta} created ON created.user_id=u.ID AND created.meta_key=%s",
self::META_CODE,
- self::META_STATUS
+ self::META_STATUS,
+ self::META_CREATED
);
$count_sql = "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u {$joins} WHERE {$where_sql}";
$total = (int) ($params
@@ -495,7 +490,7 @@ final class ReferralAttribution {
$ledger_table = \AKSRT\Core\DBMigrator::table('commission_ledger');
$stats_joins = "LEFT JOIN (SELECT promoter_id, COUNT(*) AS bound_count FROM {$relation_table} WHERE status='bound' GROUP BY promoter_id) relation_stats ON relation_stats.promoter_id=u.ID "
. "LEFT JOIN (SELECT promoter_id, COUNT(DISTINCT source_user_id) AS effective_payers FROM {$ledger_table} WHERE original_amount > 0 GROUP BY promoter_id) payer_stats ON payer_stats.promoter_id=u.ID";
- $list_sql = "SELECT DISTINCT u.ID, u.user_login, u.display_name, u.user_email, code.meta_value AS ref, state.meta_value AS ref_status, "
+ $list_sql = "SELECT DISTINCT u.ID, u.user_login, u.display_name, u.user_email, code.meta_value AS ref, state.meta_value AS ref_status, created.meta_value AS created_at, "
. "COALESCE(relation_stats.bound_count, 0) AS bound_count, COALESCE(payer_stats.effective_payers, 0) AS effective_payers "
. "FROM {$wpdb->users} u {$joins} {$stats_joins} WHERE {$where_sql} ORDER BY u.ID DESC LIMIT %d OFFSET %d";
$list_params = array_merge($params, [$per_page, ($page - 1) * $per_page]);
@@ -514,6 +509,7 @@ final class ReferralAttribution {
],
'ref' => $ref,
'status' => $ref === '' ? 'missing' : ((string) ($row['ref_status'] ?? '') === self::STATUS_DISABLED ? self::STATUS_DISABLED : self::STATUS_ACTIVE),
+ 'created_at' => (string) ($row['created_at'] ?? ''),
'bound_count' => (int) ($row['bound_count'] ?? 0),
'effective_payers' => (int) ($row['effective_payers'] ?? 0),
];
@@ -553,6 +549,7 @@ final class ReferralAttribution {
if (empty($owners)) {
update_user_meta($user_id, self::META_CODE, $code);
update_user_meta($user_id, self::META_STATUS, self::STATUS_ACTIVE);
+ update_user_meta($user_id, self::META_CREATED, current_time('mysql'));
$updated = $this->code_record($user_id);
if ($updated['code'] === $code && $updated['status'] === self::STATUS_ACTIVE) {
return $code;
diff --git a/src/Settings/AuthReader.php b/src/Settings/AuthReader.php
index 308caec3..6c5459ea 100644
--- a/src/Settings/AuthReader.php
+++ b/src/Settings/AuthReader.php
@@ -184,12 +184,6 @@ trait AuthReader {
return (bool) self::get_value('user_signup_no_repas', true);
}
- /** 推广码在注册表单中的唯一显示模式。 */
- public static function invitation_mode(): string {
- $mode = (string) self::get_value('invit_code_s', 'close');
- return in_array($mode, ['close', 'open', 'must'], true) ? $mode : 'close';
- }
-
/** 自动弹窗配置。 */
public static function sign_modal_auto(): array {
return [
diff --git a/tests/widget-system/auth-source-contract.test.cjs b/tests/widget-system/auth-source-contract.test.cjs
index 085bd6f1..9f7c2031 100644
--- a/tests/widget-system/auth-source-contract.test.cjs
+++ b/tests/widget-system/auth-source-contract.test.cjs
@@ -162,7 +162,6 @@ test('shared renderer contracts every configured authentication state', () => {
const shared = read('templates/parts/auth-content.php');
const modal = read('templates/parts/modal-auth.php');
const client = read('assets/js/auth.js');
- const settings = read('src/Settings/AuthReader.php');
assert.match(shared, /data-auth-password-fields/);
assert.match(shared, /data-auth-code-fields/);
@@ -193,8 +192,8 @@ test('shared renderer contracts every configured authentication state', () => {
assert.match(client, /form\.checkValidity\(\)[\s\S]*?field\.validationMessage/);
assert.match(client, /window\.location\.assign\(authPageUrl/);
assert.doesNotMatch(client + shared, /showMessage|data-auth-message|sign-message/);
- assert.match(settings, /invitation_mode/);
- assert.match(settings, /\['close', 'open', 'must'\]/);
+ assert.match(read('src/Settings/CreditsRuntime.php'), /invit_code_s/);
+ assert.match(read('src/Settings/CreditsRuntime.php'), /\['close', 'open', 'must'\]/);
});
test('OAuth frontend is accessible, redirect-aware, and removes retired providers', () => {
diff --git a/uninstall.php b/uninstall.php
index 5a2660db..5b09cce8 100644
--- a/uninstall.php
+++ b/uninstall.php
@@ -30,7 +30,6 @@ $tables = [
'aksrt_asset_transaction',
'aksrt_asset_account',
'aksrt_signin_log',
- 'aksrt_invite',
'aksrt_dl_token',
'aksrt_notification',
'aksrt_report',