Engineering 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().
Field Tipe Catatan idUUID (PK) member_idUUID (FK) → members.id typestring subscribe / topup / withdraw / transfer_balance / deduct / paymentflagstring pending / paid / processed / cancelled / failedamountdecimal:2 Nominal refcodestring Kode referensi invoice descriptiontext Catatan bank_account_idUUID (FK, nullable) → bank_accounts.id created_byUUID WithAuthorupdated_byUUID WithAuthortimestamps —
Relasi polymorphic
Method Tipe Target subscribe()HasMany OrderSubscribewithdraw()HasMany OrderWithdrawdeduct()HasOne OrderDeductpayment()HasOne PaymentbusinessManagers()BelongsToMany MemberBm via order_business_managersmember()BelongsTo Membermember_bm()BelongsTo MemberBmAdminRequest()HasOne AdminRequestbank_account()BelongsTo BankAccount
Accessor
Accessor Fungsi 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.
Field Tipe 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.
Field Tipe idUUID (PK) order_idUUID (FK) ads_account_idUUID (FK) amountdecimal:2 timestamps —
order_withdraws
Detail order penarikan saldo.
Field Tipe 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 ).
Field Tipe Catatan idUUID (PK) order_idUUID (FK) destination_ads_account_idUUID (FK) Akun tujuan destination_balancedecimal:2 Saldo sebelum transfer total_transferreddecimal:2 Total yang ditransfer statusstring pending / processing / completed / failederror_messagetext (nullable) Bila failed processed_atdatetime Saat mulai diproses completed_atdatetime Saat selesai timestamps —
order_transfer_balance_details
Item detail per akun sumber (1 transfer bisa multi-source).
Field Tipe idUUID (PK) order_transfer_balance_idUUID (FK) source_ads_account_idUUID (FK) amountdecimal:2 statusstring timestamps —
order_deducts
Order biaya admin/fee.
Field Tipe idUUID (PK) order_idUUID (FK) amountdecimal:2 descriptiontext timestamps —
order_business_managers (pivot)
Pivot relasi order ↔ BM (untuk order yang melibatkan BM).
Field Tipe idUUID (PK) order_idUUID (FK) business_manager_idUUID (FK) timestamps —
payments
Record pembayaran.
Field Tipe 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.
Field Tipe idUUID (PK) ads_account_idUUID (FK) order_idUUID (FK) amountdecimal:2 statusstring timestamps —
payment_methods
Master metode pembayaran.
Field Tipe idUUID (PK) namestring gatewaystring is_activeboolean configarray (JSON) timestamps —
bank_accounts
Master rekening bank member & admin.
Field Tipe idUUID (PK) member_idUUID (FK, nullable) bank_namestring account_numberstring account_namestring is_activeboolean timestamps —
Order flag lifecycle
text Copy [pending] ──payment success──► [paid] ──admin approve──► [processed]
│
└──expiry:order (timeout)──► [cancelled]
[paid] ──MyApi error──► [failed]
[processed] ──(manual)──► [failed]
Langkah berikutnya