增加百分比搜索
This commit is contained in:
		| @ -14,19 +14,21 @@ import ( | ||||
|  | ||||
| type LinePreOrderGetPageReq struct { | ||||
| 	dto.Pagination    `search:"-"` | ||||
| 	ExchangeType      string `json:"exchangeType" form:"exchangeType" search:"type:exact;column:exchange_type;table:line_pre_order" comment:"交易所类型 字典exchange_type"` | ||||
| 	SymbolType        int    `json:"symbolType" form:"symbolType" search:"type:exact;column:symbol_type;table:line_pre_order"` | ||||
| 	ApiId             string `form:"apiId"  search:"type:exact;column:api_id;table:line_pre_order" comment:"api用户"` | ||||
| 	Symbol            string `form:"symbol"  search:"type:exact;column:symbol;table:line_pre_order" comment:"交易对"` | ||||
| 	QuoteSymbol       string `form:"quoteSymbol"  search:"type:exact;column:quote_symbol;table:line_pre_order" comment:"计较货币"` | ||||
| 	SignPriceType     string `form:"signPriceType"  search:"type:exact;column:sign_price_type;table:line_pre_order" comment:"对标价类型: new=最新价格;tall=24小时最高;low=24小时最低;mixture=标记价;entrust=委托实价;add=补仓"` | ||||
| 	Rate              string `form:"rate"  search:"type:exact;column:rate;table:line_pre_order" comment:"下单百分比"` | ||||
| 	Site              string `form:"site"  search:"type:exact;column:site;table:line_pre_order" comment:"购买方向:BUY=买;SELL=卖"` | ||||
| 	OrderSn           string `form:"orderSn"  search:"type:exact;column:order_sn;table:line_pre_order" comment:"订单号"` | ||||
| 	Status            string `form:"status"  search:"type:exact;column:status;table:line_pre_order" comment:"是否被触发:0=待触发;1=已触发;2=下单失败;3=已记录;4=已取消;5=委托中;6=已平仓;7=已补单;8=补单失败;9=现货已成交;10=合约已补单;11=合约补单失败;12=合约已成交;13=已开仓"` | ||||
| 	OrderType         string `form:"orderType"  search:"type:exact;column:order_type;table:line_pre_order" comment:"订单类型:1=现货;2=合约;3=合约止盈;4=合约止损;5=现货止盈;6=现货止损;7=止损补仓;8=现货加仓;9=现货平仓;10 = 合约止损补仓,11=合约加仓;12=合约平仓"` | ||||
| 	AddPositionStatus int    `form:"addPositionStatus" search:"-"` | ||||
| 	HedgeStatus       int    `form:"hedgeStatus" search:"-"` | ||||
| 	ExchangeType      string   `json:"exchangeType" form:"exchangeType" search:"type:exact;column:exchange_type;table:line_pre_order" comment:"交易所类型 字典exchange_type"` | ||||
| 	SymbolType        int      `json:"symbolType" form:"symbolType" search:"type:exact;column:symbol_type;table:line_pre_order"` | ||||
| 	ApiId             string   `form:"apiId"  search:"type:exact;column:api_id;table:line_pre_order" comment:"api用户"` | ||||
| 	Symbol            string   `form:"symbol"  search:"type:exact;column:symbol;table:line_pre_order" comment:"交易对"` | ||||
| 	QuoteSymbol       string   `form:"quoteSymbol"  search:"type:exact;column:quote_symbol;table:line_pre_order" comment:"计较货币"` | ||||
| 	SignPriceType     string   `form:"signPriceType"  search:"type:exact;column:sign_price_type;table:line_pre_order" comment:"对标价类型: new=最新价格;tall=24小时最高;low=24小时最低;mixture=标记价;entrust=委托实价;add=补仓"` | ||||
| 	Rate              string   `form:"rate"  search:"type:exact;column:rate;table:line_pre_order" comment:"下单百分比"` | ||||
| 	Site              string   `form:"site"  search:"type:exact;column:site;table:line_pre_order" comment:"购买方向:BUY=买;SELL=卖"` | ||||
| 	OrderSn           string   `form:"orderSn"  search:"type:exact;column:order_sn;table:line_pre_order" comment:"订单号"` | ||||
| 	Status            string   `form:"status"  search:"type:exact;column:status;table:line_pre_order" comment:"是否被触发:0=待触发;1=已触发;2=下单失败;3=已记录;4=已取消;5=委托中;6=已平仓;7=已补单;8=补单失败;9=现货已成交;10=合约已补单;11=合约补单失败;12=合约已成交;13=已开仓"` | ||||
| 	OrderType         string   `form:"orderType"  search:"type:exact;column:order_type;table:line_pre_order" comment:"订单类型:1=现货;2=合约;3=合约止盈;4=合约止损;5=现货止盈;6=现货止损;7=止损补仓;8=现货加仓;9=现货平仓;10 = 合约止损补仓,11=合约加仓;12=合约平仓"` | ||||
| 	AddPositionStatus int      `form:"addPositionStatus" search:"-"` | ||||
| 	HedgeStatus       int      `form:"hedgeStatus" search:"-"` | ||||
| 	PercentStart      *float64 `form:"percentStart" search:"-"` | ||||
| 	PercentEnd        *float64 `form:"percentEnd" search:"-"` | ||||
| 	LinePreOrderOrder | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -39,12 +39,21 @@ type LinePreOrder struct { | ||||
| func (e *LinePreOrder) GetPage(c *dto.LinePreOrderGetPageReq, p *actions.DataPermission, list *[]models.LinePreOrder, count *int64) error { | ||||
| 	var err error | ||||
| 	var data models.LinePreOrder | ||||
| 	tx := e.Orm.Model(&data). | ||||
| 	query := e.Orm.Model(&data). | ||||
| 		Scopes( | ||||
| 			cDto.MakeCondition(c.GetNeedSearch()), | ||||
| 			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), | ||||
| 			actions.Permission(data.TableName(), p), | ||||
| 		).Where("pid = 0").Joins("JOIN line_api_user on line_api_user.id = line_pre_order.api_id"). | ||||
| 		).Where("pid = 0").Joins("JOIN line_api_user on line_api_user.id = line_pre_order.api_id") | ||||
|  | ||||
| 	if c.PercentStart != nil && *c.PercentStart > 0 { | ||||
| 		query.Where("rate >= ?", *c.PercentStart) | ||||
| 	} | ||||
| 	if c.PercentEnd != nil && *c.PercentEnd > 0 { | ||||
| 		query.Where("rate <= ?", *c.PercentEnd) | ||||
| 	} | ||||
|  | ||||
| 	tx := query. | ||||
| 		Joins("JOIN line_pre_order_status on line_pre_order_status.order_sn = line_pre_order.order_sn"). | ||||
| 		Select("line_pre_order.*,line_api_user.api_name,line_pre_order_status.add_position_status,line_pre_order_status.reduce_status") | ||||
| 	if c.AddPositionStatus >= 0 { | ||||
| @ -74,12 +83,21 @@ func (e *LinePreOrder) GetPage(c *dto.LinePreOrderGetPageReq, p *actions.DataPer | ||||
| func (e *LinePreOrder) GetOrderPage(c *dto.LinePreOrderGetPageReq, p *actions.DataPermission, list *[]models.LinePreOrder, count *int64) error { | ||||
| 	var err error | ||||
| 	var data models.LinePreOrder | ||||
| 	tx := e.Orm.Model(&data). | ||||
|  | ||||
| 	query := e.Orm.Model(&data). | ||||
| 		Scopes( | ||||
| 			cDto.MakeCondition(c.GetNeedSearch()), | ||||
| 			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), | ||||
| 			actions.Permission(data.TableName(), p), | ||||
| 		).Where("pid = 0 AND status != '0'").Joins("JOIN line_api_user on line_api_user.id = line_pre_order.api_id"). | ||||
| 		).Where("pid = 0 AND status != '0'").Joins("JOIN line_api_user on line_api_user.id = line_pre_order.api_id") | ||||
|  | ||||
| 	if c.PercentStart != nil && *c.PercentStart >= 0 { | ||||
| 		query.Where("rate >= ?", *c.PercentStart) | ||||
| 	} | ||||
| 	if c.PercentEnd != nil && *c.PercentEnd >= 0 { | ||||
| 		query.Where("rate <= ?", *c.PercentEnd) | ||||
| 	} | ||||
| 	tx := query. | ||||
| 		Joins("JOIN line_pre_order_status on line_pre_order_status.order_id = line_pre_order.id"). | ||||
| 		Select("line_pre_order.*,line_api_user.api_name,line_pre_order_status.add_position_status,line_pre_order_status.reduce_status") | ||||
| 	if c.AddPositionStatus >= 0 { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user