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
65ecd8f0
Commit
65ecd8f0
authored
Jan 17, 2019
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
impl GetOnesOrderWithStatus
parent
0a0af27a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
1 deletion
+58
-1
query.go
plugin/dapp/trade/executor/query.go
+58
-1
No files found.
plugin/dapp/trade/executor/query.go
View file @
65ecd8f0
...
...
@@ -641,7 +641,7 @@ func (t *trade) loadOrderFromKey(key []byte) *pty.ReplyTradeOrder {
return
txResult2OrderReply
(
txResult
)
}
func
(
t
*
trade
)
GetOnesOrderWithStatus
(
req
*
pty
.
ReqAddrAssets
)
(
types
.
Message
,
error
)
{
func
(
t
*
trade
)
GetOnesOrderWithStatus
V1
(
req
*
pty
.
ReqAddrAssets
)
(
types
.
Message
,
error
)
{
fromKey
:=
[]
byte
(
""
)
if
len
(
req
.
FromKey
)
!=
0
{
order
:=
t
.
loadOrderFromKey
([]
byte
(
req
.
FromKey
))
...
...
@@ -658,6 +658,7 @@ func (t *trade) GetOnesOrderWithStatus(req *pty.ReqAddrAssets) (types.Message, e
return
nil
,
types
.
ErrInvalidParam
}
keys
,
err
:=
t
.
GetLocalDB
()
.
List
(
calcOnesOrderPrefixStatus
(
req
.
Addr
,
orderStatus
),
fromKey
,
req
.
Count
,
req
.
Direction
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -674,3 +675,59 @@ func (t *trade) GetOnesOrderWithStatus(req *pty.ReqAddrAssets) (types.Message, e
}
return
&
replys
,
nil
}
func
(
t
*
trade
)
GetOnesOrderWithStatus
(
req
*
pty
.
ReqAddrAssets
)
(
types
.
Message
,
error
)
{
orderStatus
,
orderType
:=
fromStatus
(
req
.
Status
)
if
orderStatus
==
orderStatusInvalid
||
orderType
==
orderTypeInvalid
{
return
nil
,
types
.
ErrInvalidParam
}
// 使用 owner isFinished 组合
var
order
pty
.
LocalOrder
if
orderStatus
==
orderStatusOn
{
order
.
IsFinished
=
false
}
else
{
order
.
IsFinished
=
true
}
order
.
Owner
=
req
.
Addr
if
len
(
req
.
FromKey
)
>
0
{
order
.
TxIndex
=
req
.
FromKey
}
rows
,
err
:=
list
(
t
.
GetLocalDB
(),
"owner_isFinished"
,
&
order
,
req
.
Count
,
req
.
Direction
)
if
err
!=
nil
{
tradelog
.
Error
(
"GetOnesOrderWithStatus"
,
"err"
,
err
)
return
nil
,
err
}
var
replys
pty
.
ReplyTradeOrders
for
_
,
row
:=
range
rows
{
o
,
ok
:=
row
.
Data
.
(
*
pty
.
LocalOrder
)
if
!
ok
{
tradelog
.
Error
(
"GetOnesOrderWithStatus"
,
"err"
,
"bad row type"
)
return
nil
,
types
.
ErrTypeAsset
}
reply
:=
fmtReply
(
o
)
replys
.
Orders
=
append
(
replys
.
Orders
,
reply
)
}
return
&
replys
,
nil
}
func
fmtReply
(
order
*
pty
.
LocalOrder
)
*
pty
.
ReplyTradeOrder
{
return
&
pty
.
ReplyTradeOrder
{
TokenSymbol
:
order
.
AssetSymbol
,
Owner
:
order
.
Owner
,
AmountPerBoardlot
:
order
.
AmountPerBoardlot
,
MinBoardlot
:
order
.
MinBoardlot
,
PricePerBoardlot
:
order
.
PricePerBoardlot
,
TotalBoardlot
:
order
.
TotalBoardlot
,
TradedBoardlot
:
order
.
TradedBoardlot
,
BuyID
:
order
.
BuyID
,
Status
:
order
.
Status
,
SellID
:
order
.
SellID
,
TxHash
:
order
.
TxHash
[
0
],
Height
:
order
.
Height
,
Key
:
order
.
TxIndex
,
BlockTime
:
order
.
BlockTime
,
IsSellOrder
:
order
.
IsSellOrder
,
AssetExec
:
order
.
AssetExec
,
}
}
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