Skip to content

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 APIspin
Query / Mutation11 / 13
Nguồn dữ liệuspin, loyalty/spin
Bảng7
Luật phân quyền4
Đường dẫn Web Admin8

Thao tác (mutation) ​

MutationDomainMô tả
createSpinWheelspinTạo / Nhân bản (VQ-US-02, VQ-US-03): ACTIVE wheel with a new daily code and its configuration applied. conflict
deactivateSpinWheelspinNgừ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).
deleteSpinWheelspinXó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).
drawSpinspinRequires 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.
enterSpinSessionspinVQM S10 (BR-VQ-08, DEC-VQM-08 C): NOT_ENTERED -> ACTIVE (enteredAt), the start of the session. Needs a live Ví của
leaveSpinSessionspinU-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.
publishSpinRulespinRequires spin.write (SPN-03: operations, admin). DRAFT -> PUBLISHED; supersedes the current version.
renameSpinWheelspinRequires spin.write (SPN-03).
resumeSpinSessionspinKEPT -> 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).
saveSpinRuleDraftspinRequires spin.write (SPN-03: operations, admin).
setSpinWheelStatusspinRequires spin.write (SPN-03).
spinSessionHeartbeatspinVQM S10 (BR-VQ-08 E, DEC-VQM-07): the App is still on the wheel screen; call it every heartbeatIntervalSeconds while
updateSpinWheelspinSửa (VQ-US-05, BR-VQ-11): saves and applies the whole configuration. conflict stale_version / name_taken /

Phép đọc (query) ​

QueryDomainMô tả
mySpinSessionsspinRequires spin.read (SPN-01, own sessions only).
spinRuleDraftspinStaff (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.
spinRuleInForcespinStaff (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.
spinSessionspinRequires spin.read (SPN-01). A foreign or unknown id is not_found.
spinSessionHistoryspinLịch sử quay (VQ-US-08, BR-VQLS-01..02): one row per session, newest confirmed deposit first. search = Mã đơn, Mã
spinSessionHistoryDetailspinPopup Chi tiết phiên quay: the session and its draws; an unknown id is not_found. Requires spin.history.read (SPN-05).
spinWheelspinOne wheel (Chi tiết vòng quay); an unknown id is not_found. Requires spin.read (SPN-02).
spinWheelHistoryspinS8 Lịch sử thay đổi of one wheel (BR-VQ-12), newest first. from / to are Vietnam days YYYY-MM-DD (inclusive,
spinWheelNameAvailablespinS15 (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).
spinWheelOptionsspinDropdown of the campaign form (BR-C-09): ACTIVE, non-legacy wheels only, search = approximate code / name, accents kept. Requires spin.read (SPN-02).
spinWheelsspinDanh 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 ​

Bảng được tham chiếu nhiều nhất trong module:

BảngCộtĐược trỏ tớiRLS
wheels144✓
spin_sessions292✓
spin_draws111✓
spin_rule_versions241✓
wheel_change_events60✓
spin_order_outcomes90✓
spin_results90✓

Quyền ​

MãQuyềnỨng dụngVai tròPhạm viTrạng thái
SPN-01spin.readAPP_USERuserOWNPROPOSED
SPN-02spin.readWEB_ADMINoperations adminALLPROPOSED
SPN-03spin.writeWEB_ADMINoperations adminALLPROPOSED
SPN-04spin.playAPP_USERuserOWNPROPOSED

Danh sách đầy đủ và cách đọc các cờ: Ma trận quyền.

Giao diện Web Admin ​

Đường dẫnHằng số
/lucky-wheel/budgetLUCKY_WHEEL_BUDGET
/lucky-wheel/historyLUCKY_WHEEL_HISTORY
/lucky-wheel/prizesLUCKY_WHEEL_PRIZES
/lucky-wheel/spin-rulesLUCKY_WHEEL_SPIN_RULES
/lucky-wheel/wheelsLUCKY_WHEEL_WHEELS
/lucky-wheel/wheels/:idLUCKY_WHEEL_WHEEL_DETAIL
/lucky-wheel/wheels/:id/editLUCKY_WHEEL_WHEEL_EDIT
/lucky-wheel/wheels/newLUCKY_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.

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17