Appearance
Đơn hàng (Orders) — Technical Map
Route map
| Subdomain | Routes chính |
|---|---|
| Service order | /e/service-order, create, detail, payments, commissions, services, appointments, tasks, notes |
| Product order | /e/product-order, create, update, detail, items, notes, commissions, histories |
| Prepaid order | /e/prepaid-order, create, detail, payments, commissions, notes |
| Refund / withdraw | request-management/withdraw/* và withdraw-requests/* |
| Negative payment | /e/negative-payment-requests/:id |
FE / action map
| Flow | FE page / handler | Backend canonical path |
|---|---|---|
| Create service/prepaid order | ServiceOrderCreate.tsx, PrepaidOrderCreate.tsx | createOrder |
| Create invoice transaction | form payments | createInvoiceTransaction |
| Customer/app pay invoice | payment entry | payInvoice |
| Approve refund request | WithdrawRequestDetail.tsx | changeStatusTransaction |
| Create negative payment | order/request screens | createNegativePayment |
Actions / events quan trọng
| Thành phần | File | Vai trò |
|---|---|---|
| Action | create_order.go | Tạo service/prepaid order |
| Action | payment_order.go | createInvoiceTransaction, validate sub-invoice, wallet promo |
| Action | order_payment.go | payInvoice |
| Action | change_status_transaction_refund.go | Approve/reject/cancel refund request |
| Action | negative_payment.go | Tạo invoice âm + request approval HRM |
| Event | invoice_insert_update.go | Commission, invoice side effects |
| Event | invoice_complete.go | Complete invoice lifecycle |
| Event | transaction_request_insert.go | Insert refund/withdraw lifecycle |
| Event | transaction_request_update.go | Revenue rollback, refund commission, wallet updates |
| Event | refund_log_sync.go | Sync refund log dựa trên reference_id |
Data model cốt lõi
Order / invoice
| Bảng | Điểm cần nhớ |
|---|---|
order | Có order_kind, invoice_draft, is_refunded_order, refund_amount, wallet_receive_commission, computed debt_amount |
invoice | Có parent/sub invoice, negative, wallet_promotion_amount, request_negative_id |
invoice_commission | Link invoice với commission |
order_commission, order_commission_user, order_commission_history | Commission runtime + history |
Refund / withdraw
| Bảng | Vai trò |
|---|---|
transaction_request | Request engine của refund/withdraw |
transaction_request_user | Actors sender/receiver theo wallet flow |
transaction_request_log | Audit |
transaction_refund_log | Refund log sync |
wallet_reference_file | Chứng từ / file tham chiếu |
Negative payment
| Bảng | Vai trò |
|---|---|
request_working_schedule | Approval container của negative payment |
invoice.request_negative_id | Link từ invoice âm sang request |
Field semantics cần ghi rõ
| Field | Ý nghĩa |
|---|---|
invoice_draft | Đơn đang có invoice draft |
negative | Invoice âm |
request_negative_id | Link sang request approval negative |
wallet_promotion_amount | Tiền ví khuyến mãi trên invoice |
is_refunded_order | Đơn đã đi qua refund success |
refund_amount | Tổng tiền đã hoàn |
reference_id ở transaction_request | Overloaded; có thể mang nghĩa invoice hoặc order tùy flow |
Divergence quan trọng theo order kind
| Order kind | Payment path |
|---|---|
| Service | createOrder -> createInvoiceTransaction |
| Prepaid | createOrder -> createInvoiceTransaction |
| Product/Cosmetic | FE create/update flow riêng, còn insert invoice trực tiếp ở FE trong nhiều nhánh |
Sequence thực tế
7.1 Refund order
text
FE tạo withdraw/refund request
-> wallet.transaction_request
-> changeStatusTransaction
-> transaction_request_update event
-> update order refunded flags / revenue / point
-> có thể sinh refund commission7.2 Negative payment
text
FE tạo negative payment
-> action createNegativePayment
-> create invoice negative=true
-> create request_working_schedule
-> approval flow riêngRủi ro / Findings kỹ thuật
| Mức | Mô tả |
|---|---|
| P1 | Product order diverge khỏi service/prepaid ở payment path, nên docs không thể giả định một pipeline chung cho mọi order kind. |
| P1 | Refund detail và negative detail có dấu hiệu check approver sai actor. |
| P1 | reference_id ở transaction_request không canonical, cần nói rõ trong mọi doc downstream. |
| P1 | Side effect refund lớn nằm ở wallet event, không nằm hết trong action approve. |
| P2 | WithdrawRequestCreate có fallback amount 40000000, là default nguy hiểm cho UI. |