|
|
@@ -2341,6 +2341,83 @@ CREATE TABLE IF NOT EXISTS butler_sessions (
|
|
|
INDEX idx_user_status (user_id, status)
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='AI管家会话表';
|
|
|
|
|
|
+-- 管家服务提供商档案
|
|
|
+CREATE TABLE IF NOT EXISTS butler_profiles (
|
|
|
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
|
|
+ user_id BIGINT NOT NULL,
|
|
|
+ tier VARCHAR(10),
|
|
|
+ status VARCHAR(20) DEFAULT 'pending',
|
|
|
+ member_count INT DEFAULT 0,
|
|
|
+ max_members INT DEFAULT 50,
|
|
|
+ annual_fee_l1 BIGINT,
|
|
|
+ annual_fee_l2 BIGINT,
|
|
|
+ description TEXT,
|
|
|
+ certificates TEXT,
|
|
|
+ reject_reason VARCHAR(500),
|
|
|
+ commission_rate_l1 INT DEFAULT 1000,
|
|
|
+ commission_rate_l2 INT DEFAULT 5000,
|
|
|
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
+ approved_at DATETIME,
|
|
|
+ UNIQUE KEY uk_user_id (user_id),
|
|
|
+ INDEX idx_status (status),
|
|
|
+ INDEX idx_tier (tier)
|
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家服务提供商档案';
|
|
|
+
|
|
|
+-- 管家服务记录
|
|
|
+CREATE TABLE IF NOT EXISTS butler_service_records (
|
|
|
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
|
|
+ butler_id BIGINT NOT NULL,
|
|
|
+ member_user_id BIGINT NOT NULL,
|
|
|
+ subscription_id BIGINT,
|
|
|
+ service_type VARCHAR(20) NOT NULL,
|
|
|
+ amount_p BIGINT NOT NULL,
|
|
|
+ platform_fee_p BIGINT DEFAULT 0,
|
|
|
+ butler_amount_p BIGINT DEFAULT 0,
|
|
|
+ member_tier VARCHAR(10),
|
|
|
+ year_month VARCHAR(7),
|
|
|
+ remark VARCHAR(500),
|
|
|
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
+ INDEX idx_butler_id (butler_id),
|
|
|
+ INDEX idx_member_user_id (member_user_id),
|
|
|
+ INDEX idx_year_month (year_month)
|
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家服务记录';
|
|
|
+
|
|
|
+-- 管家月度佣金结算单
|
|
|
+CREATE TABLE IF NOT EXISTS butler_commission_settlements (
|
|
|
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
|
|
+ butler_id BIGINT NOT NULL,
|
|
|
+ year_month VARCHAR(7) NOT NULL,
|
|
|
+ member_count INT DEFAULT 0,
|
|
|
+ annual_base_amount_p BIGINT DEFAULT 0,
|
|
|
+ annual_butler_amount_p BIGINT DEFAULT 0,
|
|
|
+ annual_platform_amount_p BIGINT DEFAULT 0,
|
|
|
+ per_session_total_p BIGINT DEFAULT 0,
|
|
|
+ per_session_platform_total_p BIGINT DEFAULT 0,
|
|
|
+ per_session_butler_total_p BIGINT DEFAULT 0,
|
|
|
+ total_butler_amount_p BIGINT DEFAULT 0,
|
|
|
+ status VARCHAR(20) DEFAULT 'pending',
|
|
|
+ settled_at DATETIME,
|
|
|
+ settled_by BIGINT,
|
|
|
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
+ UNIQUE KEY uk_butler_month (butler_id, year_month),
|
|
|
+ INDEX idx_status (status),
|
|
|
+ INDEX idx_year_month (year_month)
|
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家月度佣金结算单';
|
|
|
+
|
|
|
+-- 会员-管家分配记录
|
|
|
+CREATE TABLE IF NOT EXISTS butler_assignments (
|
|
|
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
|
|
+ family_id BIGINT NOT NULL COMMENT '家庭 ID',
|
|
|
+ butler_user_id BIGINT NOT NULL COMMENT '管家用户 ID',
|
|
|
+ subscription_id BIGINT COMMENT '关联订阅 ID',
|
|
|
+ level VARCHAR(10) NOT NULL COMMENT '订阅级别 L1/L2',
|
|
|
+ assigned_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
+ UNIQUE KEY uk_family_assignment (family_id),
|
|
|
+ INDEX idx_butler_user_id (butler_user_id),
|
|
|
+ INDEX idx_subscription_id (subscription_id)
|
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员 - 管家分配记录';
|
|
|
+
|
|
|
-- 家庭订阅记录
|
|
|
CREATE TABLE IF NOT EXISTS member_subscription (
|
|
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|