Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
f64e3c5e
Commit
f64e3c5e
authored
Jan 08, 2020
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
impl Query_GetTokenBuyOrderByStatus
parent
bd9c1bd3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
31 deletions
+13
-31
query_v1.go
plugin/dapp/trade/executor/query_v1.go
+13
-31
No files found.
plugin/dapp/trade/executor/query_v1.go
View file @
f64e3c5e
...
...
@@ -17,6 +17,10 @@ func (t *trade) Query_GetTokenSellOrderByStatus(req *pty.ReqTokenSellOrder) (typ
// GetTokenSellOrderByStatus by status
// sell & TokenSymbol & status sort by price
func
(
t
*
trade
)
GetTokenSellOrderByStatus
(
req
*
pty
.
ReqTokenSellOrder
,
status
int32
)
(
types
.
Message
,
error
)
{
return
t
.
GetTokenOrderByStatus
(
true
,
req
,
status
)
}
func
(
t
*
trade
)
GetTokenOrderByStatus
(
isSell
bool
,
req
*
pty
.
ReqTokenSellOrder
,
status
int32
)
(
types
.
Message
,
error
)
{
if
req
.
Count
<=
0
||
(
req
.
Direction
!=
1
&&
req
.
Direction
!=
0
)
{
return
nil
,
types
.
ErrInvalidParam
}
...
...
@@ -31,7 +35,7 @@ func (t *trade) GetTokenSellOrderByStatus(req *pty.ReqTokenSellOrder, status int
order
.
PriceSymbol
=
t
.
GetAPI
()
.
GetConfig
()
.
GetCoinSymbol
()
order
.
PriceExec
=
defaultAssetExec
order
.
IsSellOrder
=
true
order
.
IsSellOrder
=
isSell
order
.
Status
=
req
.
Status
...
...
@@ -66,38 +70,16 @@ func (t *trade) Query_GetTokenBuyOrderByStatus(req *pty.ReqTokenBuyOrder) (types
// GetTokenBuyOrderByStatus by status
// buy & TokenSymbol & status buy sort by price
func
(
t
*
trade
)
GetTokenBuyOrderByStatus
(
req
*
pty
.
ReqTokenBuyOrder
,
status
int32
)
(
types
.
Message
,
error
)
{
if
req
.
Count
<=
0
||
(
req
.
Direction
!=
1
&&
req
.
Direction
!=
0
)
{
return
nil
,
types
.
ErrInvalidParam
}
fromKey
:=
[]
byte
(
""
)
if
len
(
req
.
FromKey
)
!=
0
{
buy
:=
t
.
replyReplyBuyOrderfromID
([]
byte
(
req
.
FromKey
))
if
buy
==
nil
{
tradelog
.
Error
(
"GetTokenBuyOrderByStatus"
,
"key not exist"
,
req
.
FromKey
)
return
nil
,
types
.
ErrInvalidParam
}
fromKey
=
calcTokensBuyOrderKeyStatus
(
buy
.
TokenSymbol
,
buy
.
Status
,
calcPriceOfToken
(
buy
.
PricePerBoardlot
,
buy
.
AmountPerBoardlot
),
buy
.
Owner
,
buy
.
Key
)
}
tradelog
.
Debug
(
"GetTokenBuyOrderByStatus"
,
"fromKey "
,
fromKey
)
// List Direction 是升序, 买单是要降序, 把高价买的放前面, 在下一页操作时, 显示买价低的。
direction
:=
1
-
req
.
Direction
values
,
err
:=
t
.
GetLocalDB
()
.
List
(
calcTokensBuyOrderPrefixStatus
(
req
.
TokenSymbol
,
status
),
fromKey
,
req
.
Count
,
direction
)
if
err
!=
nil
{
return
nil
,
err
}
var
replys
pty
.
ReplyTradeOrders
for
_
,
key
:=
range
values
{
reply
:=
t
.
loadOrderFromKey
(
key
)
if
reply
==
nil
{
continue
}
tradelog
.
Debug
(
"trade Query"
,
"getSellOrderFromID"
,
string
(
key
))
replys
.
Orders
=
append
(
replys
.
Orders
,
reply
)
}
return
&
replys
,
nil
req2
:=
pty
.
ReqTokenSellOrder
{
TokenSymbol
:
req
.
TokenSymbol
,
FromKey
:
req
.
FromKey
,
Count
:
req
.
Count
,
Direction
:
direction
,
Status
:
req
.
Status
,
}
return
t
.
GetTokenOrderByStatus
(
false
,
&
req2
,
status
)
}
// addr part
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment