性能测试种子数据规格

创建日期:2026-02-08  |  状态:已定稿

文档目的
定义性能测试租户的完整种子数据规格,包括所有表的数据量、生成依赖关系、保留策略。模拟一家拥有 150 家门店、运营 2 年的大型美甲连锁品牌。
~110
数据库表
~2.5亿
总数据行数
150
门店数量
2年
模拟运营时长

一、租户基本参数

参数说明
门店总数150 家148 活跃 + 2 inactive
员工总数3,030 人150×20 店员 + 30 核心团队
离职率10%~303 名 inactive 员工
客户总数1,000,00015% 匿名 / 55% 已识别 / 30% 注册
服务项目100 个5 大类 × 20 种,$20-200,15min-2hr
运营时长2 年(730 天)含历史交易、预约等

时区与营业时间分布

时区门店占比门店数
Eastern Time (ET)60%90 家
Pacific Time (PT)20%30 家
Central Time (CT)10%15 家
Mountain Time (MT)10%15 家
营业时间模式占比时间
标准型60%10:00-19:00
长营业型25%9:00-21:00
商场型15%10:00-22:00

员工配置

每店 20 人配置

职位人数/店角色
店长2admin
主管1manager
前台2receptionist
高级技师5senior_technician
美甲师10nail_technician

核心团队 30 人

角色人数权限
超级管理员1super_admin(全权限)
全权限管理5admin(等同 super_admin)
市场管理5admin(仅 marketing 权限)
财务4manager(finance/reports 权限)
运营4manager(operations 权限)
HR3manager(employees/schedules 权限)
客服4manager(guests/appointments 权限)
IT4admin(developer/settings 权限)

排班参数

参数分布
工作天数6 天/周 70%,5 天/周 20%,7 天/周 10%
班次模式全天 40%,早班 25%,晚班 20%,不规则 15%

预约参数

参数
每店每天~100 单
单人 vs Group80% / 20%(Group 平均 3 人,最多 10 人)
每单平均服务数2 个
来源分布员工代约 60%,Web 10%,Guest App 5%,自助机 5%,现场 20%
状态分布completed 85%,cancelled 8%,no_show 3%,active 4%

支付参数

参数
支付方式信用卡 70%,借记卡 10%,现金 10%,在线 10%
小费比例90% 给小费,集中在 15%/18%/20%,范围 5%-35%
退款率10%(其中 95% void,5% return)

二、数据生成依赖层级

核心原则
数据必须按层级顺序生成,保持引用完整性和数据一致性。第 6 层以上的聚合数据从底层交易数据推导计算,不可独立编造。
Layer 0   平台基础     tenants, platform_settings, tenant_admins
Layer 0.5 RBAC 权限    permissions, roles, role_permissions, job_titles, job_title_permissions
Layer 1   门店配置     centers, terminals, services, center_services, *_config, settings, templates, tiers
Layer 2   员工         employees, employee_roles, employee_pins, capabilities, schedules, work_schedules
Layer 3   客户         guests, guest_notes, guest_tags, memberships, preferences
Layer 4   核心预约     appointments → appointment_services, sub_appointments, appointment_groups
Layer 5   交易支付     invoices → transactions → tips, refunds, receipts, payment_requests
Layer 6   日结对账     day_end_closeouts(从 L5 汇总计算), reconciliations, cash_drawer
Layer 7   行为数据     checkins, reviews, notifications, chat, campaigns → send_history
Layer 8   营销自动化   automation_rules → execution_log, tags(从 L3-L5 推导)
Layer 9   日志报表     application_logs, audit_logs, report_instances(从真实数据查询生成)

三、完整数据表清单

