Skip to content

payment / refund ​

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 đè.

6 bảng. Quay lại payment.

refund_cases ​

P3-10. One refund case per Order, always the whole Order: cash legs per original capture, point legs per original REDEEM (refund_branches). PENDING -> APPROVED|REJECTED, APPROVED -> REFUNDED only when every leg is ACCEPTED. Maker != checker; thresholds G-FIN undecided. No provider call is made here (P3-11).

public.refund_cases · 35 cột · 16 check · 1 unique · 8 index · 2 policy · 10 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
owner_account_iduuidNOT NULLFK → accounts
origintextNOT NULL
case_typetextNOT NULL
scopetextNOT NULL
request_keytextNOT NULL
policy_version_iduuidNOT NULLFK → campaign_policy_versions
rule_versionstext[]NOT NULL
statustextNOT NULL
approval_requiredbooleanNOT NULL
requested_byuuidFK → accounts
request_reasontext
refundable_cash_vndbigintNOT NULL
points_to_reverseintegerNOT NULL
decided_byuuidFK → accounts
decided_attimestamptz
decision_notetext
threshold_policy_version_iduuid
evidence_media_idsuuid[]NOT NULL
completed_attimestamptz
last_branch_iduuid
change_sourcetextNOT NULL
change_source_idtextNOT NULL
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL
shortage_case_iduuidFK → stock_shortage_casesFU-575. The shortage case of a PARTIAL_UNITS refund case (the amounts are the stored share of that case row).
forfeit_review_iduuidFK → recurring_forfeit_reviewsFU-FORFEIT. The approved cycle forfeit review of a PARTIAL case with origin FORFEIT (one case per review, ever).
return_cycle_nointeger#479 B. The Mua định kỳ cycle of a RETURN case (scope RETURNED_CYCLE); null for every other case.
returned_ondate#479 B. Day of the return (Vietnam) Operations entered; RETURN only.
kept_cash_vndbigint#479 B. Cash of the unit the shop keeps (snapshot at the record); NO_REFUND = everything paid. RETURN only.
kept_pointsinteger#479 B. Pi-Point of the unit the buyer does not get back (snapshot at the record). RETURN only.
ops_notetext#479 B. Internal Operations note of a RETURN case (<= 500).
overpayment_case_iduuidFK → payment_overpayment_cases#479 C. The cọc dư case (payment_overpayment_cases) an EXCESS_DEPOSIT claim refunds; null for every other case.

Khoá chính: id

Trỏ ra (8):

  • decided_by → accounts · ON DELETE RESTRICT
  • forfeit_review_id → recurring_forfeit_reviews · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • overpayment_case_id → payment_overpayment_cases · ON DELETE RESTRICT
  • owner_account_id → accounts · ON DELETE RESTRICT
  • policy_version_id → campaign_policy_versions · ON DELETE RESTRICT
  • requested_by → accounts · ON DELETE RESTRICT
  • shortage_case_id → stock_shortage_cases · ON DELETE RESTRICT

Được trỏ tới (6): mission_reversal_evidence, refund_branches, refund_case_events, refund_info_update_requests, refund_receiver_profiles, refund_transfer_records

refund_branches ​

P3-10. One leg of a refund case: CASH per original captured transaction (full amount) or POINT per original accepted REDEEM (full points, original rate). Provider request machine; ACCEPTED needs the provider refund / REVERSE_REDEEM of exactly the original on file. Never complete while a leg is UNKNOWN.

public.refund_branches · 23 cột · 9 check · 4 unique · 7 index · 1 policy · 8 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
refund_case_iduuidNOT NULLFK → refund_cases
branch_kindtextNOT NULL
original_transaction_iduuidFK → provider_transactions
original_point_request_iduuidFK → point_requests
amount_vndbigint
pointsinteger
rate_snapshot_vndnumeric
rate_policy_versiontext
providertext
provider_modetext
statustextNOT NULL
attemptintegerNOT NULL
refund_transaction_iduuidFK → provider_transactions
reverse_request_iduuidFK → point_requests
result_codetext
recovery_reasontext
recovery_evidence_media_idsuuid[]NOT NULL
change_sourcetextNOT NULL
change_source_idtextNOT NULL
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL

Khoá chính: id

Trỏ ra (5):

  • original_point_request_id → point_requests · ON DELETE RESTRICT
  • original_transaction_id → provider_transactions · ON DELETE RESTRICT
  • refund_case_id → refund_cases · ON DELETE RESTRICT
  • refund_transaction_id → provider_transactions · ON DELETE RESTRICT
  • reverse_request_id → point_requests · ON DELETE RESTRICT

Được trỏ tới (1): refund_case_events

refund_case_events ​

