Giao diện
order_fulfillment / shipment
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 đè.
3 bảng. Quay lại order_fulfillment.
shipments
P2-17. Shipment of LOCKED orders/cycles with one schedule source and one delivery snapshot; state CREATED -> PACKING -> SHIPPING -> DELIVERED|DELIVERY_FAILED|RETURNED, written only by fulfillment.* functions.
public.shipments · 46 cột · 18 check · 2 unique · 10 index · 1 policy · 6 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
carrier_code | text | NOT NULL | ||
carrier_ref | text | NOT NULL | ||
schedule_kind | text | NOT NULL | ||
campaign_id | uuid | FK → campaigns | ||
milestone_id | uuid | FK → delivery_milestones | ||
recurring_cycle_id | uuid | FK → recurring_cycles | ||
cycle_no | integer | |||
delivers_from | timestamptz | NOT NULL | ||
delivers_to | timestamptz | NOT NULL | ||
delivers_from_vn | date | |||
delivers_to_vn | date | |||
expected_on | date | NOT NULL | ||
ship_recipient_name | text | NOT NULL | ||
ship_recipient_phone | phone_e164 | NOT NULL | ||
ship_province | text | NOT NULL | ||
ship_district | text | NOT NULL | ||
ship_ward | text | NOT NULL | ||
ship_address_line | text | NOT NULL | ||
ship_address_type | text | NOT NULL | ||
handed_over_at | timestamptz | NOT NULL | ||
handover_evidence_media_id | uuid | FK → media | ||
state | text | NOT NULL | U19-P1-08 machine (ASSUME-04): CREATED -> PACKING -> [PACKED ->] SHIPPING -> WAITING_REDELIVERY -> SHIPPING ... -> DELIVERED [-> RETURNED] | DELIVERY_FAILED; written only by fulfillment.* functions. | |
state_changed_at | timestamptz | NOT NULL | ||
last_event_at | timestamptz | NOT NULL | ||
delivered_at | timestamptz | |||
created_by | uuid | NOT NULL | FK → accounts | |
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL | ||
packed_at | timestamptz | U13-P1-04d. Ngày đóng gói: when packing completed; NULL until then, distinct from handed_over_at. | ||
weight_value | numeric(12,3) | |||
weight_unit | text | |||
length_value | numeric(12,3) | |||
width_value | numeric(12,3) | |||
height_value | numeric(12,3) | |||
dimension_unit | text | |||
delivery_request | text | |||
shipment_note | text | |||
fee_vnd | bigint | |||
fee_payer | text | U13-P1-04d. SHOP only in phase 1 (Khách trả disabled); the fee never enters the COD total. | ||
cod_total_snapshot_vnd | bigint | U13-P1-04d. COD total frozen at handover (immutable once written by the guard); NULL for older shipments. | ||
shipment_code | text | |||
driver_name | text | G2I-P3-03 (O8). Driver name typed by Operations; null = not given. | ||
driver_phone | phone_e164 | G2I-P3-03 (O8). Driver phone (operations contact, E.164). Staff read it in full; the buyer read selects it masked only. | ||
delivery_slot_text | text | G2I-P3-03 (O8). Delivery time slot as typed (e.g. 8h-12h); null = not given. |
Khoá chính: id
Trỏ ra (5):
campaign_id→campaigns·ON DELETE RESTRICTcreated_by→accounts·ON DELETE RESTRICThandover_evidence_media_id→media·ON DELETE RESTRICTmilestone_id→delivery_milestones·ON DELETE RESTRICTrecurring_cycle_id→recurring_cycles·ON DELETE RESTRICT
Được trỏ tới (8): cod_collections, cod_reconciliation_items, fulfillment_events, fulfillment_exceptions, order_cycle_failed_deliveries, order_return_cases, shipment_link_resolutions, shipment_order_links
shipment_order_links
P2-17. Immutable order/cycle -> shipment mapping with the goods snapshot; one shipment per order/cycle.
public.shipment_order_links · 9 cột · 3 check · 2 unique · 4 index · 1 policy · 5 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
shipment_id | uuid | NOT NULL | FK → shipments | |
order_id | uuid | NOT NULL | FK → orders | |
order_cycle_id | uuid | FK → order_cycles | ||
cycle_no | integer | |||
lines | jsonb | NOT NULL | ||
created_at | timestamptz | NOT NULL | ||
locked_payment_mode | text | |||
locked_cod_due_vnd | bigint | U13-P2-09d. OPEN COD obligations of the unit at handover (0 for an Online-paid unit); NULL for links made before. |
Khoá chính: id
Trỏ ra (3):
order_cycle_id→order_cycles·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTshipment_id→shipments·ON DELETE RESTRICT
Được trỏ tới (2): fulfillment_exceptions, shipment_link_resolutions
shipment_link_resolutions
FU-AC-TRIAGE L6. Append-only: an operator removed the line of a cancelled order from a shipment before handover.
public.shipment_link_resolutions · 7 cột · 2 check · 1 unique · 2 index · 1 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
link_id | uuid | NOT NULL | FK → shipment_order_links | |
shipment_id | uuid | NOT NULL | FK → shipments | |
resolved_by | uuid | NOT NULL | FK → accounts | |
reason | text | NOT NULL | ||
source_event_id | text | NOT NULL | ||
resolved_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (3):
link_id→shipment_order_links·ON DELETE RESTRICTresolved_by→accounts·ON DELETE RESTRICTshipment_id→shipments·ON DELETE RESTRICT
Được trỏ tới: không có