|
@@ -54,41 +54,44 @@ func (r *WrOrderQuote) calc() {
|
|
|
func (r *WrOrderQuote) buildSqlFixedPrice() string {
|
|
func (r *WrOrderQuote) buildSqlFixedPrice() string {
|
|
|
var sqlId utils.SQLVal = "with buyQuote as" +
|
|
var sqlId utils.SQLVal = "with buyQuote as" +
|
|
|
" (" +
|
|
" (" +
|
|
|
- " select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice buyPrice, sum(a.orderqty) buyQty" +
|
|
|
|
|
|
|
+ " select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice buyPrice, sum(a.orderqty) buyQty, a.deliverymonth" +
|
|
|
" from (select t.wrfactortypeid," +
|
|
" from (select t.wrfactortypeid," +
|
|
|
" t.marketid," +
|
|
" t.marketid," +
|
|
|
" t.buyorsell," +
|
|
" t.buyorsell," +
|
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
|
" t.fixedprice," +
|
|
" t.fixedprice," +
|
|
|
- " rank() over(partition by t.wrfactortypeid order by t.fixedprice desc) cnt" +
|
|
|
|
|
|
|
+ " nvl(t.deliverymonth,'0') deliverymonth," +
|
|
|
|
|
+ " rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0') order by t.fixedprice desc) cnt" +
|
|
|
" from wrtrade_orderdetail t" +
|
|
" from wrtrade_orderdetail t" +
|
|
|
" where t.wrtradetype = 1 and t.buyorsell = 0 and t.wrtradeorderstatus in(3,10) %v" +
|
|
" where t.wrtradetype = 1 and t.buyorsell = 0 and t.wrtradeorderstatus in(3,10) %v" +
|
|
|
" ) a" +
|
|
" ) a" +
|
|
|
" where a.cnt = 1" +
|
|
" where a.cnt = 1" +
|
|
|
- " group by a.wrfactortypeid, a.fixedprice)," +
|
|
|
|
|
|
|
+ " group by a.wrfactortypeid, a.fixedprice, a.deliverymonth)," +
|
|
|
"sellQuote as" +
|
|
"sellQuote as" +
|
|
|
" (" +
|
|
" (" +
|
|
|
- " select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice sellPrice, sum(a.orderqty) sellQty" +
|
|
|
|
|
|
|
+ " select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice sellPrice, sum(a.orderqty) sellQty, a.deliverymonth" +
|
|
|
" from (select t.wrfactortypeid," +
|
|
" from (select t.wrfactortypeid," +
|
|
|
" t.marketid," +
|
|
" t.marketid," +
|
|
|
" t.buyorsell," +
|
|
" t.buyorsell," +
|
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
|
" t.fixedprice," +
|
|
" t.fixedprice," +
|
|
|
- " rank() over(partition by t.wrfactortypeid order by t.fixedprice asc) cnt" +
|
|
|
|
|
|
|
+ " nvl(t.deliverymonth,'0') deliverymonth," +
|
|
|
|
|
+ " rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0') order by t.fixedprice asc) cnt" +
|
|
|
" from wrtrade_orderdetail t" +
|
|
" from wrtrade_orderdetail t" +
|
|
|
" where t.wrtradetype = 1 and t.buyorsell = 1 and t.wrtradeorderstatus in(3,10) %v " +
|
|
" where t.wrtradetype = 1 and t.buyorsell = 1 and t.wrtradeorderstatus in(3,10) %v " +
|
|
|
" ) a" +
|
|
" ) a" +
|
|
|
" where a.cnt = 1" +
|
|
" where a.cnt = 1" +
|
|
|
- " group by a.wrfactortypeid, a.fixedprice)," +
|
|
|
|
|
|
|
+ " group by a.wrfactortypeid, a.fixedprice, a.deliverymonth)," +
|
|
|
"wrQuote as (" +
|
|
"wrQuote as (" +
|
|
|
" select nvl(k1.wrfactortypeid, k2.wrfactortypeid) wrfactortypeid," +
|
|
" select nvl(k1.wrfactortypeid, k2.wrfactortypeid) wrfactortypeid," +
|
|
|
|
|
+ " nvl(k1.deliverymonth, k2.deliverymonth) deliverymonth," +
|
|
|
" k1.buyPrice," +
|
|
" k1.buyPrice," +
|
|
|
" k1.buyQty," +
|
|
" k1.buyQty," +
|
|
|
" k2.sellPrice," +
|
|
" k2.sellPrice," +
|
|
|
" k2.sellQty" +
|
|
" k2.sellQty" +
|
|
|
" from buyQuote k1" +
|
|
" from buyQuote k1" +
|
|
|
" full join sellQuote k2" +
|
|
" full join sellQuote k2" +
|
|
|
- " on k1.wrfactortypeid = k2.wrfactortypeid" +
|
|
|
|
|
|
|
+ " on k1.wrfactortypeid = k2.wrfactortypeid and k1.deliverymonth = k2.deliverymonth" +
|
|
|
")" +
|
|
")" +
|
|
|
"select k.*," +
|
|
"select k.*," +
|
|
|
" w.wrfactortypename," +
|
|
" w.wrfactortypename," +
|
|
@@ -148,7 +151,7 @@ func (r *WrOrderQuote) buildSqlPriceMove() string {
|
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
|
" t.pricemove," +
|
|
" t.pricemove," +
|
|
|
" t.wrtradeorderid," +
|
|
" t.wrtradeorderid," +
|
|
|
- " t.deliverymonth," +
|
|
|
|
|
|
|
+ " nvl(t.deliverymonth,'0') deliverymonth," +
|
|
|
" c.goodsid," +
|
|
" c.goodsid," +
|
|
|
" c.goodscode," +
|
|
" c.goodscode," +
|
|
|
" rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0'), c.goodsid order by t.pricemove desc) cnt" +
|
|
" rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0'), c.goodsid order by t.pricemove desc) cnt" +
|
|
@@ -171,7 +174,7 @@ func (r *WrOrderQuote) buildSqlPriceMove() string {
|
|
|
" t.buyorsell," +
|
|
" t.buyorsell," +
|
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
" t.orderqty - t.tradeqty as orderqty," +
|
|
|
" t.pricemove," +
|
|
" t.pricemove," +
|
|
|
- " t.deliverymonth," +
|
|
|
|
|
|
|
+ " nvl(t.deliverymonth,'0') deliverymonth," +
|
|
|
" c.goodsid," +
|
|
" c.goodsid," +
|
|
|
" c.goodscode," +
|
|
" c.goodscode," +
|
|
|
" rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0'), c.goodsid order by t.pricemove asc) cnt" +
|
|
" rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0'), c.goodsid order by t.pricemove asc) cnt" +
|
|
@@ -258,15 +261,16 @@ func (r *WrOrderQuote) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
|
|
|
// WrOrderQuoteDetail 行情大厅明细(买卖大厅)
|
|
// WrOrderQuoteDetail 行情大厅明细(买卖大厅)
|
|
|
type WrOrderQuoteDetail struct {
|
|
type WrOrderQuoteDetail struct {
|
|
|
- WRTRADEORDERID string `json:"wrtradeorderid" xorm:"WRTRADEORDERID"` // 仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)
|
|
|
|
|
- BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL" form:"buyorsell"` // 买卖 - 0:买 1:卖
|
|
|
|
|
- USERID int64 `json:"userid" xorm:"USERID" form:"userid"` // 购买方(销售方)用户ID
|
|
|
|
|
- QTY float64 `json:"orderqty" xorm:"qty"` // 买(卖)量(=委托量-成交量)
|
|
|
|
|
- PRICE float64 `json:"fixedprice" xorm:"price"` // 买(卖)价
|
|
|
|
|
- PRICEMOVE float64 `json:"pricemove" xorm:"PRICEMOVE"` // 买(卖)升贴水- 基差
|
|
|
|
|
- USERNAME string `json:"username" xorm:"'USERNAME'"` // 购买方(销售方)
|
|
|
|
|
- ENUMDICNAME string `json:"enumdicname" xorm:"'enumdicname'"` // 单位名称
|
|
|
|
|
- MINIVALUE int32 `json:"minivalue" xorm:"'MINIVALUE'"` // 现货商品最小变动值
|
|
|
|
|
|
|
+ WRTRADEORDERID string `json:"wrtradeorderid" xorm:"WRTRADEORDERID"` // 仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)
|
|
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL" form:"buyorsell"` // 买卖 - 0:买 1:卖
|
|
|
|
|
+ USERID int64 `json:"userid" xorm:"USERID" form:"userid"` // 购买方(销售方)用户ID
|
|
|
|
|
+ QTY float64 `json:"orderqty" xorm:"qty"` // 买(卖)量(=委托量-成交量)
|
|
|
|
|
+ PRICE float64 `json:"fixedprice" xorm:"price"` // 买(卖)价
|
|
|
|
|
+ PRICEMOVE float64 `json:"pricemove" xorm:"PRICEMOVE"` // 买(卖)升贴水- 基差
|
|
|
|
|
+ USERNAME string `json:"username" xorm:"'USERNAME'"` // 购买方(销售方)
|
|
|
|
|
+ ENUMDICNAME string `json:"enumdicname" xorm:"'enumdicname'"` // 单位名称
|
|
|
|
|
+ MINIVALUE int32 `json:"minivalue" xorm:"'MINIVALUE'"` // 现货商品最小变动值
|
|
|
|
|
+ DELIVERYMONTH string `json:"deliverymonth" xorm:"'DELIVERYMONTH'" form:"deliverymonth"` // 交收月
|
|
|
PageEx `xorm:"extends"`
|
|
PageEx `xorm:"extends"`
|
|
|
|
|
|
|
|
WRFACTORTYPEID int64 `json:"-" form:"wrfactortypeid"` // 仓单要素id
|
|
WRFACTORTYPEID int64 `json:"-" form:"wrfactortypeid"` // 仓单要素id
|
|
@@ -289,6 +293,7 @@ func (r *WrOrderQuoteDetail) buildSql() string {
|
|
|
" t.pricemove," +
|
|
" t.pricemove," +
|
|
|
" t.wrpricetype," +
|
|
" t.wrpricetype," +
|
|
|
" t.buyorsell," +
|
|
" t.buyorsell," +
|
|
|
|
|
+ " t.deliverymonth," +
|
|
|
" u.accountname as username," +
|
|
" u.accountname as username," +
|
|
|
" c.goodsid," +
|
|
" c.goodsid," +
|
|
|
" c.goodscode," +
|
|
" c.goodscode," +
|
|
@@ -311,6 +316,7 @@ func (r *WrOrderQuoteDetail) buildSql() string {
|
|
|
sqlId.AndEx("c.goodsid", r.GOODSID, r.GOODSID > 0)
|
|
sqlId.AndEx("c.goodsid", r.GOODSID, r.GOODSID > 0)
|
|
|
sqlId.And("t.buyorsell", r.BUYORSELL)
|
|
sqlId.And("t.buyorsell", r.BUYORSELL)
|
|
|
sqlId.AndEx("t.marketid", r.MarketId, r.MarketId > 0)
|
|
sqlId.AndEx("t.marketid", r.MarketId, r.MarketId > 0)
|
|
|
|
|
+ sqlId.AndEx("t.deliverymonth", r.DELIVERYMONTH, len(r.DELIVERYMONTH) > 0)
|
|
|
|
|
|
|
|
if r.BUYORSELL == 0 {
|
|
if r.BUYORSELL == 0 {
|
|
|
if r.WrPriceType == 1 {
|
|
if r.WrPriceType == 1 {
|
|
@@ -1636,3 +1642,53 @@ func (r *WrMarketTradeConfig) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
}
|
|
|
return sData, err
|
|
return sData, err
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// WrFtWrstandard 品类筛选列表
|
|
|
|
|
+type WrFtWrstandard struct {
|
|
|
|
|
+ WRSTANDARDID int64 `json:"wrstandardid"` // 现货商品ID
|
|
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode"` // 现货商品代码
|
|
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname"` // 商品名称
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// WrFtDeliveryGoods 品种筛选列表
|
|
|
|
|
+type WrFtDeliveryGoods struct {
|
|
|
|
|
+ DELIVERYGOODSID int32 `json:"deliverygoodsid"` // 品种ID
|
|
|
|
|
+ DELIVERYGOODSCODE string `json:"deliverygoodscode"` // 品种代码
|
|
|
|
|
+ DELIVERYGOODSNAME string `json:"deliverygoodsname"` // 品种名称
|
|
|
|
|
+ WDLST []WrFtWrstandard `json:"wdlst"` // 商品列表
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// GetDataEx 获取品种商品筛选列表
|
|
|
|
|
+func (r *WrFtDeliveryGoods) GetDataEx() (interface{}, error) {
|
|
|
|
|
+ sData := make([]WrFtDeliveryGoods, 0)
|
|
|
|
|
+ mg := ErmcpDeliveryGoods{}
|
|
|
|
|
+ sMgData, err := mg.GetData()
|
|
|
|
|
+ if err == nil {
|
|
|
|
|
+ mWd := Ermcp3Wrstandard{}
|
|
|
|
|
+ if d, er := mWd.GetDataEx(); er == nil {
|
|
|
|
|
+ if sMd, ok := d.([]Ermcp3Wrstandard); ok {
|
|
|
|
|
+ for _, v := range sMgData {
|
|
|
|
|
+ item := WrFtDeliveryGoods{
|
|
|
|
|
+ DELIVERYGOODSID: v.DELIVERYGOODSID,
|
|
|
|
|
+ DELIVERYGOODSCODE: v.DELIVERYGOODSCODE,
|
|
|
|
|
+ DELIVERYGOODSNAME: v.DELIVERYGOODSNAME,
|
|
|
|
|
+ WDLST: make([]WrFtWrstandard, 0),
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, a := range sMd {
|
|
|
|
|
+ if a.DELIVERYGOODSID == item.DELIVERYGOODSID {
|
|
|
|
|
+ val := WrFtWrstandard{
|
|
|
|
|
+ WRSTANDARDID: a.WRSTANDARDID,
|
|
|
|
|
+ WRSTANDARDNAME: a.WRSTANDARDNAME,
|
|
|
|
|
+ WRSTANDARDCODE: a.WRSTANDARDCODE,
|
|
|
|
|
+ }
|
|
|
|
|
+ item.WDLST = append(item.WDLST, val)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ sData = append(sData, item)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return sData, err
|
|
|
|
|
+}
|