package model

import (
	"time"

	"gorm.io/datatypes"
)

type PaymentOrder struct {
	ID              uint64         `gorm:"primaryKey" json:"id"`
	PaymentNo       string         `gorm:"size:64;not null;uniqueIndex" json:"payment_no"`
	OrderID         uint64         `gorm:"not null;index" json:"order_id"`
	OrderNo         string         `gorm:"size:64;not null;index" json:"order_no"`
	UserID          uint64         `gorm:"not null;index" json:"user_id"`
	Provider        string         `gorm:"size:32;not null" json:"provider"`
	MerchantID      string         `gorm:"size:32;not null;default:''" json:"merchant_id"`
	ThirdOrderID    string         `gorm:"size:64;not null;uniqueIndex" json:"third_order_id"`
	ProviderOrderID string         `gorm:"size:64;not null;default:'';index" json:"provider_order_id"`
	PayWay          string         `gorm:"size:16;not null;default:''" json:"pay_way"`
	JSPayFlag       string         `gorm:"column:jspay_flag;size:8;not null;default:''" json:"jspay_flag"`
	AmountCent      int64          `gorm:"not null;default:0" json:"amount_cent"`
	BizType         string         `gorm:"size:32;not null;default:'order_pay';index" json:"biz_type"`
	Status          string         `gorm:"size:32;not null;default:'created';index" json:"status"`
	TDCode          string         `gorm:"size:512;not null;default:''" json:"td_code"`
	JSPayURL        string         `gorm:"column:jspay_url;size:512;not null;default:''" json:"jspay_url"`
	JSPayInfo       string         `gorm:"column:jspay_info;type:text" json:"jspay_info"`
	RawRequest      datatypes.JSON `json:"raw_request"`
	RawResponse     datatypes.JSON `json:"raw_response"`
	PaidAt          *time.Time     `json:"paid_at"`
	NotifiedAt      *time.Time     `json:"notified_at"`
	CreatedAt       time.Time      `json:"created_at"`
	UpdatedAt       time.Time      `json:"updated_at"`
}

func (PaymentOrder) TableName() string {
	return "payment_orders"
}
