75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
package domain
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type ReferralStatus string
|
|
|
|
const (
|
|
ReferralPending ReferralStatus = "PENDING"
|
|
ReferralCompleted ReferralStatus = "COMPLETED"
|
|
ReferralExpired ReferralStatus = "EXPIRED"
|
|
ReferralCancelled ReferralStatus = "CANCELLED"
|
|
)
|
|
|
|
func (rs *ReferralStatus) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*rs = ReferralStatus(s)
|
|
case string:
|
|
*rs = ReferralStatus(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ReferralStatus: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (rs ReferralStatus) Value() (driver.Value, error) {
|
|
return string(rs), nil
|
|
}
|
|
|
|
type ReferralStats struct {
|
|
TotalReferrals int
|
|
CompletedReferrals int
|
|
TotalRewardEarned float64
|
|
PendingRewards float64
|
|
}
|
|
|
|
type ReferralSettings struct {
|
|
ID int64
|
|
ReferralRewardAmount float64
|
|
CashbackPercentage float64
|
|
BetReferralBonusPercentage float64
|
|
MaxReferrals int32
|
|
ExpiresAfterDays int32
|
|
UpdatedBy string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
Version int32
|
|
}
|
|
|
|
type ReferralSettingsReq struct {
|
|
ReferralRewardAmount float64 `json:"referral_reward_amount" validate:"required"`
|
|
CashbackPercentage float64 `json:"cashback_percentage" validate:"required"`
|
|
MaxReferrals int32 `json:"max_referrals" validate:"required"`
|
|
ExpiresAfterDays int32 `json:"expires_afterdays" validate:"required"`
|
|
UpdatedBy string `json:"updated_by" validate:"required"`
|
|
}
|
|
|
|
type Referral struct {
|
|
ID int64
|
|
ReferralCode string
|
|
ReferrerID int64
|
|
CompanyID int64
|
|
ReferredID *int64
|
|
Status ReferralStatus
|
|
RewardAmount float64
|
|
CashbackAmount float64
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ExpiresAt time.Time
|
|
}
|