Appearance
Hệ thống Catalog (Danh mục Dịch vụ / Sản phẩm)
Thông tin nhanh
- 6 bảng: service_categories, services (enhanced), products, service_packages, package_items, price_history
- Migration: 030_catalog_system.sql
- API:
/api/catalog/*— CRUD categories, services, products, packages- Admin UI: Settings → Catalog (4 tabs)
Xem thêm: Database · Catalog API
Mô hình Dữ liệu
API Endpoints
Tất cả endpoints yêu cầu JWT auth (tenant-scoped):
Categories
| Method | Path | Mô tả |
|---|---|---|
| GET | /api/catalog/categories | Danh sách categories |
| POST | /api/catalog/categories | Tạo category mới |
| PATCH | /api/catalog/categories/:id | Cập nhật category |
| DELETE | /api/catalog/categories/:id | Xoá (soft delete) |
Services
| Method | Path | Mô tả |
|---|---|---|
| GET | /api/catalog/services | Danh sách services (?category=) |
| POST | /api/catalog/services | Tạo service mới |
| PATCH | /api/catalog/services/:id | Cập nhật service |
| DELETE | /api/catalog/services/:id | Xoá (soft delete) |
Products
| Method | Path | Mô tả |
|---|---|---|
| GET | /api/catalog/products | Danh sách products (?category=) |
| POST | /api/catalog/products | Tạo product mới |
| PATCH | /api/catalog/products/:id | Cập nhật product |
| DELETE | /api/catalog/products/:id | Xoá (soft delete) |
Packages
| Method | Path | Mô tả |
|---|---|---|
| GET | /api/catalog/packages | Danh sách packages + items |
| POST | /api/catalog/packages | Tạo package mới |
| PATCH | /api/catalog/packages/:id | Cập nhật package |
| DELETE | /api/catalog/packages/:id | Xoá (soft delete) |
Price History Tracking
Khi giá service hoặc product thay đổi, hệ thống tự ghi vào price_history:
Backfill Logic
Migration 030 tự động backfill service_id cho bookings và leads có sẵn:
sql
-- Link bookings.service text → services.id
UPDATE bookings b SET service_id = s.id
FROM services s
WHERE b.tenant_id = s.tenant_id AND b.service = s.name AND b.service_id IS NULL;
-- Link leads.service_interest text → services.id
UPDATE leads l SET service_id = s.id
FROM services s
WHERE l.tenant_id = s.tenant_id AND l.service_interest = s.name AND l.service_id IS NULL;Admin UI
Settings → Catalog gồm 4 tabs:
| Tab | Component | Chức năng |
|---|---|---|
| Danh mục | CatalogSettings (tab 1) | CRUD categories với icon + color |
| Dịch vụ | CatalogSettings (tab 2) | CRUD services + variants + pricing |
| Sản phẩm | CatalogSettings (tab 3) | CRUD products + SKU + stock |
| Gói dịch vụ | CatalogSettings (tab 4) | CRUD packages + item builder |