Skip to content

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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
order_cycle_iduuidNOT NULLFK → order_cycles
cycle_nointegerNOT NULL
shipment_iduuidFK → shipments
notetext
skips_usedintegerNOT NULL
failed_count_afterintegerNOT NULL
skip_maxintegerNOT NULL
outcometextNOT NULL
recorded_byuuidNOT NULLFK → accounts
source_idtextNOT NULL
created_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (4):

  • order_cycle_id → order_cycles · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • recorded_by → accounts · ON DELETE RESTRICT
  • shipment_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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
version_nointegerNOT NULL
statustextNOT NULL
window_minutesinteger
effective_fromtimestamptz
decision_reftext
created_attimestamptzNOT 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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
outcome_iduuidNOT NULLFK → campaign_outcomes
campaign_iduuidNOT NULLFK → campaign_outcomes
order_iduuidNOT NULLFK → orders
order_cycle_iduuidNOT NULLFK → order_cycles
cycle_nointegerNOT NULL
methodtextNOT NULL
order_value_vndbigintNOT NULL
final_value_vndbigintNOT NULL
value_vndbigintNOT NULL
clamped_vndbigintNOT NULL
cash_share_vndbigintNOT NULL
points_value_share_vndbigintNOT NULL
points_shareintegerNOT NULL
owed_vndbigintNOT NULL
obligation_iduuidFK → payment_obligations
recorded_attimestamptzNOT NULL
rounding_vndbigintNOT NULLU19-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_policytextNOT NULLU28-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 RESTRICT
  • order_cycle_id → order_cycles · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • outcome_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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
review_iduuidNOT NULL
order_iduuidNOT NULLFK → orders
order_cycle_iduuidNOT NULLFK → order_cycles
cycle_nointegerNOT NULL
cod_vndbigintNOT NULL
created_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (2):

  • order_cycle_id → order_cycles · ON DELETE RESTRICT
  • order_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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
skip_request_iduuidNOT NULL
order_iduuidNOT NULLFK → orders
order_cycle_iduuidNOT NULLFK → order_cycles
cycle_nointegerNOT NULL
basistextNOT NULL
cash_share_vndbigintNOT NULL
due_vndbigintNOT NULL
cod_vndbigintNOT NULL
created_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (2):

  • order_cycle_id → order_cycles · ON DELETE RESTRICT
  • order_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ộtKiểuKhoáMô tả
order_iduuidNOT NULLPK FK → orders
window_iduuidNOT NULLFK → order_payment_windows
window_minutesintegerNOT NULL
order_created_attimestamptzNOT NULL
due_attimestamptzNOT NULL
expired_attimestamptzNOT NULL
order_versionintegerNOT NULL
source_idtextNOT NULL
correlation_idcorrelation_refNOT NULL

Khoá chính: order_id

Trỏ ra (2):

  • order_id → orders · ON DELETE RESTRICT
  • window_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ộtKiểuKhoáMô tả
order_iduuidNOT NULLPK FK → orders
close_outcome_iduuidFK → order_close_outcomes
campaign_iduuidNOT NULL
owner_account_iduuidNOT NULLFK → accounts
pointsintegerNOT NULL
request_idtextNOT NULL
statustextNOT NULL
point_request_iduuidFK → point_requests
recorded_attimestamptzNOT NULL
refunded_attimestamptz
campaign_outcome_iduuidFK → campaign_outcomesU28-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 RESTRICT
  • close_outcome_id → order_close_outcomes · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • owner_account_id → accounts · ON DELETE RESTRICT
  • point_request_id → point_requests · ON DELETE RESTRICT

Được trỏ tới: không có

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17