Commit a5d577e2 authored by harrylee's avatar harrylee Committed by vipwzw

fix a bug

parent d7fe5d7c
...@@ -595,17 +595,20 @@ func QueryHistoryOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey str ...@@ -595,17 +595,20 @@ func QueryHistoryOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey str
} }
var rows []*tab.Row var rows []*tab.Row
var err error var err error
var orderList et.OrderList
HERE:
if primaryKey == "" { //第一次查询,默认展示最新得成交记录 if primaryKey == "" { //第一次查询,默认展示最新得成交记录
rows, err = table.ListIndex(indexName, prefix, nil, count, direction) rows, err = table.ListIndex(indexName, prefix, nil, count, direction)
} else { } else {
rows, err = table.ListIndex(indexName, prefix, []byte(primaryKey), count, direction) rows, err = table.ListIndex(indexName, prefix, []byte(primaryKey), count, direction)
} }
if err != nil { if err != nil && err != types.ErrNotFound {
elog.Error("QueryCompletedOrderList.", "left", left, "right", right, "err", err.Error()) elog.Error("QueryCompletedOrderList.", "left", left, "right", right, "err", err.Error())
return nil, err return nil, err
} }
if err == types.ErrNotFound {
var orderList et.OrderList return &orderList, nil
}
for _, row := range rows { for _, row := range rows {
order := row.Data.(*et.Order) order := row.Data.(*et.Order)
//因为这张表里面记录了 completed,revoked 两种状态的订单,所以需要过滤 //因为这张表里面记录了 completed,revoked 两种状态的订单,所以需要过滤
...@@ -615,10 +618,15 @@ func QueryHistoryOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey str ...@@ -615,10 +618,15 @@ func QueryHistoryOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey str
//替换已经成交得量 //替换已经成交得量
order.Executed = order.GetLimitOrder().Amount - order.Balance order.Executed = order.GetLimitOrder().Amount - order.Balance
orderList.List = append(orderList.List, order) orderList.List = append(orderList.List, order)
} if len(orderList.List) == int(count) {
//设置主键索引 //设置主键索引
if len(rows) == int(count) { orderList.PrimaryKey = string(row.Primary)
orderList.PrimaryKey = string(rows[len(rows)-1].Primary) return &orderList, nil
}
}
if len(orderList.List) == 0 && len(rows) == int(count) {
primaryKey = string(rows[len(rows)-1].Primary)
goto HERE
} }
return &orderList, nil return &orderList, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment