delivery.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Package models 40.a交割服务
  2. package models
  3. import (
  4. "fmt"
  5. "mtp2_if/db"
  6. )
  7. // Deliveryrelation 商品交割关系表
  8. type Deliveryrelation struct {
  9. Goodsid int64 `json:"goodsid" xorm:"'GOODSID'" binding:"required"` // 交易合约ID
  10. Deliverymode int64 `json:"deliverymode" xorm:"'DELIVERYMODE'"` // 交割方式 - 1:点选式 2:申报式
  11. Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 仓单标准ID
  12. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 交割商品
  13. Mindeliveryqty int64 `json:"mindeliveryqty" xorm:"'MINDELIVERYQTY'" binding:"required"` // 最小交割系数(K)
  14. Rratio1 int64 `json:"rratio1" xorm:"'RRATIO1'"` // 兑换系数(交易合约)(R1)
  15. Rratio2 int64 `json:"rratio2" xorm:"'RRATIO2'"` // 兑换系数(仓单标准)(R2)
  16. Deliverypricerule int64 `json:"deliverypricerule" xorm:"'DELIVERYPRICERULE'"` // 交割价规则- 1:行情价 2:建仓价
  17. Begindate string `json:"begindate" xorm:"'BEGINDATE'" binding:"required"` // 起始日期(yyyyMMdd)
  18. Enddate string `json:"enddate" xorm:"'ENDDATE'" binding:"required"` // 结束日期(yyyyMMdd)
  19. Buytemplateid int64 `json:"buytemplateid" xorm:"'BUYTEMPLATEID'"` // 买履约计划模板ID
  20. Selltemplateid int64 `json:"selltemplateid" xorm:"'SELLTEMPLATEID'"` // 卖履约计划模板ID
  21. Deliverytype int64 `json:"deliverytype" xorm:"'DELIVERYTYPE'"` // 交割模式 - 1:X交割 2:X+P交割 3:X+C交割 4:X+P+C交割
  22. Xdeliveryratio int64 `json:"xdeliveryratio" xorm:"'XDELIVERYRATIO'" binding:"required"` // 交易合约系数(m)
  23. Ppricemode int64 `json:"ppricemode" xorm:"'PPRICEMODE'"` // P合约价格方式 - 1:商品价 2:固定值
  24. Pdeliveryprice float64 `json:"pdeliveryprice" xorm:"'PDELIVERYPRICE'"` // P合约价格(商品价时填写0,固定值时填写固定值)
  25. Pdeliveryratio int64 `json:"pdeliveryratio" xorm:"'PDELIVERYRATIO'"` // P合约系数(n)
  26. Pgoodsid int64 `json:"pgoodsid" xorm:"'PGOODSID'"` // P合约ID
  27. P2pricemode int64 `json:"p2pricemode" xorm:"'P2PRICEMODE'"` // P2合约价格方式 - 1:商品价 2:固定值
  28. P2deliveryprice float64 `json:"p2deliveryprice" xorm:"'P2DELIVERYPRICE'"` // P2合约价格(商品价时填写0,固定值时填写固定值)
  29. P2deliveryratio int64 `json:"p2deliveryratio" xorm:"'P2DELIVERYRATIO'"` // P2合约系数(p)
  30. P2goodsid int64 `json:"p2goodsid" xorm:"'P2GOODSID'"` // P2合约ID
  31. Rratio int64 `json:"rratio" xorm:"'RRATIO'"` // 兑换系数(R)
  32. }
  33. // TableName is DELIVERYRELATION
  34. func (Deliveryrelation) TableName() string {
  35. return "DELIVERYRELATION"
  36. }
  37. // GetDeliverGoods 获取交割商品
  38. func GetDeliverGoods() ([]Deliverygoods, error) {
  39. engine := db.GetEngine()
  40. d := make([]Deliverygoods, 0)
  41. if err := engine.Where("IsValid=1").And("categoryid<>0").Find(&d); err != nil {
  42. return nil, fmt.Errorf("query deleiverygoods fail")
  43. }
  44. return d, nil
  45. }