Commit 7d5224b8 authored by linj's avatar linj

fix ; fmt

parent a92ce051
...@@ -8,11 +8,12 @@ import ( ...@@ -8,11 +8,12 @@ import (
"github.com/33cn/chain33/common/db/table" "github.com/33cn/chain33/common/db/table"
pty "github.com/33cn/plugin/plugin/dapp/trade/types" pty "github.com/33cn/plugin/plugin/dapp/trade/types"
"github.com/33cn/chain33/types"
"fmt" "fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common"
"strconv" "strconv"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
) )
/* /*
...@@ -31,8 +32,8 @@ import ( ...@@ -31,8 +32,8 @@ import (
*/ */
var opt_order_table = &table.Option{ var opt_order_table = &table.Option{
Prefix: "LODB_trade", Prefix: "LODB_trade",
Name: "order", Name: "order",
Primary: "txIndex", Primary: "txIndex",
// asset = asset_exec+asset_symbol // asset = asset_exec+asset_symbol
// //
...@@ -41,16 +42,16 @@ var opt_order_table = &table.Option{ ...@@ -41,16 +42,16 @@ var opt_order_table = &table.Option{
// 00 10 11 12 1* // 00 10 11 12 1*
// 排序过滤条件: 可以组合,status&isSell 和前缀冲突 // 排序过滤条件: 可以组合,status&isSell 和前缀冲突
Index: []string{ Index: []string{
"key", // 内部查询用 "key", // 内部查询用
"asset", // 按资产统计订单 "asset", // 按资产统计订单
"asset_isSell_status", // 接口 3 "asset_isSell_status", // 接口 3
// "asset_status", 可能需求, 用于资产的交易历史 // "asset_status", 可能需求, 用于资产的交易历史
// "asset_isSell", // "asset_isSell",
"owner", // 接口 1.1, 1.3 "owner", // 接口 1.1, 1.3
"owner_asset", // 接口 1.2, 1.4, 4, 7 "owner_asset", // 接口 1.2, 1.4, 4, 7
"owner_asset_isSell", // 接口 4 "owner_asset_isSell", // 接口 4
"owner_asset_status", // 新需求, 在 "owner_asset_status", // 新需求, 在
"owner_isSell", // 接口 6 "owner_isSell", // 接口 6
// "owner_isSell_status", 可能需求, 界面分开显示订单 // "owner_isSell_status", 可能需求, 界面分开显示订单
// "owner_isSell_statusPrefix", // 状态可以定制组合, 成交历史需求 // "owner_isSell_statusPrefix", // 状态可以定制组合, 成交历史需求
"owner_status", // 接口 2 "owner_status", // 接口 2
...@@ -58,7 +59,6 @@ var opt_order_table = &table.Option{ ...@@ -58,7 +59,6 @@ var opt_order_table = &table.Option{
}, },
} }
type OrderRow struct { type OrderRow struct {
*pty.LocalOrder *pty.LocalOrder
} }
...@@ -89,7 +89,7 @@ func (r *OrderRow) Get(key string) ([]byte, error) { ...@@ -89,7 +89,7 @@ func (r *OrderRow) Get(key string) ([]byte, error) {
case "asset": case "asset":
return []byte(fmt.Sprintf("%s", r.asset())), nil return []byte(fmt.Sprintf("%s", r.asset())), nil
case "asset_isSell_status": case "asset_isSell_status":
return []byte(fmt.Sprintf("%s_%d_", r.asset(), r.isSell(), r.status())), nil return []byte(fmt.Sprintf("%s_%d_%s", r.asset(), r.isSell(), r.status())), nil
case "owner": case "owner":
return []byte(fmt.Sprintf("%s", r.Owner)), nil return []byte(fmt.Sprintf("%s", r.Owner)), nil
case "owner_asset": case "owner_asset":
...@@ -151,23 +151,23 @@ func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase, ...@@ -151,23 +151,23 @@ func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase,
status = pty.TradeOrderStatusSellHalfRevoked status = pty.TradeOrderStatusSellHalfRevoked
} }
order := &pty.LocalOrder{ order := &pty.LocalOrder{
AssetSymbol: sellorder.TokenSymbol, AssetSymbol: sellorder.TokenSymbol,
Owner: sellorder.Address, Owner: sellorder.Address,
AmountPerBoardlot: sellorder.AmountPerBoardlot, AmountPerBoardlot: sellorder.AmountPerBoardlot,
MinBoardlot: sellorder.MinBoardlot, MinBoardlot: sellorder.MinBoardlot,
PricePerBoardlot: sellorder.PricePerBoardlot, PricePerBoardlot: sellorder.PricePerBoardlot,
TotalBoardlot: sellorder.TotalBoardlot, TotalBoardlot: sellorder.TotalBoardlot,
TradedBoardlot: sellorder.SoldBoardlot, TradedBoardlot: sellorder.SoldBoardlot,
BuyID: "", BuyID: "",
Status: status, Status: status,
SellID: sell.SellID, SellID: sell.SellID,
TxHash: []string{common.ToHex(tx.Hash())}, TxHash: []string{common.ToHex(tx.Hash())},
Height: sell.Height, Height: sell.Height,
Key: sell.SellID, Key: sell.SellID,
BlockTime: t.GetBlockTime(), BlockTime: t.GetBlockTime(),
IsSellOrder: true, IsSellOrder: true,
AssetExec: sellorder.AssetExec, AssetExec: sellorder.AssetExec,
TxIndex: txIndex, TxIndex: txIndex,
} }
return order return order
} }
...@@ -238,27 +238,26 @@ func parseOrderPriceFloat(s string) int64 { ...@@ -238,27 +238,26 @@ func parseOrderPriceFloat(s string) int64 {
return int64(x * float64(types.Coin)) return int64(x * float64(types.Coin))
} }
func (t *trade) genSellMarket(tx *types.Transaction, sell *pty.ReceiptSellBase, txIndex string) *pty.LocalOrder { func (t *trade) genSellMarket(tx *types.Transaction, sell *pty.ReceiptSellBase, txIndex string) *pty.LocalOrder {
order := &pty.LocalOrder{ order := &pty.LocalOrder{
AssetSymbol: sell.TokenSymbol, AssetSymbol: sell.TokenSymbol,
Owner: sell.Owner, Owner: sell.Owner,
AmountPerBoardlot: parseOrderAmountFloat(sell.AmountPerBoardlot), AmountPerBoardlot: parseOrderAmountFloat(sell.AmountPerBoardlot),
MinBoardlot: sell.MinBoardlot, MinBoardlot: sell.MinBoardlot,
PricePerBoardlot: parseOrderPriceFloat(sell.PricePerBoardlot), PricePerBoardlot: parseOrderPriceFloat(sell.PricePerBoardlot),
TotalBoardlot: sell.TotalBoardlot, TotalBoardlot: sell.TotalBoardlot,
TradedBoardlot: sell.SoldBoardlot, TradedBoardlot: sell.SoldBoardlot,
BuyID: sell.BuyID, BuyID: sell.BuyID,
Status: pty.TradeOrderStatusSoldOut, Status: pty.TradeOrderStatusSoldOut,
SellID: calcTokenSellID(common.Bytes2Hex(tx.Hash())), SellID: calcTokenSellID(common.Bytes2Hex(tx.Hash())),
TxHash: []string{common.ToHex(tx.Hash())}, TxHash: []string{common.ToHex(tx.Hash())},
Height: sell.Height, Height: sell.Height,
Key: calcTokenSellID(common.Bytes2Hex(tx.Hash())), Key: calcTokenSellID(common.Bytes2Hex(tx.Hash())),
BlockTime: t.GetBlockTime(), BlockTime: t.GetBlockTime(),
IsSellOrder: true, IsSellOrder: true,
AssetExec: sell.AssetExec, AssetExec: sell.AssetExec,
TxIndex: txIndex, TxIndex: txIndex,
} }
return order return order
} }
......
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