package entity

import (
	_const "chonho/const"
	"github.com/lib/pq"
)

type StorePayment struct {
	Method        string `json:"method"`
	ChannelName   string `json:"channel_name"`
	AccountName   string `json:"account_name"`
	AccountNumber string `json:"account_number"`
	ExtraInfo     string `json:"extra_info"`
}

type Store struct {
	Id                   int64          `json:"id"`
	Name                 string         `json:"name"`
	Phone                string         `json:"phone"`
	SellerPhone          string         `json:"seller_phone"`
	Description          string         `json:"description"`
	Rating               float64        `json:"rating"`
	Image                string         `json:"image"`
	ApartmentId          int64          `json:"apartment_id"`
	ApartmentHouseNumber string         `json:"apartment_house_number"`
	CategoryIds          []int64        `json:"category_ids" gorm:"-"`
	Category             pq.Int64Array  `json:"-" gorm:"type:integer[]"`
	StorePayment         []StorePayment `json:"payment_info" gorm:"-"`
	PaymentAcceptCash    bool           `json:"payment_accept_cash"`
	Payment              string         `json:"-" gorm:"column=payment"`
}

type StorePaymentInfo struct {
	Id                int64          `json:"id"`
	StorePayment      []StorePayment `json:"payment_info" gorm:"-"`
	PaymentAcceptCash bool           `json:"payment_accept_cash"`
	Payment           string         `json:"-" gorm:"column=payment"`
}

type GetStoreResponse struct {
	Response
	Data Store `json:"data"`
}

type ListStoreResponse struct {
	Response
	Data []Store `json:"data"`
}

type ListStorePaymentInfo struct {
	Response
	Data []StorePaymentInfo `json:"data"`
}

type RateStore struct {
	Rate    float64 `json:"rate" validate:"required"`
	Comment string  `json:"comment" validate:"required"`
}

func AppendStorePaymentCOD(arr []StorePayment) []StorePayment {
	return append(arr, StorePayment{
		Method:      "COD",
		ChannelName: _const.CashOnDelivery,
	})
}
