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)
| # | Task | Ghi chú |
|---|---|---|
| 1.1 | Thêm flow shop_player_deposit vào cash_transaction_flow | Phase 2 ship trước; shop_player_redemption có thể cùng migration |
| 1.2 | Thêm player vào hierarchy_owner_type | |
| 1.3 | Cột cashier_transaction_id, shift_id nullable | |
| 1.4 | Cập nhật constants/cashTransaction.js | |
| 1.5 | Doc schema-cash-transactions |
Phase 2 — Backend biz (deposit only)
| # | Task | Ghi chú |
|---|---|---|
| 2.1 | createCounterDepositCashTransaction trong cashTransactionBizService | seller=shop, buyer=player |
| 2.2 | Hook sau shopPlayerBizService._adjustCreditsAdd | Chỉ khi transfer thành công |
| 2.3 | expected_cash = credit_amount; metadata.grossMargin | Snapshot shop.costRate |
| 2.4 | Gắn cashier_transaction_id + shift_id từ ledgerContext | Cashier path |
| 2.5 | performed_by_type: cashier | shop | |
| 2.6 | Link payment + wallet txs | |
| 2.7 | Idempotency theo reqId | |
| 2.8 | Unit tests deposit + margin + cashier link | Không test redeem ở đây |
Phase 3 — Shop portal API (deposit filter)
| # | Task | Ghi chú |
|---|---|---|
| 3.1 | GET /api/shop/cash-transactions?flow=shop_player_deposit | |
| 3.2 | Detail + export scoped deposit | |
| 3.3 | Summary: Cash In, gross margin aggregate | Full filter, không chỉ page |
Phase 4 — Shop portal UI
| # | Task | Ghi chú |
|---|---|---|
| 4.1 | Tab Receivable — Deposits | Mockup phase2 deposit tab |
| 4.2 | Summary cards Cash In + Margin | |
| 4.3 | Extend PortalCashTransactionsLedger filter shop_player_deposit | |
| 4.4 | Không build redemption tab — Phase 3 |
Phase 5 — QA (deposit)
| # | Scenario | Expected |
|---|---|---|
| 5.1 | Cashier deposit 50, cost rate 0.80 | cash tx margin $10; cashDelta +50 |
| 5.2 | Shop manual add (card) | cash tx; no shift link |
| 5.3 | Insufficient shop credit | 400, no cash tx |
| 5.4 | Player wrong shop | 403 |
Thứ tự
Schema (1) → Deposit biz hook (2) → Shop API deposit (3) → UI tab Deposits (4) → QA (5)
Sau đó mới Phase 3 redemption.