Skip to content

Customer Workspace — Business Rules

Tổng quan

Domain này là customer workspace thật của user module. Nó không chỉ là danh sách khách hàng, mà là một shell hồ sơ khách hàng tổng hợp, kéo dữ liệu từ nhiều module khác nhau.

Scope nghiệp vụ

NhómVai tròVí dụ surface
Customer listTìm kiếm, lọc, phân trang khách hàngCustomers.tsx, CustomerTable
Customer create / editTạo hoặc cập nhật hồ sơ kháchCustomerCreate.tsx
Customer detail shellWorkspace chính của một khách hàngCustomerDetail.tsx
Customer detail tabsNote, contact book, appointment, activity, reward, ticket, call history, task, order, record, payment, SMS, collaborator, complaintnested routes dưới ROUTE_CUSTOMER_DETAIL

Luồng chính

text
Customer list
  -> filter / search / export
  -> mở customer detail
  -> workspace shell hiển thị profile + wallet stats + cumulative stats
  -> đổi tab sang note / order / payment / ticket / collaborator / complaint
  -> nhiều tab reuse component từ crm / ecommerce / wallet / affiliate

Quy tắc nghiệp vụ

Quy tắc
BR-UCW-001CustomerDetail là shell tổng hợp; customer_id được dùng chung cho toàn bộ tab con.
BR-UCW-002Route detail mặc định redirect về tab note.
BR-UCW-003Customer workspace không tự sở hữu toàn bộ business logic; nó chủ yếu là lớp hợp nhất read/write surface từ module khác.
BR-UCW-004Collaborator flows của khách hàng được mount trực tiếp trong user detail nhưng thực chất reuse pages/components từ module affiliate.
BR-UCW-005Khi chạy ở CRM platform, navigation customer đổi path sang /crm/customer, nhưng ownership code vẫn nằm trong module user.
BR-UCW-006Customer workspace không phải read-only thuần; create/update customer, note/contact book, ticket status và một số thao tác affiliate đều có write path ngay trong shell này.

Boundary

BoundaryGhi chú
crmCustomer visit, ticket manager, call history, một phần route constants
ecommerceAppointment, order history, record, treatment images
walletWallet stats, payment/refund histories
affiliateCollaborator order/payment/withdraw flows

Rủi ro / Findings

MứcFinding
P1Customer workspace bị coupling rất mạnh với crm, ecommerce, wallet, affiliate; đổi route/tab dễ gây vỡ liên module.
P1Navigation customer thay đổi theo platform (admin/pos vs crm), nên trace route thực tế không chỉ nhìn user/module.ts.
P2CustomerCreate.tsx đang import route constants từ crm/types, cho thấy boundary UI bị trộn ngay từ create flow.
P2Complaint tab không query từ module complaint mà dùng query/report layer, nên ownership dữ liệu ở nhánh này khá mờ.