Yimaru-BackEnd/internal/domain/report.go

509 lines
16 KiB
Go

package domain
import "time"
type TimeFrame string
const (
Daily TimeFrame = "daily"
Weekly TimeFrame = "weekly"
Monthly TimeFrame = "monthly"
)
type ReportFrequency string
const (
ReportDaily ReportFrequency = "daily"
ReportWeekly ReportFrequency = "weekly"
ReportMonthly ReportFrequency = "monthly"
)
type PaginatedFileResponse struct {
Response `json:",inline"`
Data []string `json:"data"`
Pagination Pagination `json:"pagination"`
}
type ReportRequest struct {
Frequency ReportFrequency
StartDate time.Time
EndDate time.Time
}
type ReportData struct {
TotalBets int64
TotalCashIn float64
TotalCashOut float64
CashBacks float64
Withdrawals float64
Deposits float64
TotalTickets int64
VirtualGameStats []VirtualGameStat
CompanyReports []CompanyReport
BranchReports []BranchReport
}
type VirtualGameStat struct {
GameName string
NumBets int64
TotalTransaction float64
}
type Report struct {
ID string
TimeFrame TimeFrame
PeriodStart time.Time
PeriodEnd time.Time
TotalBets int
TotalCashIn float64
TotalCashOut float64
TotalCashBack float64
GeneratedAt time.Time
}
type LiveMetric struct {
TotalCashSportsbook float64
TotalCashSportGames float64
TotalLiveTickets int64
TotalUnsettledCash float64
TotalGames int64
}
type MetricUpdates struct {
TotalCashSportsbookDelta *float64
TotalCashSportGamesDelta *float64
TotalLiveTicketsDelta *int64
TotalUnsettledCashDelta *float64
TotalGamesDelta *int64
}
type DashboardSummary struct {
TotalStakes Currency `json:"total_stakes"`
TotalBets int64 `json:"total_bets"`
ActiveBets int64 `json:"active_bets"`
WinBalance Currency `json:"win_balance"`
TotalWins int64 `json:"total_wins"`
TotalLosses int64 `json:"total_losses"`
CustomerCount int64 `json:"customer_count"`
Profit Currency `json:"profit"`
WinRate float64 `json:"win_rate"`
AverageStake Currency `json:"average_stake"`
TotalDeposits Currency `json:"total_deposits"`
TotalWithdrawals Currency `json:"total_withdrawals"`
ActiveCustomers int64 `json:"active_customers"`
BranchesCount int64 `json:"branches_count"`
ActiveBranches int64 `json:"active_branches"`
TotalCashiers int64 `json:"total_cashiers"`
ActiveCashiers int64 `json:"active_cashiers"`
InactiveCashiers int64 `json:"inactive_cashiers"`
TotalWallets int64 `json:"total_wallets"`
TotalGames int64 `json:"total_games"`
ActiveGames int64 `json:"active_games"`
InactiveGames int64 `json:"inactive_games"`
TotalManagers int64 `json:"total_managers"`
ActiveManagers int64 `json:"active_managers"`
InactiveManagers int64 `json:"inactive_managers"`
InactiveBranches int64 `json:"inactive_branches"`
TotalAdmins int64 `json:"total_admins"`
ActiveAdmins int64 `json:"active_admins"`
InactiveAdmins int64 `json:"inactive_admins"`
TotalCompanies int64 `json:"total_companies"`
ActiveCompanies int64 `json:"active_companies"`
InactiveCompanies int64 `json:"inactive_companies"`
InactiveCustomers int64 `json:"inactive_customers"`
TotalNotifications int64 `json:"total_notifications"`
ReadNotifications int64 `json:"read_notifications"`
UnreadNotifications int64 `json:"unread_notifications"`
}
type DashboardSummaryRes struct {
TotalStakes float32 `json:"total_stakes"`
TotalBets int64 `json:"total_bets"`
ActiveBets int64 `json:"active_bets"`
WinBalance float32 `json:"win_balance"`
TotalWins int64 `json:"total_wins"`
TotalLosses int64 `json:"total_losses"`
CustomerCount int64 `json:"customer_count"`
Profit float32 `json:"profit"`
WinRate float64 `json:"win_rate"`
AverageStake float32 `json:"average_stake"`
TotalDeposits float32 `json:"total_deposits"`
TotalWithdrawals float32 `json:"total_withdrawals"`
ActiveCustomers int64 `json:"active_customers"`
BranchesCount int64 `json:"branches_count"`
ActiveBranches int64 `json:"active_branches"`
TotalCashiers int64 `json:"total_cashiers"`
ActiveCashiers int64 `json:"active_cashiers"`
InactiveCashiers int64 `json:"inactive_cashiers"`
TotalWallets int64 `json:"total_wallets"`
TotalGames int64 `json:"total_games"`
ActiveGames int64 `json:"active_games"`
InactiveGames int64 `json:"inactive_games"`
TotalManagers int64 `json:"total_managers"`
ActiveManagers int64 `json:"active_managers"`
InactiveManagers int64 `json:"inactive_managers"`
InactiveBranches int64 `json:"inactive_branches"`
TotalAdmins int64 `json:"total_admins"`
ActiveAdmins int64 `json:"active_admins"`
InactiveAdmins int64 `json:"inactive_admins"`
TotalCompanies int64 `json:"total_companies"`
ActiveCompanies int64 `json:"active_companies"`
InactiveCompanies int64 `json:"inactive_companies"`
InactiveCustomers int64 `json:"inactive_customers"`
TotalNotifications int64 `json:"total_notifications"`
ReadNotifications int64 `json:"read_notifications"`
UnreadNotifications int64 `json:"unread_notifications"`
}
func ConvertDashboardSummaryToRes(summary DashboardSummary) DashboardSummaryRes {
return DashboardSummaryRes{
TotalStakes: summary.TotalStakes.Float32(),
TotalBets: summary.TotalBets,
ActiveBets: summary.ActiveBets,
WinBalance: summary.WinBalance.Float32(),
TotalWins: summary.TotalWins,
TotalLosses: summary.TotalLosses,
CustomerCount: summary.CustomerCount,
Profit: summary.Profit.Float32(),
WinRate: summary.WinRate,
AverageStake: summary.AverageStake.Float32(),
TotalDeposits: summary.TotalDeposits.Float32(),
TotalWithdrawals: summary.TotalWithdrawals.Float32(),
ActiveCustomers: summary.ActiveCustomers,
BranchesCount: summary.BranchesCount,
ActiveBranches: summary.ActiveBranches,
TotalCashiers: summary.TotalCashiers,
ActiveCashiers: summary.ActiveCashiers,
InactiveCashiers: summary.InactiveCashiers,
TotalWallets: summary.TotalWallets,
TotalGames: summary.TotalGames,
ActiveGames: summary.ActiveGames,
InactiveGames: summary.InactiveGames,
TotalManagers: summary.TotalManagers,
ActiveManagers: summary.ActiveManagers,
InactiveManagers: summary.InactiveManagers,
InactiveBranches: summary.InactiveBranches,
TotalAdmins: summary.TotalAdmins,
ActiveAdmins: summary.ActiveAdmins,
InactiveAdmins: summary.InactiveAdmins,
TotalCompanies: summary.TotalCompanies,
ActiveCompanies: summary.ActiveCompanies,
InactiveCompanies: summary.InactiveCompanies,
InactiveCustomers: summary.InactiveCustomers,
TotalNotifications: summary.TotalNotifications,
ReadNotifications: summary.ReadNotifications,
UnreadNotifications: summary.UnreadNotifications,
}
}
type CustomerActivity struct {
CustomerID int64 `json:"customer_id"`
CustomerName string `json:"customer_name"`
TotalBets int64 `json:"total_bets"`
TotalStakes Currency `json:"total_stakes"`
TotalWins int64 `json:"total_wins"`
TotalPayouts Currency `json:"total_payouts"`
Profit Currency `json:"profit"`
FirstBetDate time.Time `json:"first_bet_date"`
LastBetDate time.Time `json:"last_bet_date"`
FavoriteSport string `json:"favorite_sport"`
FavoriteMarket string `json:"favorite_market"`
AverageStake Currency `json:"average_stake"`
AverageOdds float64 `json:"average_odds"`
WinRate float64 `json:"win_rate"`
ActivityLevel string `json:"activity_level"` // High, Medium, Low
}
type BranchPerformance struct {
BranchID int64 `json:"branch_id"`
BranchName string `json:"branch_name"`
Location string `json:"location"`
ManagerName string `json:"manager_name"`
TotalBets int64 `json:"total_bets"`
TotalStakes Currency `json:"total_stakes"`
TotalWins int64 `json:"total_wins"`
TotalPayouts Currency `json:"total_payouts"`
Profit Currency `json:"profit"`
CustomerCount int64 `json:"customer_count"`
Deposits Currency `json:"deposits"`
Withdrawals Currency `json:"withdrawals"`
WinRate float64 `json:"win_rate"`
AverageStake Currency `json:"average_stake"`
PerformanceScore float64 `json:"performance_score"`
}
type SportPerformance struct {
SportID string `json:"sport_id"`
SportName string `json:"sport_name"`
TotalBets int64 `json:"total_bets"`
TotalStakes Currency `json:"total_stakes"`
TotalWins int64 `json:"total_wins"`
TotalPayouts Currency `json:"total_payouts"`
Profit Currency `json:"profit"`
PopularityRank int `json:"popularity_rank"`
WinRate float64 `json:"win_rate"`
AverageStake Currency `json:"average_stake"`
AverageOdds float64 `json:"average_odds"`
MostPopularMarket string `json:"most_popular_market"`
}
type BetAnalysis struct {
Date time.Time `json:"date"`
TotalBets int64 `json:"total_bets"`
TotalStakes Currency `json:"total_stakes"`
TotalWins int64 `json:"total_wins"`
TotalPayouts Currency `json:"total_payouts"`
Profit Currency `json:"profit"`
MostPopularSport string `json:"most_popular_sport"`
MostPopularMarket string `json:"most_popular_market"`
HighestStake Currency `json:"highest_stake"`
HighestPayout Currency `json:"highest_payout"`
AverageOdds float64 `json:"average_odds"`
}
type ValidOutcomeStatus struct {
Value OutcomeStatus
Valid bool // Valid is true if Value is not NULL
}
// ReportFilter contains filters for report generation
type ReportFilter struct {
StartTime ValidTime `json:"start_time"`
EndTime ValidTime `json:"end_time"`
CompanyID ValidInt64 `json:"company_id"`
BranchID ValidInt64 `json:"branch_id"`
RecipientID ValidInt64 `json:"recipient_id"`
UserID ValidInt64 `json:"user_id"`
SportID ValidString `json:"sport_id"`
Status ValidOutcomeStatus `json:"status"`
}
// BetStat represents aggregated bet statistics
type BetStat struct {
Date time.Time
TotalBets int64
TotalStakes Currency
TotalWins int64
TotalPayouts Currency
AverageOdds float64
}
// ExtremeValues represents extreme values in betting
type ExtremeValues struct {
HighestStake Currency
HighestPayout Currency
}
// CustomerBetActivity represents customer betting activity
type CustomerBetActivity struct {
CustomerID int64
TotalBets int64
TotalStakes Currency
TotalWins int64
TotalPayouts Currency
FirstBetDate time.Time
LastBetDate time.Time
AverageOdds float64
}
// BranchBetActivity represents branch betting activity
type BranchBetActivity struct {
BranchID int64
TotalBets int64
TotalStakes Currency
TotalWins int64
TotalPayouts Currency
}
// BranchDetail represents branch details
// type BranchDetail struct {
// Name string
// Location string
// ManagerName string
// }
// BranchTransactions represents branch transaction totals
type BranchTransactions struct {
Deposits Currency
Withdrawals Currency
}
// SportBetActivity represents sport betting activity
type SportBetActivity struct {
SportID string
TotalBets int64
TotalStakes Currency
TotalWins int64
TotalPayouts Currency
AverageOdds float64
}
// CustomerDetail represents customer details
type CustomerDetail struct {
Name string
}
// BalanceSummary represents wallet balance summary
type BalanceSummary struct {
TotalBalance Currency
ActiveBalance Currency
InactiveBalance Currency
BettableBalance Currency
NonBettableBalance Currency
}
// In your domain package
type CustomerPreferences struct {
FavoriteSport string `json:"favorite_sport"`
FavoriteMarket string `json:"favorite_market"`
}
// type DashboardSummary struct {
// TotalStakes Currency `json:"total_stakes"`
// TotalBets int64 `json:"total_bets"`
// ActiveBets int64 `json:"active_bets"`
// WinBalance Currency `json:"win_balance"`
// TotalWins int64 `json:"total_wins"`
// TotalLosses int64 `json:"total_losses"`
// CustomerCount int64 `json:"customer_count"`
// Profit Currency `json:"profit"`
// WinRate float64 `json:"win_rate"`
// AverageStake Currency `json:"average_stake"`
// TotalDeposits Currency `json:"total_deposits"`
// TotalWithdrawals Currency `json:"total_withdrawals"`
// ActiveCustomers int64 `json:"active_customers"`
// BranchesCount int64 `json:"branches_count"`
// ActiveBranches int64 `json:"active_branches"`
// }
type ErrorResponse struct {
Message string `json:"message"`
Error string `json:"error,omitempty"`
}
type NotificationReport struct {
CountsByType []NotificationTypeCount `json:"counts_by_type"`
DeliveryStats NotificationDeliveryStats `json:"delivery_stats"`
ActiveRecipients []ActiveNotificationRecipient `json:"active_recipients"`
}
type NotificationTypeCount struct {
Type string `json:"type"`
Total int64 `json:"total"`
Read int64 `json:"read"`
Unread int64 `json:"unread"`
}
type NotificationDeliveryStats struct {
TotalSent int64 `json:"total_sent"`
FailedDeliveries int64 `json:"failed_deliveries"`
SuccessRate float64 `json:"success_rate"`
MostUsedChannel string `json:"most_used_channel"`
}
type ActiveNotificationRecipient struct {
RecipientID int64 `json:"recipient_id"`
RecipientName string `json:"recipient_name"`
NotificationCount int64 `json:"notification_count"`
LastNotificationTime time.Time `json:"last_notification_time"`
}
type CompanyPerformance struct {
CompanyID int64 `json:"company_id"`
CompanyName string `json:"company_name"`
ContactEmail string `json:"contact_email"`
TotalBets int64 `json:"total_bets"`
TotalStakes Currency `json:"total_stakes"`
TotalWins int64 `json:"total_wins"`
TotalPayouts Currency `json:"total_payouts"`
Profit Currency `json:"profit"`
WinRate float64 `json:"win_rate"`
AverageStake Currency `json:"average_stake"`
TotalBranches int64 `json:"total_branches"`
ActiveBranches int64 `json:"active_branches"`
TotalCashiers int64 `json:"total_cashiers"`
ActiveCashiers int64 `json:"active_cashiers"`
WalletBalance Currency `json:"wallet_balance"`
LastActivity time.Time `json:"last_activity"`
}
type CashierPerformance struct {
CashierID int64 `json:"cashier_id"`
CashierName string `json:"cashier_name"`
BranchID int64 `json:"branch_id"`
BranchName string `json:"branch_name"`
CompanyID int64 `json:"company_id"`
TotalBets int64 `json:"total_bets"`
TotalStakes Currency `json:"total_stakes"`
TotalWins int64 `json:"total_wins"`
TotalPayouts Currency `json:"total_payouts"`
Profit Currency `json:"profit"`
WinRate float64 `json:"win_rate"`
AverageStake Currency `json:"average_stake"`
Deposits Currency `json:"deposits"`
Withdrawals Currency `json:"withdrawals"`
NetTransactionAmount Currency `json:"net_transaction_amount"`
FirstActivity time.Time `json:"first_activity"`
LastActivity time.Time `json:"last_activity"`
ActiveDays int `json:"active_days"`
}
type CompanyWalletBalance struct {
CompanyID int64 `json:"company_id"`
CompanyName string `json:"company_name"`
Balance float64 `json:"balance"`
}
type BranchWalletBalance struct {
BranchID int64 `json:"branch_id"`
BranchName string `json:"branch_name"`
CompanyID int64 `json:"company_id"`
Balance float64 `json:"balance"`
}
type LiveWalletMetrics struct {
Timestamp time.Time `json:"timestamp"`
CompanyBalances []CompanyWalletBalance `json:"company_balances"`
BranchBalances []BranchWalletBalance `json:"branch_balances"`
}
type CompanyReport struct {
CompanyID int64
CompanyName string
TotalBets int64
TotalCashIn float64
TotalCashOut float64
TotalCashBacks float64
}
type BranchReport struct {
BranchID int64
BranchName string
CompanyID int64
TotalBets int64
TotalCashIn float64
TotalCashOut float64
TotalCashBacks float64
}