Skip to main content

Tasks — Shop/Cashier → Player (Phase 2)

Spec: shop-cashier-to-player · Mockup: Deposits tab

Phụ thuộc: Phase 1 hoàn tất (tasks Agent → Shop); Cashier deposit flow (Cashier spec).

Phạm vi V1: Chỉ deposit. Redemption → Phase 3 tasks. Auto-settled, 1:1 cash:credit, detail view-only.


Phase 1 — Schema (shared với Phase 3)

#TaskGhi chú
1.1Thêm flow shop_player_deposit vào cash_transaction_flowPhase 2 ship trước; shop_player_redemption có thể cùng migration
1.2Thêm player vào hierarchy_owner_type
1.3Cột cashier_transaction_id, shift_id nullable
1.4Cập nhật constants/cashTransaction.js
1.5Doc schema-cash-transactions

Phase 2 — Backend biz (deposit only)

#TaskGhi chú
2.1createCounterDepositCashTransaction trong cashTransactionBizServiceseller=shop, buyer=player
2.2Hook sau shopPlayerBizService._adjustCreditsAddChỉ khi transfer thành công
2.3expected_cash = credit_amount; metadata.grossMarginSnapshot shop.costRate
2.4Gắn cashier_transaction_id + shift_id từ ledgerContextCashier path
2.5performed_by_type: cashier | shop
2.6Link payment + wallet txs
2.7Idempotency theo reqId
2.8Unit tests deposit + margin + cashier linkKhông test redeem ở đây

Phase 3 — Shop portal API (deposit filter)

#TaskGhi chú
3.1GET /api/shop/cash-transactions?flow=shop_player_deposit
3.2Detail + export scoped deposit
3.3Summary: Cash In, gross margin aggregateFull filter, không chỉ page

Phase 4 — Shop portal UI

#TaskGhi chú
4.1Tab Receivable — DepositsMockup phase2 deposit tab
4.2Summary cards Cash In + Margin
4.3Extend PortalCashTransactionsLedger filter shop_player_deposit
4.4Không build redemption tab — Phase 3

Phase 5 — QA (deposit)

#ScenarioExpected
5.1Cashier deposit 50, cost rate 0.80cash tx margin $10; cashDelta +50
5.2Shop manual add (card)cash tx; no shift link
5.3Insufficient shop credit400, no cash tx
5.4Player wrong shop403

Thứ tự

Schema (1) → Deposit biz hook (2) → Shop API deposit (3) → UI tab Deposits (4) → QA (5)

Sau đó mới Phase 3 redemption.