P3-10. Append-only refund case history: one row per case version (case decisions, evidence, each leg change).

public.refund_case_events · 14 cột · 3 check · 1 unique · 2 index · 1 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
refund_case_iduuidNOT NULLFK → refund_cases
case_versionintegerNOT NULL
event_kindtextNOT NULL
branch_iduuidFK → refund_branches
from_statustext
to_statustextNOT NULL
actor_account_iduuidFK → accounts
source_typetextNOT NULL
source_idtextNOT NULL
evidence_media_idsuuid[]NOT NULL
recorded_attimestamptzNOT NULL
actor_labeltext
actor_rolestext[]

Khoá chính: id

Trỏ ra (3):

  • actor_account_id → accounts · ON DELETE RESTRICT
  • branch_id → refund_branches · ON DELETE RESTRICT
  • refund_case_id → refund_cases · ON DELETE RESTRICT

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

refund_info_update_requests ​

U19-P2-15 (DH-US-16). Operations asked the customer to send the refund request again: the rejected revision, the reason and the note shown to the customer. Append-only; written by payment.refund_ops_request_update only.

public.refund_info_update_requests · 12 cột · 6 check · 2 unique · 4 index · 0 policy · 2 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
refund_case_iduuidNOT NULLFK → refund_cases
order_iduuidNOT NULLFK → orders
profile_revisionintegerNOT NULL
case_versionintegerNOT NULL
reasontextNOT NULLU19-P2-15; G2I-P1-03: internal note of Operations (1..1000). Never sent to the customer; filled with the code when blank.
customer_notetext
requested_byuuidNOT NULLFK → accounts
requested_attimestamptzNOT NULL
source_idtextNOT NULL
reason_codetextNOT NULLG2I-P1-03 O6a/E2. Why the request was sent back, as a fixed code the clients turn into a friendly sentence.
note_customer_visiblebooleanNOT NULLG2I-P1-03 O6a/E2. True when Operations marked customer_note for the customer; only then does the buyer read it.

Khoá chính: id

Trỏ ra (3):

  • order_id → orders · ON DELETE RESTRICT
  • refund_case_id → refund_cases · ON DELETE RESTRICT
  • requested_by → accounts · ON DELETE RESTRICT

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

refund_receiver_profiles ​

U13-P2-06d, U19-P2-14. Receiver of a refund transfer, submitted by the CUSTOMER on the app (append-only revisions per case). Citizen id and account number are stored encrypted (API key REFUND_PII_KEY) plus their last 4 digits; legacy rows keep plaintext until scripts/operator/encrypt-refund-profiles.ts seals them. Every read is masked. Names are shown in full.

public.refund_receiver_profiles · 18 cột · 10 check · 2 unique · 3 index · 0 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
refund_case_iduuidNOT NULLFK → refund_cases
revisionintegerNOT NULL
receiver_nametextNOT NULL
citizen_idtext
bank_nametextNOT NULL
account_numbertext
holder_nametextNOT NULL
recorded_byuuidNOT NULLFK → accounts
recorded_attimestamptzNOT NULL
source_idtextNOT NULL
citizen_id_encbytea
account_number_encbytea
pii_key_idtext
citizen_id_last4textNOT NULL
account_number_last4textNOT NULL
submitted_by_kindtextNOT NULL
holder_matches_id_namebooleanNOT NULLU19-P2-14. Account holder name = name on the CCCD (accent/case/blank-insensitive). A sign for Operations, never a block.

Khoá chính: id

Trỏ ra (2):

  • recorded_by → accounts · ON DELETE RESTRICT
  • refund_case_id → refund_cases · ON DELETE RESTRICT

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

refund_transfer_records ​

U13-P2-06d (GAP-DH-V1-06). The manual external transfer fact of a refund case (code, date, evidence, the case cash at that time); it moves no leg and calls no provider. One per case, one per transaction code.

public.refund_transfer_records · 12 cột · 6 check · 2 unique · 4 index · 0 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
refund_case_iduuidNOT NULLFK → refund_cases
transaction_codetextNOT NULL
transferred_ondateNOT NULL
amount_vndbigintNOT NULL
evidence_media_idsuuid[]NOT NULL
profile_revisionintegerNOT NULL
recorded_byuuidNOT NULLFK → accounts
recorded_attimestamptzNOT NULL
source_idtextNOT NULL
ops_notetextU19-P2-15. Operations note of the confirm (Word, <= 500).
settles_casebooleanNOT NULLU19-P2-15. True only for the Operations confirm (one step, D-SEC-01): the cash of the case is refunded by this transfer.

Khoá chính: id

Trỏ ra (2):

  • recorded_by → accounts · ON DELETE RESTRICT
  • refund_case_id → refund_cases · ON DELETE RESTRICT

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

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17