feat(douyu): 新增客户领取与角色绑定工作台
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
-- 171_douyu_customer_fulfillment.sql
|
||||
--
|
||||
-- 斗鱼精英宝典客户领取:
|
||||
-- 1. 人工 SKU 配置可显式启用斗鱼客户绑定;
|
||||
-- 2. order_site 保存客户资料和 live-hub 安全状态投影;
|
||||
-- 3. 内部账号、CK、积分、二维码原始协议仍由 live-hub 负责。
|
||||
|
||||
ALTER TABLE manual_fulfillment_configs
|
||||
ADD COLUMN IF NOT EXISTS douyu_fulfillment_enabled BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
COMMENT ON COLUMN manual_fulfillment_configs.douyu_fulfillment_enabled IS
|
||||
'是否启用斗鱼精英宝典客户领取与角色绑定';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS douyu_fulfillment_tasks (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
order_id BIGINT NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
|
||||
order_item_id BIGINT NOT NULL UNIQUE REFERENCES order_items(id) ON DELETE CASCADE,
|
||||
fulfillment_id BIGINT REFERENCES fulfillments(id) ON DELETE SET NULL,
|
||||
manual_fulfillment_config_id BIGINT
|
||||
REFERENCES manual_fulfillment_configs(id) ON DELETE SET NULL,
|
||||
live_session_id BIGINT,
|
||||
status TEXT NOT NULL DEFAULT 'waiting_profile'
|
||||
CHECK (status IN (
|
||||
'waiting_profile',
|
||||
'preparing',
|
||||
'qr_pending',
|
||||
'role_ready',
|
||||
'bound',
|
||||
'waiting_operator',
|
||||
'processing',
|
||||
'completed',
|
||||
'failed',
|
||||
'manual_required',
|
||||
'cancelled'
|
||||
)),
|
||||
customer_role_name TEXT NOT NULL DEFAULT '',
|
||||
customer_platform TEXT NOT NULL DEFAULT ''
|
||||
CHECK (customer_platform IN ('', 'wechat', 'qq')),
|
||||
customer_system TEXT NOT NULL DEFAULT ''
|
||||
CHECK (customer_system IN ('', 'ios', 'android')),
|
||||
binding_phase TEXT NOT NULL DEFAULT '',
|
||||
live_execution_status TEXT NOT NULL DEFAULT '',
|
||||
live_binding_status TEXT NOT NULL DEFAULT '',
|
||||
issue_code TEXT NOT NULL DEFAULT '',
|
||||
last_error TEXT NOT NULL DEFAULT '',
|
||||
bound_role_name TEXT NOT NULL DEFAULT '',
|
||||
bound_area_name TEXT NOT NULL DEFAULT '',
|
||||
bound_plat_name TEXT NOT NULL DEFAULT '',
|
||||
customer_link_opened_at TIMESTAMPTZ,
|
||||
binding_started_at TIMESTAMPTZ,
|
||||
bound_at TIMESTAMPTZ,
|
||||
completed_at TIMESTAMPTZ,
|
||||
last_synced_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_tasks_status
|
||||
ON douyu_fulfillment_tasks (status, updated_at DESC, id DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_tasks_order
|
||||
ON douyu_fulfillment_tasks (order_id, id);
|
||||
CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_tasks_live
|
||||
ON douyu_fulfillment_tasks (live_session_id)
|
||||
WHERE live_session_id IS NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS douyu_fulfillment_events (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
task_id BIGINT NOT NULL REFERENCES douyu_fulfillment_tasks(id) ON DELETE CASCADE,
|
||||
event_type TEXT NOT NULL,
|
||||
actor_type TEXT NOT NULL DEFAULT 'system'
|
||||
CHECK (actor_type IN ('system', 'customer', 'admin', 'integration')),
|
||||
actor_id TEXT NOT NULL DEFAULT '',
|
||||
detail_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_events_task
|
||||
ON douyu_fulfillment_events (task_id, id DESC);
|
||||
|
||||
COMMENT ON TABLE douyu_fulfillment_tasks IS
|
||||
'斗鱼精英宝典客户领取任务;客户资料以本表为准,绑定状态为 live-hub 安全投影';
|
||||
COMMENT ON COLUMN douyu_fulfillment_tasks.live_session_id IS
|
||||
'live-hub platform_fulfillment_tasks.id;不得保存内部账号或 CK';
|
||||
Reference in New Issue
Block a user