VIP tier engine
Translator note: machine-translated baseline. Needs human review by a native UK speaker. EN source is canonical.
Operator-defined tier драбина з auto-promotion на основі lifetime activity. Default seed: Bronze → Silver → Gold → Platinum.
Tier shape
{
"code": "gold", // lowercase, alphanumeric_underscore
"name": "Gold",
"rank": 2, // ordering: 0 = baseline
"color": "#FFD700", // hex для badge
"glyph": "★★★", // unicode badge
"requirements": {
"lifetime_deposit_subunit": 500000, // €5000
"lifetime_wagered_subunit": 2500000, // €25000
"min_days_active": 14
},
"demotion": { "inactivity_days": 60 }, // null = sticky tier
"perks": {
"cashback_pct": 5,
"dedicated_host": true,
"priority_kyc": true
},
"is_active": true
}
Requirements + perks — operator-defined; casinocrm.io не enforce-ить specific values, тільки structural shape.
Auto-promotion
recomputeTierForPlayer(tenantId, playerId) оцінює eligibility:
- Loads активні tiers ordered by rank DESC.
- Для кожного tier checks all requirement умови (AND-ed):
total_deposited >=,total_wagered >=, days sincefirst_seen_at >=. - Highest matched rank wins.
Всі thresholds — currency-aware — lifetime_deposit_subunit denominated в tenant base валюті, і players.total_deposited вже maintained у base stream-processor-ом. Жодної FX математики at evaluation.
Demotion
Per-tier demotion правила (demotion.inactivity_days). Якщо current tier гравця має demotion rule + вони перетнули inactivity window, drop on one tier (не aж до baseline — concierge model).
reconcileTierDemotions запускається щодня як cron-able script.
Manual override
POST /v1/players/:id/tier { to_code: "platinum", reason: "VIP host invitation" } пише history entry з trigger=manual. Корисно для concierge promotions, де operator хоче когось у Platinum без задоволення auto thresholds.
Наступний auto-recompute respect-ить override: якщо гравець ВСЕ ЩЕ не задовольняє Platinum thresholds, manual tier sticks. Auto path змінює tiers тільки коли eligibility computation каже.
History
player_tier_history — append-only audit:
SELECT from_code, to_code, trigger, occurred_at
FROM player_tier_history
WHERE player_id = $1
ORDER BY occurred_at DESC
LIMIT 50;
trigger — auto (engine), manual (admin), або reset (one-time backfill).
Events
Engine не emits events directly; tier changes show up в player_tier_history. Future enhancement: emit tier_promoted / tier_demoted канонічні події для journey triggers.
Stream-processor wiring
Per-event tier recompute deferred в MVP — використовуємо daily reconciliation cron + on-demand admin recompute via POST /v1/players/:id/tier. Operators, які потребують real-time, можуть flip on per-event call by setting RECOMPUTE_TIER_ON_EVENT=1 в stream-processor env (adds ~5ms HTTP latency per money event).