delivery.go 5.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Package models 40.a交割服务
  2. package models
  3. import (
  4. "fmt"
  5. "mtp2_if/db"
  6. )
  7. // Deliverygoods 现货品种表
  8. type Deliverygoods struct {
  9. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'" binding:"required"` // 交割商品ID(SEQ_DELIVERYGOODS)
  10. Deliverygoodscode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'" binding:"required"` // 交割商品代码
  11. Deliverygoodsname string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 交割商品名称
  12. Goodsunitid int32 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 交割商品单位ID
  13. Deliverygoodstype int32 `json:"deliverygoodstype" xorm:"'DELIVERYGOODSTYPE'"` // 交割商品类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细
  14. Standardqty int64 `json:"standardqty" xorm:"'STANDARDQTY'"` // 标准数量(库位数量) [标准品特有]
  15. Standardqtyrange float64 `json:"standardqtyrange" xorm:"'STANDARDQTYRANGE'"` // 标准数量偏差范围 [标准品特有]
  16. Auditflag int32 `json:"auditflag" xorm:"'AUDITFLAG'"` // 交割是否需要审核 - 0:不需要 1:需要审核 默认为0
  17. Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  18. Agreeunit int64 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位[散货时默认为1, 整装时默认为标准数量]
  19. Issplit int32 `json:"issplit" xorm:"'ISSPLIT'"` // 是否拆分 - 0:不拆分 1:拆分 [整装] 0:不记录明细 1:记录明细 [散货] - 作废整装时不拆分,则标准数量=合约单位;拆分时标准数量为合约单位的整数倍;整装时必须记录明细表数据
  20. Qtydecimalplace int32 `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
  21. Categoryid int32 `json:"categoryid" xorm:"'CATEGORYID'"` // 类别ID(SEQ_WRCATEGORY)
  22. Dgstatus int32 `json:"dgstatus" xorm:"'DGSTATUS'"` // 品种状态 - 作废 - 0:未激活 1:正常
  23. }
  24. // TableName is DELIVERYGOODS
  25. func (Deliverygoods) TableName() string {
  26. return "DELIVERYGOODS"
  27. }
  28. // Deliveryrelation 商品交割关系表
  29. type Deliveryrelation struct {
  30. Goodsid int64 `json:"goodsid" xorm:"'GOODSID'" binding:"required"` // 交易合约ID
  31. Deliverymode int64 `json:"deliverymode" xorm:"'DELIVERYMODE'"` // 交割方式 - 1:点选式 2:申报式
  32. Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 仓单标准ID
  33. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 交割商品
  34. Mindeliveryqty int64 `json:"mindeliveryqty" xorm:"'MINDELIVERYQTY'" binding:"required"` // 最小交割系数(K)
  35. Rratio1 int64 `json:"rratio1" xorm:"'RRATIO1'"` // 兑换系数(交易合约)(R1)
  36. Rratio2 int64 `json:"rratio2" xorm:"'RRATIO2'"` // 兑换系数(仓单标准)(R2)
  37. Deliverypricerule int64 `json:"deliverypricerule" xorm:"'DELIVERYPRICERULE'"` // 交割价规则- 1:行情价 2:建仓价
  38. Begindate string `json:"begindate" xorm:"'BEGINDATE'" binding:"required"` // 起始日期(yyyyMMdd)
  39. Enddate string `json:"enddate" xorm:"'ENDDATE'" binding:"required"` // 结束日期(yyyyMMdd)
  40. Buytemplateid int64 `json:"buytemplateid" xorm:"'BUYTEMPLATEID'"` // 买履约计划模板ID
  41. Selltemplateid int64 `json:"selltemplateid" xorm:"'SELLTEMPLATEID'"` // 卖履约计划模板ID
  42. Deliverytype int64 `json:"deliverytype" xorm:"'DELIVERYTYPE'"` // 交割模式 - 1:X交割 2:X+P交割 3:X+C交割 4:X+P+C交割
  43. Xdeliveryratio int64 `json:"xdeliveryratio" xorm:"'XDELIVERYRATIO'" binding:"required"` // 交易合约系数(m)
  44. Ppricemode int64 `json:"ppricemode" xorm:"'PPRICEMODE'"` // P合约价格方式 - 1:商品价 2:固定值
  45. Pdeliveryprice float64 `json:"pdeliveryprice" xorm:"'PDELIVERYPRICE'"` // P合约价格(商品价时填写0,固定值时填写固定值)
  46. Pdeliveryratio int64 `json:"pdeliveryratio" xorm:"'PDELIVERYRATIO'"` // P合约系数(n)
  47. Pgoodsid int64 `json:"pgoodsid" xorm:"'PGOODSID'"` // P合约ID
  48. P2pricemode int64 `json:"p2pricemode" xorm:"'P2PRICEMODE'"` // P2合约价格方式 - 1:商品价 2:固定值
  49. P2deliveryprice float64 `json:"p2deliveryprice" xorm:"'P2DELIVERYPRICE'"` // P2合约价格(商品价时填写0,固定值时填写固定值)
  50. P2deliveryratio int64 `json:"p2deliveryratio" xorm:"'P2DELIVERYRATIO'"` // P2合约系数(p)
  51. P2goodsid int64 `json:"p2goodsid" xorm:"'P2GOODSID'"` // P2合约ID
  52. Rratio int64 `json:"rratio" xorm:"'RRATIO'"` // 兑换系数(R)
  53. }
  54. // TableName is DELIVERYRELATION
  55. func (Deliveryrelation) TableName() string {
  56. return "DELIVERYRELATION"
  57. }
  58. // 获取交割商品
  59. func GetDeliverGoods() ([]Deliverygoods, error) {
  60. engine := db.GetEngine()
  61. d := make([]Deliverygoods, 0)
  62. if err := engine.Where("IsValid=1").And("categoryid<>0").Find(&d); err != nil {
  63. return nil, fmt.Errorf("query deleiverygoods fail")
  64. }
  65. return d, nil
  66. }