package models

import (
	"time"

	"go-admin/common/models"

	"github.com/shopspring/decimal"
)

type LineReverseOrder struct {
	models.Model

	ApiId    int `json:"apiId" gorm:"type:bigint;comment:api id"`
	Category int `json:"category" gorm:"type:tinyint;comment:分类 0-原始订单 1-反单"`

	OrderSn       string          `json:"orderSn" gorm:"type:varchar(50);comment:订单号 0-主单 1-止盈 2-止损"`
	OrderId       string          `json:"orderId" gorm:"type:varchar(50);comment:币安订单号"`
	FollowOrderSn string          `json:"followOrderSn" gorm:"type:varchar(50);comment:跟随币安订单号"`
	Symbol        string          `json:"symbol" gorm:"type:varchar(20);comment:交易对"`
	Type          string          `json:"type" gorm:"type:varchar(20);comment:交易类型"`
	OrderType     int             `json:"orderType" gorm:"type:tinyint;comment:订单类型 0-主单 1-止盈  2-止损 3-减仓单 4-平仓单"`
	BuyPrice      decimal.Decimal `json:"buyPrice" gorm:"type:decimal(18,8);comment:购买金额"`
	Price         decimal.Decimal `json:"price" gorm:"type:decimal(18,8);comment:委托价格"`
	TotalNum      decimal.Decimal `json:"totalNum" gorm:"type:decimal(18,8);comment:总成交数量"`
	PriceU        decimal.Decimal `json:"priceU" gorm:"type:decimal(18,8);comment:委托价格(U)"`
	FinalPrice    decimal.Decimal `json:"finalPrice" gorm:"type:decimal(18,8);comment:实际成交价"`
	PositionSide  string          `json:"positionSide" gorm:"type:varchar(10);comment:持仓方向 LONG-多 SHORT-空"`
	Side          string          `json:"side" gorm:"type:varchar(10);comment:买卖方向 SELL-卖 BUY-买"`
	SignPrice     decimal.Decimal `json:"signPrice" gorm:"type:decimal(18,8);comment:行情价"`
	TriggerTime   *time.Time      `json:"triggerTime" gorm:"type:datetime;comment:触发时间"`
	Status        int             `json:"status" gorm:"type:tinyint;comment:状态 1-待下单 2-已下单 3-已成交 6-已取消 7-已过期 8-已失败"`
	IsAddPosition int             `json:"isAddPosition" gorm:"type:tinyint;comment:是否增加仓位 1-否 2-是"`
	IsReduce      int             `json:"isReduce" gorm:"type:tinyint;comment:是否减少仓位 1-否 2-是"`
	Remark        string          `json:"remark" gorm:"type:varchar(255);comment:备注"`
	models.ModelTime
	models.ControlBy
}

func (LineReverseOrder) TableName() string {
	return "line_reverse_order"
}

func (e *LineReverseOrder) Generate() models.ActiveRecord {
	o := *e
	return &o
}

func (e *LineReverseOrder) GetId() interface{} {
	return e.Id
}
