package models

import "time"

//////////////////////////////////////////////////////////////
// Horoscope Request Log
//////////////////////////////////////////////////////////////

// HoroscopeRequest is one horoscope a customer or astrologer opened. The admin
// panel's Horoscope screens read it; this API only ever inserts. The table is
// owned by the admin repo's migration
// (2026_09_23_120000_add_horoscope_requests_and_feedback_context.php), and
// every categorical column is a varchar the admin filters match on exactly -
// write only the values in the Horoscope* constants in services.
type HoroscopeRequest struct {
	ID            uint64     `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	UserID        *uint      `gorm:"column:user_id" json:"user_id"`
	AstrologerID  *uint      `gorm:"column:astrologer_id" json:"astrologer_id"`
	ActorType     string     `gorm:"column:actor_type" json:"actor_type"`
	Platform      string     `gorm:"column:platform" json:"platform"`
	DeviceType    *string    `gorm:"column:device_type" json:"device_type"`
	AppVersion    *string    `gorm:"column:app_version" json:"app_version"`
	HoroscopeType string     `gorm:"column:horoscope_type" json:"horoscope_type"`
	Zodiac        *int       `gorm:"column:zodiac" json:"zodiac"`
	Nakshatra     *int       `gorm:"column:nakshatra" json:"nakshatra"`
	PeriodDate    *time.Time `gorm:"column:period_date;type:date" json:"period_date"`
	PeriodLabel   *string    `gorm:"column:period_label" json:"period_label"`
	PeriodYear    *int       `gorm:"column:period_year" json:"period_year"`
	Langcode      string     `gorm:"column:langcode" json:"langcode"`
	WasCharged    bool       `gorm:"column:was_charged" json:"was_charged"`
	ChargedAmount float64    `gorm:"column:charged_amount" json:"charged_amount"`
	Succeeded     bool       `gorm:"column:succeeded" json:"succeeded"`
	FailureReason *string    `gorm:"column:failure_reason" json:"failure_reason"`
	ResponseMs    *int64     `gorm:"column:response_ms" json:"response_ms"`
	IPAddress     *string    `gorm:"column:ip_address" json:"ip_address"`
	IsTest        bool       `gorm:"column:is_test" json:"is_test"`
	CreatedAt     time.Time  `gorm:"column:created_at" json:"created_at"`
}

func (HoroscopeRequest) TableName() string {
	return "horoscope_requests"
}

//////////////////////////////////////////////////////////////
// Horoscope Feedback
//////////////////////////////////////////////////////////////

// HoroscopeFeedback is the pre-existing horoscopefeedback table, which the
// Laravel addHoroscopeFeedback also writes. horoscope_type, zodiac, platform
// and is_test were added for the admin panel and are nullable there.
type HoroscopeFeedback struct {
	ID            uint      `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	UserID        uint      `gorm:"column:userId" json:"userId"`
	Feedback      *string   `gorm:"column:feedback" json:"feedback"`
	FeedbackType  string    `gorm:"column:feedbacktype" json:"feedbacktype"`
	HoroscopeType *string   `gorm:"column:horoscope_type" json:"horoscope_type"`
	Zodiac        *int      `gorm:"column:zodiac" json:"zodiac"`
	Platform      *string   `gorm:"column:platform" json:"platform"`
	IsTest        bool      `gorm:"column:is_test" json:"is_test"`
	CreatedAt     time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt     time.Time `gorm:"column:updated_at" json:"updated_at"`
}

func (HoroscopeFeedback) TableName() string {
	return "horoscopefeedback"
}
