D
Engineering

Orders Schema

Skema tabel orders (polymorphic), order_subscribes, order_topups, order_withdraws, order_transfer_balances, order_transfer_balance_details, order_deducts, order_business_managers, payments, refunds, payment_methods, bank_accounts.

Skema entitas Order & Payment Konco. Tabel orders adalah master polymorphic — tipe order ditentukan oleh relasi ke OrderSubscribe, OrderTopup, OrderWithdraw, dll.

orders

Master order — polymorphic via relasi subscribe(), topup(), withdraw(), transferBalance(), deduct(), payment(), businessManagers().

FieldTipeCatatan
idUUID (PK)
member_idUUID (FK)→ members.id
typestringsubscribe / topup / withdraw / transfer_balance / deduct / payment
flagstringpending / paid / processed / cancelled / failed
amountdecimal:2Nominal
refcodestringKode referensi invoice
descriptiontextCatatan
bank_account_idUUID (FK, nullable)→ bank_accounts.id
created_byUUIDWithAuthor
updated_byUUIDWithAuthor
timestamps—

Relasi polymorphic

MethodTipeTarget
subscribe()HasManyOrderSubscribe
withdraw()HasManyOrderWithdraw
deduct()HasOneOrderDeduct
payment()HasOnePayment
businessManagers()BelongsToManyMemberBm via order_business_managers
member()BelongsToMember
member_bm()BelongsToMemberBm
AdminRequest()HasOneAdminRequest
bank_account()BelongsToBankAccount

Accessor

AccessorFungsi
transaction_typeLabel tipe transaksi
transaction_iconIcon CSS class
transaction_status_labelLabel status (flag)
request_status_labelLabel status admin request
account_countJumlah akun terlibat
bm_problem_countJumlah BM bermasalah

order_subscribes

Detail order sewa akun iklan.

FieldTipe
idUUID (PK)
order_idUUID (FK)
ads_account_idUUID (FK)
durationinteger (months)
fee_setting_idUUID (FK)
amountdecimal:2
timestamps—

order_topups

Detail order top up spend cap.

FieldTipe
idUUID (PK)
order_idUUID (FK)
ads_account_idUUID (FK)
amountdecimal:2
timestamps—

order_withdraws

Detail order penarikan saldo.

FieldTipe
idUUID (PK)
order_idUUID (FK)
ads_account_idUUID (FK)
amountdecimal:2
completed_atdatetime
timestamps—

order_transfer_balances

Master transfer saldo antar-akun (lihat juga Transfer Balance).

FieldTipeCatatan
idUUID (PK)
order_idUUID (FK)
destination_ads_account_idUUID (FK)Akun tujuan
destination_balancedecimal:2Saldo sebelum transfer
total_transferreddecimal:2Total yang ditransfer
statusstringpending / processing / completed / failed
error_messagetext (nullable)Bila failed
processed_atdatetimeSaat mulai diproses
completed_atdatetimeSaat selesai
timestamps—

order_transfer_balance_details

Item detail per akun sumber (1 transfer bisa multi-source).

FieldTipe
idUUID (PK)
order_transfer_balance_idUUID (FK)
source_ads_account_idUUID (FK)
amountdecimal:2
statusstring
timestamps—

order_deducts

Order biaya admin/fee.

FieldTipe
idUUID (PK)
order_idUUID (FK)
amountdecimal:2
descriptiontext
timestamps—

order_business_managers (pivot)

Pivot relasi order ↔ BM (untuk order yang melibatkan BM).

FieldTipe
idUUID (PK)
order_idUUID (FK)
business_manager_idUUID (FK)
timestamps—

payments

Record pembayaran.

FieldTipe
idUUID (PK)
order_idUUID (FK)
payment_method_idUUID (FK)
amountdecimal:2
gatewaystring (monitpay / duitku / transfer)
gateway_referencestring
statusstring
payloadarray (JSON) — gateway response
timestamps—

refunds

Record refund saldo.

FieldTipe
idUUID (PK)
ads_account_idUUID (FK)
order_idUUID (FK)
amountdecimal:2
statusstring
timestamps—

payment_methods

Master metode pembayaran.

FieldTipe
idUUID (PK)
namestring
gatewaystring
is_activeboolean
configarray (JSON)
timestamps—

bank_accounts

Master rekening bank member & admin.

FieldTipe
idUUID (PK)
member_idUUID (FK, nullable)
bank_namestring
account_numberstring
account_namestring
is_activeboolean
timestamps—

Order flag lifecycle

text
[pending] ──payment success──► [paid] ──admin approve──► [processed]
   │
   └──expiry:order (timeout)──► [cancelled]

[paid] ──MyApi error──► [failed]
[processed] ──(manual)──► [failed]

Langkah berikutnya