package models

import (
	"time"
)

// Deal vts_deal 成交记录表
type Deal struct {
	ID             int       `db:"id"`
	UserID         int       `db:"userid"`
	CurrencyID     int       `db:"currencyid"`  //
	CoinID         int       `db:"coinid"`      //
	OrderType      int       `db:"ordertype"`   //订单类型：1限价，2限价止盈止损，3市价
	BuyType        int       `db:"buytype"`     //买卖类型：1买，2卖
	IsTrigger      int       `db:"istrigger"`   //是否触发撮合-是：1，否：2
	MatchID        int64     `db:"matchid"`     //撮合id
	OrderNO        int64     `db:"orderno"`     //订单号
	CreateDateInt  int64     `db:"-"`           //成交日期
	EntrustDateInt int64     `db:"-"`           //委托时间
	DealNO         string    `db:"dealno"`      //成交单号
	Price          float64   `db:"price"`       //成交价格
	Num            float64   `db:"num"`         //成交数量
	Poundage       float64   `db:"poundage"`    //手续费
	TotalAmt       float64   `db:"totalamt"`    //总金额
	SurAmt         float64   `db:"suramt"`      //剩余金额
	BuyInPrice     float64   `db:"buyinprice"`  //买卖方原始价格
	FreezeAmt      float64   `db:"freezeamt"`   //
	CreateDate     time.Time `db:"createdate"`  //成交日期
	EntrustDate    time.Time `db:"entrustdate"` //委托时间
}

// DealStatistics vts_dealstatistics 成交量和最新最大最小价格统计
type DealStatistics struct {
	ID         int     `db:"id"`
	CurrencyID int     `db:"currencyid"`
	CoinID     int     `db:"coinid"`
	NewPrice   float64 `db:"newprice"`  //最新价格
	HighPrice  float64 `db:"highprice"` //24小时最高价
	LowPrice   float64 `db:"lowprice"`  //24小时最小价格
	DealNum    float64 `db:"dealnum"`   //24小时成交量
	DealAmt    float64 `db:"dealamt"`   //24小时成交金额
	OpenPrice  float64 `db:"openprice"` //开盘价
	Rate       float64 `db:"rate"`      //涨幅--未乘百分比
	Change     float64 `db:"-"`
	DealDate   int64   `db:"-"`
}

// DealKLine 发送k线消息队列实体
type DealKLine struct {
	CurrencyID    int
	CoinID        int
	IsTrigger     int   //是否触发撮合-是：1，否：2
	CreateDateInt int64 //成交日期
	Price         float64
	Num           float64 //成交数量
	TotalAmt      float64 //总金额
	Poundage      float64
	CreateDate    time.Time //成交日期
}

// KLine vts_kline model
type KLine struct {
	CurrencyID int       `db:"currencyid"`
	CoinID     int       `db:"coinid"`
	KlineType  int       `db:"klinetype"` //kline类型：对应 KlineTypeMap的值
	Opened     float64   `db:"opened"`    //开盘
	Highest    float64   `db:"highest"`   //最高
	Lowest     float64   `db:"lowest"`    //最低
	Closed     float64   `db:"closed"`    //收盘
	DNum       float64   `db:"dnum"`      //成交
	DAmt       float64   `db:"damt"`      //金额
	DealDate   time.Time `db:"dealdate"`  //时间
	IsUpdate   bool      `db:"-"`
}

//KlineType  int       `db:"klinetype"` //kline类型：1--分时线,2--1分线,3--5分线,4--15分线,5--30分线,6--60分线,7--日线,8--周线,9--月线线,10--交易行情
//KlineType  string    `db:"klinetype"` //kline类型：1--分时线,2--1分线,3--5分线,4--15分线,5--30分线,6--60分线,7--日线,8--周线,9--月线线,10--交易行情

type DbDealDataSend struct {
	Deals []Deal
}

type BalanceUpdate struct {
	Event string `json:"e"`    //
	Data  int    `json:"data"` //
}

type ErrCode struct {
	Event string `json:"e"`    //错误的订阅
	Data  string `json:"data"` //
}

// BuySellFive set five item
type BuySellFive struct {
	Price float64
	Num   float64
}

// DealDay 行情成交记录表 vts_dealday
type DealDay struct {
	ID         int       `db:"id"`
	CurrencyID int       `db:"currencyid"` //
	CoinID     int       `db:"coinid"`     //
	IsTrigger  int       `db:"istrigger"`  //是否触发撮合-是：1，否：2
	Price      float64   `db:"price"`      //成交价格
	Num        float64   `db:"num"`        //成交数量
	CreateDate time.Time `db:"createdate"` //成交日期
}

// PushNewDealNew Push new deal to redis
type PushNewDealNew struct {
	Type   int        `json:"type"`
	Symbol string     `json:"symbol"` //交易对，比如BTC-USDT
	Data   [][]string `json:"data"`
}

type PushNewDealNewStr struct {
	Type   int      `json:"type"`
	Symbol string   `json:"symbol"` //交易对，比如BTC-USDT
	Data   []string `json:"data"`
}
