Yimaru-BackEnd/internal/domain/virtual_game.go

319 lines
11 KiB
Go

package domain
import (
"time"
)
type Provider string
const (
PROVIDER_POPOK Provider = "PopOk"
PROVIDER_ALEA_PLAY Provider = "AleaPlay"
PROVIDER_VELI_GAMES Provider = "VeliGames"
)
type FavoriteGame struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
GameID int64 `json:"game_id"`
CreatedAt time.Time `json:"created_at"`
}
type FavoriteGameRequest struct {
GameID int64 `json:"game_id"`
}
type FavoriteGameResponse struct {
GameID int64 `json:"game_id"`
GameName string `json:"game_name"`
}
type VirtualGame struct {
ID int64 `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
Category string `json:"category"`
MinBet float64 `json:"min_bet"`
MaxBet float64 `json:"max_bet"`
Volatility string `json:"volatility"`
IsActive bool `json:"is_active"`
RTP float64 `json:"rtp"`
IsFeatured bool `json:"is_featured"`
PopularityScore int `json:"popularity_score"`
ThumbnailURL string `json:"thumbnail_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type VirtualGameSession struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
GameID string `json:"game_id"`
SessionToken string `json:"session_token"`
Currency string `json:"currency"`
Status string `json:"status"` // ACTIVE, COMPLETED, FAILED
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExpiresAt time.Time `json:"expires_at"`
// Alea Play specific fields
ExternalSessionID string `json:"external_session_id"` // Alea's session reference
OperatorID string `json:"operator_id"` // Your operator ID with Alea
GameMode string `json:"game_mode"` // real, demo, tournament
}
type VirtualGameHistory struct {
ID int64 `json:"id"`
SessionID string `json:"session_id,omitempty"` // Optional, if session tracking is used
UserID int64 `json:"user_id"`
CompanyID int64 `json:"company_id"`
Provider string `json:"provider"`
WalletID *int64 `json:"wallet_id,omitempty"` // Optional if wallet detail is needed
GameID *int64 `json:"game_id,omitempty"` // Optional for game-level analysis
TransactionType string `json:"transaction_type"` // BET, WIN, CANCEL, etc.
Amount int64 `json:"amount"` // Stored in minor units (e.g. cents)
Currency string `json:"currency"` // e.g., ETB, USD
ExternalTransactionID string `json:"external_transaction_id"` // Provider transaction ID
ReferenceTransactionID string `json:"reference_transaction_id,omitempty"` // For CANCELs pointing to BETs
Status string `json:"status"` // COMPLETED, CANCELLED, FAILED, etc.
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type VirtualGameTransaction struct {
ID int64 `json:"id"`
SessionID int64 `json:"session_id"`
UserID int64 `json:"user_id"`
CompanyID int64 `json:"company_id"`
Provider string `json:"provider"`
GameID string `json:"game_id"`
WalletID int64 `json:"wallet_id"`
TransactionType string `json:"transaction_type"` // BET, WIN, REFUND, CASHOUT, etc.
Amount int64 `json:"amount"` // Always in cents
Currency string `json:"currency"`
ExternalTransactionID string `json:"external_transaction_id"`
ReferenceTransactionID string `json:"reference_transaction_id"`
Status string `json:"status"` // PENDING, COMPLETED, FAILED
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Alea Play specific fields
GameRoundID string `json:"game_round_id"` // Round identifier
Multiplier float64 `json:"multiplier"` // For games like Aviator
IsFreeRound bool `json:"is_free_round"` // For bonus play
OperatorID string `json:"operator_id"` // Your operator ID
// Veli specific fields
GameSpecificData GameSpecificData `json:"game_specific_data"`
}
type CreateVirtualGameSession struct {
UserID int64
GameID string
Currency string
Mode string // REAL, DEMO
}
type PopOKConfig struct {
ClientID string
SecretKey string
BaseURL string
CallbackURL string
Platform string
}
type PopOKCallback struct {
TransactionID string `json:"transaction_id"`
SessionID string `json:"session_id"`
Type string `json:"type"` // BET, WIN, REFUND, JACKPOT_WIN
Amount float64 `json:"amount"`
Currency string `json:"currency"`
Timestamp int64 `json:"timestamp"`
Signature string `json:"signature"` // HMAC-SHA256 signature for verification
}
type PopOKPlayerInfoRequest struct {
ExternalToken string `json:"externalToken"`
}
type PopOKPlayerInfoResponse struct {
Country string `json:"country"`
Currency string `json:"currency"`
Balance float64 `json:"balance"`
PlayerID string `json:"playerId"`
}
type PopOKBetRequest struct {
ExternalToken string `json:"externalToken"`
PlayerID string `json:"playerId"`
GameID string `json:"gameId"`
TransactionID string `json:"transactionId"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
}
type PopOKBetResponse struct {
TransactionID string `json:"transactionId"`
ExternalTrxID string `json:"externalTrxId"`
Balance float64 `json:"balance"`
}
// domain/popok.go
type PopOKWinRequest struct {
ExternalToken string `json:"externalToken"`
PlayerID string `json:"playerId"`
GameID string `json:"gameId"`
TransactionID string `json:"transactionId"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
}
type PopOKWinResponse struct {
TransactionID string `json:"transactionId"`
ExternalTrxID string `json:"externalTrxId"`
Balance float64 `json:"balance"`
}
type PopOKGenerateTokenRequest struct {
GameID string `json:"newGameId"`
Token string `json:"token"`
}
type PopOKCancelRequest struct {
ExternalToken string `json:"externalToken"`
PlayerID string `json:"playerId"`
GameID string `json:"gameId"`
TransactionID string `json:"transactionId"`
}
type PopOKCancelResponse struct {
TransactionID string `json:"transactionId"`
ExternalTrxID string `json:"externalTrxId"`
Balance float64 `json:"balance"`
}
type PopOKGenerateTokenResponse struct {
NewToken string `json:"newToken"`
}
type AleaPlayCallback struct {
EventID string `json:"event_id"`
TransactionID string `json:"transaction_id"`
SessionID string `json:"session_id"`
UserID string `json:"user_id"`
GameID string `json:"game_id"`
Type string `json:"type"` // BET, WIN, CASHOUT, etc.
Amount float64 `json:"amount"`
Currency string `json:"currency"`
RoundID string `json:"round_id"`
Multiplier float64 `json:"multiplier"`
IsFreeRound bool `json:"is_free_round"`
OperatorID string `json:"operator_id"`
Timestamp int64 `json:"timestamp"`
Signature string `json:"signature"`
}
type VeliCallback struct {
EventType string `json:"event_type"` // "bet_placed", "game_result", etc.
RoundID string `json:"round_id"` // Unique round identifier (replaces transaction_id)
SessionID string `json:"session_id"` // Matches VirtualGameSession.SessionToken
UserID string `json:"user_id"` // Veli's user identifier
GameID string `json:"game_id"` // e.g., "veli_aviator_v1"
Amount float64 `json:"amount"` // Transaction amount
Multiplier float64 `json:"multiplier"` // For games with multipliers (Aviator/Plinko)
Currency string `json:"currency"` // e.g., "USD"
Timestamp int64 `json:"timestamp"` // Unix timestamp
Signature string `json:"signature"` // HMAC-SHA256
}
type GameSpecificData struct {
Multiplier float64 `json:"multiplier,omitempty"`
RiskLevel string `json:"risk_level,omitempty"` // For Mines
BucketIndex int `json:"bucket_index,omitempty"` // For Plinko
}
type PopOKGame struct {
ID int `json:"id"`
GameName string `json:"gameName"`
Bets []float64 `json:"bets"`
Thumbnail string `json:"thumbnail"`
Status int `json:"status"`
}
type PopOKGameListResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
Slots []PopOKGame `json:"slots"`
} `json:"data"`
}
type GameRecommendation struct {
GameID int `json:"game_id"`
GameName string `json:"game_name"`
Thumbnail string `json:"thumbnail"`
Bets []float64 `json:"bets"`
Reason string `json:"reason"` // e.g., "Based on your activity", "Popular", "Random pick"
}
type PopokLaunchRequest struct {
Action string `json:"action"`
Platform int `json:"platform"`
PartnerID int `json:"partnerId"`
Time string `json:"time"`
Hash string `json:"hash"`
Data PopokLaunchRequestData `json:"data"`
}
type PopokLaunchRequestData struct {
GameMode string `json:"gameMode"`
GameID string `json:"gameId"`
Lang string `json:"lang"`
Token string `json:"token"`
ExitURL string `json:"exitURL"`
}
type PopokLaunchResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
LauncherURL string `json:"launcherURL"`
} `json:"data"`
}
type VirtualGameProvider struct {
// ID int64 `json:"id" db:"id"`
ProviderID string `json:"provider_id" db:"provider_id"`
ProviderName string `json:"provider_name" db:"provider_name"`
LogoDark *string `json:"logo_dark,omitempty" db:"logo_dark"`
LogoLight *string `json:"logo_light,omitempty" db:"logo_light"`
Enabled bool `json:"enabled" db:"enabled"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"`
}
// VirtualGameProviderPagination is used when returning paginated results
type VirtualGameProviderPagination struct {
Providers []VirtualGameProvider `json:"providers"`
TotalCount int64 `json:"total_count"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
type UnifiedGame struct {
GameID string `json:"gameId"`
ProviderID string `json:"providerId"`
Provider string `json:"provider"`
Name string `json:"name"`
Category string `json:"category,omitempty"`
DeviceType string `json:"deviceType,omitempty"`
Volatility string `json:"volatility,omitempty"`
RTP *float64 `json:"rtp,omitempty"`
HasDemo bool `json:"hasDemo"`
HasFreeBets bool `json:"hasFreeBets"`
Bets []float64 `json:"bets,omitempty"`
Thumbnail string `json:"thumbnail,omitempty"`
Status int `json:"status,omitempty"`
DemoURL string `json:"demoUrl"`
}