Skip to content

Khuyến mãi, Trả trước & Request Flows — Technical Map

Route map

SubdomainRoutes / pages
Prepaid order/e/prepaid-order, create, detail, payments, commissions, notes
Withdraw / Refund/e/requests/withdraw/*/e/withdraw-requests/*
Fund managementfund-management list/create/detail/update
Negative payment/e/negative-payment-requests/:id
PromotionConstants/pages/GraphQL còn tồn tại, nhưng route registration đang comment

FE GraphQL / pages chính

FileVai trò
prepaid_order.graphqlPrepaid order list/detail/payments/commission
withdraw_request.graphqlRefund / withdraw request
fund.graphqlFund list/detail/filter
negative_payment_request.graphqlApproval flow negative payment
promotion.graphqlPromotion/voucher-related operations còn trong code
PrepaidOrderCreate.tsxRule create prepaid
WithdrawRequestDetail.tsxApproval/refund detail
NegativePaymentRequestDetail.tsxApproval negative payment

Data model cốt lõi

BảngDBVai trò
order, invoice, order_commission, campaign_orderecommercePrepaid/order/payment
transaction_request, transaction_request_user, transaction_request_logwalletRefund / withdraw lifecycle
transaction_refund_logecommerceAudit refund
wallet_reference_filewalletFile đính kèm refund
fund, fund_fileecommerceFund management
voucher_campaigns, user_vouchers, voucher_logsecommerceVoucher lifecycle
request_working_schedulehrmApproval của negative payment

Action / event map

Thành phầnFileVai trò
Actioncreate_order.goTạo service/prepaid order
Actionpayment_order.gocreateInvoiceTransaction cho parent/sub invoice
Actionorder_payment.gopayInvoice
Actionchange_status_transaction_refund.goApprove/reject/cancel refund request
Actionnegative_payment.goTạo negative invoice + approval request
Eventinvoice_insert_update.goCommission, invoice side effects
Eventtransaction_request_insert.goInsert lifecycle cho refund/withdraw
Eventtransaction_request_update.goRevenue rollback, refund commission, wallet updates
Eventrestore_voucher_on_order_cancel.goRestore voucher khi order cancel
Actionapprove_voucher_campaign.goPublish voucher campaign
Actionactivate_offline_voucher.goActivate voucher offline

Data semantics cần ghi rõ

FieldÝ nghĩa
order.invoice_draftĐơn đang có invoice draft
order.is_refunded_orderĐơn đã có refund flow success
order.refund_amountTổng tiền đã refund
invoice.negativeInvoice âm cho negative payment
invoice.request_negative_idLink ngược sang request approval
invoice.wallet_promotion_amountPhần wallet promotion trên invoice
transaction_request.reference_idKhông canonical tuyệt đối; có thể trỏ invoice hoặc order tùy flow

Boundary matrix

FlowCanonical engine
Prepaid create/paymentecommerce-api + ecommerce.invoice
Refund / withdrawwallet-api + wallet.transaction_request
Negative paymentecommerce-api + hrm.request_working_schedule
Voucher publish/activate/restoreecommerce-api
Fund reportingFE fund screens + ecommerce tables/views

Rủi ro / Findings kỹ thuật

MứcMô tả
P1reference_id trong transaction_request đang bị overload, phải fallback invoice -> order hoặc order trực tiếp để hiểu nghĩa thật.
P1Product order diverge với service/prepaid vì invoice được insert trực tiếp ở FE, không đi cùng action backend chuẩn.
P1Refund/negative approval guard ở FE có dấu hiệu check sai actor.
P2Promotion routes bị comment nhưng code còn đầy đủ, tạo vùng dead-code / dormant feature.