Tính năng nghiệp vụ
1. Quản lý phân cấp
Super Agent quản lý cây Agents → Shops → Players:
flowchart TB
SA[Super Agent] --> A1[Agent 1]
SA --> A2[Agent 2]
A1 --> S1[Shop A]
A1 --> S2[Shop B]
S1 --> P1[Player]
| Action | API |
|---|---|
| Di chuyển shop sang agent khác | PATCH /super-agent/shops/:id/move |
| Di chuyển player sang shop khác | PATCH /super-agent/players/:id/move |
| Suspend/unsuspend agent | PATCH .../agents/:id/suspend|unsuspend |
2. Tạo & cấu hình Agent
Tạo agent mới tại /agents/new:
- Username, email, password, cost rate
- Popup permissions
- Game mappings
Chi tiết agent (/agents/:agentId):
- Cập nhật rate, password, tên
- Phân phối/rút credit
- Bật/tắt game providers
3. Ví & Credit
Mua credit
- Crypto (Zerox static wallets) hoặc USD → credits
- Payment return:
/payment/return
Phân phối credit
| Luồng | API |
|---|---|
| Super Agent → Managed Agent | POST /super-agent/agents/:id/credits/distribute |
| Super Agent → Shop | POST /agent/credits/distribute |
| Rút từ agent | POST /super-agent/agents/:id/credits/withdraw |
4. Shop governance
- Tạo shop (
POST /agent/shops) - Suspend/unsuspend, đổi password, popup permission
- Xem CDN wallet + USD wallet ledger riêng
- Cập nhật cost rate (
PATCH /super-agent/shops/:id/rates)
5. Rút USD crypto
Luồng tương tự Agent Portal:
- Kiểm tra OTP eligibility
- Gửi/verify OTP
- Preview phí
- Tạo withdrawal
Giới hạn: GET /super-agent/portal-withdrawal-limits
6. Fraud & Communication
- Fraud: filter theo shop, profit analysis, resolve
- Broadcast: nhận qua bell, gửi nếu
can_delegate_popups - Popup: modes
once/sticky_daily
7. So sánh với Agent Portal
| Tính năng | Super Agent | Agent |
|---|---|---|
| Quản lý agents | ✅ Tạo, suspend, rates | — |
| Di chuyển shop/player | ✅ | — |
| Quản lý shops | ✅ Toàn hệ thống | ✅ Shops của mình |
| Tạo shop | ✅ | ✅ |
| Game mappings (agent level) | ✅ | ✅ (shop level) |
| Provider fees | Read-only | Read-only |
Ghi chú triển khai
- Port dev 3003 — tránh clash admin (3000); lưu ý agent cũng dùng 3003 trong
.env.example. - API prefix
/super-agent-authvà/super-agent/*— không dùng/agent-auth. - README repo có thể mô tả cũ — ưu tiên code thực tế.
- Backend CORS: thêm domain vào bảng
domainshoặcDISABLE_CORS=truekhi dev.