Giao diện
Vòng quay may mắn
Trang sinh tự động
Phần nghiệp vụ viết tay; API, dữ liệu, quyền, đường dẫn và file nguồn do bộ sinh điền từ source tại ad83b0aea.
Làm gì
Cấu hình vòng quay 8 ô theo đợt ngày của chiến dịch. Khách được lượt quay khi cọc đơn; phiên quay đi từ chưa vào → đang quay → xong hoặc mất lượt, có heartbeat để phát hiện mất kết nối.
Quy mô
| Domain API | spin |
| Query / Mutation | 11 / 13 |
| Nguồn dữ liệu | spin, loyalty/spin |
| Bảng | 7 |
| Luật phân quyền | 4 |
| Đường dẫn Web Admin | 8 |
Thao tác (mutation)
| Mutation | Domain | Mô tả |
|---|---|---|
createSpinWheel | spin | Tạo / Nhân bản (VQ-US-02, VQ-US-03): ACTIVE wheel with a new daily code and its configuration applied. conflict |
deactivateSpinWheel | spin | Ngừng hoạt động (VQ-US-06): one way, allowed while locked; an INACTIVE wheel is returned unchanged (DEC-VQM-23); not_found. Requires spin.write (SPN-03). |
deleteSpinWheel | spin | Xóa (VQ-US-07, BR-VQ-05): only a wheel never chosen by a campaign; conflict wheel_ever_chosen / wheel_legacy, not_found. Requires spin.write (SPN-03). |
drawSpin | spin | Requires spin.play (SPN-04, own session). An existing drawNo is returned first (replayed: true, same slot and points), whatever the session state and the requestId. Otherwise only on an entered ACTIVE session (enterSpinSession first): another state answers conflict session_ended (details.session); an ACTIVE session whose last signal is older than the server threshold ends DISCONNECTED (the end is kept, no draw recorded) and answers session_ended with it. The draw counts as a heartbeat. policy_undecided only on a legacy session without spins. |
enterSpinSession | spin | VQM S10 (BR-VQ-08, DEC-VQM-08 C): NOT_ENTERED -> ACTIVE (enteredAt), the start of the session. Needs a live Ví của |
leaveSpinSession | spin | U-42 Rời phiên (BR-VQ-08). ACTIVE with >= 1 draw -> COMPLETED (highest kept, untaken spins lost), ACTIVE with no draw -> FORFEITED (Mất lượt, never reopened); endReason LEFT, or DISCONNECTED when the last signal was already older than the server threshold (DEC-VQM-07). Any other state (NOT_ENTERED, already ended, a legacy KEPT row) is returned unchanged. Requires spin.play (SPN-04, own session); a foreign or unknown id is not_found. |
publishSpinRule | spin | Requires spin.write (SPN-03: operations, admin). DRAFT -> PUBLISHED; supersedes the current version. |
renameSpinWheel | spin | Requires spin.write (SPN-03). |
resumeSpinSession | spin | KEPT -> ACTIVE with a new window (now + the snapshotted sessionDurationSeconds), only before the campaign close; any other state is conflict. Requires spin.play (SPN-04, own session). |
saveSpinRuleDraft | spin | Requires spin.write (SPN-03: operations, admin). |
setSpinWheelStatus | spin | Requires spin.write (SPN-03). |
spinSessionHeartbeat | spin | VQM S10 (BR-VQ-08 E, DEC-VQM-07): the App is still on the wheel screen; call it every heartbeatIntervalSeconds while |
updateSpinWheel | spin | Sửa (VQ-US-05, BR-VQ-11): saves and applies the whole configuration. conflict stale_version / name_taken / |
Phép đọc (query)
| Query | Domain | Mô tả |
|---|---|---|
mySpinSessions | spin | Requires spin.read (SPN-01, own sessions only). |
spinRuleDraft | spin | Staff (SPN-02 spin.read): the wheel's current DRAFT (at most one), to edit further; null when there is none. CV3 (S4): exactly one of wheelId / campaignId. |
spinRuleInForce | spin | Staff (SPN-02 spin.read, operations / admin): the wheel's PUBLISHED rule in force; null when none is published (GAP-342, owner E11). CV3 (S4): exactly one of wheelId / campaignId. |
spinSession | spin | Requires spin.read (SPN-01). A foreign or unknown id is not_found. |
spinSessionHistory | spin | Lịch sử quay (VQ-US-08, BR-VQLS-01..02): one row per session, newest confirmed deposit first. search = Mã đơn, Mã |
spinSessionHistoryDetail | spin | Popup Chi tiết phiên quay: the session and its draws; an unknown id is not_found. Requires spin.history.read (SPN-05). |
spinWheel | spin | One wheel (Chi tiết vòng quay); an unknown id is not_found. Requires spin.read (SPN-02). |
spinWheelHistory | spin | S8 Lịch sử thay đổi of one wheel (BR-VQ-12), newest first. from / to are Vietnam days YYYY-MM-DD (inclusive, |
spinWheelNameAvailable | spin | S15 (VQ-US-02 AC07, on blur): true when no other wheel, legacy ones included, has this name (trimmed NFC, any case); excludeId = the wheel being edited. Requires spin.read (SPN-02). |
spinWheelOptions | spin | Dropdown of the campaign form (BR-C-09): ACTIVE, non-legacy wheels only, search = approximate code / name, accents kept. Requires spin.read (SPN-02). |
spinWheels | spin | Danh sách vòng quay (BR-VQDS-01..02): both statuses unless filtered; search = code or name, contains, any case; newest updatedAt first; pageSize 1..500, default 50 (50 / 100 / 500). Requires spin.read (SPN-02). |
Dữ liệu
- Domain
spin— 2 bảng, 1 nhóm con: wheel (2) - Nhóm
loyalty/spin— 5 bảng
Bảng được tham chiếu nhiều nhất trong module:
| Bảng | Cột | Được trỏ tới | RLS |
|---|---|---|---|
wheels | 14 | 4 | ✓ |
spin_sessions | 29 | 2 | ✓ |
spin_draws | 11 | 1 | ✓ |
spin_rule_versions | 24 | 1 | ✓ |
wheel_change_events | 6 | 0 | ✓ |
spin_order_outcomes | 9 | 0 | ✓ |
spin_results | 9 | 0 | ✓ |
Quyền
| Mã | Quyền | Ứng dụng | Vai trò | Phạm vi | Trạng thái |
|---|---|---|---|---|---|
SPN-01 | spin.read | APP_USER | user | OWN | PROPOSED |
SPN-02 | spin.read | WEB_ADMIN | operations admin | ALL | PROPOSED |
SPN-03 | spin.write | WEB_ADMIN | operations admin | ALL | PROPOSED |
SPN-04 | spin.play | APP_USER | user | OWN | PROPOSED |
Danh sách đầy đủ và cách đọc các cờ: Ma trận quyền.
Giao diện Web Admin
| Đường dẫn | Hằng số |
|---|---|
/lucky-wheel/budget | LUCKY_WHEEL_BUDGET |
/lucky-wheel/history | LUCKY_WHEEL_HISTORY |
/lucky-wheel/prizes | LUCKY_WHEEL_PRIZES |
/lucky-wheel/spin-rules | LUCKY_WHEEL_SPIN_RULES |
/lucky-wheel/wheels | LUCKY_WHEEL_WHEELS |
/lucky-wheel/wheels/:id | LUCKY_WHEEL_WHEEL_DETAIL |
/lucky-wheel/wheels/:id/edit | LUCKY_WHEEL_WHEEL_EDIT |
/lucky-wheel/wheels/new | LUCKY_WHEEL_WHEEL_NEW |
File nguồn
Backend:
code/apps/api/supabase/functions/graphql/domains/spin/
Dữ liệu: bảng thuộc domain spin, loyalty/spin — xem Cơ sở dữ liệu.