model

package
v0.0.0-...-54421ad Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2019 License: BSD-3-Clause Imports: 3 Imported by: 8

Documentation

Index

Constants

View Source
const (
	//  待完成
	ORDER_STATUS_TBD = iota
	//  完成
	ORDER_STATUS_FINISH
	//  撤销
	ORDER_STATUS_REVOKE
)

订单状态

View Source
const (
	TRADE_TYPE_NONE = iota
	TRADE_TYPE_BUY
	TRADE_TYPE_SALE
)

交易类型

Variables

This section is empty.

Functions

This section is empty.

Types

type Tb_order

type Tb_order struct {
	gorm.Model
	User_id int `gorm:"not null"`

	Stock_name  string  `grom:"type:varchar(16); not null"`
	Stock_code  string  `grom:"type:varchar(16); not null"`
	Stock_price float64 `gorm:"type:decimal(12,2); not null"`
	Stock_count int     `grom:"default:0;"`

	Transfer_fee float64 `grom:"type:decimal(12,2);default:0.0"` //  交易 过户费
	Brokerage    float64 `gorm:"type:decimal(12,2);default:0.0"` // 佣金
	// 冻结金额: 买入:存放冻结金额,  卖出此值为0
	Freeze_amount float64 `gorm:"default:0"`

	// 交易类型:  0买入   1 卖出
	Trade_type int `grom:"not null"`
	// 交易类型: 文字描述; eg 买入, 卖出
	Trade_type_desc string `gorm:"type:varchar(32); not null"`

	// 订单状态
	Order_status int `gorm:"default:0;"`

	// 比赛id: 默认非比赛情况
	Contest_id int `gorm:"default:0"`
}

用户的订单表,每次下单生成该记录, 当订单部分成交时,不更改表记录 完成时更改记录状态: 待成交, 已完成, 已撤单

type Tb_order_real

type Tb_order_real struct {
	gorm.Model
	Order_id    int     `gorm:"not null"` // 外键引用: order 表
	User_id     int     `gorm:"not null"`
	Stock_name  string  `grom:"type:varchar(16); not null"`
	Stock_code  string  `grom:"type:varchar(16); not null"`
	Stock_price float64 `gorm:"type:decimal(12,2); not null"`
	Stock_count int     `grom:"default:0;"`
	// 冻结金额: 买入:存放冻结金额,  卖出此值为0
	Freeze_amount float64 `gorm:"default:0"`

	// 交易类型:  0买入   1 卖出
	Trade_type int `grom:"not null"`
	// 交易类型: 文字描述; eg 买入, 卖出
	Trade_type_desc string `gorm:"type:varchar(32); not null"`

	// 订单状态
	Order_status int `gorm:"default:0;"`

	// 比赛id: 默认非比赛情况
	Contest_id int `gorm:"default:0"`
}

用户的订单表,每次下单生成该记录, 当订单部分成交时,更改记录,修改剩余股数量 完成时更改记录状态: 待成交, 已完成, 已撤单

type Tb_stock_trend

type Tb_stock_trend struct {
	gorm.Model
	//  用户的当前 市值
	Day        time.Time `gorm:"type:date; not null"`
	Price      float64   `gorm:"type:decimal(12,3);default 0"`
	Stock_code string    `gorm:"type:varchar(16);"`
}

股价日走势图

type Tb_tick_data

type Tb_tick_data struct {
	gorm.Model
	Tick_time  time.Time `json:"tick_time"`
	Tick_code  string    `json:"tick_code"`
	Tick_count int       `json:"tick_count"`
	Tick_price float64   `json:"tick_price"`
	Tick_Type  string    `json:"tick_type"` // 交易类型: 买盘, 卖盘, 中性盘
}

type Tb_trade_detail

type Tb_trade_detail struct {
	gorm.Model
	Order_id    int     `gorm:"not null"`
	User_id     int     `gorm:"not null"`
	Stock_name  string  `grom:"type:varchar(16); not null"`
	Stock_code  string  `grom:"type:varchar(16); not null"`
	Stock_price float64 `gorm:"type:decimal(12,2); not null"`
	Stock_count int     `grom:"default:0;"`
	Trade_type  int     `gorm:"default:0;"`

	Stamp_tax float64 `gorm:"type:decimal(12,2);default:0.0"` // 印花税
	// 比赛id: 默认非比赛情况
	Contest_id int `gorm:"default:0"`
}

成交历史:在这里记录每笔成交的记录。

每个订单可能产生多个 成交记录

type Tb_user_assets

type Tb_user_assets struct {
	gorm.Model
	User_id int `gorm:"not null; unique_index"`
	// 用户的可用资金
	User_money float64 `gorm:"type:decimal(12,3);default 0"`
	//  用户的当前 市值
	User_mv float64 `gorm:"type:decimal(12,3);default 0"`
}

用户账户表, 不存其他的业务数据, 关联 业务用户userid 本表只存储本系统中用到的数据

type Tb_user_assets_trend

type Tb_user_assets_trend struct {
	gorm.Model
	Day     time.Time `gorm:"type:date; not null"`
	User_id int       `gorm:"not null;"`
	//  用户的当前 市值
	User_mv float64 `gorm:"type:decimal(12,3);default 0"`
}

用户资产走势图

type Tb_user_contest_position

type Tb_user_contest_position struct {
	gorm.Model
	User_id    int    `gorm:"not null"`
	Stock_name string `grom:"type:varchar(16); not null"`
	Stock_code string `grom:"type:varchar(16); not null"`
	// 持有?股
	Stock_count int `grom:"default:0;"`
	// 持倉價
	Stock_price float64 `gorm:"type:decimal(12,2); not null"`

	// T+1 本股可卖部分, 当前交易日卖的股票本交易日不能出售
	Stock_count_can_sale int `grom:"default 0"`
	// 比赛id: 默认非比赛情况
	Contest_id int `gorm:"default:0"`
}

用户的 持股表 每个用户的每支股票对一个一条记录, 买卖时修改记录

type Tb_user_position

type Tb_user_position struct {
	gorm.Model
	User_id    int    `gorm:"not null"`
	Stock_name string `grom:"type:varchar(16); not null"`
	Stock_code string `grom:"type:varchar(16); not null"`
	// 持有?股
	Stock_count int `grom:"default:0;"`
	// 持倉價
	Stock_price float64 `gorm:"type:decimal(12,2); not null"`

	// T+1 本股可卖部分, 当前交易日卖的股票本交易日不能出售
	Stock_count_can_sale int `grom:"default 0"`
}

用户的 持股表 每个用户的每支股票对一个一条记录, 买卖时修改记录

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL