Skip to content

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ầnVai trò
product (type=service)Master dịch vụ
product_relationLiên kết subtask / tour limit / default subtask
role_commissionCommission theo role / payment method
branch_service_configOverride theo chi nhánh

Appointment / Tour

Thành phầnVai trò
order_itemDịch vụ đã bán
appointmentBuổi thực hiện / tour
appointment_userCustomer, staff, consultant
project_task, project_task_assigneeWork 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_limitGiới hạn tổng
product_relation.tour_limit_subtaskGiới hạn mặc định theo subtask
order_service_tour_override.tour_limit_subtaskOverride theo order item

Quy tắc nghiệp vụ

Quy tắc
BR-SVC-001Khi insert service order, hệ thống seed order_service_tour_override cho từng related subtask.
BR-SVC-002Nếu là quà tặng manual, override có thể bị ép nil.
BR-SVC-003Action 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 flows

Quy tắc nghiệp vụ

Quy tắc
BR-SVC-004Appointment service insert có thể tự sinh project_task cha và subtask mặc định nếu service thuộc automation project.
BR-SVC-005appointment.from là nguồn sync cho project_task.due_date.
BR-SVC-006appointment.confirmed set confirmed_at; completed có thể auto-complete service order đã paid.
BR-SVC-007canceled 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ụ

Quy tắc
BR-SVC-008project_task_assignee_insert có thể auto-fill tour_money theo tag_tour_moneys và level assignee.
BR-SVC-009project_task_assignee_update chặn tăng tour_money vượt limit; có thể reset assignee hiện tại về 0.
BR-SVC-010request_working_schedule là downstream touchpoint của project/doctors, không phải phần core của appointment.

Reminder

LuồngVai trò
appointment_reminderIn-app reminder theo app setting period
appointment_service_reminder_smsSMS/ZNS 24h trước lịch service
appointment_consultant_reminder_smsReminder cho consultation
CRM schedulersconsolidate_ticket_4, remind_ticket_tomorrow

Quy tắc nghiệp vụ

Quy tắc
BR-SVC-011Reminder chạy đa kênh, không chỉ một scheduler duy nhất.
BR-SVC-012appointment_service_reminder_sms đang dedupe theo customer, không theo từng appointment.

RBAC thực tế

ActionStaffManagerAdmin
Xem runtime order/appointment
Sửa service configKhôngKhôngCó / settings roles
Override tour limitKhôngMột phần
Xem mọi branchKhôngBranch

Rủi ro / Findings

MứcMô tả
P1Nếu doc gom service config và service runtime thành một lớp sẽ sai boundary hệ thống.
P1Popup hủy lịch hẹn có nhập lý do nhưng code hiện có nguy cơ không persist cancel_reason.
P1Tour limit enforcement thấy rõ ở update path, nhưng insert path không đối xứng hoàn toàn.
P2Reminder 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_subtaskSubtask mặc định được seed vào runtime
tour_limit_subtaskGiới hạn tour theo subtask
order_service_tour_overrideOverride limit theo order item
tour_moneyTiền tour trên assignee của project task