Aile 帳號身份體系規格說明書
版本: v1.0
最後更新: 2026-06-13
服務範圍: aile-service-account、aile-service-tenant、aile-service-room
1. 概述
Aile 的身份體系採用分層設計,以 Account(帳號) 為頂層統一身份,向下關聯 AppAccount(應用帳號)、TenantEmployee(員工)、TenantContact(客戶/聯繫人) 等租戶級身份。系統支援匿名訪客到實名用戶的平滑過渡,並透過 Scope 機制管理渠道級身份映射。
1.1 核心設計原則
| 原則 | 說明 |
|---|---|
| Account 是統一身份錨點 | 所有租戶級身份(員工、客戶)都歸屬於一個 Account |
| 租戶隔離 | 同一 Account 在不同租戶中有獨立的 Employee 或 Contact 記錄 |
| 渠道多身份 | 同一 Account 可透過多個 channel+scopeId 訪問同一服務號 |
| 匿名可合併 | 匿名訪客的 Contact 資料可在實名登入後合併到實名 Account |
2. 身份層級總覽
┌─────────────────────────────────────────────────────────┐
│ AccountModel │
│ (aile.account) — 頂層統一身份 │
│ 欄位: mobile, channel, status, isSystem, personRoomId │
│ 類型: Anonymous | NonRealName | RealName | System │
└────────────┬──────────────┬──────────────────────────────┘
│ │
┌─ ─────▼──────┐ ┌───▼──────────────────────────┐
│ AppAccount │ │ AccountScopeModel │
│ Model │ │ (aile.account.scope) │
│ (aile. │ │ 帳號在渠道上的 scope 映射 │
│ account │ │ accountId ↔ channel ↔ scopeId│
│ .app) │ └───────────────────────────────┘
│ 應用帳號 │
└─────────────┘
┌──────────────────────────────────────────────────────────┐
│ 租戶層 (Tenant) │
│ │
│ ┌─────────────────────┐ ┌────────────────────────────┐ │
│ │ TenantEmployeeModel │ │ TenantContactModel │ │
│ │ (aile.tenant. │ │ (aile.tenant.contact) │ │
│ │ employee) │ │ 客戶 / 聯繫人 │ │
│ │ 員工 │ │ type: RealName | │ │
│ │ joinType: Guarantor │ │ Anonymous | │ │
│ │ | Invitation │ │ Independent │ │
│ └─────────┬───────────┘ └─────────────┬──────────────┘ │
│ │ │ │
└────────────┼─────────────────────────────┼────────────────┘
│ │
┌──────▼──────┐ ┌───────▼──────────────┐
│ServiceMember│ │ ServiceNumberScope │
│ Model │ │ Model │
│ 服務號成員 │ │ 服務號進線 scope │
│ privilege: │ │ customerId ↔ │
│ Owner / │ │ serviceNumberId ↔ │
│ Manager / │ │ channel ↔ scopeId │
│ Common │ │ ↔ roomId │
└─────────────┘ └───────────────────────┘
│
┌───────▼──────────────┐
│ServiceNumberRelation │
│ Model │
│ 服務號訂閱關係 │
│ customerId ↔ │
│ serviceNumberId ↔ │
│ accountId │
└───────────────────────┘