Appearance
Dịch vụ & Lịch hẹn (Services & Appointments) — Business Rules
Tổng quan
Domain này chỉ đúng khi nhìn theo 4 lớp:
text
Service Config
-> Order Item Service
-> Appointment / Tour
-> Project Task / Tour Money / ReminderĐiểm quan trọng: service config nằm ở settings, còn runtime bán hàng - appointment - project task nằm ở ecommerce.
Cấu trúc dịch vụ
| Thành phần | Vai trò |
|---|---|
product (type=service) | Master dịch vụ |
product_relation | Liên kết subtask / tour limit / default subtask |
role_commission | Commission theo role / payment method |
branch_service_config | Override theo chi nhánh |
Appointment / Tour
| Thành phần | Vai trò |
|---|---|
order_item | Dịch vụ đã bán |
appointment | Buổi thực hiện / tour |
appointment_user | Customer, staff, consultant |
project_task, project_task_assignee | Work tracking và tour money |
Tour limit
Tour limit không chỉ là một con số.
Nguồn dữ liệu
| Lớp | Ý nghĩa |
|---|---|
product.tour_limit | Giới hạn tổng |
product_relation.tour_limit_subtask | Giới hạn mặc định theo subtask |
order_service_tour_override.tour_limit_subtask | Override theo order item |
Quy tắc nghiệp vụ
| Mã | Quy tắc |
|---|---|
| BR-SVC-001 | Khi insert service order, hệ thống seed order_service_tour_override cho từng related subtask. |
| BR-SVC-002 | Nếu là quà tặng manual, override có thể bị ép nil. |
| BR-SVC-003 | Action GetListTourLimit ưu tiên override trước rồi mới tính counted/actual times. |
Appointment lifecycle
text
Order item service
-> tạo appointment
-> appointment confirmed
-> appointment completed / canceled
-> sync sang project task / order status / reminder flowsQuy tắc nghiệp vụ
| Mã | Quy tắc |
|---|---|
| BR-SVC-004 | Appointment service insert có thể tự sinh project_task cha và subtask mặc định nếu service thuộc automation project. |
| BR-SVC-005 | appointment.from là nguồn sync cho project_task.due_date. |
| BR-SVC-006 | appointment.confirmed set confirmed_at; completed có thể auto-complete service order đã paid. |
| BR-SVC-007 | canceled có notification flow riêng. |
Tour money / assignee
text
Project task assignee insert/update
-> tính `tour_money`
-> check limit
-> downstream sang doctor commission / working schedule nếu cóQuy tắc nghiệp vụ
| Mã | Quy tắc |
|---|---|
| BR-SVC-008 | project_task_assignee_insert có thể auto-fill tour_money theo tag_tour_moneys và level assignee. |
| BR-SVC-009 | project_task_assignee_update chặn tăng tour_money vượt limit; có thể reset assignee hiện tại về 0. |
| BR-SVC-010 | request_working_schedule là downstream touchpoint của project/doctors, không phải phần core của appointment. |
Reminder
| Luồng | Vai trò |
|---|---|
appointment_reminder | In-app reminder theo app setting period |
appointment_service_reminder_sms | SMS/ZNS 24h trước lịch service |
appointment_consultant_reminder_sms | Reminder cho consultation |
| CRM schedulers | consolidate_ticket_4, remind_ticket_tomorrow |
Quy tắc nghiệp vụ
| Mã | Quy tắc |
|---|---|
| BR-SVC-011 | Reminder chạy đa kênh, không chỉ một scheduler duy nhất. |
| BR-SVC-012 | appointment_service_reminder_sms đang dedupe theo customer, không theo từng appointment. |
RBAC thực tế
| Action | Staff | Manager | Admin |
|---|---|---|---|
| Xem runtime order/appointment | Có | Có | Có |
| Sửa service config | Không | Không | Có / settings roles |
| Override tour limit | Không | Một phần | Có |
| Xem mọi branch | Không | Branch | Có |
Rủi ro / Findings
| Mức | Mô tả |
|---|---|
| P1 | Nếu doc gom service config và service runtime thành một lớp sẽ sai boundary hệ thống. |
| P1 | Popup hủy lịch hẹn có nhập lý do nhưng code hiện có nguy cơ không persist cancel_reason. |
| P1 | Tour limit enforcement thấy rõ ở update path, nhưng insert path không đối xứng hoàn toàn. |
| P2 | Reminder service đang dedupe theo customer đầu tiên, một khách nhiều lịch có thể chỉ nhận 1 reminder. |
Thuật ngữ
| Thuật ngữ | Định nghĩa |
|---|---|
default_subtask | Subtask mặc định được seed vào runtime |
tour_limit_subtask | Giới hạn tour theo subtask |
order_service_tour_override | Override limit theo order item |
tour_money | Tiền tour trên assignee của project task |