Giao diện
payment / order
Trang sinh tự động
Sinh từ ad83b0aea — chạy 820 migration lên PostgreSQL 17 rồi đọc pg_catalog. Mô tả bảng và cột lấy từ COMMENT ON. Không sửa tay: lần chạy docgen sau sẽ ghi đè.
7 bảng. Quay lại payment.
order_cycle_failed_deliveries
#479 A (Product 11/11 Q2). Append-only: one row per Mua định kỳ cycle Operations settled after its delivery failed for good (DELIVERY_FAILED, not paid): the skips used and the failed cycles counted with this one against n of the package, the outcome (CONTINUED, or ORDER_CANCELLED past n: the order Đã hủy + Mất cọc). Written only by ordering.settle_failed_delivery_cycle.
public.order_cycle_failed_deliveries · 13 cột · 3 check · 2 unique · 4 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
order_id | uuid | NOT NULL | FK → orders | |
order_cycle_id | uuid | NOT NULL | FK → order_cycles | |
cycle_no | integer | NOT NULL | ||
shipment_id | uuid | FK → shipments | ||
note | text | |||
skips_used | integer | NOT NULL | ||
failed_count_after | integer | NOT NULL | ||
skip_max | integer | NOT NULL | ||
outcome | text | NOT NULL | ||
recorded_by | uuid | NOT NULL | FK → accounts | |
source_id | text | NOT NULL | ||
created_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (4):
order_cycle_id→order_cycles·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTrecorded_by→accounts·ON DELETE RESTRICTshipment_id→shipments·ON DELETE RESTRICT
Được trỏ tới (1): point_reward_partial_cancels
order_payment_windows
FU-DEF149 GAP-150. Versioned, immutable, UNSEEDED window an order may wait for its first payment; only APPROVED versions apply (fail closed). decision_ref = the decisions.csv id of the owner decision.
public.order_payment_windows · 7 cột · 3 check · 1 unique · 2 index · 0 policy · 3 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
version_no | integer | NOT NULL | ||
status | text | NOT NULL | ||
window_minutes | integer | |||
effective_from | timestamptz | |||
decision_ref | text | |||
created_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra: không có
Được trỏ tới (1): order_payment_expiries
order_cycle_close_values
FU-F3 DEC-CP-CLOSE-OBLIGATIONS (interim). One immutable row per order cycle written by the CONFIRMED Recurring close: final value (never above the order-time value, the clamp is recorded), the prepaid cash/points share and the amount still owed.
public.order_cycle_close_values · 19 cột · 3 check · 2 unique · 4 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
outcome_id | uuid | NOT NULL | FK → campaign_outcomes | |
campaign_id | uuid | NOT NULL | FK → campaign_outcomes | |
order_id | uuid | NOT NULL | FK → orders | |
order_cycle_id | uuid | NOT NULL | FK → order_cycles | |
cycle_no | integer | NOT NULL | ||
method | text | NOT NULL | ||
order_value_vnd | bigint | NOT NULL | ||
final_value_vnd | bigint | NOT NULL | ||
value_vnd | bigint | NOT NULL | ||
clamped_vnd | bigint | NOT NULL | ||
cash_share_vnd | bigint | NOT NULL | ||
points_value_share_vnd | bigint | NOT NULL | ||
points_share | integer | NOT NULL | ||
owed_vnd | bigint | NOT NULL | ||
obligation_id | uuid | FK → payment_obligations | ||
recorded_at | timestamptz | NOT NULL | ||
rounding_vnd | bigint | NOT NULL | U19-P2-07 (BR-DK-08, GAP-W-CD-17). What rounding the COD of the cycle up to 1,000đ adds (0 for ONLINE). | |
allocation_policy | text | NOT NULL | U28-P2-01 (DEC-U28-01). EVEN_SPLIT = closed before DEC-U28-01 (Pi-Point evenly, campaign.recurring_allocate); ACTUAL_PRICE = campaign.recurring_allocate_actual on the kept lines at least(final, order-time) unit price. Frozen at the close, one per outcome; readers branch on it and never recompute. |
Khoá chính: id
Trỏ ra (4):
obligation_id→payment_obligations·ON DELETE RESTRICTorder_cycle_id→order_cycles·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICToutcome_id, campaign_id→campaign_outcomes·ON DELETE RESTRICT
Được trỏ tới: không có
order_cycle_cod_rebalances
PAF-P1-25 (DEC-PAF-28). Append-only: the COD of every close row of a Mua định kỳ order after a forfeit approval that rebalanced the 1,000đ rounding (payment.recurring_cod_balance). payment.recurring_cycle_alloc reads the latest one newer than the latest skip snapshot. Written only by payment.recurring_forfeit_cod_rebalance.
public.order_cycle_cod_rebalances · 7 cột · 1 check · 1 unique · 3 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
review_id | uuid | NOT NULL | ||
order_id | uuid | NOT NULL | FK → orders | |
order_cycle_id | uuid | NOT NULL | FK → order_cycles | |
cycle_no | integer | NOT NULL | ||
cod_vnd | bigint | NOT NULL | ||
created_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (2):
order_cycle_id→order_cycles·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICT
Được trỏ tới: không có
order_cycle_skip_values
PAF-P1-03 (DEC-PAF-06). Append-only: the deposit allocation of a Mua định kỳ order after one skip, one row per close row: basis SKIPPED (0), FIXED (paid / cancelled / Đang đóng gói or later: unchanged) or RESPREAD (deposit spread again last -> first, COD ⌈due⌉ balanced); the latest skip of the order is the current allocation (payment.recurring_cycle_alloc). Written only by payment.recurring_skip_respread.
public.order_cycle_skip_values · 10 cột · 2 check · 1 unique · 3 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
skip_request_id | uuid | NOT NULL | ||
order_id | uuid | NOT NULL | FK → orders | |
order_cycle_id | uuid | NOT NULL | FK → order_cycles | |
cycle_no | integer | NOT NULL | ||
basis | text | NOT NULL | ||
cash_share_vnd | bigint | NOT NULL | ||
due_vnd | bigint | NOT NULL | ||
cod_vnd | bigint | NOT NULL | ||
created_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (2):
order_cycle_id→order_cycles·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICT
Được trỏ tới: không có
order_payment_expiries
FU-DEF149 GAP-150. Append-only evidence that an unpaid DEPOSIT_PENDING order was expired by the P1-16 job (window version, due and expiry instants, resulting order version).
public.order_payment_expiries · 9 cột · 4 check · 1 unique · 2 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
order_id | uuid | NOT NULL | PK FK → orders | |
window_id | uuid | NOT NULL | FK → order_payment_windows | |
window_minutes | integer | NOT NULL | ||
order_created_at | timestamptz | NOT NULL | ||
due_at | timestamptz | NOT NULL | ||
expired_at | timestamptz | NOT NULL | ||
order_version | integer | NOT NULL | ||
source_id | text | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL |
Khoá chính: order_id
Trỏ ra (2):
order_id→orders·ON DELETE RESTRICTwindow_id→order_payment_windows·ON DELETE RESTRICT
Được trỏ tới: không có
order_points_excess_refunds
G1S-P1-02, U28-P2-02 (BR-APP-08, TB-12, BR-C-08). The Pi-Point a LOCK order used above its actual value, returned once to the wallet by a partial REVERSE_REDEEM (request id order:<order>:excess). Written by the Group close trigger (close_outcome_id) or the Recurring close (campaign_outcome_id), marked REFUNDED by campaign.record_points_excess_refund. SYSTEM_ONLY: no table privilege.
public.order_points_excess_refunds · 11 cột · 4 check · 2 unique · 3 index · 0 policy · 3 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
order_id | uuid | NOT NULL | PK FK → orders | |
close_outcome_id | uuid | FK → order_close_outcomes | ||
campaign_id | uuid | NOT NULL | ||
owner_account_id | uuid | NOT NULL | FK → accounts | |
points | integer | NOT NULL | ||
request_id | text | NOT NULL | ||
status | text | NOT NULL | ||
point_request_id | uuid | FK → point_requests | ||
recorded_at | timestamptz | NOT NULL | ||
refunded_at | timestamptz | |||
campaign_outcome_id | uuid | FK → campaign_outcomes | U28-P2-02 (CD-US-12 AC21, BR-C-08). The Recurring campaign outcome whose close recorded the excess Pi-Point (the order has no order_close_outcomes LOCK row); null for a Group row (close_outcome_id). |
Khoá chính: order_id
Trỏ ra (5):
campaign_outcome_id→campaign_outcomes·ON DELETE RESTRICTclose_outcome_id→order_close_outcomes·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTowner_account_id→accounts·ON DELETE RESTRICTpoint_request_id→point_requests·ON DELETE RESTRICT
Được trỏ tới: không có