package model

type Order struct {
	ID                      int      `gorm:"primaryKey;column:id" json:"id"`
	UserID                  int      `gorm:"column:user_id" json:"user_id"`
	PlanID                  *int     `gorm:"column:plan_id" json:"plan_id"`
	PaymentID               *int     `gorm:"column:payment_id" json:"payment_id"`
	Period                  string   `gorm:"column:period" json:"period"`
	TradeNo                 string   `gorm:"column:trade_no" json:"trade_no"`
	TotalAmount             int64    `gorm:"column:total_amount" json:"total_amount"`
	HandlingAmount          *int64   `gorm:"column:handling_amount" json:"handling_amount"`
	BalanceAmount           *int64   `gorm:"column:balance_amount" json:"balance_amount"`
	RefundAmount            *int64   `gorm:"column:refund_amount" json:"refund_amount"`
	SurplusAmount           *int64   `gorm:"column:surplus_amount" json:"surplus_amount"`
	Type                    int      `gorm:"column:type" json:"type"`
	Status                  int      `gorm:"column:status" json:"status"`
	SurplusOrderIDs         *string  `gorm:"column:surplus_order_ids" json:"surplus_order_ids"`
	CouponID                *int     `gorm:"column:coupon_id" json:"coupon_id"`
	CreatedAt               int64    `gorm:"column:created_at" json:"created_at"`
	UpdatedAt               int64    `gorm:"column:updated_at" json:"updated_at"`
	CommissionStatus        *int     `gorm:"column:commission_status" json:"commission_status"`
	InviteUserID            *int     `gorm:"column:invite_user_id" json:"invite_user_id"`
	ActualCommissionBalance *int64   `gorm:"column:actual_commission_balance" json:"actual_commission_balance"`
	CommissionRate          *int     `gorm:"column:commission_rate" json:"commission_rate"`
	CommissionAutoCheck     *int     `gorm:"column:commission_auto_check" json:"commission_auto_check"`
	CommissionBalance       *int64   `gorm:"column:commission_balance" json:"commission_balance"`
	DiscountAmount          *int64   `gorm:"column:discount_amount" json:"discount_amount"`
	PaidAt                  *int64   `gorm:"column:paid_at" json:"paid_at"`
	CallbackNo              *string  `gorm:"column:callback_no" json:"callback_no"`
	Plan                    *Plan    `gorm:"foreignKey:PlanID" json:"plan,omitempty"`
	Payment                 *Payment `gorm:"foreignKey:PaymentID" json:"payment,omitempty"`
}

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