package models

import (
	"time"

	"gorm.io/gorm"
)

// CompetitorBranch is a field-surveyed branch of a competing courier company.
type CompetitorBranch struct {
	ID        uint64         `gorm:"primaryKey;autoIncrement" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	CreatedBy uint64         `json:"created_by"`
	UpdatedBy uint64         `json:"updated_by"`

	Company       string `gorm:"size:255;not null;index" json:"company"`
	Area          string `gorm:"size:255" json:"area"`
	Phone         string `gorm:"size:30" json:"phone"`
	PlusCode      string `gorm:"size:100" json:"plus_code"`
	Address       string `gorm:"type:text" json:"address"`
	Pincodes      string `gorm:"type:text" json:"pincodes"` // Comma-separated list of pincodes served

	RatePerKg     string `gorm:"size:255" json:"rate_per_kg"`
	OffersPickup  string `gorm:"size:255" json:"offers_pickup"`
	OffersDrop    string `gorm:"size:255" json:"offers_drop"`
	TimeInDays    string `gorm:"size:255" json:"time_in_days"`
	PackingCharge string `gorm:"size:255" json:"packing_charge"`
	Frequency     string `gorm:"size:255" json:"frequency"`
}

func (CompetitorBranch) TableName() string { return "competitor_branches" }

// CarrierPricing holds per-company, per-weight-slab, per-zone rate ranges.
type CarrierPricing struct {
	ID        uint64    `gorm:"primaryKey;autoIncrement" json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	CreatedBy uint64    `json:"created_by"`
	UpdatedBy uint64    `json:"updated_by"`

	Company      string `gorm:"size:255;not null;index" json:"company"`
	WeightSlab   string `gorm:"size:60" json:"weight_slab"`
	ServiceType  string `gorm:"size:120" json:"service_type"`
	Zone         string `gorm:"size:120" json:"zone"`
	Rate         string `gorm:"size:60" json:"rate"`
	DeliveryTime string `gorm:"size:60" json:"delivery_time"`
}

func (CarrierPricing) TableName() string { return "carrier_pricing" }
