Skip to main content

Technical Inquiry: New Accounts Starting with 12 Spins — Where is the Configuration?

Last Updated: 15/07/2026
Type: Bug Investigation + Config Guidance — Lucky Spin Default Spins
Screen: Lucky Spin Popup Modal

Feedback Screenshot:


1. The Issue

The Lucky Spin Popup currently displays "Bạn có 12 lượt quay" (You have 12 spins) for newly created or test accounts.
According to business specifications (see lucky-spin-mechanics-and-widget.md), each account should only receive 1 free daily spin — not 12.

Questions:

❓ Where do these 12 spins come from? Where is this configured?
❓ Where is the popup display frequency (within a 24-hour window) configured?


2. Potential Causes

Cause 1 — Residual test data in the database (Most Likely 🔴)

During testing, developers may have manually inserted multiple spin ticket records into the user_spin_tickets table for this specific user. These test tickets were not cleaned up.

How to verify:

-- Query the user's spin tickets
SELECT * FROM user_spin_tickets
WHERE user_id = '<user_id>'
AND status = 'available'
AND expires_at > NOW()
ORDER BY expires_at ASC;

→ If 12 records with status available are returned, it confirms residual test data. Delete them or update their status to expired.

Cause 2 — Hardcoded defaultSpins in backend code

The initial spin granting service may have a hardcoded value of 12 instead of 1.

How to verify: Search the backend codebase:

# Search for hardcoded spin counts
grep -r "defaultSpins\|freeSpins\|dailySpins\|spin.*12\|12.*spin" --include="*.ts" --include="*.js"

Cause 3 — Incorrect CMS configuration

The configuration field on the CMS panel for default spins may be configured as 12 instead of 1.


3. Configuration Locations

3.1 Default Daily Spin Count

Correct Configuration Pattern — The developer should ensure:

// File: lucky-spin.service.ts or spin-grant.service.ts (Backend)

const DAILY_FREE_SPINS = config.get('LUCKY_SPIN_DAILY_FREE_SPINS') ?? 1;
// ↑ Fetched from config/env, defaults to 1
// ❌ Do not hardcode this value directly

// Spin grant logic triggered on first login of the day
async function grantDailySpinIfEligible(userId: string) {
const hasReceivedTodaySpin = await checkDailySpinGranted(userId);
if (hasReceivedTodaySpin) return; // Already granted

await createSpinTicket({
userId,
spinType: 'default',
amount: DAILY_FREE_SPINS, // ← Should be 1
expiresAt: endOfDay(new Date()), // Expires at 23:59:59 of the current day
});
}

If CMS-configured:

CMS Setting SectionFieldCorrect ValueCurrent Value
Settings > Minigames > Lucky SpinDaily Free Spins112 (?)

3.2 Popup Display Frequency in 24h

The popup should only appear once per day when the app is launched for the first time.

Configuration Location:

Mobile App — check the storage logic determining if the popup was shown today:

// File: useDailyPopup.ts or HomeScreen.tsx (Mobile)

const POPUP_DAILY_LIMIT = 1; // Max 1 per day

async function shouldShowSpinPopup(userId: string): Promise<boolean> {
// Retrieve last shown timestamp from AsyncStorage or server API
const lastShownAt = await AsyncStorage.getItem(`spin_popup_shown_${userId}`);

if (!lastShownAt) return true; // Never shown -> show

const lastDate = new Date(lastShownAt);
const today = new Date();

// Only show if the last shown date is in the past
return !isSameDay(lastDate, today);
}

CMS — if frequency is adjustable:

CMS Setting SectionFieldDefault ValueNotes
Settings > Minigames > Lucky SpinMax daily popups1Avoid setting > 1 to prevent spamming users

4. Action Items

Backend Dev

  • Check database: Query user_spin_tickets for the test account → delete extra records if necessary.
  • Check code logic: Ensure amount = 1 for spin_type = 'default'.
  • Clean test data: Reset spin tickets of test accounts.

CMS Dev

  • Verify if the CMS has the "Daily Free Spins" field configured. If not, implement it so admins can configure this without code releases.
  • Verify if the "Max daily popups" field exists.

Mobile Dev

  • Verify shouldShowSpinPopup() logic — use calendar date matching rather than absolute 24-hour timestamps to avoid timezone/reset drift bugs.

5. Correct Business Settings

ParameterValueDetails
Daily Free Spins1Resets at 00:00 local time
Max Daily Popups1Only displays on the first app launch of the day
Marketing Bonus SpinsCampaign-drivenCustom expiry dates per ticket
Rollover Daily SpinsNoDaily free spins expire at midnight if unused