Skip to content

Đơn hàng (Orders) — Technical Map

Route map

SubdomainRoutes 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 / withdrawrequest-management/withdraw/*withdraw-requests/*
Negative payment/e/negative-payment-requests/:id

FE / action map

FlowFE page / handlerBackend canonical path
Create service/prepaid orderServiceOrderCreate.tsx, PrepaidOrderCreate.tsxcreateOrder
Create invoice transactionform paymentscreateInvoiceTransaction
Customer/app pay invoicepayment entrypayInvoice
Approve refund requestWithdrawRequestDetail.tsxchangeStatusTransaction
Create negative paymentorder/request screenscreateNegativePayment

Actions / events quan trọng

Thành phầnFileVai trò
Actioncreate_order.goTạo service/prepaid order
Actionpayment_order.gocreateInvoiceTransaction, validate sub-invoice, wallet promo
Actionorder_payment.gopayInvoice
Actionchange_status_transaction_refund.goApprove/reject/cancel refund request
Actionnegative_payment.goTạo invoice âm + request approval HRM
Eventinvoice_insert_update.goCommission, invoice side effects
Eventinvoice_complete.goComplete invoice lifecycle
Eventtransaction_request_insert.goInsert refund/withdraw lifecycle
Eventtransaction_request_update.goRevenue rollback, refund commission, wallet updates
Eventrefund_log_sync.goSync refund log dựa trên reference_id

Data model cốt lõi

Order / invoice

BảngĐiểm cần nhớ
orderorder_kind, invoice_draft, is_refunded_order, refund_amount, wallet_receive_commission, computed debt_amount
invoiceCó parent/sub invoice, negative, wallet_promotion_amount, request_negative_id
invoice_commissionLink invoice với commission
order_commission, order_commission_user, order_commission_historyCommission runtime + history

Refund / withdraw

BảngVai trò
transaction_requestRequest engine của refund/withdraw
transaction_request_userActors sender/receiver theo wallet flow
transaction_request_logAudit
transaction_refund_logRefund log sync
wallet_reference_fileChứng từ / file tham chiếu

Negative payment

BảngVai trò
request_working_scheduleApproval container của negative payment
invoice.request_negative_idLink từ invoice âm sang request

Field semantics cần ghi rõ

FieldÝ nghĩa
invoice_draftĐơn đang có invoice draft
negativeInvoice âm
request_negative_idLink sang request approval negative
wallet_promotion_amountTiền ví khuyến mãi trên invoice
is_refunded_orderĐơn đã đi qua refund success
refund_amountTổng tiền đã hoàn
reference_idtransaction_requestOverloaded; có thể mang nghĩa invoice hoặc order tùy flow

Divergence quan trọng theo order kind

Order kindPayment path
ServicecreateOrder -> createInvoiceTransaction
PrepaidcreateOrder -> createInvoiceTransaction
Product/CosmeticFE 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 commission

7.2 Negative payment

text
FE tạo negative payment
  -> action createNegativePayment
  -> create invoice negative=true
  -> create request_working_schedule
  -> approval flow riêng

Rủi ro / Findings kỹ thuật

MứcMô tả
P1Product 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.
P1Refund detail và negative detail có dấu hiệu check approver sai actor.
P1reference_idtransaction_request không canonical, cần nói rõ trong mọi doc downstream.
P1Side effect refund lớn nằm ở wallet event, không nằm hết trong action approve.
P2WithdrawRequestCreate có fallback amount 40000000, là default nguy hiểm cho UI.