package domain import ( "math/big" "time" dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db" ) type FinancialReport struct { ID int64 `json:"id"` GameID string `json:"gameId"` ProviderID string `json:"providerId"` ReportDate string `json:"reportDate"` // YYYY-MM-DD ReportType string `json:"reportType"` TotalBets float64 `json:"totalBets"` TotalWins float64 `json:"totalWins"` GGR float64 `json:"ggr"` RTP float64 `json:"rtp"` CreatedAt time.Time `json:"createdAt"` UpdatedAt *time.Time `json:"updatedAt,omitempty"` } func ConvertDBFinancialReport(dbReport dbgen.VirtualGameFinancialReport) FinancialReport { return FinancialReport{ ID: dbReport.ID, GameID: dbReport.GameID, ProviderID: dbReport.ProviderID, ReportDate: dbReport.ReportDate.Time.Format("2006-01-02"), ReportType: dbReport.ReportType, TotalBets: float64(dbReport.TotalBets.Exp), TotalWins: float64(dbReport.TotalWins.Exp), GGR: float64(dbReport.Ggr.Exp), RTP: float64(dbReport.Rtp.Exp), CreatedAt: dbReport.CreatedAt.Time, UpdatedAt: &dbReport.UpdatedAt.Time, } } type CompanyReport struct { ID int64 `json:"id"` CompanyID int64 `json:"companyId"` ProviderID string `json:"providerId"` ReportDate string `json:"reportDate"` // YYYY-MM-DD ReportType string `json:"reportType"` TotalBetAmount float64 `json:"totalBetAmount"` TotalWinAmount float64 `json:"totalWinAmount"` NetProfit float64 `json:"netProfit"` ProfitMargin float64 `json:"profitMargin"` CreatedAt time.Time `json:"createdAt"` UpdatedAt *time.Time `json:"updatedAt,omitempty"` } // ConvertDBCompanyReport converts the SQLC generated CompanyReport struct to domain.CompanyReport func ConvertDBCompanyReport(dbReport dbgen.VirtualGameCompanyReport) CompanyReport { var updatedAt *time.Time if !dbReport.UpdatedAt.Time.IsZero() { updatedAt = &dbReport.UpdatedAt.Time } // convert big.Int-backed numeric fields to float64 safely var totalBetAmount float64 if dbReport.TotalBetAmount.Int != nil { if f, _ := new(big.Float).SetInt(dbReport.TotalBetAmount.Int).Float64(); true { totalBetAmount = f } } var totalWinAmount float64 if dbReport.TotalWinAmount.Int != nil { if f, _ := new(big.Float).SetInt(dbReport.TotalWinAmount.Int).Float64(); true { totalWinAmount = f } } var netProfit float64 if dbReport.NetProfit.Int != nil { if f, _ := new(big.Float).SetInt(dbReport.NetProfit.Int).Float64(); true { netProfit = f } } var profitMargin float64 if dbReport.ProfitMargin.Int != nil { if f, _ := new(big.Float).SetInt(dbReport.ProfitMargin.Int).Float64(); true { profitMargin = f } } return CompanyReport{ ID: dbReport.ID, CompanyID: dbReport.CompanyID, ProviderID: dbReport.ProviderID, ReportDate: dbReport.ReportDate.Time.Format("2006-01-02"), ReportType: dbReport.ReportType, TotalBetAmount: totalBetAmount, TotalWinAmount: totalWinAmount, NetProfit: netProfit, ProfitMargin: profitMargin, CreatedAt: dbReport.CreatedAt.Time, UpdatedAt: updatedAt, } } type CompanyProfitTrend struct { ReportDate string `json:"reportDate"` TotalProfit float64 `json:"totalProfit"` } type PlayerActivityReport struct { ID int64 `json:"id"` UserID int64 `json:"userId"` ReportDate string `json:"reportDate"` // YYYY-MM-DD ReportType string `json:"reportType"` TotalDeposits float64 `json:"totalDeposits"` TotalWithdrawals float64 `json:"totalWithdrawals"` NetContribution float64 `json:"netContribution"` TotalBetAmount float64 `json:"totalBetAmount"` TotalWinAmount float64 `json:"totalWinAmount"` NetResult float64 `json:"netResult"` RoundsPlayed int64 `json:"roundsPlayed"` AvgBetSize float64 `json:"avgBetSize"` CreatedAt time.Time `json:"createdAt"` UpdatedAt *time.Time `json:"updatedAt,omitempty"` } func ConvertDBPlayerActivityReport(dbReport dbgen.VirtualGamePlayerActivityReport) PlayerActivityReport { return PlayerActivityReport{ ID: dbReport.ID, UserID: dbReport.UserID, ReportDate: dbReport.ReportDate.Time.Format("2006-01-02"), ReportType: dbReport.ReportType, TotalDeposits: float64(dbReport.TotalDeposits.Exp), TotalWithdrawals: float64(dbReport.TotalWithdrawals.Exp), NetContribution: float64(dbReport.NetContribution.Exp), TotalBetAmount: float64(dbReport.TotalBetAmount.Exp), TotalWinAmount: float64(dbReport.TotalWinAmount.Exp), NetResult: float64(dbReport.NetResult.Exp), RoundsPlayed: dbReport.RoundsPlayed.Int64, AvgBetSize: float64(dbReport.AvgBetSize.Exp), CreatedAt: dbReport.CreatedAt.Time, UpdatedAt: &dbReport.UpdatedAt.Time, } } type TopPlayerNetResult struct { UserID int64 `json:"userId"` TotalNet float64 `json:"totalNet"` }