This system manages player VIP status and other custom statuses (e.g., premium, premium2).
-- Table for storing VIP information
-- total_spent: The single source of truth for lifetime top-up amount
-- VIP level can be calculated in code: vipLevel = floor(total_spent / 100)
CREATE TABLE IF NOT EXISTS vip_data (
account_type VARCHAR(50) NOT NULL DEFAULT 'player',
account_uuid VARCHAR(36) NOT NULL,
total_spent BIGINT DEFAULT 0,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (account_type, account_uuid)
);
-- Table for managing account statuses (one active status per account)
-- time_left: Remaining duration in seconds
CREATE TABLE IF NOT EXISTS account_status (
account_type VARCHAR(50) NOT NULL DEFAULT 'player',
account_uuid VARCHAR(36) NOT NULL,
status_name VARCHAR(50) NOT NULL,
priority INTEGER DEFAULT 0,
time_left BIGINT NOT NULL,
is_active INTEGER DEFAULT 1,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (account_type, account_uuid)
);
-- Index for faster lookup when querying active statuses per account
CREATE INDEX IF NOT EXISTS idx_status_uuid ON account_status(account_type, account_uuid, is_active);All endpoints are prefixed with /api and require a valid Bearer token.
- GET
/api/vip/:uuid?account_type=player: Returns VIP data for an account. - POST
/api/vip/topup: Incrementstotal_spentfor an account.- Body:
{ "account_type": "player", "account_uuid": "...", "amount": 100 }
- Body:
- GET
/api/status/:uuid?account_type=player: Returns the active status for an account. - POST
/api/status/set: Sets a status for an account.- If an account already has an active status, it can only be overwritten if:
- The
status_nameis identical (updates duration/priority). - The new status has a strictly higher
prioritythan the existing one.
- The
- In case 2, the previous status will be automatically deactivated (
is_activeset to 0). - Body:
{ "account_type": "player", "account_uuid": "...", "status_name": "premium", "priority": 1, "time_left": 3600 }
- If an account already has an active status, it can only be overwritten if:
- POST
/api/status/deactivate: Removes the active status for an account.- Body:
{ "account_type": "player", "account_uuid": "..." }
- Body: