|
@@ -0,0 +1,942 @@
|
|
|
|
|
+package models
|
|
|
|
|
+
|
|
|
|
|
+import (
|
|
|
|
|
+ "mtp2_if/db"
|
|
|
|
|
+ "mtp2_if/utils"
|
|
|
|
|
+ "time"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+// MineCpTradePreSaleResult 我的持仓-预售持仓
|
|
|
|
|
+type MineCpTradePreSaleResult struct {
|
|
|
|
|
+ TRADEID int64 `json:"tradeid" xorm:"TRADEID"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
|
|
+ GOODSID int64 `json:"goodsid" xorm:"GOODSID"` // 商品ID
|
|
|
|
|
+ BUYACCOUNTID int64 `json:"buyaccountid" xorm:"BUYACCOUNTID"` // 买方账户ID
|
|
|
|
|
+ BUYUSERID int64 `json:"buyuserid" xorm:"BUYUSERID" form:"userid" binding:"required"` // 买方用户ID
|
|
|
|
|
+ SELLACCOUNTID int64 `json:"sellaccountid" xorm:"SELLACCOUNTID"` // 卖方账户ID
|
|
|
|
|
+ SELLUSERID int64 `json:"selluserid" xorm:"SELLUSERID"` // 卖方用户ID
|
|
|
|
|
+ RELATEDGOODSID int64 `json:"relatedgoodsid" xorm:"RELATEDGOODSID"` // 关联交易合约ID
|
|
|
|
|
+ TRADEQTY int64 `json:"tradeqty" xorm:"TRADEQTY"` // 成交数量
|
|
|
|
|
+ HANDLEFLAG int32 `json:"handleflag" xorm:"HANDLEFLAG"` // 处理标识 - 0:未处理 1:已处理
|
|
|
|
|
+ HANDLESTATUS int32 `json:"handlestatus" xorm:"HANDLESTATUS"` // 处理状态
|
|
|
|
|
+ CREATETIME time.Time `json:"createtime" xorm:"CREATETIME"` // 创建时间
|
|
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
|
|
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
|
|
|
|
|
+ RELATEDMARKETID int64 `json:"relatedmarketid" xorm:"RELATEDMARKETID"` // 关联交易合约市场ID
|
|
|
|
|
+ APPLYID int64 `json:"applyid" xorm:"APPLYID"` // 预售申请ID
|
|
|
|
|
+ OPENPRICE float64 `json:"openprice" xorm:"OPENPRICE"` // 建仓价格\预售价
|
|
|
|
|
+ TRADEAMOUNT float64 `json:"tradeamount" xorm:"TRADEAMOUNT"` // 成交金额\转让定金
|
|
|
|
|
+ SELLHANDLEFLAG int32 `json:"sellhandleflag" xorm:"SELLHANDLEFLAG"` // 卖处理标识
|
|
|
|
|
+ BUYHANDLEFLAG int32 `json:"buyhandleflag" xorm:"BUYHANDLEFLAG"` // 买处理标识
|
|
|
|
|
+ RELATEDTRADEID int64 `json:"relatedtradeid" xorm:"RELATEDTRADEID"` // 二级市场成交单ID
|
|
|
|
|
+ TRANSFERDEPOSIT float64 `json:"transferdeposit" xorm:"TRANSFERDEPOSIT"` // 转让定金
|
|
|
|
|
+ DEPOSITREMAIN float64 `json:"depositremain" xorm:"DEPOSITREMAIN"` // 未付定金
|
|
|
|
|
+ PAYSTATUS int32 `json:"paystatus" xorm:"PAYSTATUS"` // 支付状态 - 1:待支付 2:已支付
|
|
|
|
|
+
|
|
|
|
|
+ STARTTIME string `json:"starttime" xorm:"STARTTIME"` // 预售开始时间
|
|
|
|
|
+ ENDTIME string `json:"endtime" xorm:"ENDTIME"` // 预售结束时间
|
|
|
|
|
+
|
|
|
|
|
+ GOODSCODE string `json:"goodscode" xorm:"GOODSCODE"` // 期货合约代码(内部)
|
|
|
|
|
+ GOODSNAME string `json:"goodsname" xorm:"GOODSNAME"` // 期货合约名称
|
|
|
|
|
+ Goodsnamedisplay string `json:"goodsnamedisplay" xorm:"GOODSNAMEDISPLAY"` // 商品名称
|
|
|
|
|
+ TRANSFERDEPOSITRATIO float64 `json:"transferdepositratio" xorm:"TRANSFERDEPOSITRATIO"` // 转让定金比例(49)
|
|
|
|
|
+
|
|
|
|
|
+ CUSTOMERNAME string `json:"sellname" xorm:"SELLNAME"` // 客户名称(企业名称)
|
|
|
|
|
+
|
|
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineCpTradePreSaleResult) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineCpTradePreSaleResult) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "GOODSNAMEDISPLAY",
|
|
|
|
|
+ ui.customername "SELLNAME",
|
|
|
|
|
+ to_char(pge.starttime, 'yyyy-mm-dd') STARTTIME,
|
|
|
|
|
+ to_char(pge.endtime, 'yyyy-mm-dd') ENDTIME,
|
|
|
|
|
+ g.transferdepositratio,
|
|
|
|
|
+ t.tradeid,
|
|
|
|
|
+ t.goodsid,
|
|
|
|
|
+ t.buyaccountid,
|
|
|
|
|
+ t.buyuserid,
|
|
|
|
|
+ t.sellaccountid,
|
|
|
|
|
+ t.selluserid,
|
|
|
|
|
+ t.relatedgoodsid,
|
|
|
|
|
+ t.tradeqty,
|
|
|
|
|
+ t.handleflag,
|
|
|
|
|
+ t.handlestatus,
|
|
|
|
|
+ t.createtime,
|
|
|
|
|
+ t.tradedate,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.relatedmarketid,
|
|
|
|
|
+ t.applyid,
|
|
|
|
|
+ t.openprice,
|
|
|
|
|
+ t.tradeamount,
|
|
|
|
|
+ t.sellhandleflag,
|
|
|
|
|
+ t.buyhandleflag,
|
|
|
|
|
+ t.relatedtradeid,
|
|
|
|
|
+ t.transferdeposit,
|
|
|
|
|
+ t.depositremain,
|
|
|
|
|
+ t.paystatus
|
|
|
|
|
+ from CPTrade_PresaleResult t
|
|
|
|
|
+ left join CPTrade_PresaleGoodsEx pge on t.goodsid = pge.goodsid
|
|
|
|
|
+ left join Goods g on t.relatedgoodsid = g.goodsid
|
|
|
|
|
+ left join userinfo ui on pge.userid = ui.userid
|
|
|
|
|
+ where t.handleflag = 0 and pge.marketid = 48201
|
|
|
|
|
+ and t.buyuserid = %v
|
|
|
|
|
+ order by t.paystatus, pge.endtime
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.FormatParam(r.BUYUSERID)
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineCpTradePreSaleResult) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
+ sData := make([]MineCpTradePreSaleResult, 0)
|
|
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
|
|
+ total := 0
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ total = sData[i].Total
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// MineTradePositionEx 我的持仓-转让持仓
|
|
|
|
|
+type MineTradePositionEx struct {
|
|
|
|
|
+ ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账号Id
|
|
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品Id
|
|
|
|
|
+ TRANSFERDEPOSIT float64 `json:"transferdeposit" xorm:"TRANSFERDEPOSIT"` // 转让定金(49)
|
|
|
|
|
+ DEPOSITREMAIN float64 `json:"depositremain" xorm:"DEPOSITREMAIN"` // 未付定金
|
|
|
|
|
+ PAYSTATUS int32 `json:"paystatus" xorm:"PAYSTATUS"` // 支付状态 -1:待支付 2:已支付
|
|
|
|
|
+
|
|
|
|
|
+ BUYCURPOSITIONQTY int64 `json:"buycurpositionqty" xorm:"BUYCURPOSITIONQTY"` // 买当前持仓总数量
|
|
|
|
|
+ BUYCURHOLDERAMOUNT float64 `json:"buycurholderamount" xorm:"BUYCURHOLDERAMOUNT"` // 买当前持仓总金额[商品币种]
|
|
|
|
|
+ BUYFROZENQTY int64 `json:"buyfrozenqty" xorm:"BUYFROZENQTY"` // 买持仓冻结数量
|
|
|
|
|
+
|
|
|
|
|
+ GOODSCODE string `json:"goodscode" xorm:"GOODSCODE"` // 期货合约代码(内部)
|
|
|
|
|
+ GOODSNAME string `json:"goodsname" xorm:"GOODSNAME"` // 期货合约名称
|
|
|
|
|
+ Goodsnamedisplay string `json:"goodsnamedisplay" xorm:"GOODSNAMEDISPLAY"` // 商品名称
|
|
|
|
|
+ PRESALEPRICE float64 `json:"presaleprice" xorm:"PRESALEPRICE"` // 发售价(49)
|
|
|
|
|
+ TRANSFERDEPOSITRATIO float64 `json:"transferdepositratio" xorm:"TRANSFERDEPOSITRATIO"` // 转让定金比例(49)
|
|
|
|
|
+ LASTTRADEDATE string `json:"lasttradedate" xorm:"LASTTRADEDATE"` // 最后交易日期
|
|
|
|
|
+
|
|
|
|
|
+ RELATEDGOODSID int64 `json:"relatedgoodsid" xorm:"RELATEDGOODSID"` // 关联交易合约ID
|
|
|
|
|
+
|
|
|
|
|
+ CUSTOMERNAME string `json:"sellname" xorm:"SELLNAME"` // 客户名称(企业名称)
|
|
|
|
|
+
|
|
|
|
|
+ Userid int `json:"-" xorm:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
|
|
+
|
|
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradePositionEx) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradePositionEx) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "GOODSNAMEDISPLAY",
|
|
|
|
|
+ tp.buycurpositionqty,
|
|
|
|
|
+ tp.buycurholderamount,
|
|
|
|
|
+ tp.buyfrozenqty,
|
|
|
|
|
+ ui.customername "SELLNAME",
|
|
|
|
|
+ g.presaleprice,
|
|
|
|
|
+ g.transferdepositratio,
|
|
|
|
|
+ to_char(g.lasttradedate, 'yyyy-mm-dd') LASTTRADEDATE,
|
|
|
|
|
+ tpe.accountid,
|
|
|
|
|
+ tpe.transferdepositratio,
|
|
|
|
|
+ tpe.transferdeposit,
|
|
|
|
|
+ tpe.depositremain,
|
|
|
|
|
+ tpe.paystatus
|
|
|
|
|
+ from tradepositionEx tpe
|
|
|
|
|
+ inner join tradeposition tp
|
|
|
|
|
+ on tpe.accountid = tp.accountid
|
|
|
|
|
+ and tpe.goodsid = tp.goodsid
|
|
|
|
|
+ inner join goods g
|
|
|
|
|
+ on tpe.goodsid = g.goodsid
|
|
|
|
|
+ left join CPTrade_PresaleGoodsEx ge
|
|
|
|
|
+ on tpe.goodsid = ge.relatedgoodsid
|
|
|
|
|
+ left join userinfo ui
|
|
|
|
|
+ on ge.userid = ui.userid
|
|
|
|
|
+ left join taaccount ta
|
|
|
|
|
+ on tpe.accountid = ta.accountid
|
|
|
|
|
+ where g.marketid = 49201
|
|
|
|
|
+ and ta.relateduserid = %v
|
|
|
|
|
+ order by tpe.paystatus, g.goodscode
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.FormatParam(r.Userid)
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradePositionEx) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
+ sData := make([]MineTradePositionEx, 0)
|
|
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
|
|
+ total := 0
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ total = sData[i].Total
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// MineTradeOrderDetail 我的订单-预售认购
|
|
|
|
|
+type MineTradeOrderDetail struct {
|
|
|
|
|
+ ORDERID string `json:"orderid" xorm:"ORDERID"` // 委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
|
|
|
|
|
+ BUILDTYPE int32 `json:"buildtype" xorm:"BUILDTYPE"` // 委托单据类型 - 1:建仓 2:平仓 3:先平后建
|
|
|
|
|
+ PREORDERID int64 `json:"preorderid" xorm:"PREORDERID"` // 关联预埋单号(止盈止损单时填写)
|
|
|
|
|
+ CANCELORDERID int64 `json:"cancelorderid" xorm:"CANCELORDERID"` // 撤单单号(撤单时填写)
|
|
|
|
|
+ RELATEDID int64 `json:"relatedid" xorm:"RELATEDID"` // 关联单号(交割单)
|
|
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
|
|
|
|
|
+ ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账户ID[报价币种]
|
|
|
|
|
+ MEMBERUSERID int64 `json:"memberuserid" xorm:"MEMBERUSERID"` // 所属会员UserID
|
|
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL"` // 买卖 - 0:买 1:卖
|
|
|
|
|
+ PRICEMODE int32 `json:"pricemode" xorm:"PRICEMODE"` // 取价方式 - 1:市价 2: 限价 3:浮动价
|
|
|
|
|
+ ORDERPRICE float64 `json:"orderprice" xorm:"ORDERPRICE"` // 委托价格
|
|
|
|
|
+ MARKETMAXSUB float64 `json:"marketmaxsub" xorm:"MARKETMAXSUB"` // 市价最大偏移范围 [浮动价 - 点差]
|
|
|
|
|
+ ORDERQTY int64 `json:"orderqty" xorm:"ORDERQTY"` // 委托数量
|
|
|
|
|
+ TRADEQTY int64 `json:"tradeqty" xorm:"TRADEQTY"` // 成交数量
|
|
|
|
|
+ CANCELQTY int64 `json:"cancelqty" xorm:"CANCELQTY"` // 撤单数量
|
|
|
|
|
+ OPENQTY int64 `json:"openqty" xorm:"OPENQTY"` // 开仓数量(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSEQTY int64 `json:"closeqty" xorm:"CLOSEQTY"` // 平仓数量(先建后平操作 需要记录)
|
|
|
|
|
+ OPENTRADEQTY int64 `json:"opentradeqty" xorm:"OPENTRADEQTY"` // 开仓成交数量(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSETRADEQTY int64 `json:"closetradeqty" xorm:"CLOSETRADEQTY"` // 平仓成交数量(先建后平操作,需要记录)
|
|
|
|
|
+ FREEZEMARGIN float64 `json:"freezemargin" xorm:"FREEZEMARGIN"` // 冻结保证金(冻结交易金额)
|
|
|
|
|
+ UNFREEZEMARGIN float64 `json:"unfreezemargin" xorm:"UNFREEZEMARGIN"` // 解冻保证金
|
|
|
|
|
+ FREEZECHARGE float64 `json:"freezecharge" xorm:"FREEZECHARGE"` // 冻结手续费
|
|
|
|
|
+ UNFREEZECHARGE float64 `json:"unfreezecharge" xorm:"UNFREEZECHARGE"` // 解冻手续费
|
|
|
|
|
+ OPENFREEZECHARGE float64 `json:"openfreezecharge" xorm:"OPENFREEZECHARGE"` // 开仓冻结手续费(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSEFREEZECHARGE float64 `json:"closefreezecharge" xorm:"CLOSEFREEZECHARGE"` // 平仓冻结手续费(先建后平操作,需要记录)
|
|
|
|
|
+ OPENUNFREEZECHARGE float64 `json:"openunfreezecharge" xorm:"OPENUNFREEZECHARGE"` // 开仓解冻手续费(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSEUNFREEZECHARGE float64 `json:"closeunfreezecharge" xorm:"CLOSEUNFREEZECHARGE"` // 平仓解冻手续费(先建后平操作,需要记录)
|
|
|
|
|
+ VALIDTYPE int32 `json:"validtype" xorm:"VALIDTYPE"` // 有效类型 - 1当日有效 2本周有效 3指定日期有效 4一直有效 5指定时间有效
|
|
|
|
|
+ VALIDTIME time.Time `json:"validtime" xorm:"VALIDTIME"` // 有效期限
|
|
|
|
|
+ VOLUMETYPE int32 `json:"volumetype" xorm:"VOLUMETYPE"` // 当时间有效类型为 “立即执行否则取消 IOC” 时,需要此项 - 0:任意量 1:最小量(暂时不支持) 2:全部量
|
|
|
|
|
+ OPERATETYPE int32 `json:"operatetype" xorm:"OPERATETYPE"` // 操作类型 - 1:正常下单 2:斩仓 3:转单 4:结算撤单 5:系统卖出(适用于先平后建的卖出) 6:行情源报价 7:(结算)到期强平 8:(结算)协议转让 9:系统对冲单 10:(结算)到期无效 11:交割协议转让 12:交割协议平仓 13:交割成交(所有权) 14:管理端强行平仓 15:管理端协议转让 ... 23:融资买入
|
|
|
|
|
+ ORDERTIME string `json:"ordertime" xorm:"ORDERTIME"` // 委托时间
|
|
|
|
|
+ ORDERSRC int32 `json:"ordersrc" xorm:"ORDERSRC"` // 委托来源 - 1:客户端 2:管理端 3:风控服务 4:交割服务 5:交易服务 6:交易日结 7:商品强平 8:管理端商品退市强平 9:交易接口 10:交割服务商被动(受托竞价) 11:预埋触发
|
|
|
|
|
+ ORDERSTATUS int32 `json:"orderstatus" xorm:"ORDERSTATUS"` // 委托状态 - 参考枚举'orderstatus' - 1:委托请求 2:待冻结 3:委托成功 4:委托失败 5:配对成功 6:已撤 7:部成 8:已成 9:部成部撤 10:成交失败 11:委托拒绝 12:经过摘牌(先摘后挂专用) 13:冻结成功(通道交易专用) 14:通道已撤 15:通道部成部撤 16:成交失败违约(荷兰式竞拍专用) 17:冻结PD成功 18:冻结PD失败 19:冻结能量成功 20:冻结能量失败 21:预约已报价 22:过期未付 23:优惠券处理中 24:仓单生成失败 25:首付扣款失败 26:履约失败 27:撤单解冻贷款失败
|
|
|
|
|
+ OPERATORID int64 `json:"operatorid" xorm:"OPERATORID"` // 登录账号(LoginID)
|
|
|
|
|
+ UPDATETIME time.Time `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
|
|
|
|
|
+ CLIENTORDERTIME time.Time `json:"clientordertime" xorm:"CLIENTORDERTIME"` // 客户端委托时间
|
|
|
|
|
+ CLIENTTICKET string `json:"clientticket" xorm:"CLIENTTICKET"` // 客户端流水号
|
|
|
|
|
+ UUID string `json:"uuid" xorm:"UUID"` // 发起端唯一id
|
|
|
|
|
+ CLIENTTYPE int32 `json:"clienttype" xorm:"CLIENTTYPE"` // 客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江)
|
|
|
|
|
+ RETCODE int32 `json:"retcode" xorm:"RETCODE"` // 错误代码
|
|
|
|
|
+ TRADEPROPERTY int32 `json:"tradeproperty" xorm:"TRADEPROPERTY"` // 交易属性
|
|
|
|
|
+ LISTINGSELECTTYPE int32 `json:"listingselecttype" xorm:"LISTINGSELECTTYPE"` // 挂牌点选类型 - 1:挂牌 2:摘牌 3:先摘后挂
|
|
|
|
|
+ DELISTINGTYPE int32 `json:"delistingtype" xorm:"DELISTINGTYPE"` // 摘牌类型 - 1:价格最优 2:点选成交
|
|
|
|
|
+ MARGINALGORITHM int32 `json:"marginalgorithm" xorm:"MARGINALGORITHM"` // 保证金收取方式 1:比率 2:固定
|
|
|
|
|
+ MARGINVALUE float64 `json:"marginvalue" xorm:"MARGINVALUE"` // 即市保证金设置值
|
|
|
|
|
+ OPENFEEALGORITHM int32 `json:"openfeealgorithm" xorm:"OPENFEEALGORITHM"` // 建仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ OPENMEMBERCHARGEVALUE float64 `json:"openmemberchargevalue" xorm:"OPENMEMBERCHARGEVALUE"` // 建仓会员手续费设置值
|
|
|
|
|
+ OPENEXCHAGECHARGEVALUE float64 `json:"openexchagechargevalue" xorm:"OPENEXCHAGECHARGEVALUE"` // 建仓交易所手续费设置值
|
|
|
|
|
+ CLOSEFEEALGORITHM int32 `json:"closefeealgorithm" xorm:"CLOSEFEEALGORITHM"` // 平仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ CLOSEMEMBERCHARGEVALUE float64 `json:"closememberchargevalue" xorm:"CLOSEMEMBERCHARGEVALUE"` // 平仓会员手续费设置值
|
|
|
|
|
+ CLOSEEXCHAGECHARGEVALUE float64 `json:"closeexchagechargevalue" xorm:"CLOSEEXCHAGECHARGEVALUE"` // 平仓交易所手续费设置值
|
|
|
|
|
+ OPTIONTYPE int32 `json:"optiontype" xorm:"OPTIONTYPE"` // 期权类型 - 1:认购(看涨) 2:认沽(看跌)
|
|
|
|
|
+ PREMIUM float64 `json:"premium" xorm:"PREMIUM"` // 权利金
|
|
|
|
|
+ ISPREEXERCISE int32 `json:"ispreexercise" xorm:"ISPREEXERCISE"` // 是否预申报- 0:否 1:是
|
|
|
|
|
+ PREEXERCISEPRICE float64 `json:"preexerciseprice" xorm:"PREEXERCISEPRICE"` // 预申报价格
|
|
|
|
|
+ ISCONFIRMEXERCISE int32 `json:"isconfirmexercise" xorm:"ISCONFIRMEXERCISE"` // 是否确认行权- 0:否 1:是
|
|
|
|
|
+ QUOTEID int64 `json:"quoteid" xorm:"QUOTEID"` // 报价单ID
|
|
|
|
|
+ GCACCOUNTID int64 `json:"gcaccountid" xorm:"GCACCOUNTID"` // 账户ID[合约币种]
|
|
|
|
|
+ SESSIONID int64 `json:"sessionid" xorm:"SESSIONID"` // 会话ID
|
|
|
|
|
+ FREEZEQTY int64 `json:"freezeqty" xorm:"FREEZEQTY"` // 冻结数量
|
|
|
|
|
+ AMOUNTFLAG int32 `json:"amountflag" xorm:"AMOUNTFLAG"` // 资金标识 - 1:余额 2;待付
|
|
|
|
|
+ ORDERFLAG int32 `json:"orderflag" xorm:"ORDERFLAG"` // 委托标识 - 1:按量 2:按金额
|
|
|
|
|
+
|
|
|
|
|
+ PRESALEDEPOSITALGORITHM int32 `json:"presaledepositalgorithm" xorm:"PRESALEDEPOSITALGORITHM"` // 预售定金方式(48) - 1:比率 2:固定
|
|
|
|
|
+ PRESALEDEPOSITVALUE float64 `json:"presaledepositvalue" xorm:"PRESALEDEPOSITVALUE"` // 预售定金设置值(48)
|
|
|
|
|
+ STARTPRICE float64 `json:"startprice" xorm:"STARTPRICE"` // 起拍价[大宗式竞拍]
|
|
|
|
|
+ STARTTIME string `json:"starttime" xorm:"STARTTIME"` // 预售开始时间
|
|
|
|
|
+ ENDTIME string `json:"endtime" xorm:"ENDTIME"` // 预售结束时间
|
|
|
|
|
+ TRADEPRICE float64 `json:"tradeprice" xorm:"TRADEPRICE"` // 成交价[大宗]
|
|
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID
|
|
|
|
|
+
|
|
|
|
|
+ GOODSCODE string `json:"goodscode" xorm:"GOODSCODE"` // 期货合约代码(内部)
|
|
|
|
|
+ GOODSNAME string `json:"goodsname" xorm:"GOODSNAME"` // 期货合约名称
|
|
|
|
|
+ Goodsnamedisplay string `json:"goodsnamedisplay" xorm:"GOODSNAMEDISPLAY"` // 商品名称
|
|
|
|
|
+
|
|
|
|
|
+ CUSTOMERNAME string `json:"sellname" xorm:"SELLNAME"` // 客户名称(企业名称)
|
|
|
|
|
+
|
|
|
|
|
+ Userid int `json:"-" xorm:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
|
|
+ IsHis bool `json:"-" xorm:"-" form:"ishis"` // 是否历史查询
|
|
|
|
|
+ BeginDate string `json:"-" xorm:"-" form:"begindate"` // 开始交易日
|
|
|
|
|
+ EndDate string `json:"-" xorm:"-" form:"enddate"` // 结束交易日
|
|
|
|
|
+
|
|
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrderDetail) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrderDetail) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "GOODSNAMEDISPLAY",
|
|
|
|
|
+ pge.presaledepositalgorithm,
|
|
|
|
|
+ pge.presaledepositvalue,
|
|
|
|
|
+ ui.customername "SELLNAME",
|
|
|
|
|
+ pge.startprice,
|
|
|
|
|
+ to_char(pge.starttime, 'yyyy-mm-dd') STARTTIME,
|
|
|
|
|
+ to_char(pge.endtime, 'yyyy-mm-dd') ENDTIME,
|
|
|
|
|
+ pge.tradeprice,
|
|
|
|
|
+ t.cancelorderid,
|
|
|
|
|
+ t.relatedid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.accountid,
|
|
|
|
|
+ t.marketmaxsub,
|
|
|
|
|
+ t.tradeqty,
|
|
|
|
|
+ t.cancelqty,
|
|
|
|
|
+ t.opentradeqty,
|
|
|
|
|
+ t.closetradeqty,
|
|
|
|
|
+ t.freezemargin,
|
|
|
|
|
+ t.unfreezemargin,
|
|
|
|
|
+ t.freezecharge,
|
|
|
|
|
+ t.unfreezecharge,
|
|
|
|
|
+ t.openfreezecharge,
|
|
|
|
|
+ t.closefreezecharge,
|
|
|
|
|
+ t.openunfreezecharge,
|
|
|
|
|
+ t.closeunfreezecharge,
|
|
|
|
|
+ t.validtype,
|
|
|
|
|
+ t.validtime,
|
|
|
|
|
+ t.operatetype,
|
|
|
|
|
+ t.orderstatus,
|
|
|
|
|
+ t.operatorid,
|
|
|
|
|
+ t.updatetime,
|
|
|
|
|
+ t.tradeproperty,
|
|
|
|
|
+ t.marginalgorithm,
|
|
|
|
|
+ t.marginvalue,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.gcaccountid,
|
|
|
|
|
+ t.amountflag,
|
|
|
|
|
+ t.orderflag,
|
|
|
|
|
+ to_char(t.ordertime, 'yyyy-mm-dd hh24:mi:ss') ORDERTIME,
|
|
|
|
|
+ to_char(t.orderid) ORDERID,
|
|
|
|
|
+ t.orderqty,
|
|
|
|
|
+ t.orderprice
|
|
|
|
|
+
|
|
|
|
|
+ from trade_orderdetail t
|
|
|
|
|
+
|
|
|
|
|
+ inner join CPTrade_PresaleGoodsEx pge
|
|
|
|
|
+ on t.goodsid = pge.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join taaccount ta
|
|
|
|
|
+ on t.accountid = ta.accountid
|
|
|
|
|
+
|
|
|
|
|
+ left join userinfo ui
|
|
|
|
|
+ on pge.userid = ui.userid
|
|
|
|
|
+
|
|
|
|
|
+ where t.marketid = 48201
|
|
|
|
|
+ and ta.userid = %v
|
|
|
|
|
+
|
|
|
|
|
+ order by t.ordertime desc
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.FormatParam(r.Userid)
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrderDetail) buildSql_His() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "GOODSNAMEDISPLAY",
|
|
|
|
|
+ pge.presaledepositalgorithm,
|
|
|
|
|
+ pge.presaledepositvalue,
|
|
|
|
|
+ ui.customername "SELLNAME",
|
|
|
|
|
+ pge.startprice,
|
|
|
|
|
+ pge.starttime,
|
|
|
|
|
+ pge.endtime,
|
|
|
|
|
+ pge.tradeprice,
|
|
|
|
|
+ t.cancelorderid,
|
|
|
|
|
+ t.relatedid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.accountid,
|
|
|
|
|
+ t.marketmaxsub,
|
|
|
|
|
+ t.tradeqty,
|
|
|
|
|
+ t.cancelqty,
|
|
|
|
|
+ t.opentradeqty,
|
|
|
|
|
+ t.closetradeqty,
|
|
|
|
|
+ t.freezemargin,
|
|
|
|
|
+ t.unfreezemargin,
|
|
|
|
|
+ t.freezecharge,
|
|
|
|
|
+ t.unfreezecharge,
|
|
|
|
|
+ t.openfreezecharge,
|
|
|
|
|
+ t.closefreezecharge,
|
|
|
|
|
+ t.openunfreezecharge,
|
|
|
|
|
+ t.closeunfreezecharge,
|
|
|
|
|
+ t.validtype,
|
|
|
|
|
+ t.validtime,
|
|
|
|
|
+ t.operatetype,
|
|
|
|
|
+ t.orderstatus,
|
|
|
|
|
+ t.operatorid,
|
|
|
|
|
+ t.updatetime,
|
|
|
|
|
+ t.tradeproperty,
|
|
|
|
|
+ t.marginalgorithm,
|
|
|
|
|
+ t.marginvalue,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.gcaccountid,
|
|
|
|
|
+ t.amountflag,
|
|
|
|
|
+ t.orderflag,
|
|
|
|
|
+ to_char(t.ordertime, 'yyyy-mm-dd hh24:mi:ss') ORDERTIME,
|
|
|
|
|
+ to_char(t.orderid) ORDERID,
|
|
|
|
|
+ t.orderqty,
|
|
|
|
|
+ t.orderprice
|
|
|
|
|
+
|
|
|
|
|
+ from HIS_Trade_OrderDetail t
|
|
|
|
|
+
|
|
|
|
|
+ inner join CPTrade_PresaleGoodsEx pge
|
|
|
|
|
+ on t.goodsid = pge.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join taaccount ta
|
|
|
|
|
+ on t.accountid = ta.accountid
|
|
|
|
|
+
|
|
|
|
|
+ left join userinfo ui
|
|
|
|
|
+ on pge.userid = ui.userid
|
|
|
|
|
+
|
|
|
|
|
+ where t.marketid = 48201 and t.isvaliddata = 1
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.And("ta.userid", r.Userid)
|
|
|
|
|
+ if r.BeginDate != "" && r.EndDate != "" {
|
|
|
|
|
+ sqlId.JoinFormat(" AND (t.TRADEDATE >= '%v' AND t.TRADEDATE <= '%v')", r.BeginDate, r.EndDate)
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlId.OrderByDesc("t.ordertime")
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrderDetail) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
+ sData := make([]MineTradeOrderDetail, 0)
|
|
|
|
|
+ sql := ""
|
|
|
|
|
+ if r.IsHis {
|
|
|
|
|
+ sql = r.buildSql_His()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sql = r.buildSql()
|
|
|
|
|
+ }
|
|
|
|
|
+ err := db.GetEngine().SQL(sql).Find(&sData)
|
|
|
|
|
+ total := 0
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ total = sData[i].Total
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// MineTradeOrder 我的订单-转让委托
|
|
|
|
|
+type MineTradeOrder struct {
|
|
|
|
|
+ ORDERID string `json:"orderid" xorm:"ORDERID"` // 委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
|
|
|
|
|
+ BUILDTYPE int32 `json:"buildtype" xorm:"BUILDTYPE"` // 委托单据类型 - 1:建仓 2:平仓 3:先平后建
|
|
|
|
|
+ PREORDERID int64 `json:"preorderid" xorm:"PREORDERID"` // 关联预埋单号(止盈止损单时填写)
|
|
|
|
|
+ CANCELORDERID int64 `json:"cancelorderid" xorm:"CANCELORDERID"` // 撤单单号(撤单时填写)
|
|
|
|
|
+ RELATEDID int64 `json:"relatedid" xorm:"RELATEDID"` // 关联单号(交割单)
|
|
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
|
|
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID
|
|
|
|
|
+ ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账户ID[报价币种]
|
|
|
|
|
+ MEMBERUSERID int64 `json:"memberuserid" xorm:"MEMBERUSERID"` // 所属会员UserID
|
|
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL"` // 买卖 - 0:买 1:卖
|
|
|
|
|
+ PRICEMODE int32 `json:"pricemode" xorm:"PRICEMODE"` // 取价方式 - 1:市价 2: 限价 3:浮动价
|
|
|
|
|
+ ORDERPRICE float64 `json:"orderprice" xorm:"ORDERPRICE"` // 委托价格
|
|
|
|
|
+ MARKETMAXSUB float64 `json:"marketmaxsub" xorm:"MARKETMAXSUB"` // 市价最大偏移范围 [浮动价 - 点差]
|
|
|
|
|
+ ORDERQTY int64 `json:"orderqty" xorm:"ORDERQTY"` // 委托数量
|
|
|
|
|
+ TRADEQTY int64 `json:"tradeqty" xorm:"TRADEQTY"` // 成交数量
|
|
|
|
|
+ CANCELQTY int64 `json:"cancelqty" xorm:"CANCELQTY"` // 撤单数量
|
|
|
|
|
+ OPENQTY int64 `json:"openqty" xorm:"OPENQTY"` // 开仓数量(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSEQTY int64 `json:"closeqty" xorm:"CLOSEQTY"` // 平仓数量(先建后平操作 需要记录)
|
|
|
|
|
+ OPENTRADEQTY int64 `json:"opentradeqty" xorm:"OPENTRADEQTY"` // 开仓成交数量(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSETRADEQTY int64 `json:"closetradeqty" xorm:"CLOSETRADEQTY"` // 平仓成交数量(先建后平操作,需要记录)
|
|
|
|
|
+ FREEZEMARGIN float64 `json:"freezemargin" xorm:"FREEZEMARGIN"` // 冻结保证金(冻结交易金额)
|
|
|
|
|
+ UNFREEZEMARGIN float64 `json:"unfreezemargin" xorm:"UNFREEZEMARGIN"` // 解冻保证金
|
|
|
|
|
+ FREEZECHARGE float64 `json:"freezecharge" xorm:"FREEZECHARGE"` // 冻结手续费
|
|
|
|
|
+ UNFREEZECHARGE float64 `json:"unfreezecharge" xorm:"UNFREEZECHARGE"` // 解冻手续费
|
|
|
|
|
+ OPENFREEZECHARGE float64 `json:"openfreezecharge" xorm:"OPENFREEZECHARGE"` // 开仓冻结手续费(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSEFREEZECHARGE float64 `json:"closefreezecharge" xorm:"CLOSEFREEZECHARGE"` // 平仓冻结手续费(先建后平操作,需要记录)
|
|
|
|
|
+ OPENUNFREEZECHARGE float64 `json:"openunfreezecharge" xorm:"OPENUNFREEZECHARGE"` // 开仓解冻手续费(先建后平操作,需要记录)
|
|
|
|
|
+ CLOSEUNFREEZECHARGE float64 `json:"closeunfreezecharge" xorm:"CLOSEUNFREEZECHARGE"` // 平仓解冻手续费(先建后平操作,需要记录)
|
|
|
|
|
+ VALIDTYPE int32 `json:"validtype" xorm:"VALIDTYPE"` // 有效类型 - 1当日有效 2本周有效 3指定日期有效 4一直有效 5指定时间有效
|
|
|
|
|
+ VALIDTIME time.Time `json:"validtime" xorm:"VALIDTIME"` // 有效期限
|
|
|
|
|
+ VOLUMETYPE int32 `json:"volumetype" xorm:"VOLUMETYPE"` // 当时间有效类型为 “立即执行否则取消 IOC” 时,需要此项 - 0:任意量 1:最小量(暂时不支持) 2:全部量
|
|
|
|
|
+ OPERATETYPE int32 `json:"operatetype" xorm:"OPERATETYPE"` // 操作类型 - 1:正常下单 2:斩仓 3:转单 4:结算撤单 5:系统卖出(适用于先平后建的卖出) 6:行情源报价 7:(结算)到期强平 8:(结算)协议转让 9:系统对冲单 10:(结算)到期无效 11:交割协议转让 12:交割协议平仓 13:交割成交(所有权) 14:管理端强行平仓 15:管理端协议转让 ... 23:融资买入
|
|
|
|
|
+ ORDERTIME string `json:"ordertime" xorm:"ORDERTIME"` // 委托时间
|
|
|
|
|
+ ORDERSRC int32 `json:"ordersrc" xorm:"ORDERSRC"` // 委托来源 - 1:客户端 2:管理端 3:风控服务 4:交割服务 5:交易服务 6:交易日结 7:商品强平 8:管理端商品退市强平 9:交易接口 10:交割服务商被动(受托竞价) 11:预埋触发
|
|
|
|
|
+ ORDERSTATUS int32 `json:"orderstatus" xorm:"ORDERSTATUS"` // 委托状态 - 参考枚举'orderstatus' - 1:委托请求 2:待冻结 3:委托成功 4:委托失败 5:配对成功 6:已撤 7:部成 8:已成 9:部成部撤 10:成交失败 11:委托拒绝 12:经过摘牌(先摘后挂专用) 13:冻结成功(通道交易专用) 14:通道已撤 15:通道部成部撤 16:成交失败违约(荷兰式竞拍专用) 17:冻结PD成功 18:冻结PD失败 19:冻结能量成功 20:冻结能量失败 21:预约已报价 22:过期未付 23:优惠券处理中 24:仓单生成失败 25:首付扣款失败 26:履约失败 27:撤单解冻贷款失败
|
|
|
|
|
+ OPERATORID int64 `json:"operatorid" xorm:"OPERATORID"` // 登录账号(LoginID)
|
|
|
|
|
+ UPDATETIME time.Time `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
|
|
|
|
|
+ CLIENTORDERTIME time.Time `json:"clientordertime" xorm:"CLIENTORDERTIME"` // 客户端委托时间
|
|
|
|
|
+ CLIENTTICKET string `json:"clientticket" xorm:"CLIENTTICKET"` // 客户端流水号
|
|
|
|
|
+ UUID string `json:"uuid" xorm:"UUID"` // 发起端唯一id
|
|
|
|
|
+ CLIENTTYPE int32 `json:"clienttype" xorm:"CLIENTTYPE"` // 客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江)
|
|
|
|
|
+ RETCODE int32 `json:"retcode" xorm:"RETCODE"` // 错误代码
|
|
|
|
|
+ TRADEPROPERTY int32 `json:"tradeproperty" xorm:"TRADEPROPERTY"` // 交易属性
|
|
|
|
|
+ LISTINGSELECTTYPE int32 `json:"listingselecttype" xorm:"LISTINGSELECTTYPE"` // 挂牌点选类型 - 1:挂牌 2:摘牌 3:先摘后挂
|
|
|
|
|
+ DELISTINGTYPE int32 `json:"delistingtype" xorm:"DELISTINGTYPE"` // 摘牌类型 - 1:价格最优 2:点选成交
|
|
|
|
|
+ MARGINALGORITHM int32 `json:"marginalgorithm" xorm:"MARGINALGORITHM"` // 保证金收取方式 1:比率 2:固定
|
|
|
|
|
+ MARGINVALUE float64 `json:"marginvalue" xorm:"MARGINVALUE"` // 即市保证金设置值
|
|
|
|
|
+ OPENFEEALGORITHM int32 `json:"openfeealgorithm" xorm:"OPENFEEALGORITHM"` // 建仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ OPENMEMBERCHARGEVALUE float64 `json:"openmemberchargevalue" xorm:"OPENMEMBERCHARGEVALUE"` // 建仓会员手续费设置值
|
|
|
|
|
+ OPENEXCHAGECHARGEVALUE float64 `json:"openexchagechargevalue" xorm:"OPENEXCHAGECHARGEVALUE"` // 建仓交易所手续费设置值
|
|
|
|
|
+ CLOSEFEEALGORITHM int32 `json:"closefeealgorithm" xorm:"CLOSEFEEALGORITHM"` // 平仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ CLOSEMEMBERCHARGEVALUE float64 `json:"closememberchargevalue" xorm:"CLOSEMEMBERCHARGEVALUE"` // 平仓会员手续费设置值
|
|
|
|
|
+ CLOSEEXCHAGECHARGEVALUE float64 `json:"closeexchagechargevalue" xorm:"CLOSEEXCHAGECHARGEVALUE"` // 平仓交易所手续费设置值
|
|
|
|
|
+ OPTIONTYPE int32 `json:"optiontype" xorm:"OPTIONTYPE"` // 期权类型 - 1:认购(看涨) 2:认沽(看跌)
|
|
|
|
|
+ PREMIUM float64 `json:"premium" xorm:"PREMIUM"` // 权利金
|
|
|
|
|
+ ISPREEXERCISE int32 `json:"ispreexercise" xorm:"ISPREEXERCISE"` // 是否预申报- 0:否 1:是
|
|
|
|
|
+ PREEXERCISEPRICE float64 `json:"preexerciseprice" xorm:"PREEXERCISEPRICE"` // 预申报价格
|
|
|
|
|
+ ISCONFIRMEXERCISE int32 `json:"isconfirmexercise" xorm:"ISCONFIRMEXERCISE"` // 是否确认行权- 0:否 1:是
|
|
|
|
|
+ QUOTEID int64 `json:"quoteid" xorm:"QUOTEID"` // 报价单ID
|
|
|
|
|
+ GCACCOUNTID int64 `json:"gcaccountid" xorm:"GCACCOUNTID"` // 账户ID[合约币种]
|
|
|
|
|
+ SESSIONID int64 `json:"sessionid" xorm:"SESSIONID"` // 会话ID
|
|
|
|
|
+ FREEZEQTY int64 `json:"freezeqty" xorm:"FREEZEQTY"` // 冻结数量
|
|
|
|
|
+ AMOUNTFLAG int32 `json:"amountflag" xorm:"AMOUNTFLAG"` // 资金标识 - 1:余额 2;待付
|
|
|
|
|
+ ORDERFLAG int32 `json:"orderflag" xorm:"ORDERFLAG"` // 委托标识 - 1:按量 2:按金额
|
|
|
|
|
+
|
|
|
|
|
+ GOODSCODE string `json:"goodscode" xorm:"GOODSCODE"` // 期货合约代码(内部)
|
|
|
|
|
+ GOODSNAME string `json:"goodsname" xorm:"GOODSNAME"` // 期货合约名称
|
|
|
|
|
+ Goodsnamedisplay string `json:"goodsnamedisplay" xorm:"GOODSNAMEDISPLAY"` // 商品名称
|
|
|
|
|
+ PRESALEPRICE float64 `json:"presaleprice" xorm:"PRESALEPRICE"` // 发售价(49)
|
|
|
|
|
+
|
|
|
|
|
+ Userid int `json:"-" xorm:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
|
|
+ IsHis bool `json:"-" xorm:"-" form:"ishis"` // 是否历史查询
|
|
|
|
|
+ BeginDate string `json:"-" xorm:"-" form:"begindate"` // 开始交易日
|
|
|
|
|
+ EndDate string `json:"-" xorm:"-" form:"enddate"` // 结束交易日
|
|
|
|
|
+
|
|
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrder) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrder) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "GOODSNAMEDISPLAY",
|
|
|
|
|
+ g.presaleprice,
|
|
|
|
|
+
|
|
|
|
|
+ t.cancelorderid,
|
|
|
|
|
+ t.relatedid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.accountid,
|
|
|
|
|
+ t.marketmaxsub,
|
|
|
|
|
+ t.tradeqty,
|
|
|
|
|
+ t.cancelqty,
|
|
|
|
|
+ t.opentradeqty,
|
|
|
|
|
+ t.closetradeqty,
|
|
|
|
|
+ t.freezemargin,
|
|
|
|
|
+ t.unfreezemargin,
|
|
|
|
|
+ t.freezecharge,
|
|
|
|
|
+ t.unfreezecharge,
|
|
|
|
|
+ t.openfreezecharge,
|
|
|
|
|
+ t.closefreezecharge,
|
|
|
|
|
+ t.openunfreezecharge,
|
|
|
|
|
+ t.closeunfreezecharge,
|
|
|
|
|
+ t.validtype,
|
|
|
|
|
+ t.validtime,
|
|
|
|
|
+ t.operatetype,
|
|
|
|
|
+ t.orderstatus,
|
|
|
|
|
+ t.operatorid,
|
|
|
|
|
+ t.updatetime,
|
|
|
|
|
+ t.tradeproperty,
|
|
|
|
|
+ t.marginalgorithm,
|
|
|
|
|
+ t.marginvalue,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.gcaccountid,
|
|
|
|
|
+ t.amountflag,
|
|
|
|
|
+ t.orderflag,
|
|
|
|
|
+ to_char(t.ordertime, 'yyyy-mm-dd hh24:mi:ss') ORDERTIME,
|
|
|
|
|
+ to_char(t.orderid) ORDERID,
|
|
|
|
|
+ t.orderqty,
|
|
|
|
|
+ t.orderprice
|
|
|
|
|
+
|
|
|
|
|
+ from trade_orderdetail t
|
|
|
|
|
+
|
|
|
|
|
+ inner join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join taaccount ta
|
|
|
|
|
+ on t.accountid = ta.accountid
|
|
|
|
|
+
|
|
|
|
|
+ where t.marketid = 49201
|
|
|
|
|
+ and t.buyorsell = 1
|
|
|
|
|
+ and ta.userid = %v
|
|
|
|
|
+ order by t.ordertime desc
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.FormatParam(r.Userid)
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrder) buildSql_His() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "GOODSNAMEDISPLAY",
|
|
|
|
|
+ g.presaleprice,
|
|
|
|
|
+
|
|
|
|
|
+ t.cancelorderid,
|
|
|
|
|
+ t.relatedid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.accountid,
|
|
|
|
|
+ t.marketmaxsub,
|
|
|
|
|
+ t.tradeqty,
|
|
|
|
|
+ t.cancelqty,
|
|
|
|
|
+ t.opentradeqty,
|
|
|
|
|
+ t.closetradeqty,
|
|
|
|
|
+ t.freezemargin,
|
|
|
|
|
+ t.unfreezemargin,
|
|
|
|
|
+ t.freezecharge,
|
|
|
|
|
+ t.unfreezecharge,
|
|
|
|
|
+ t.openfreezecharge,
|
|
|
|
|
+ t.closefreezecharge,
|
|
|
|
|
+ t.openunfreezecharge,
|
|
|
|
|
+ t.closeunfreezecharge,
|
|
|
|
|
+ t.validtype,
|
|
|
|
|
+ t.validtime,
|
|
|
|
|
+ t.operatetype,
|
|
|
|
|
+ t.orderstatus,
|
|
|
|
|
+ t.operatorid,
|
|
|
|
|
+ t.updatetime,
|
|
|
|
|
+ t.tradeproperty,
|
|
|
|
|
+ t.marginalgorithm,
|
|
|
|
|
+ t.marginvalue,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.gcaccountid,
|
|
|
|
|
+ t.amountflag,
|
|
|
|
|
+ t.orderflag,
|
|
|
|
|
+ to_char(t.ordertime, 'yyyy-mm-dd hh24:mi:ss') ORDERTIME,
|
|
|
|
|
+ to_char(t.orderid) ORDERID,
|
|
|
|
|
+ t.orderqty,
|
|
|
|
|
+ t.orderprice
|
|
|
|
|
+
|
|
|
|
|
+ from HIS_Trade_OrderDetail t
|
|
|
|
|
+
|
|
|
|
|
+ inner join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join taaccount ta
|
|
|
|
|
+ on t.accountid = ta.accountid
|
|
|
|
|
+
|
|
|
|
|
+ where t.marketid = 49201
|
|
|
|
|
+ and t.buyorsell = 1
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.And("ta.userid", r.Userid)
|
|
|
|
|
+ if r.BeginDate != "" && r.EndDate != "" {
|
|
|
|
|
+ sqlId.JoinFormat(" AND (t.TRADEDATE >= '%v' AND t.TRADEDATE <= '%v')", r.BeginDate, r.EndDate)
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlId.OrderByDesc("t.ordertime")
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeOrder) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
+ sData := make([]MineTradeOrder, 0)
|
|
|
|
|
+ sql := ""
|
|
|
|
|
+ if r.IsHis {
|
|
|
|
|
+ sql = r.buildSql_His()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sql = r.buildSql()
|
|
|
|
|
+ }
|
|
|
|
|
+ err := db.GetEngine().SQL(sql).Find(&sData)
|
|
|
|
|
+ total := 0
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ total = sData[i].Total
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// MineTradeTradeDetail 我的订单-转让成交
|
|
|
|
|
+type MineTradeTradeDetail struct {
|
|
|
|
|
+ TRADEID string `json:"tradeid" xorm:"TRADEID"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL"` // 方向 - 0:买 1:卖
|
|
|
|
|
+ ORDERID int64 `json:"orderid" xorm:"ORDERID"` // 委托单号
|
|
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
|
|
|
|
|
+ ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账户ID[报价币种]
|
|
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID
|
|
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
|
|
|
|
|
+ MEMBERUSERID int64 `json:"memberuserid" xorm:"MEMBERUSERID"` // 会员id 个人投资者 需要填写
|
|
|
|
|
+ MATCHACCOUNTID int64 `json:"matchaccountid" xorm:"MATCHACCOUNTID"` // 对手账号id
|
|
|
|
|
+ TRADETIME string `json:"tradetime" xorm:"TRADETIME"` // 成交时间
|
|
|
|
|
+ TRADEPRICE float64 `json:"tradeprice" xorm:"TRADEPRICE"` // 成交价格
|
|
|
|
|
+ TRADEQTY int64 `json:"tradeqty" xorm:"TRADEQTY"` // 成交数量
|
|
|
|
|
+ TRADEAMOUNT float64 `json:"tradeamount" xorm:"TRADEAMOUNT"` // 成交金额[账户币种,用于所有权]
|
|
|
|
|
+ CLOSEPL float64 `json:"closepl" xorm:"CLOSEPL"` // 平仓盈亏
|
|
|
|
|
+ INTCLOSEPL int64 `json:"intclosepl" xorm:"INTCLOSEPL"` // 整型盈亏(用于交易结算试算平衡-收益权)
|
|
|
|
|
+ OPENCHARGE float64 `json:"opencharge" xorm:"OPENCHARGE"` // 建仓手续费(支付总手续费=(交易所比率+会员比率)*成交金额)
|
|
|
|
|
+ CLOSECHARGE float64 `json:"closecharge" xorm:"CLOSECHARGE"` // 平仓手续费(支付总手续费=(交易所比率+会员比率)*成交金额)
|
|
|
|
|
+ TRADETYPE int32 `json:"tradetype" xorm:"TRADETYPE"` // 成交类别 - 1:正常委托成交 2:定向做市成交(接单) 3:交割协议平仓成交 4:交割减仓成交 5:到期强平成交 6:风控斩仓成交 7:协议平仓(管理端)成交 8:仓单转持仓成交 9: 交割协议转让成交 10:受托竞价成交(接单) 11:协议转让成交 12:系统强行平仓 13:期权违约平仓
|
|
|
|
|
+ BUILDTYPE int32 `json:"buildtype" xorm:"BUILDTYPE"` // 委托单据类型 1:建仓 2:平仓 3:先平后建
|
|
|
|
|
+ OPENQTY int64 `json:"openqty" xorm:"OPENQTY"` // 开仓数量(先建后平操作 需要记录)
|
|
|
|
|
+ CLOSEQTY int64 `json:"closeqty" xorm:"CLOSEQTY"` // 平仓数量(先建后平操作 需要记录)
|
|
|
|
|
+ STATUS int32 `json:"status" xorm:"STATUS"` // 处理状态 - 1:待处理 2:已处理 3:处理失败
|
|
|
|
|
+ ISRECKONED int32 `json:"isreckoned" xorm:"ISRECKONED"` // 是否结算 - 0:未结算 1:已结算
|
|
|
|
|
+ TRADEPROPERTY int32 `json:"tradeproperty" xorm:"TRADEPROPERTY"` // 交易属性
|
|
|
|
|
+ OPENFEEALGORITHM int32 `json:"openfeealgorithm" xorm:"OPENFEEALGORITHM"` // 建仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ OPENMEMBERCHARGEVALUE float64 `json:"openmemberchargevalue" xorm:"OPENMEMBERCHARGEVALUE"` // 建仓会员手续费设置值
|
|
|
|
|
+ OPENEXCHAGECHARGEVALUE float64 `json:"openexchagechargevalue" xorm:"OPENEXCHAGECHARGEVALUE"` // 建仓交易所手续费设置值
|
|
|
|
|
+ CLOSEFEEALGORITHM int32 `json:"closefeealgorithm" xorm:"CLOSEFEEALGORITHM"` // 平仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ CLOSEMEMBERCHARGEVALUE float64 `json:"closememberchargevalue" xorm:"CLOSEMEMBERCHARGEVALUE"` // 平仓会员手续费设置值
|
|
|
|
|
+ CLOSEEXCHAGECHARGEVALUE float64 `json:"closeexchagechargevalue" xorm:"CLOSEEXCHAGECHARGEVALUE"` // 平仓交易所手续费设置值
|
|
|
|
|
+ OPTIONTYPE int32 `json:"optiontype" xorm:"OPTIONTYPE"` // 期权类型 - 1:认购(看涨) 2:认沽(看跌)
|
|
|
|
|
+ PREMIUM float64 `json:"premium" xorm:"PREMIUM"` // 权利金 - [持仓单的权利金]
|
|
|
|
|
+ ISPREEXERCISE int32 `json:"ispreexercise" xorm:"ISPREEXERCISE"` // 是否预申报- 0:否 1:是
|
|
|
|
|
+ PREEXERCISEPRICE float64 `json:"preexerciseprice" xorm:"PREEXERCISEPRICE"` // 预申报价格
|
|
|
|
|
+ ISCONFIRMEXERCISE int32 `json:"isconfirmexercise" xorm:"ISCONFIRMEXERCISE"` // 是否确认行权- 0:否 1:是
|
|
|
|
|
+ ISMAIN int32 `json:"ismain" xorm:"ISMAIN"` // 是否主单 - 0:不是 1:是
|
|
|
|
|
+ PERFORMANCEPLANID int64 `json:"performanceplanid" xorm:"PERFORMANCEPLANID"` // 履约计划ID[期权]
|
|
|
|
|
+ PERFORMANCESTATUS int32 `json:"performancestatus" xorm:"PERFORMANCESTATUS"` // 履约状态[期权] - 0:无履约 1:未履约 2:履约中 3:履约完成
|
|
|
|
|
+ CREDITAMOUNT float64 `json:"creditamount" xorm:"CREDITAMOUNT"` // 授信金额
|
|
|
|
|
+ GCACCOUNTID int64 `json:"gcaccountid" xorm:"GCACCOUNTID"` // 账户ID[合约币种]
|
|
|
|
|
+ CLOSEPL2 float64 `json:"closepl2" xorm:"CLOSEPL2"` // 平仓盈亏[逐笔]
|
|
|
|
|
+ RELATEDOUTTRADEID int64 `json:"relatedouttradeid" xorm:"RELATEDOUTTRADEID"` // 关联外部成交单ID
|
|
|
|
|
+
|
|
|
|
|
+ GOODSCODE string `json:"goodscode" xorm:"GOODSCODE"` // 期货合约代码(内部)
|
|
|
|
|
+ GOODSNAME string `json:"goodsname" xorm:"GOODSNAME"` // 期货合约名称
|
|
|
|
|
+ Goodsnamedisplay string `json:"goodsnamedisplay" xorm:"GOODSNAMEDISPLAY"` // 商品名称
|
|
|
|
|
+ PRESALEPRICE float64 `json:"presaleprice" xorm:"PRESALEPRICE"` // 发售价(49)
|
|
|
|
|
+
|
|
|
|
|
+ Userid int `json:"-" xorm:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
|
|
+ IsHis bool `json:"-" xorm:"-" form:"ishis"` // 是否历史查询
|
|
|
|
|
+ BeginDate string `json:"-" xorm:"-" form:"begindate"` // 开始交易日
|
|
|
|
|
+ EndDate string `json:"-" xorm:"-" form:"enddate"` // 结束交易日
|
|
|
|
|
+
|
|
|
|
|
+ ACCOUNTNAME string `json:"accountname" xorm:"ACCOUNTNAME"` // 账户名称(机构名称)
|
|
|
|
|
+
|
|
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeTradeDetail) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeTradeDetail) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "goodsnamedisplay",
|
|
|
|
|
+ g.presaleprice,
|
|
|
|
|
+ ua.accountname,
|
|
|
|
|
+
|
|
|
|
|
+ to_char(t.tradeid) TRADEID,
|
|
|
|
|
+ t.buyorsell,
|
|
|
|
|
+ t.orderid,
|
|
|
|
|
+ t.tradedate,
|
|
|
|
|
+ t.accountid,
|
|
|
|
|
+ t.goodsid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.memberuserid,
|
|
|
|
|
+ t.matchaccountid,
|
|
|
|
|
+ to_char(t.tradetime, 'yyyy-mm-dd hh24:mi:ss') TRADETIME,
|
|
|
|
|
+ t.tradeprice,
|
|
|
|
|
+ t.tradeqty,
|
|
|
|
|
+ t.tradeamount,
|
|
|
|
|
+ t.closepl,
|
|
|
|
|
+ t.intclosepl,
|
|
|
|
|
+ t.opencharge,
|
|
|
|
|
+ t.closecharge,
|
|
|
|
|
+ t.tradetype,
|
|
|
|
|
+ t.buildtype,
|
|
|
|
|
+ t.openqty,
|
|
|
|
|
+ t.closeqty,
|
|
|
|
|
+ t.status,
|
|
|
|
|
+ t.isreckoned,
|
|
|
|
|
+ t.tradeproperty,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.optiontype,
|
|
|
|
|
+ t.premium,
|
|
|
|
|
+ t.ispreexercise,
|
|
|
|
|
+ t.preexerciseprice,
|
|
|
|
|
+ t.isconfirmexercise,
|
|
|
|
|
+ t.ismain,
|
|
|
|
|
+ t.performanceplanid,
|
|
|
|
|
+ t.performancestatus,
|
|
|
|
|
+ t.creditamount,
|
|
|
|
|
+ t.gcaccountid,
|
|
|
|
|
+ t.closepl2,
|
|
|
|
|
+ t.relatedouttradeid
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ from trade_tradedetail t
|
|
|
|
|
+
|
|
|
|
|
+ inner join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join taaccount ta
|
|
|
|
|
+ on t.accountid = ta.accountid
|
|
|
|
|
+
|
|
|
|
|
+ left join taaccount ta2
|
|
|
|
|
+ on t.matchaccountid = ta2.accountid
|
|
|
|
|
+
|
|
|
|
|
+ left join useraccount ua
|
|
|
|
|
+ on ua.userid = ta2.userid
|
|
|
|
|
+
|
|
|
|
|
+ where t.marketid = 49201
|
|
|
|
|
+ and ta.userid = %v
|
|
|
|
|
+
|
|
|
|
|
+ order by t.tradetime desc
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.FormatParam(r.Userid)
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeTradeDetail) buildSql_His() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode,
|
|
|
|
|
+ g.goodsname,
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname "goodsnamedisplay",
|
|
|
|
|
+ g.presaleprice,
|
|
|
|
|
+ ua.accountname,
|
|
|
|
|
+
|
|
|
|
|
+ to_char(t.tradeid) TRADEID,
|
|
|
|
|
+ t.buyorsell,
|
|
|
|
|
+ t.orderid,
|
|
|
|
|
+ t.tradedate,
|
|
|
|
|
+ t.accountid,
|
|
|
|
|
+ t.goodsid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.memberuserid,
|
|
|
|
|
+ t.matchaccountid,
|
|
|
|
|
+ to_char(t.tradetime, 'yyyy-mm-dd hh24:mi:ss') TRADETIME,
|
|
|
|
|
+ t.tradeprice,
|
|
|
|
|
+ t.tradeqty,
|
|
|
|
|
+ t.tradeamount,
|
|
|
|
|
+ t.closepl,
|
|
|
|
|
+ t.intclosepl,
|
|
|
|
|
+ t.opencharge,
|
|
|
|
|
+ t.closecharge,
|
|
|
|
|
+ t.tradetype,
|
|
|
|
|
+ t.buildtype,
|
|
|
|
|
+ t.openqty,
|
|
|
|
|
+ t.closeqty,
|
|
|
|
|
+ t.status,
|
|
|
|
|
+ t.isreckoned,
|
|
|
|
|
+ t.tradeproperty,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.optiontype,
|
|
|
|
|
+ t.premium,
|
|
|
|
|
+ t.ispreexercise,
|
|
|
|
|
+ t.preexerciseprice,
|
|
|
|
|
+ t.isconfirmexercise,
|
|
|
|
|
+ t.ismain,
|
|
|
|
|
+ t.performanceplanid,
|
|
|
|
|
+ t.performancestatus,
|
|
|
|
|
+ t.creditamount,
|
|
|
|
|
+ t.gcaccountid,
|
|
|
|
|
+ t.closepl2,
|
|
|
|
|
+ t.relatedouttradeid
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ from HIS_Trade_TradeDetail t
|
|
|
|
|
+
|
|
|
|
|
+ inner join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+
|
|
|
|
|
+ inner join taaccount ta
|
|
|
|
|
+ on t.accountid = ta.accountid
|
|
|
|
|
+
|
|
|
|
|
+ left join taaccount ta2
|
|
|
|
|
+ on t.matchaccountid = ta2.accountid
|
|
|
|
|
+
|
|
|
|
|
+ left join useraccount ua
|
|
|
|
|
+ on ua.userid = ta2.userid
|
|
|
|
|
+
|
|
|
|
|
+ where t.marketid = 49201 and t.isvaliddata = 1
|
|
|
|
|
+ `
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.And("ta.userid", r.Userid)
|
|
|
|
|
+ if r.BeginDate != "" && r.EndDate != "" {
|
|
|
|
|
+ sqlId.JoinFormat(" AND (t.TRADEDATE >= '%v' AND t.TRADEDATE <= '%v')", r.BeginDate, r.EndDate)
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlId.OrderByDesc("t.tradetime")
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *MineTradeTradeDetail) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
+ sData := make([]MineTradeTradeDetail, 0)
|
|
|
|
|
+ sql := ""
|
|
|
|
|
+ if r.IsHis {
|
|
|
|
|
+ sql = r.buildSql_His()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sql = r.buildSql()
|
|
|
|
|
+ }
|
|
|
|
|
+ err := db.GetEngine().SQL(sql).Find(&sData)
|
|
|
|
|
+ total := 0
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ total = sData[i].Total
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
|
|
+}
|