|
@@ -80,6 +80,8 @@ type QueryTradePositionRsp struct {
|
|
|
MarketAmount float64 `json:"marketamount"` // 市值
|
|
MarketAmount float64 `json:"marketamount"` // 市值
|
|
|
LastPrice float64 `json:"lastprice"` // 最新价
|
|
LastPrice float64 `json:"lastprice"` // 最新价
|
|
|
Tradeproperty int32 `json:"tradeproperty"` // 交易属性
|
|
Tradeproperty int32 `json:"tradeproperty"` // 交易属性
|
|
|
|
|
+ REFGOODSID int32 `json:"refgoodsid" xorm:"'REFGOODSID'"` // 参考商品ID
|
|
|
|
|
+ REFGOODSCODE string `json:"refgoodscode" xorm:"'REFGOODSCODE'"` // 参考商品代码
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// QueryTradePosition 持仓汇总查询(合约市场)
|
|
// QueryTradePosition 持仓汇总查询(合约市场)
|
|
@@ -127,15 +129,19 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
|
|
|
Marketid int32 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
|
|
Marketid int32 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
|
|
|
Trademode int32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
|
|
Trademode int32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
|
|
|
QTYDECIMALPLACE int32 `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
|
|
QTYDECIMALPLACE int32 `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
|
|
|
|
|
+ REFGOODSID int32 `json:"refgoodsid" xorm:"'REFGOODSID'"` // 参考商品ID
|
|
|
|
|
+ REFGOODSCODE string `json:"refgoodscode" xorm:"'REFGOODSCODE'"` // 参考商品代码
|
|
|
}
|
|
}
|
|
|
datas := make([]tradePosition, 0)
|
|
datas := make([]tradePosition, 0)
|
|
|
engine := db.GetEngine()
|
|
engine := db.GetEngine()
|
|
|
// ORACLE好像在JOIN里不支持别名功能(在XORM中)
|
|
// ORACLE好像在JOIN里不支持别名功能(在XORM中)
|
|
|
s := engine.Table("TRADEPOSITION").
|
|
s := engine.Table("TRADEPOSITION").
|
|
|
Join("LEFT", "GOODS", "TRADEPOSITION.GOODSID = GOODS.GOODSID").
|
|
Join("LEFT", "GOODS", "TRADEPOSITION.GOODSID = GOODS.GOODSID").
|
|
|
|
|
+ Join("LEFT", "GOODS G2", "GOODS.REFGOODSID = G2.GOODSID").
|
|
|
Join("LEFT", "MARKET", "GOODS.MARKETID = MARKET.MARKETID").
|
|
Join("LEFT", "MARKET", "GOODS.MARKETID = MARKET.MARKETID").
|
|
|
Join("LEFT", "ENUMDICITEM", "GOODS.GOODUNITID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'goodsunit'").
|
|
Join("LEFT", "ENUMDICITEM", "GOODS.GOODUNITID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'goodsunit'").
|
|
|
- Select("TRADEPOSITION.*, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.CURRENCYID, GOODS.GOODUNITID,GOODS.QTYDECIMALPLACE, ENUMDICITEM.ENUMDICNAME as GOODUNIT, GOODS.AGREEUNIT, GOODS.DECIMALPLACE, MARKET.MARKETID, MARKET.TRADEMODE").
|
|
|
|
|
|
|
+ Select("TRADEPOSITION.*, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.CURRENCYID, GOODS.GOODUNITID,GOODS.QTYDECIMALPLACE, G2.REFGOODSID, G2.REFGOODSCODE, " +
|
|
|
|
|
+ "ENUMDICITEM.ENUMDICNAME as GOODUNIT, GOODS.AGREEUNIT, GOODS.DECIMALPLACE, MARKET.MARKETID, MARKET.TRADEMODE").
|
|
|
Where(fmt.Sprintf(`TRADEPOSITION.ACCOUNTID in (%s)`, accIds))
|
|
Where(fmt.Sprintf(`TRADEPOSITION.ACCOUNTID in (%s)`, accIds))
|
|
|
if len(tradeModes) > 0 {
|
|
if len(tradeModes) > 0 {
|
|
|
s = s.And(fmt.Sprintf(`MARKET.TRADEMODE in (%s)`, tradeModes))
|
|
s = s.And(fmt.Sprintf(`MARKET.TRADEMODE in (%s)`, tradeModes))
|
|
@@ -193,6 +199,8 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
|
|
|
// json -> struct
|
|
// json -> struct
|
|
|
_ = json.Unmarshal(jsonBytes, &tradePosition)
|
|
_ = json.Unmarshal(jsonBytes, &tradePosition)
|
|
|
tradePosition.Tradeproperty = v.Tradeproperty
|
|
tradePosition.Tradeproperty = v.Tradeproperty
|
|
|
|
|
+ tradePosition.REFGOODSID = v.REFGOODSID
|
|
|
|
|
+ tradePosition.REFGOODSCODE = v.REFGOODSCODE
|
|
|
tradePosition.BuyOrSell = 0
|
|
tradePosition.BuyOrSell = 0
|
|
|
tradePosition.PositionQTY = c.CovertQty(v.Buypositionqty)
|
|
tradePosition.PositionQTY = c.CovertQty(v.Buypositionqty)
|
|
|
tradePosition.HolderAmount = v.Buyholderamount
|
|
tradePosition.HolderAmount = v.Buyholderamount
|
|
@@ -233,6 +241,8 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
|
|
|
// json -> struct
|
|
// json -> struct
|
|
|
_ = json.Unmarshal(jsonBytes, &tradePosition)
|
|
_ = json.Unmarshal(jsonBytes, &tradePosition)
|
|
|
tradePosition.Tradeproperty = v.Tradeproperty
|
|
tradePosition.Tradeproperty = v.Tradeproperty
|
|
|
|
|
+ tradePosition.REFGOODSID = v.REFGOODSID
|
|
|
|
|
+ tradePosition.REFGOODSCODE = v.REFGOODSCODE
|
|
|
tradePosition.BuyOrSell = 1
|
|
tradePosition.BuyOrSell = 1
|
|
|
tradePosition.PositionQTY = c.CovertQty(v.Sellpositionqty)
|
|
tradePosition.PositionQTY = c.CovertQty(v.Sellpositionqty)
|
|
|
tradePosition.HolderAmount = v.Sellholderamount
|
|
tradePosition.HolderAmount = v.Sellholderamount
|