Skip to main content

VIP Daily Cashback Log

Tracks daily cashback calculations and credits for VIP players. Each row represents one player's cashback for one day, calculated as a percentage of their net gaming loss (NGR).

Table Comment

Tracks daily cashback calculations and credits for VIP players

Relationships

  • Belongs to players via player_id
  • Belongs to brands via brand_id
  • Belongs to companies via company_id
  • References vip_levels via vip_level_id
  • References transactions via transaction_id (the credit transaction when cashback is paid out)

Columns

ColumnTypeNullableDefaultDescription
iduuidNOgen_random_uuid()Primary key
player_iduuidNOFK to players. The player receiving cashback.
brand_iduuidNOFK to brands. Brand context.
company_iduuidNOFK to companies. Parent company.
calculation_datedateNOThe date the cashback is calculated for. Unique per player per day.
vip_level_idintegerYESFK to vip_levels. The player's VIP level used for this calculation.
vip_level_rankintegerNOSnapshot of the VIP level rank at calculation time
cashback_percentagenumeric(5)NOCashback percentage applied (from vip_levels.cashback_percentage)
total_betsnumeric(18)YES0Total bets placed by the player on calculation_date
total_winsnumeric(18)YES0Total wins by the player on calculation_date
net_lossnumeric(18)YES0Net loss (bets - wins). Cashback only applies when net_loss > 0.
cashback_amountnumeric(18)YES0Calculated cashback amount: net_loss * cashback_percentage / 100, capped by cashback_max_amount from vip_levels
transaction_iduuidYESFK to transactions. The credit transaction created when cashback is paid out. NULL until credited.
statusvarchar(20)YES'calculated'Workflow status. See values below.
created_attimestampYESCURRENT_TIMESTAMPRecord creation timestamp

Status Values

StatusDescription
calculatedCashback has been calculated but not yet credited to the player
creditedCashback has been paid out — transaction_id is set
skippedCashback was skipped (e.g., player had no net loss, or was below minimum threshold)

Key Indexes

IndexColumnsNotes
vip_daily_cashback_log_pkeyidPrimary key
vip_daily_cashback_uniqueplayer_id, calculation_dateUnique constraint — one calculation per player per day
idx_vip_daily_cashback_player_dateplayer_id, calculation_datePlayer cashback history
idx_vip_daily_cashback_statusstatus, calculation_dateProcess pending calculations

Business Rules

  • Cashback is calculated daily as: cashback_amount = net_loss * cashback_percentage / 100
  • The cashback_max_amount from vip_levels caps the maximum cashback per day
  • Only net losses trigger cashback — if the player is in profit for the day, no cashback is generated (status = skipped)
  • The unique constraint on (player_id, calculation_date) prevents duplicate calculations
  • When cashback is credited, a corresponding transaction is created and transaction_id is set
  • Cashback percentages are determined by the player's VIP level at calculation time (see vip_levels.cashback_percentage)
  • The vip_level_rank is snapshotted for historical accuracy
  • A player_sweepstakes_rewards entry with reward_type = 'vip_cashback' is also created when cashback is credited