feat: unify invite flow with referral ref
This commit is contained in:
1 parent
f1d6809109
commit
b501cf4611
47 files changed
+1083
-2548
No files matched your search
@@ -14,7 +14,7 @@ class DBMigrator {
|
||||
use DBMigratorVip;
|
||||
|
||||
/** Current schema version; changing it re-runs dbDelta. */
|
||||
const SCHEMA_VERSION = '1.23.0';
|
||||
const SCHEMA_VERSION = '1.24.0';
|
||||
|
||||
const OPT_KEY = 'aksrt_db_schema_version';
|
||||
|
||||
|
||||
@@ -71,24 +71,7 @@ trait DBMigratorPart2 {
|
||||
) {$charset_collate};";
|
||||
dbDelta($sql_signin);
|
||||
|
||||
// ---------- 3. 邀请 ----------
|
||||
$sql_invite = "CREATE TABLE {$prefix}aksrt_invite (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
inviter_id BIGINT UNSIGNED NOT NULL,
|
||||
invitee_id BIGINT UNSIGNED DEFAULT NULL,
|
||||
invite_code VARCHAR(32) NOT NULL,
|
||||
status VARCHAR(16) NOT NULL DEFAULT 'pending',
|
||||
created_at DATETIME NOT NULL,
|
||||
rewarded_at DATETIME DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uniq_code (invite_code),
|
||||
KEY idx_inviter (inviter_id),
|
||||
KEY idx_invitee (invitee_id),
|
||||
KEY idx_status (status)
|
||||
) {$charset_collate};";
|
||||
dbDelta($sql_invite);
|
||||
|
||||
// ---------- 4. 下载 token ----------
|
||||
// ---------- 3. 下载 token ----------
|
||||
$sql_dl_token = "CREATE TABLE {$prefix}aksrt_dl_token (
|
||||
token CHAR(48) NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -377,7 +360,7 @@ trait DBMigratorPart2 {
|
||||
) {$charset_collate};";
|
||||
dbDelta($sql_rebate_log);
|
||||
|
||||
// ── affiliate attribution (new contract; no legacy invite reads) ──
|
||||
// ── canonical Ref attribution and permanent user binding ──
|
||||
$sql_affiliate_relation = "CREATE TABLE {$prefix}aksrt_affiliate_relation (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
referral_code VARCHAR(32) NOT NULL,
|
||||
@@ -386,12 +369,17 @@ trait DBMigratorPart2 {
|
||||
first_touch_at DATETIME NOT NULL,
|
||||
bound_at DATETIME DEFAULT NULL,
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'captured',
|
||||
reward_status VARCHAR(20) NOT NULL DEFAULT 'skipped',
|
||||
rewarded_at DATETIME DEFAULT NULL,
|
||||
registration_ip VARCHAR(64) DEFAULT NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_referral_code (referral_code),
|
||||
UNIQUE KEY uniq_invitee (invitee_id),
|
||||
KEY idx_promoter (promoter_id),
|
||||
KEY idx_status_touch (status, first_touch_at)
|
||||
KEY idx_status_touch (status, first_touch_at),
|
||||
KEY idx_reward_status (reward_status),
|
||||
KEY idx_reward_ip (registration_ip, rewarded_at)
|
||||
) {$charset_collate};";
|
||||
dbDelta($sql_affiliate_relation);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ trait DBMigratorPart3 {
|
||||
'credit_log' => 'aksrt_credit_log',
|
||||
'balance_log' => 'aksrt_balance_log',
|
||||
'signin_log' => 'aksrt_signin_log',
|
||||
'invite' => 'aksrt_invite',
|
||||
'dl_token' => 'aksrt_dl_token',
|
||||
'notification' => 'aksrt_notification',
|
||||
'conversation' => 'aksrt_conversation',
|
||||
|
||||
Reference in new issue
Block a user