// Package models 40.6.3仓单优化_产能预售 package models import ( "mtp2_if/db" "time" ) // Cptradepresalegoodsex 产能预售商品扩展表 type Cptradepresalegoodsex struct { Goodsid int64 `json:"goodsid" xorm:"'GOODSID'" binding:"required"` // 商品ID Applyid int64 `json:"applyid" xorm:"'APPLYID'"` // 关联申请ID Userid int64 `json:"userid" xorm:"'USERID'"` // 卖方用户ID Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 卖方账户ID Relatedgoodsid int64 `json:"relatedgoodsid" xorm:"'RELATEDGOODSID'"` // 关联交易合约ID Presaleqty int64 `json:"presaleqty" xorm:"'PRESALEQTY'"` // 预售数量 Starttime time.Time `json:"starttime" xorm:"'STARTTIME'"` // 预售开始时间 Endtime time.Time `json:"endtime" xorm:"'ENDTIME'"` // 预售结束时间 Attachmenturl string `json:"attachmenturl" xorm:"'ATTACHMENTURL'"` // 附件地址 Presalemode int32 `json:"presalemode" xorm:"'PRESALEMODE'"` // 预售模式 - 1:一口价 2:大宗式竞拍 Marketid int32 `json:"marketid" xorm:"'MARKETID'"` // 预售市场ID - 根据预售模式选择市场 Refprice float64 `json:"refprice" xorm:"'REFPRICE'"` // 参考价格[一口价] Startprice float64 `json:"startprice" xorm:"'STARTPRICE'"` // 起拍价[大宗式竞拍] Floorprice float64 `json:"floorprice" xorm:"'FLOORPRICE'"` // 底价[大宗式竞拍] Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间 Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd) Relatedmarketid int64 `json:"relatedmarketid" xorm:"'RELATEDMARKETID'"` // 关联交易合约市场ID Presaledqty int64 `json:"presaledqty" xorm:"'PRESALEDQTY'"` // 已预售量(预售结束时更新) 71-委托时更新 Presaledamount float64 `json:"presaledamount" xorm:"'PRESALEDAMOUNT'"` // 已预售总金额(预售结束时更新)71-委托时更新 Sellstatus int32 `json:"sellstatus" xorm:"'SELLSTATUS'"` // 卖方处理状态 - 1:卖方头寸未处理 2:卖方头寸已处理 Goodsdetail string `json:"goodsdetail" xorm:"'GOODSDETAIL'"` // 详情[大宗] Tradeprice float64 `json:"tradeprice" xorm:"'TRADEPRICE'"` // 成交价[大宗] Buymaxqty int64 `json:"buymaxqty" xorm:"'BUYMAXQTY'"` // 购买上限 [71] - 0为不限 } // TableName is CPTRADE_PRESALEGOODSEX func (Cptradepresalegoodsex) TableName() string { return "CPTRADE_PRESALEGOODSEX" } // Cptradebuylimitedconfig 产能预售商品购买限制表 type Cptradebuylimitedconfig struct { Goodsid int64 `json:"goodsid" xorm:"'GOODSID'" binding:"required"` // 商品ID Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'" binding:"required"` // 账户ID Buymaxqty int64 `json:"buymaxqty" xorm:"'BUYMAXQTY'"` // 限制上限 Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人 Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间 } // TableName is CPTRADE_BUYLIMITEDCONFIG func (Cptradebuylimitedconfig) TableName() string { return "CPTRADE_BUYLIMITEDCONFIG" } // GetCPTradeBuyLimit 获取目标预售商品购买限制 func GetCPTradeBuyLimit(goodsID, accountID int) (int, error) { engine := db.GetEngine() // 先尝试从“产能预售商品购买限制表”中获取定制化信息 var cptradebuylimitedconfig Cptradebuylimitedconfig has, err := engine.Where("GOODSID = ?", goodsID).And("ACCOUNTID = ?", accountID).Get(&cptradebuylimitedconfig) if err != nil { return 0, err } if has { return int(cptradebuylimitedconfig.Buymaxqty), nil } // 没有定制化信息则从“产能预售商品扩展表”获取 var cptradepresalegoodsex Cptradepresalegoodsex if has, err = engine.Where("GOODSID = ?", goodsID).Get(&cptradepresalegoodsex); err != nil { return 0, err } if has { return int(cptradepresalegoodsex.Buymaxqty), nil } return 0, nil }