package model

import (
	"pure/global"
	"time"
)

type Order struct {
	global.MG_MODEL
	Platform    string     `gorm:"size:10" json:"platform"`             // 购买平台
	StoreNo     string     `gorm:"size:60" json:"store_no"`             // 店铺编号
	OrderID     string     `gorm:"size:50;index" json:"orderID"`        //订单号
	PaypalID    string     `gorm:"size:50" json:"paypalID"`             //paypal订单号
	CaptureID   string     `gorm:"size:50" json:"captureID"`            //paypal收款确认id
	Code        string     `gorm:"size:20" json:"code"`                 //网红码?
	UserID      string     `gorm:"size:50;index" json:"userID"`         //用户id
	CommodID    uint       `gorm:"size:50;index" json:"commodID"`       //商品id
	SkuNo       string     `gorm:"type:varchar(60);" json:"sku_no"`     //商品规格编号
	SkuID       int        `gorm:"type:int(10);" json:"sku_id"`         //商品规格编号
	Type        int        `gorm:"type:int(1);default:1" json:"type"`   //类型 1-普通订单 2-预售订单
	Price       float64    `gorm:"type:decimal(10,2)" json:"price"`     //商品价格
	Number      int        `gorm:"type:int(10)" json:"number"`          //数量
	PaidPrice   float64    `gorm:"type:decimal(10,2)" json:"paidPrice"` //实付价格
	Status      int        `gorm:"type:int(1)" json:"status"`           //订单状态 //订单状态 1-待付款 2-待发货 3-已发货 4-已完成 5-已取消
	PayTime     *time.Time `gorm:"" json:"payTime"`                     //付款时间
	SendTime    *time.Time `gorm:"" json:"sendTime"`                    //发货时间
	ConfirmTime *time.Time `gorm:"" json:"confirmTime"`                 //收货时间
}

type OrderList struct {
	Order
	Goods            OrderGoodsDetail `json:"goods"`            // 商品信息
	User             UserSimple       `gorm:"-" json:"user"`    //买家信息
	InfluencerAmount string           `gorm:"-" json:"IAmount"` //网红佣金
}

type OrderDetail struct {
	Order
	Goods            OrderGoodsDetail `gorm:"-" json:"goods"`    // 商品信息
	Address          OrderAddress     `gorm:"-" json:"address"`  //地址
	Deliver          OrderDeliver     `gorm:"-" json:"deliver"`  //发货信息
	Store            SellerStoreInfo  `gorm:"-" json:"store"`    // 店铺信息
	PostSale         PostSale         `gorm:"-" json:"postSale"` // 售后信息
	Bill             BillView         `gorm:"-" json:"bill"`     // 交易信息
	Chain            Chain            `gorm:"-" json:"chain"`    // 区块链
	InfluencerAmount string           `gorm:"-" json:"IAmount"`  //网红佣金
}

type OrderTotal struct {
	Status2 int `json:"status2"` //待发货
	Status3 int `json:"status3"` //已发货
	Status4 int `json:"status4"` //已收货
}

type Chain struct {
	Address string `json:"address"` // 合约地址
}

func (Order) TableName() string {
	return "order"
}

func (OrderList) TableName() string {
	return "order"
}

func (OrderDetail) TableName() string {
	return "order"
}