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
eee32aab
Commit
eee32aab
authored
Jan 23, 2019
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
7c308c64
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
60 deletions
+59
-60
local_order.go
plugin/dapp/trade/executor/local_order.go
+4
-4
local_order_test.go
plugin/dapp/trade/executor/local_order_test.go
+39
-39
query.go
plugin/dapp/trade/executor/query.go
+16
-17
trade.pb.go
plugin/dapp/trade/types/trade.pb.go
+0
-0
No files found.
plugin/dapp/trade/executor/local_order.go
View file @
eee32aab
...
...
@@ -5,8 +5,8 @@
package
executor
import
(
"fmt"
"encoding/hex"
"fmt"
"strconv"
"github.com/33cn/chain33/common"
...
...
@@ -54,7 +54,7 @@ var opt_order_table = &table.Option{
"owner_isSell"
,
// 接口 6
// "owner_isSell_status", 可能需求, 界面分开显示订单
// "owner_isSell_statusPrefix", // 状态可以定制组合, 成交历史需求
"owner_status"
,
// 接口 2
"owner_status"
,
// 接口 2
"assset_isSell_isFinished"
,
// 用 isFinish, 进行订单是否完成的列表功能
"owner_asset_isFinished"
,
"owner_isFinished"
,
...
...
@@ -146,7 +146,7 @@ func (r *OrderRow) isFinished() int {
// 进行中, 撤销, 部分成交 , 全部成交, 完成状态统一前缀. 数字和原来不一样
// 01 10 11 12 19 -> 1*
func
(
r
*
OrderRow
)
status
()
string
{
if
r
.
Status
==
pty
.
TradeOrderStatusOnBuy
||
r
.
Status
==
pty
.
TradeOrderStatusOnSale
{
if
r
.
Status
==
pty
.
TradeOrderStatusOnBuy
||
r
.
Status
==
pty
.
TradeOrderStatusOnSale
{
return
"01"
// 试图用1 可以匹配所有完成的
}
else
if
r
.
Status
==
pty
.
TradeOrderStatusSoldOut
||
r
.
Status
==
pty
.
TradeOrderStatusBoughtOut
{
return
"12"
...
...
@@ -291,7 +291,7 @@ func (t *trade) genSellMarket(tx *types.Transaction, sell *pty.ReceiptSellBase,
IsSellOrder
:
true
,
AssetExec
:
sell
.
AssetExec
,
IsFinished
:
true
,
IsFinished
:
true
,
}
return
order
}
...
...
plugin/dapp/trade/executor/local_order_test.go
View file @
eee32aab
package
executor
import
(
pty
"github.com/33cn/plugin/plugin/dapp/trade/types"
"github.com/33cn/chain33/system/dapp"
"testing"
"github.com/33cn/chain33/system/dapp"
pty
"github.com/33cn/plugin/plugin/dapp/trade/types"
//"github.com/33cn/chain33/common/db"
//"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/util"
...
...
@@ -11,48 +12,47 @@ import (
)
var
order1
=
&
pty
.
LocalOrder
{
AssetSymbol
:
"A"
,
Owner
:
"O1"
,
AmountPerBoardlot
:
1
,
MinBoardlot
:
1
,
PricePerBoardlot
:
1
,
TotalBoardlot
:
10
,
TradedBoardlot
:
0
,
BuyID
:
"B1"
,
Status
:
pty
.
TradeOrderStatusOnBuy
,
SellID
:
""
,
TxHash
:
nil
,
Height
:
1
,
Key
:
"B1"
,
BlockTime
:
1
,
IsSellOrder
:
false
,
AssetExec
:
"a"
,
TxIndex
:
dapp
.
HeightIndexStr
(
1
,
1
),
IsFinished
:
false
,
AssetSymbol
:
"A"
,
Owner
:
"O1"
,
AmountPerBoardlot
:
1
,
MinBoardlot
:
1
,
PricePerBoardlot
:
1
,
TotalBoardlot
:
10
,
TradedBoardlot
:
0
,
BuyID
:
"B1"
,
Status
:
pty
.
TradeOrderStatusOnBuy
,
SellID
:
""
,
TxHash
:
nil
,
Height
:
1
,
Key
:
"B1"
,
BlockTime
:
1
,
IsSellOrder
:
false
,
AssetExec
:
"a"
,
TxIndex
:
dapp
.
HeightIndexStr
(
1
,
1
),
IsFinished
:
false
,
}
var
order2
=
&
pty
.
LocalOrder
{
AssetSymbol
:
"A"
,
Owner
:
"O1"
,
AmountPerBoardlot
:
1
,
MinBoardlot
:
1
,
PricePerBoardlot
:
1
,
TotalBoardlot
:
10
,
TradedBoardlot
:
0
,
BuyID
:
"B2"
,
Status
:
pty
.
TradeOrderStatusOnBuy
,
SellID
:
""
,
TxHash
:
nil
,
Height
:
2
,
Key
:
"B2"
,
BlockTime
:
2
,
IsSellOrder
:
false
,
AssetExec
:
"a"
,
TxIndex
:
dapp
.
HeightIndexStr
(
2
,
1
),
IsFinished
:
false
,
AssetSymbol
:
"A"
,
Owner
:
"O1"
,
AmountPerBoardlot
:
1
,
MinBoardlot
:
1
,
PricePerBoardlot
:
1
,
TotalBoardlot
:
10
,
TradedBoardlot
:
0
,
BuyID
:
"B2"
,
Status
:
pty
.
TradeOrderStatusOnBuy
,
SellID
:
""
,
TxHash
:
nil
,
Height
:
2
,
Key
:
"B2"
,
BlockTime
:
2
,
IsSellOrder
:
false
,
AssetExec
:
"a"
,
TxIndex
:
dapp
.
HeightIndexStr
(
2
,
1
),
IsFinished
:
false
,
}
func
TestListAll
(
t
*
testing
.
T
)
{
dir
,
ldb
,
tdb
:=
util
.
CreateTestDB
()
t
.
Log
(
dir
,
ldb
,
tdb
)
...
...
plugin/dapp/trade/executor/query.go
View file @
eee32aab
...
...
@@ -662,7 +662,6 @@ func (t *trade) GetOnesOrderWithStatusV1(req *pty.ReqAddrAssets) (types.Message,
return
nil
,
types
.
ErrInvalidParam
}
keys
,
err
:=
t
.
GetLocalDB
()
.
List
(
calcOnesOrderPrefixStatus
(
req
.
Addr
,
orderStatus
),
fromKey
,
req
.
Count
,
req
.
Direction
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -717,22 +716,22 @@ func (t *trade) GetOnesOrderWithStatus(req *pty.ReqAddrAssets) (types.Message, e
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
,
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
,
}
}
...
...
plugin/dapp/trade/types/trade.pb.go
View file @
eee32aab
This diff is collapsed.
Click to expand it.
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