Skip to content

Type — Complaint Lifecycle And Status

1. Create flow hiện tại

Complaint mới được tạo từ dialog FE bằng direct insert thay vì qua action backend chuyên biệt.

text
User mở /complaint/create
  -> chọn customer, contact, branch, loại complaint, cấp độ, thời gian, nội dung
  -> optional: chọn service / ticket gần nhất
  -> submit
  -> insert_complaint_schedule
  -> insert complaint_schedule_history(status = new_history_complaint)
  -> đóng dialog + refetch list

Dữ liệu tạo mới đáng chú ý

FieldVai trò
customer_idKhách hàng khiếu nại
account_address_idLiên hệ gắn complaint
branch_idChi nhánh chịu trách nhiệm
complaint_kindLoại complaint
complaint_levelCấp độ complaint
ticket_codeTicket liên quan nếu có
complaint_contentNội dung khiếu nại
product_sku / product_nameSnapshot dịch vụ/sản phẩm liên quan
session_created_byNgười thao tác thực tế

Rules

IDRule
CLS-001FE chặn thời gian tạo nằm ở tương lai.
CLS-002Ticket gợi ý chỉ lấy ticket completed gần đây theo query FE.
CLS-003Sau create luôn có một dòng new_history_complaint.
CLS-004Validation create không được backend action chuẩn hóa lại trong flow hiện tại.

2. List flow không phải all-data query

complaintScheduleList là read engine thật cho complaint list.

Input chính

InputVai trò
limit, offsetPagination
searchTìm theo code / customer keyword
branch_idsLọc theo branch
complaint_levelLọc theo cấp độ
statusLọc theo trạng thái

Visibility logic

List complaint được trả về nếu user:

  1. là người tạo complaint,
  2. có branch permission qua resolver/approver tables,
  3. hoặc có full-view role.

Điều này có nghĩa complaint list thực tế đã là permission-aware projection, không phải query trực tiếp lên bảng complaint_schedule.

3. Detail flow có 2 semantics

A. Complaint module detail

  • Dùng action complaintScheduleDetail.
  • Có permission guard.
  • Trả về timeline từ complaint_schedule_history.
  • Trả về complaint_action_role.

B. Customer context detail

  • Dùng query raw ComplaintDetail.
  • FE tự ép complaint_action_role = view.
  • Phù hợp cho read-only context trong customer workspace.

4. Status transitions chuẩn

FromActionToHistory
createdirect insertnew_complaintnew_history_complaint
new_complaintresolvepending_inspection_complaintreceive_history_complaint
pending_inspection_complaintapproveapproved_complaintapproved_history_complaint
pending_inspection_complaintrejectrejected_complaintrejected_history_complaint
pending_inspection_complaintrequest supplementpending_supplement_complaintrequest_supplement_history_complaint
pending_supplement_complaintsupplementpending_inspection_complaintprocess_supplement_history_complaint

Không thấy nhánh reopen hay cancel trong complaint workflow hiện tại.

5. FE step bar không đồng nhất hoàn toàn với status semantics

StatusStep UIÝ nghĩa FE
new_complaint0Chưa giải trình
pending_inspection_complaint1Đang xử lý
pending_supplement_complaint1Đang xử lý
approved_complaint2Kết thúc
rejected_complaint2Kết thúc

Điểm đáng chú ý:

  • FE không tách step riêng cho pha "chờ bổ sung".
  • Người dùng chỉ thấy complaint đang ở pha xử lý chung, còn nuance ai đang nợ hành động phải đọc thêm status text và timeline.

6. Action role là contract quan trọng nhất

complaint_action_roleFE hành xử thế nào
resolveMở dialog giải trình
approveHiện các action duyệt / từ chối / yêu cầu bổ sung
supplementMở dialog bổ sung
viewRead-only, không hiện action mutating

Nếu backend trả role sai, FE sẽ sai ngay ở action footer. Complaint module do đó phụ thuộc mạnh vào correctness của complaintScheduleDetail.

7. Rủi ro / Findings

IDFinding
CLS-F01Create flow chưa được action layer chuẩn hóa nên business rule create không có single source ở backend.
CLS-F02Cùng một complaint có thể vào detail qua 2 sources khác nhau, dẫn đến semantics action/read-only khác nhau.
CLS-F03Step bar FE đang nén pending_inspectionpending_supplement vào cùng một bước, có thể làm BA/QA bỏ sót edge case bổ sung.