# store.sqlite3 表概览（schema v1）

来源：`store_db/schema_v1.py`。单库 `store.sqlite3`，各 skill 共享。

## 会员与钱包

| 表 | PK | 关键字段 |
|----|-----|----------|
| `store_members` | `id` | name, phone, birthday, due_date, tags_json, fields_json, status |
| `store_custom_field_defs` | (entity, field_key) | label, field_type, options_json |
| `store_wallet` | member_id → members | balance, total_recharge, total_consume |
| `store_followups` | id | member_id, content, next_followup_date |
| `store_transactions` | id (AUTO) | member_id, type, amount, ref_appt_id, ref_order_id |
| `store_consumption_log` | member_id | last_visit_at, visit_count, fav_service |
| `store_cards` | id | member_id, name, service_name, total_times, used_times, expire_date, status |

## 目录

| 表 | PK | 关键字段 |
|----|-----|----------|
| `catalog_services` | id (AUTO) | name (UNIQUE), price, duration_min, status |
| `catalog_products` | id (AUTO) | name (UNIQUE), cost, sale_price, unit, threshold, status |
| `catalog_service_materials` | (service_id, product_name) | qty |

## 员工

| 表 | PK | 关键字段 |
|----|-----|----------|
| `staff_staff` | id | name, phone, base_salary, fields_json, status |
| `staff_commission_rules` | id (AUTO) | staff_id, kind, target_name, ratio |
| `staff_schedules` | (staff_id, date) | status, slots_json |
| `staff_performance` | id (AUTO) | staff_id, ymd, kind, target_name, amount, source_appt_id/order_id |

## 预约与订单

| 表 | PK | 关键字段 |
|----|-----|----------|
| `store_appointments` | id | member_id, service_name, technician_id, start_dt, duration_min, status |
| `store_orders` | id | member_id, status, total_amount |
| `store_order_lines` | id (AUTO) | order_id, kind, ref_name, qty, unit_price, line_amount |
| `store_order_line_staff` | id (AUTO) | line_id, staff_id, role, split_ratio |
| `store_payments` | id (AUTO) | appt_id, order_id, type, amount, meta_json |

## 库存与元数据

| 表 | PK | 关键字段 |
|----|-----|----------|
| `inv_items` | key | stock_qty, unit, cost, sale_price, low_stock_threshold, status |
| `inv_logs` | id (AUTO) | item_key, direction, type, quantity, before/after_qty, ref_appt_id/order_id |
| `sent_reminders` | UNIQUE(type, target_id, bucket) | reminder_type, target_id, sent_at；由 `daily-summary --mark-sent` / `daily-plan` / `reminder schedule` 写入 |
| `store_meta` | key | value_json（segment_preset、lexicon 等） |
| `store_operation_log` | id (AUTO) | skill, command, op, table_name, entity_id, result, error_code |

## 必需表（verify-seed）

`store_members`, `store_wallet`, `store_operation_log`, `catalog_services`, `inv_items`, `staff_staff`, `store_meta`
