Skip to content

Đơn hàng ​

Trang sinh tự động

Phần nghiệp vụ viết tay; API, dữ liệu, quyền, đường dẫn và file nguồn do bộ sinh điền từ source tại ad83b0aea.

Làm gì ​

Đơn hàng của cả hai mô hình mua, với mã đơn riêng và lịch sử trạng thái. Mua định kỳ chia theo kỳ, mỗi kỳ có cửa sổ giao và quyền bỏ qua trong giới hạn gói. Huỷ đơn chưa thanh toán thì miễn phí; đơn đã cọc đi theo đường hoàn tiền.

Quy mô ​

Domain APIorder, order-return, recurring-skip
Query / Mutation16 / 7
Nguồn dữ liệuorder_fulfillment
Bảng21
Luật phân quyền9
Đường dẫn Web Admin6

Thao tác (mutation) ​

MutationDomainMô tả
cancelCycleSkiprecurring-skipU28-P2-04 (DEC-U28-02): a confirmed skip cannot be undone, every call is conflict skip_irreversible (nothing written; the ACTIVE skips already recorded stay). Kept for compatibility. Requires order.request_skip (SKP-01, OWN).
dropOrderPointsorderU-30b "Tiếp tục không dùng điểm" (BR-DC-06): the caller's own Group Buy
requestCycleSkiprecurring-skipSkips one cycle of an own LOCKED Recurring order while the cycle has no shipment (cycle_in_shipment after; PAF DEC-PAF-05: no time lock, cutoff_passed no longer returned). Past the package n: conflict limit_reached, nothing written (owner 22/10, D13). U28-P2-04 (DEC-U28-03): a cycle empty after the MOQ is conflict cycle_empty, no skip counted. Requires order.request_skip (SKP-01, OWN).
requestOrderCancellationorderCancels an own order before the cutoff: a PLACED order requests its refund; an unpaid one is cancelled free (O3; conflict reason payment_pending while a deposit attempt is in flight). Requires order.request_cancel (U-03, OWN).
settleFailedDeliveryCycleorder#479 A. Operations settle a Mua định kỳ cycle whose delivery failed for good (DELIVERY_FAILED) and is not paid in full:
submitGroupOrderorderCreates a DEPOSIT_PENDING order from an open own quote. Requires order.create.
submitRecurringOrderorderCommits the quoted basket (its package and window) into one DEPOSIT_PENDING

Phép đọc (query) ​

QueryDomainMô tả
adminOrderorderU19-P2-11. One order for the Admin detail. Requires order.read (OPS-02
adminOrderHistoryorderOrder history of every change (order status, payment, delivery, Pi-Point,
adminOrdersorderStaff order list/search, newest first. Requires order.read (OPS-02 ALL; M-02 TEAM: orders attributed to a Sale
adminOrderTabCountsorderU19-P2-10. Tab counts (Tat ca / Mua chung / Mua dinh ky) of adminOrders under the same search and filters,
cycleSchedulerecurring-skipSchedule, immutable n/cutoff snapshot and skip state of an own Recurring order. Requires order.read (U-01, OWN).
groupQuoteorderServer quote for one Group Buy product. Requires order.create (U-02, own).
myOrderCountsorderChip counts of the caller's own orders, same filters as myOrders. Requires order.read (U-01, own).
myOrdersorderThe caller's own orders, newest first. Requires order.read (U-01, own).
orderorderOne own order; another account's order is not_found. Requires order.read.
orderCancellationEligibilityorderServer-computed cancellation eligibility of an own order. Requires order.read (U-01, OWN).
orderEventsorderOrder history, oldest first. Requires order.read (U-01 own, M-02 TEAM).
orderReturnCaseorder-returnThe RETURN case of one Order, or null. Requires order.read (GAP-1320: no role yet).
orderReturnCasesorder-returnRETURN cases, newest first, optionally of one shipment. Requires order.read.
paymentStatusorderCanonical status of one payment attempt. Requires payment.read (U-04 own, F-01 Finance).
publicRecurringQuoteorderG2S S12: quote of a guest's device basket for a published OPEN Recurring campaign (closed: conflict campaign_closed; unknown, unpublished or Group Buy: not_found; an empty cycle: validation_failed cycle_empty). No sign-in needed (deal.read_public, PUB-01; a Sale reads not_found); x-pi-app is still required.
recurringQuoteorderServer quote of the caller's own Recurring basket. G2S (DEC-FS27-MD-EMPTY-CYCLE; the same rule as U28-P2-04 DEC-U28-03): a cycle where every product is 0 is validation_failed reason cycle_empty with details.cycleNo (the first one); every cycle must reach the minimum. Requires order.create (U-02, own).

Dữ liệu ​

Bảng được tham chiếu nhiều nhất trong module:

BảngCộtĐược trỏ tớiRLS
orders6541✓
order_cycles149✓
shipments468✓
order_periods154✓
stock_shortage_cases144✓
order_close_outcomes262✓
order_lines182✓
order_quotes322✓
shipment_order_links92✓
fulfillment_events201✓

Quyền ​

MãQuyềnỨng dụngVai tròPhạm viTrạng thái
M-02order.readWEB_ADMINsale_managerTEAMDEFINED
O-02order.manageWEB_ADMINoperations adminALLPROPOSED
OPS-02order.readWEB_ADMINoperations adminALLPROPOSED
ORD-01order.cancelWEB_ADMINoperations adminALLDEFINED
S-02order.readAPP_SALEsaleASSIGNEDDEFINED
SKP-01order.request_skipAPP_USERuserOWNPROPOSED
U-01order.readAPP_USERuserOWNDEFINED
U-02order.createAPP_USERuserOWNPROPOSED
U-03order.request_cancelAPP_USERuserOWNPROPOSED

Danh sách đầy đủ và cách đọc các cờ: Ma trận quyền.

Giao diện Web Admin ​

Đường dẫnHằng số
/ordersORDERS
/orders/:idORDER_DETAIL
/orders/:id/paymentORDER_PAYMENT
/orders/exceptionsORDER_EXCEPTIONS
/orders/exceptions/:idORDER_EXCEPTION_DETAIL
/orders/exceptions/newORDER_EXCEPTION_NEW

File nguồn ​

Backend:

  • code/apps/api/supabase/functions/graphql/domains/order/
  • code/apps/api/supabase/functions/graphql/domains/order-return/
  • code/apps/api/supabase/functions/graphql/domains/recurring-skip/

Dữ liệu: bảng thuộc domain order_fulfillment — xem Cơ sở dữ liệu.

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17