Layer 0 — 平台基础
表名数据量保留说明
tenants1永久测试租户
platform_settings~20永久平台级配置
tenant_admins1永久租户超管
Layer 0.5 — RBAC 权限体系
表名数据量保留说明
permissions90永久系统预设权限(resource:action)
roles6永久super_admin, admin, manager, employee, staff, guest
role_permissions~360永久角色-权限映射
job_titles~8永久5 预设 + 3 自定义
job_title_permissions~240永久职位-权限映射
Layer 1 — 门店与配置
表名数据量保留说明
centers150永久148 活跃 + 2 inactive
terminals375永久每店 2-3 台 POS
services100永久5 类 × 20 种
center_services14,250永久30% 全服务 + 70% 缺 10%
service_price_history~300永久2 年约 3 次调价
booking_config150永久每店预约配置
checkin_config150永久每店签到配置
time_clock_settings150永久每店打卡配置
setting_categories~15永久设置分类
setting_definitions~80永久设置项定义
setting_values~3,000永久150 店 × ~20 自定义值
system_config~50永久系统级配置
email_templates~30永久预设邮件模板
sms_templates~20永久预设短信模板
template_categories~8永久模板分类
message_templates~25永久消息模板
membership_tiers5永久bronze/silver/gold/platinum/diamond
points_triggers~8永久积分规则
center_job_title_tip_settings750永久150 店 × 5 职位
discount_rules3,700永久折扣规则
coupons3,700永久优惠券(1:1 对应 discount_rules)
mobile_promotion_settings150永久每店移动端营销配置
delivery_config~5永久消息投递配置
Layer 2 — 员工
表名数据量保留说明
employees3,030永久含 10% inactive
employee_roles3,030永久每人 1 条角色分配
employee_special_permissions~150永久5% 员工有特殊权限覆盖
employee_store_permissions~90永久核心团队跨店权限
employee_pins2,727永久活跃员工打卡 PIN
employee_service_capabilities~54,000永久基于 job_title.can_provide_service
employee_notification_settings3,030永久每人通知偏好
employee_push_tokens~2,727永久活跃员工设备 token
Layer 2 — 排班与打卡
表名数据量保留说明
employee_work_schedules~15,000永久周循环模板
employee_work_schedules_daily~59,5004 周滚动未来 4 周每日班次
employee_available_times~5,710,0004 周滚动触发器自动生成的 5 分钟时段
employee_available_start_times~1,430,0004 周滚动可用起始时间(子集)
leave_requests42,000永久HR 审计需要
swap_requests15,000永久换班记录
time_cards1,600,000永久每日打卡汇总
time_punches3,200,000永久每次打卡明细
time_card_edits~80,000永久约 5% 修改记录
Layer 3 — 客户
表名数据量保留说明
guests1,000,000永久15% 匿名 / 55% 已识别 / 30% 注册
guest_notes2,315,000永久80% 已识别 + 90% 注册有备注
guest_relationships50,000永久客户间关系对
guest_merge_logs15,000永久客户合并审计
guest_auth_fields300,000永久注册用户扩展认证字段
guest_auth_sessions~50,000临时活跃 Guest App session
guest_tokens~50,000临时Guest 认证 token
guest_login_history~3,000,0001 年Guest 登录日志
guest_verification_codes~200临时OTP 验证码
guest_password_resets~500临时密码重置 token
guest_email_verifications~1,000临时邮件验证 token
user_preferences~150,000永久50% 注册用户有偏好
subscription_preferences~300,000永久注册用户订阅偏好
Layer 3 — 标签与会员
表名数据量保留说明
tag_definitions50永久20+ 模板 + 自定义
guest_tags4,250,000永久85 万客户 × 平均 5 标签
tag_change_logs10,000,000永久标签变更审计
tag_evaluation_logs30,000永久评估性能日志
customer_segments~30永久分群定义
segment_members~2,000,000永久分群成员关联
customer_memberships300,000永久会员关系
points_accounts300,000永久积分账户
points_transactions4,350,000永久积分流水
customer_discount_eligibility~50,000永久折扣资格
Layer 4 — 核心预约
表名数据量保留说明
appointments11,000,000永久100/店/天 × 730 天
appointment_services22,000,000永久每单平均 2 个服务
sub_appointments6,600,000永久Group 预约子记录
appointment_groups2,200,000永久20% 为 Group 预约
appointment_group_members6,600,000永久每组平均 3 人
checkins1,100,000永久10% 的预约有签到
checkin_queue~50临时瞬时队列数据
service_reviews110,000永久1% 的预约有评价
Layer 4 — 通知
表名数据量保留说明
appointment_notifications20,000,0001 年3-4 条/预约(确认+提醒)
notifications19,250,000永久各类推送/系统通知
push_notifications5,000,0001 年推送通知记录
Layer 5 — 交易与支付
表名数据量保留说明
invoices9,350,0007 年仅已支付的预约(85%)
invoice_items5,610,0007 年Group invoice 明细
transactions11,000,0007 年支付交易
transaction_history13,750,0001 年交易状态变更日志
tips9,900,0007 年90% 的交易有小费
refunds1,100,0007 年10%(95% void + 5% return)
receipts7,150,0001 年平均 1.3 张/交易
payment_requests6,000,0001 年POS 终端支付请求
gift_cards300,000永久60% 已用/20% 活跃/16% 过期/4% 其他
gift_card_transactions750,000永久购买+使用记录
gift_card_claims~200,000永久兑换记录
coupon_usage_history2,440,000永久优惠券使用记录
Layer 6 — 日结与对账(从 L5 汇总计算)
表名数据量保留说明
day_end_closeouts110,000永久148 店 × 730 天
day_end_checklist_items660,000永久每次 ~6 个检查步骤
tip_distributions1,550,000永久每日每员工小费分配
cash_drawer_sessions108,000永久每店每天 1 次
cash_counts238,000永久每 session 2.2 次清点
payment_reconciliations108,0007 年每店每天 1 次对账
reconciliation_items11,000,0007 年匹配每笔交易
bank_deposits108,0007 年每店每天 1 条
income_expenses45,000永久非交易收支记录
Layer 7 — 营销与沟通
表名数据量保留说明
campaigns1,800永久全平台+每店活动
campaign_recipients8,400,000永久活动接收人
campaign_send_history8,400,0001 年发送明细(替代 promotion_send_logs)
campaign_trigger_links~100永久活动-触发器关联
promotion_analytics~50,000永久营销分析聚合
automation_rules40永久自动化营销规则
trigger_templates20永久触发器模板
automation_execution_log1,500,0001 年自动化执行日志
inbound_sms50,000永久入站短信
outreach_logs100,0001 年外展日志
Layer 7 — 聊天与公告
表名数据量保留说明
chat_conversations5,000永久聊天会话
chat_conversation_members15,000永久每会话 ~3 人
chat_messages3,400,000永久聊天消息
announcements208永久每周 2 条
announcement_reads500,000永久已读记录
experiments~20永久A/B 实验
Layer 8 — 报表
表名数据量保留说明
report_schedules310永久定时报表配置
report_instances30,00090 天报表运行记录
report_exports3,00090 天导出记录
report_audit_logs~10,00090 天报表访问审计
payroll_reports~1,500永久工资单报表
Layer 9 — 日志与审计
表名数据量保留说明
application_logs4,500,00090 天应用日志
system_error_logs1,000,00090 天系统错误日志
auth_audit_logs1,800,0001 年登录审计
permission_audit_logs180,0001 年权限变更审计
setting_history5,000永久设置变更审计
export_logs2,00090 天导出记录
tracking_tokens50,000永久追踪 token
认证与安全(临时/小量)
表名数据量保留说明
auth_sessions~5,000临时管理端活跃 session
auth_token_blacklist~10,000临时已撤销 token
jwt_keys~5永久JWT 签名密钥
jwt_blacklist~10,000临时黑名单 token
password_reset_tokens~500临时密码重置 token

