|
|
@@ -9,6 +9,7 @@ import (
|
|
|
"mtp2_if/global/e"
|
|
|
"mtp2_if/logger"
|
|
|
"mtp2_if/models"
|
|
|
+ "mtp2_if/mtpcache"
|
|
|
"mtp2_if/utils"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
|
@@ -239,6 +240,7 @@ type QueryTradeOrderDetailRsp struct {
|
|
|
Ordersrc int64 `json:"ordersrc" xorm:"'ORDERSRC'"` // 委托来源 - 1:客户端 2:管理端 3:风控服务 4:交割服务 5:交易服务 6:交易日结 7:商品强平 8:管理端商品退市强平 9:交易接口 10:交割服务商被动(受托竞价) 11:预埋触发
|
|
|
Clienttype int64 `json:"clienttype" xorm:"'CLIENTTYPE'"` // 客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江)
|
|
|
Operatorid int64 `json:"operatorid" xorm:"'OPERATORID'"` // 登录账号(LoginID)
|
|
|
+ GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 商品单位id
|
|
|
|
|
|
GoodsCode string `json:"goodscode" xorm:"GOODSCODE"` // 商品代码
|
|
|
GoodsName string `json:"goodsname" xorm:"GOODSNAME"` // 商品名称
|
|
|
@@ -246,6 +248,7 @@ type QueryTradeOrderDetailRsp struct {
|
|
|
QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 商品报价小数位
|
|
|
Marketname string `json:"marketname" xorm:"'MARKETNAME'"` // 市场名称
|
|
|
TradeMode int32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
|
|
|
Enableqty float64 `json:"enableqty" xorm:"ENABLEQTY"` // 可用数量 = 委托数量 - 成交数量 - 撤单数量
|
|
|
}
|
|
|
@@ -262,6 +265,7 @@ func (r *QueryTradeOrderDetailRsp) calc() {
|
|
|
fCovert(&r.Opentradeqty)
|
|
|
fCovert(&r.Closetradeqty)
|
|
|
fCovert(&r.Enableqty)
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
|
|
|
}
|
|
|
|
|
|
// QueryTradeOrderDetail 委托单查询请求(合约市场)
|
|
|
@@ -296,7 +300,7 @@ func QueryTradeOrderDetail(c *gin.Context) {
|
|
|
Join("LEFT", "MARKET", "MARKET.MARKETID = TRADE_ORDERDETAIL.MARKETID").
|
|
|
Select(`to_char(TRADE_ORDERDETAIL.ORDERID) as ORDERID, to_char(TRADE_ORDERDETAIL.PREORDERID) as PREORDERID, to_char(TRADE_ORDERDETAIL.CANCELORDERID) as CANCELORDERID, to_char(TRADE_ORDERDETAIL.RELATEDID) as RELATEDID,
|
|
|
TRADE_ORDERDETAIL.*, TRADE_ORDERDETAIL.ORDERQTY - TRADE_ORDERDETAIL.TRADEQTY - TRADE_ORDERDETAIL.CANCELQTY as ENABLEQTY,
|
|
|
- GOODS.GOODSCODE, GOODS.GOODSNAME,GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE, MARKET.MARKETNAME, MARKET.TRADEMODE`).
|
|
|
+ GOODS.GOODSCODE, GOODS.GOODSNAME,GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE,GOODS.GOODUNITID, MARKET.MARKETNAME, MARKET.TRADEMODE`).
|
|
|
Where(fmt.Sprintf(`TRADE_ORDERDETAIL.ORDERSRC != 10 and TRADE_ORDERDETAIL.ACCOUNTID in (%s)`, req.AccountID)).
|
|
|
Desc("TRADE_ORDERDETAIL.ORDERTIME")
|
|
|
if len(req.OrderStatus) > 0 {
|
|
|
@@ -341,8 +345,10 @@ type QueryHisTradeOrderDetailRsp struct {
|
|
|
GoodsName string `json:"goodsname" xorm:"GOODSNAME"` // 商品名称
|
|
|
DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
|
|
|
QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
|
|
|
+ GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 商品单位id
|
|
|
Marketname string `json:"marketname" xorm:"'MARKETNAME'"` // 市场名称
|
|
|
TradeMode int32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
}
|
|
|
|
|
|
func (r *QueryHisTradeOrderDetailRsp) calc() {
|
|
|
@@ -356,6 +362,7 @@ func (r *QueryHisTradeOrderDetailRsp) calc() {
|
|
|
fCovert(&r.Closeqty)
|
|
|
fCovert(&r.Opentradeqty)
|
|
|
fCovert(&r.Closetradeqty)
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
|
|
|
}
|
|
|
|
|
|
// QueryHisTradeOrderDetail 历史委托单查询请求(合约市场)
|
|
|
@@ -391,7 +398,7 @@ func QueryHisTradeOrderDetail(c *gin.Context) {
|
|
|
Join("LEFT", "MARKET", "MARKET.MARKETID = HIS_TRADE_ORDERDETAIL.MARKETID").
|
|
|
Select(`to_char(HIS_TRADE_ORDERDETAIL.ORDERID) as ORDERID, to_char(HIS_TRADE_ORDERDETAIL.PREORDERID) as PREORDERID, to_char(HIS_TRADE_ORDERDETAIL.CANCELORDERID) as CANCELORDERID, to_char(HIS_TRADE_ORDERDETAIL.RELATEDID) as RELATEDID,
|
|
|
HIS_TRADE_ORDERDETAIL.*,
|
|
|
- GOODS.GOODSCODE, GOODS.GOODSNAME,GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE, MARKET.MARKETNAME, MARKET.TRADEMODE`).
|
|
|
+ GOODS.GOODSCODE, GOODS.GOODSNAME,GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE,GOODS.GOODUNITID, MARKET.MARKETNAME, MARKET.TRADEMODE`).
|
|
|
Where(fmt.Sprintf(`HIS_TRADE_ORDERDETAIL.ORDERSRC != 10 and HIS_TRADE_ORDERDETAIL.ISVALIDDATA = 1 and HIS_TRADE_ORDERDETAIL.ACCOUNTID in (%s)`, req.AccountID)).
|
|
|
Desc("HIS_TRADE_ORDERDETAIL.ORDERTIME")
|
|
|
if len(req.OrderStatus) > 0 {
|
|
|
@@ -443,11 +450,13 @@ type QueryTradeDetailRsp struct {
|
|
|
GoodsName string `json:"goodsname" xorm:"GOODSNAME"` // 商品名称
|
|
|
DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
|
|
|
QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 商品报价小数位
|
|
|
+ GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 商品单位id
|
|
|
Marketname string `json:"marketname" xorm:"'MARKETNAME'"` // 市场名称
|
|
|
TradeMode int32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
|
|
|
ListingSelectType int32 `json:"listingselecttype" xorm:"'LISTINGSELECTTYPE'"` // 关联委托单挂牌点选类型 - 1:挂牌 2:摘牌 3:先摘后挂
|
|
|
|
|
|
- Charge float64 `json:"charge" xorm:"CHARGE"` // 手续费
|
|
|
+ Charge float64 `json:"charge" xorm:"CHARGE"` // 手续费
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
}
|
|
|
|
|
|
func (r *QueryTradeDetailRsp) calc() {
|
|
|
@@ -457,6 +466,7 @@ func (r *QueryTradeDetailRsp) calc() {
|
|
|
fCovert(&r.Tradeqty)
|
|
|
fCovert(&r.Openqty)
|
|
|
fCovert(&r.Closeqty)
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
|
|
|
}
|
|
|
|
|
|
// QueryTradeDetail 成交单查询(合约市场)
|
|
|
@@ -494,7 +504,7 @@ func QueryTradeDetail(c *gin.Context) {
|
|
|
Join("LEFT", "TRADE_ORDERDETAIL", "TRADE_ORDERDETAIL.ORDERID = TRADE_TRADEDETAIL.ORDERID").
|
|
|
Select(`to_char(TRADE_TRADEDETAIL.TRADEID) as TRADEID, to_char(TRADE_TRADEDETAIL.ORDERID) as ORDERID,
|
|
|
TRADE_TRADEDETAIL.*, CASE TRADE_TRADEDETAIL.BUILDTYPE WHEN 1 THEN TRADE_TRADEDETAIL.OPENCHARGE ELSE TRADE_TRADEDETAIL.CLOSECHARGE END as CHARGE,
|
|
|
- GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE, MARKET.MARKETNAME, MARKET.TRADEMODE,
|
|
|
+ GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE,GOODS.GOODUNITID, MARKET.MARKETNAME, MARKET.TRADEMODE,
|
|
|
TRADE_ORDERDETAIL.LISTINGSELECTTYPE`).
|
|
|
Where(fmt.Sprintf("TRADE_TRADEDETAIL.TRADETYPE <= 13 and TRADE_TRADEDETAIL.ACCOUNTID in (%s)", req.AccountID)).
|
|
|
Desc("TRADE_TRADEDETAIL.TRADETIME")
|
|
|
@@ -552,11 +562,13 @@ type QueryHisTradeDetailRsp struct {
|
|
|
GoodsName string `json:"goodsname" xorm:"GOODSNAME"` // 商品名称
|
|
|
DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
|
|
|
QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 商品报价小数位
|
|
|
+ GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 商品单位id
|
|
|
Marketname string `json:"marketname" xorm:"'MARKETNAME'"` // 市场名称
|
|
|
TradeMode int32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
|
|
|
ListingSelectType int32 `json:"listingselecttype" xorm:"'LISTINGSELECTTYPE'"` // 关联委托单挂牌点选类型 - 1:挂牌 2:摘牌 3:先摘后挂
|
|
|
|
|
|
- Charge float64 `json:"charge" xorm:"CHARGE"` // 手续费
|
|
|
+ Charge float64 `json:"charge" xorm:"CHARGE"` // 手续费
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
}
|
|
|
|
|
|
func (r *QueryHisTradeDetailRsp) calc() {
|
|
|
@@ -566,6 +578,7 @@ func (r *QueryHisTradeDetailRsp) calc() {
|
|
|
fCovert(&r.Tradeqty)
|
|
|
fCovert(&r.Openqty)
|
|
|
fCovert(&r.Closeqty)
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
|
|
|
}
|
|
|
|
|
|
// QueryHisTradeDetail 历史成交单查询(合约市场)
|
|
|
@@ -605,7 +618,7 @@ func QueryHisTradeDetail(c *gin.Context) {
|
|
|
Join("LEFT", "HIS_TRADE_ORDERDETAIL", "HIS_TRADE_ORDERDETAIL.ORDERID = HIS_TRADE_TRADEDETAIL.ORDERID").
|
|
|
Select(`to_char(HIS_TRADE_TRADEDETAIL.TRADEID) as TRADEID, to_char(HIS_TRADE_TRADEDETAIL.ORDERID) as ORDERID,
|
|
|
HIS_TRADE_TRADEDETAIL.*, CASE HIS_TRADE_TRADEDETAIL.BUILDTYPE WHEN 1 THEN HIS_TRADE_TRADEDETAIL.OPENCHARGE ELSE HIS_TRADE_TRADEDETAIL.CLOSECHARGE END as CHARGE,
|
|
|
- GOODS.GOODSCODE, GOODS.GOODSNAME,GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE, MARKET.MARKETNAME, MARKET.TRADEMODE,
|
|
|
+ GOODS.GOODSCODE, GOODS.GOODSNAME,GOODS.DECIMALPLACE, GOODS.QTYDECIMALPLACE, GOODS.GOODUNITID, MARKET.MARKETNAME, MARKET.TRADEMODE,
|
|
|
HIS_TRADE_ORDERDETAIL.LISTINGSELECTTYPE`).
|
|
|
Where(fmt.Sprintf("HIS_TRADE_TRADEDETAIL.TRADETYPE <= 13 and HIS_TRADE_TRADEDETAIL.ISVALIDDATA = 1 and HIS_TRADE_TRADEDETAIL.ACCOUNTID in (%s)", req.AccountID)).
|
|
|
Desc("HIS_TRADE_TRADEDETAIL.TRADETIME")
|
|
|
@@ -616,7 +629,7 @@ func QueryHisTradeDetail(c *gin.Context) {
|
|
|
s = s.And("HIS_TRADE_TRADEDETAIL.ORDERID = ?", req.OrderID)
|
|
|
}
|
|
|
if req.GoodsID > 0 {
|
|
|
- s = s.And("TRADE_TRADEDETAIL.GOODSID = ?", req.GoodsID)
|
|
|
+ s = s.And("HIS_TRADE_TRADEDETAIL.GOODSID = ?", req.GoodsID)
|
|
|
}
|
|
|
if len(req.TradeMode) > 0 {
|
|
|
s = s.And(fmt.Sprintf("MARKET.TRADEMODE in (%s)", req.TradeMode))
|