|
|
@@ -479,3 +479,104 @@ func (r *WrPosition) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
|
return sData, err
|
|
|
}
|
|
|
+
|
|
|
+// WrOrderDetail 仓单贸易委托单
|
|
|
+type WrOrderDetail struct {
|
|
|
+ HASWR int32 `json:"haswr" xorm:"HASWR" form:"haswr"` // 是否有仓单-卖方 - 0:无仓单 1:有仓单
|
|
|
+ WRTRADEORDERID string `json:"wrtradeorderid" xorm:"WRTRADEORDERID"` // 仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE" form:"tradedate"` // 交易日(yyyyMMdd)
|
|
|
+ WRTRADETYPE int32 `json:"wrtradetype" xorm:"WRTRADETYPE" form:"wrtradetype"` // 仓单贸易类型 - 1:挂牌 2:摘牌 3:提货卖(文化中国) 4:提货买(文化中国)
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL" form:"buyorsell"` // 买卖 - 0:买 1:卖(挂牌类型 买为采购 卖为销售)
|
|
|
+ MARKETID int64 `json:"marketid" xorm:"MARKETID" form:"marketid"` // 市场ID
|
|
|
+ USERID int64 `json:"userid" xorm:"USERID" form:"userid"` // 用户ID
|
|
|
+ WRFACTORTYPEID int64 `json:"wrfactortypeid" xorm:"WRFACTORTYPEID"` // 仓单要素类型ID/商品ID(77)
|
|
|
+ ORDERQTY float64 `json:"orderqty" xorm:"ORDERQTY" form:"orderqty"` // 委托数量
|
|
|
+ TRADEQTY float64 `json:"tradeqty" xorm:"TRADEQTY" form:"tradeqty"` // 成交数量
|
|
|
+ CANCELQTY float64 `json:"cancelqty" xorm:"CANCELQTY" form:"cancelqty"` // 撤销数量
|
|
|
+ WRPRICETYPE int32 `json:"wrpricetype" xorm:"WRPRICETYPE" form:"wrpricetype"` // 价格方式 - 1:固定价 2-浮动价 - [挂牌]
|
|
|
+ FIXEDPRICE float64 `json:"fixedprice" xorm:"FIXEDPRICE" form:"fixedprice"` // 固定价格 - [挂牌]
|
|
|
+ PRICEMOVE float64 `json:"pricemove" xorm:"PRICEMOVE" form:"pricemove"` // 升贴水(浮动价时填写) - [挂牌]
|
|
|
+ TRADEPRICE float64 `json:"tradeprice" xorm:"TRADEPRICE" form:"tradeprice"` // 成交价格 - [摘牌] (浮动价 ((商品1价格*商品1价格系数+升贴水)* 商品1重量系数 + 商品2价格*商品2价格系数+商品2升贴水)* 商品2重量系数 ...)* 委托单价格系数 + 委托单升贴水)
|
|
|
+ ORDERTIME string `json:"ordertime" xorm:"ORDERTIME" form:"ordertime"` // 委托时间(挂牌时间)
|
|
|
+ WRTRADEORDERSTATUS int32 `json:"wrtradeorderstatus" xorm:"WRTRADEORDERSTATUS"` // 委托状态 - 1:委托请求 2:待冻结 3:委托成功 4:委托失败 5:配对成功 6:已撤 7:已成 8:成交失败 9:委托拒绝 10:挂牌部分成交 11:仓单生成失败 12:首付扣款失败 13:履约失败 14:撤单解冻贷款失败 15:部成部撤
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"'GOODSID'"` // 期货商品id
|
|
|
+ GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 期货合约
|
|
|
+ FUTUPRICEMOVE float64 `json:"futupricemove" xorm:"'FUTUPRICEMOVE'"` // 期货升贴水
|
|
|
+ DELIVERYMONTH string `json:"deliverymonth" xorm:"'DELIVERYMONTH'"` // 交收月
|
|
|
+ Wr2FactorType `xorm:"extends"`
|
|
|
+
|
|
|
+ FUTUSHOW string `json:"futushow"` // 期货合约/升贴水
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrOrderDetail) calc() {
|
|
|
+ if r.GOODSCODE == "" {
|
|
|
+ r.FUTUSHOW = "-"
|
|
|
+ } else {
|
|
|
+ r.FUTUSHOW = fmt.Sprintf("%v//%.2f", r.GOODSCODE, r.FUTUPRICEMOVE)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrOrderDetail) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = "with tmp as" +
|
|
|
+ " (select t.wrfactortypeid," +
|
|
|
+ " t.wrfactortypename," +
|
|
|
+ " t.wrstandardid," +
|
|
|
+ " t.deliverygoodsid," +
|
|
|
+ " g.deliverygoodscode," +
|
|
|
+ " g.deliverygoodsname," +
|
|
|
+ " w.wrstandardcode," +
|
|
|
+ " w.wrstandardname," +
|
|
|
+ " h.warehousecode," +
|
|
|
+ " h.warehousename," +
|
|
|
+ " e.enumdicname," +
|
|
|
+ " w.wrstandardname || '-' || t.wrfactortypename as wrtypename" +
|
|
|
+ " from wrfactortype t" +
|
|
|
+ " left join deliverygoods g" +
|
|
|
+ " on t.deliverygoodsid = g.deliverygoodsid" +
|
|
|
+ " left join wrstandard w" +
|
|
|
+ " on t.wrstandardid = w.wrstandardid" +
|
|
|
+ " left join warehouseinfo h" +
|
|
|
+ " on t.warehouseid = h.autoid" +
|
|
|
+ " left join enumdicitem e on w.unitid = e.enumitemname and e.enumdiccode='goodsunit')" +
|
|
|
+ "select t.HASWR," +
|
|
|
+ " t.WRTRADEORDERID," +
|
|
|
+ " t.TRADEDATE," +
|
|
|
+ " t.DELIVERYMONTH," +
|
|
|
+ " t.WRTRADETYPE," +
|
|
|
+ " t.BUYORSELL," +
|
|
|
+ " t.MARKETID," +
|
|
|
+ " t.USERID," +
|
|
|
+ " t.WRFACTORTYPEID," +
|
|
|
+ " t.ORDERQTY," +
|
|
|
+ " t.TRADEQTY," +
|
|
|
+ " t.CANCELQTY," +
|
|
|
+ " t.WRPRICETYPE," +
|
|
|
+ " t.FIXEDPRICE," +
|
|
|
+ " t.PRICEMOVE," +
|
|
|
+ " t.TRADEPRICE," +
|
|
|
+ " to_char(t.ORDERTIME,'yyyy-mm-dd hh24:mi:ss') ORDERTIME," +
|
|
|
+ " t.WRTRADEORDERSTATUS," +
|
|
|
+ " c.GOODSID," +
|
|
|
+ " c.GOODSCODE," +
|
|
|
+ " c.pricemove FUTUPRICEMOVE," +
|
|
|
+ " k.*" +
|
|
|
+ " from wrtrade_orderdetail t" +
|
|
|
+ " left join wrtrade_goodsconfig c" +
|
|
|
+ " on t.wrtradeorderid = c.wrtradeorderid" +
|
|
|
+ " left join tmp k" +
|
|
|
+ " on t.wrfactortypeid = k.wrfactortypeid" +
|
|
|
+ " where t.WRTRADETYPE = 1"
|
|
|
+ sqlId.And("t.USERID", r.USERID)
|
|
|
+ sqlId.And("t.haswr", r.HASWR)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取仓单贸易委托单
|
|
|
+func (r *WrOrderDetail) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]WrOrderDetail, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|