四、保留策略汇总

保留策略适用表依据
90 天 application_logs, system_error_logs, export_logs, report_instances, report_exports, report_audit_logs 运营日志,3 个月后价值极低
1 年 auth_audit_logs, permission_audit_logs, guest_login_history, receipts, payment_requests, transaction_history, appointment_notifications, push_notifications, campaign_send_history, automation_execution_log, outreach_logs PCI DSS 审计要求 + 安全事件回溯
7 年 transactions, tips, refunds, invoices, invoice_items, payment_reconciliations, reconciliation_items, bank_deposits IRS 税务合规要求
永久 所有业务实体表、配置表、客户数据、预约记录 核心业务数据
4 周滚动 employee_work_schedules_daily, employee_available_times, employee_available_start_times 仅用于预约可用性查询,历史无价值
临时 guest_auth_sessions, guest_tokens, verification_codes, checkin_queue, auth_sessions, jwt_blacklist 等 运行时临时数据,量极小

五、实施注意事项

数据一致性要求
employee_available_times 不需要手动生成
该表由数据库触发器从 employee_work_schedules_daily 自动生成。种子数据只需插入 employee_work_schedules_daily,触发器会自动填充 5 分钟可用时段。
种子数据生成顺序
严格按照 Layer 0 → Layer 9 的顺序生成,每一层的数据依赖上一层。在 Layer 5(交易)生成完成后,Layer 6(日结对账)的数据通过聚合查询从 Layer 5 计算得出。