Skip to main content

Tasks — Agent → Shop

Spec: agent-to-shop · Mockup: sell-credit (modal), list, detail

Hiện trạng: Đã có creditDistributionBizService.distribute (debit agent, credit shop, PaymentTransaction provider agent_cash). UI: DistributeCreditsTrigger trên Agent portal và Super Agent portal (chỉ amount + shop select trên SA portal). Chưa ghi cash_transactions, chưa form đầy đủ.

Phụ thuộc: Backend Phase 1 từ tasks Admin → SA + UI package UI.1–UI.7.

Phạm vi V1: Modal từ Shop detail (Agent portal). Status paid_full only. Detail view-only.

UI dùng chung: ui-package-cash-settlement — Agent portal chỉ wire API.


Phase 1 — Backend

#TaskGhi chú
1.1Thêm flow agent_shop vào cash_transactions
1.2Refactor creditDistributionBizService.distributeTạo cash_transaction; payload mới đầy đủ field
1.3Cost rate snapshot = Shop buyerexpected = credits × shop.costRate
1.4Validate agent có đủ creditInsufficient balance error
1.5Validate shop thuộc agentGiữ check shop.agentId
1.6Ghi performed_by = agent user id
1.7Link cash_transaction ↔ wallet txs ↔ payment_transaction
1.8API POST /agent/shops/:id/cash-credits (hoặc mở rộng /credits/distribute)Shop id từ URL — không cần shopId trong body khi mở từ detail
1.9GET /agent/cash-transactions + GET /agent/cash-transactions/:idScope agent đang login
1.10Unit testsShop wrong agent, zero cost rate, balance

Phase 2 — Agent portal wire

UI từ @kioskgaming/ui — không duplicate component.

#TaskGhi chú
2.1Shop detail: SellCreditsCashModalflow=agent_shop, buyer = shop đang xem
2.2API hook + extend distributeCreditsThay logic DistributeCreditsTrigger
2.3Route list/detail + menuPortalCashTransactionsLedger / Detail
2.4Submit → refresh shop + agent wallet

Tham chiếu: kioskgaming_agent/.../DistributeCreditsTrigger.tsx


Phase 3 — Super Agent portal (distribution path)

Super Agent portal cũng có DistributeCreditsTrigger (chọn shop + amount) — quyết định V1:

#TaskGhi chú
3.1Option A: Chỉ Agent portal bán Agent→ShopKhuyến nghị
3.2Option B: SA portal proxy distribute shopCần PM confirm
3.3Option A: ẩn distribute shop trên SA portalTránh duplicate

Phase 4 — Admin visibility (optional V1)

#TaskGhi chú
4.1Admin list/detail flow Agent→ShopGeneric UI package

Phase 5 — QA

#TaskGhi chú
5.1Agent bán → Shop wallet +, Agent wallet −
5.2Shop USD wallet không đổi
5.3List/detail Agent portal

Liên quan