package payment

import (
	"time"

	"gorm.io/datatypes"
)

type StartPaymentRequest struct {
	PayWay    string `json:"pay_way"`
	JSPayFlag string `json:"jspay_flag"`
}

type PaymentDTO struct {
	ID              uint64     `json:"id"`
	PaymentNo       string     `json:"payment_no"`
	OrderID         uint64     `json:"order_id"`
	OrderNo         string     `json:"order_no"`
	PaymentConfigID uint64     `json:"payment_config_id"`
	Provider        string     `json:"provider"`
	ThirdOrderID    string     `json:"third_order_id"`
	ProviderOrderID string     `json:"provider_order_id"`
	PayWay          string     `json:"pay_way"`
	JSPayFlag       string     `json:"jspay_flag"`
	AmountCent      int64      `json:"amount_cent"`
	Status          string     `json:"status"`
	TDCode          string     `json:"td_code,omitempty"`
	JSPayURL        string     `json:"jspay_url,omitempty"`
	JSPayInfo       string     `json:"jspay_info,omitempty"`
	Paid            bool       `json:"paid"`
	PaidAt          *time.Time `json:"paid_at,omitempty"`
	CreatedAt       time.Time  `json:"created_at"`
	UpdatedAt       time.Time  `json:"updated_at"`
}

type RefundDTO struct {
	ID              uint64     `json:"id"`
	PaymentNo       string     `json:"payment_no"`
	OrderID         uint64     `json:"order_id"`
	OrderNo         string     `json:"order_no"`
	BizType         string     `json:"biz_type"`
	AmountCent      int64      `json:"amount_cent"`
	Status          string     `json:"status"`
	ProviderOrderID string     `json:"provider_order_id,omitempty"`
	PaidAt          *time.Time `json:"paid_at,omitempty"`
	CreatedAt       time.Time  `json:"created_at"`
	UpdatedAt       time.Time  `json:"updated_at"`
}

type NotifyResult struct {
	OK      bool
	Message string
}

type AdminPaymentQuery struct {
	UserID   uint64
	OrderID  uint64
	OrderNo  string
	BizType  string
	Status   string
	Provider string
	Page     int
	PageSize int
}

type PaginatedResult struct {
	Items    interface{} `json:"items"`
	Total    int64       `json:"total"`
	Page     int         `json:"page"`
	PageSize int         `json:"page_size"`
}

type AdminPaymentDTO struct {
	ID              uint64         `json:"id"`
	PaymentNo       string         `json:"payment_no"`
	OrderID         uint64         `json:"order_id"`
	OrderNo         string         `json:"order_no"`
	UserID          uint64         `json:"user_id"`
	PaymentConfigID uint64         `json:"payment_config_id"`
	UserPhone       string         `json:"user_phone"`
	Provider        string         `json:"provider"`
	MerchantID      string         `json:"merchant_id"`
	ThirdOrderID    string         `json:"third_order_id"`
	ProviderOrderID string         `json:"provider_order_id"`
	PayWay          string         `json:"pay_way"`
	AmountCent      int64          `json:"amount_cent"`
	BizType         string         `json:"biz_type"`
	Status          string         `json:"status"`
	ErrorCode       string         `json:"error_code"`
	ErrorMessage    string         `json:"error_message"`
	RawRequest      datatypes.JSON `json:"raw_request"`
	RawResponse     datatypes.JSON `json:"raw_response"`
	PaidAt          *time.Time     `json:"paid_at,omitempty"`
	NotifiedAt      *time.Time     `json:"notified_at,omitempty"`
	CreatedAt       time.Time      `json:"created_at"`
	UpdatedAt       time.Time      `json:"updated_at"`
}
