|
|
@@ -905,8 +905,9 @@ type InternalEnableTradeDetail struct {
|
|
|
AGREEUNIT float64 `json:"agreeunit" xorm:"AGREEUNIT"` // 合约乘数
|
|
|
CONVERTRATIO float64 `json:"convertratio" xorm:"CONVERTRATIO"` // 品种系数
|
|
|
|
|
|
- AREAUSERID int64 `json:"areauserid" xorm:"AREAUSERID" form:"areauserid" binding:"required"` // 企业ID
|
|
|
- GOODSID int64 `form:"goodsid" binding:"required"` // 期货合约ID
|
|
|
+ AREAUSERID int64 `json:"areauserid" xorm:"AREAUSERID" form:"areauserid" binding:"required"` // 企业ID
|
|
|
+ GOODSID int64 `form:"goodsid" binding:"required"` // 期货合约ID
|
|
|
+ TRADEUSERID int64 `form:"tradeuserid" binding:"required"` // 交易用户ID
|
|
|
}
|
|
|
|
|
|
func (r *InternalEnableTradeDetail) calc() {
|
|
|
@@ -940,6 +941,7 @@ func (r *InternalEnableTradeDetail) buildSql() string {
|
|
|
`
|
|
|
sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
sqlId.And("g.GOODSID", r.GOODSID)
|
|
|
+ sqlId.And("hi.TRADEUSERID", r.TRADEUSERID)
|
|
|
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
@@ -1324,7 +1326,8 @@ type Ermcp8EnableHedgeditem struct {
|
|
|
|
|
|
ACCOUNTNAME string `json:"accountname" xorm:"ACCOUNTNAME"` // 套期主体
|
|
|
|
|
|
- USERID int64 `json:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
+ USERID int64 `json:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
+ WRSTANDARDID int64 `form:"wrstandardid"` // 现货商品ID
|
|
|
}
|
|
|
|
|
|
func (r *Ermcp8EnableHedgeditem) calc() {
|
|
|
@@ -1340,14 +1343,17 @@ func (r *Ermcp8EnableHedgeditem) buildSql() string {
|
|
|
t.HEDGEDTYPE,
|
|
|
to_char(t.PLANSTARTDATE, 'yyyy-mm-dd') PLANSTARTDATE,
|
|
|
to_char(t.PLANENDDATE, 'yyyy-mm-dd') PLANENDDATE,
|
|
|
- u.ACCOUNTNAME
|
|
|
+ u.ACCOUNTNAME,
|
|
|
+ wr.WRSTANDARDNAME
|
|
|
FROM ERMCP2_HedgedItem t
|
|
|
LEFT JOIN useraccount u ON u.userid = t.tradeuserid
|
|
|
+ LEFT JOIN WRStandard wr ON wr.wrstandardid = t.wrstandardid
|
|
|
WHERE
|
|
|
t.HEDGEDITEMSTATUS = 2
|
|
|
AND (t.TRADEUSERID = %v OR t.AREAUSERID = %v)
|
|
|
+ AND (t.WRSTANDARDID IS NULL OR t.WRSTANDARDID = %v)
|
|
|
`
|
|
|
- sqlId.FormatParam(r.USERID, r.USERID)
|
|
|
+ sqlId.FormatParam(r.USERID, r.USERID, r.WRSTANDARDID)
|
|
|
switch r.SPOTTYPE {
|
|
|
case 1, 2:
|
|
|
sqlId.And("t.HEDGEDTYPE", r.SPOTTYPE)
|
|
|
@@ -2091,3 +2097,45 @@ func (r *Ermcp2hedgeditemlink) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
|
return sData, nil
|
|
|
}
|
|
|
+
|
|
|
+// Marketcalendar 市场节假日表
|
|
|
+type Marketcalendar struct {
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID" form:"marketid"` // 市场ID
|
|
|
+ HOLIDAYDATE string `json:"holidaydate" xorm:"HOLIDAYDATE"` // 节假日期(yyyy-MM-dd)
|
|
|
+}
|
|
|
+
|
|
|
+// TableName is MARKETCALENDAR
|
|
|
+func (r *Marketcalendar) TableName() string {
|
|
|
+ return "MARKETCALENDAR"
|
|
|
+}
|
|
|
+
|
|
|
+func (r *Marketcalendar) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *Marketcalendar) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+ SELECT
|
|
|
+ t.MARKETID,
|
|
|
+ to_char(to_date(t.HOLIDAYDATE,'yyyyMMdd'), 'yyyy-MM-dd') HOLIDAYDATE
|
|
|
+ FROM MarketCalendar t
|
|
|
+ WHERE 1 = 1
|
|
|
+ `
|
|
|
+ sqlId.AndEx("t.MARKETID", r.MARKETID, r.MARKETID > 0)
|
|
|
+
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 从数据库中查询数据
|
|
|
+func (r *Marketcalendar) GetDataEx() (interface{}, error) {
|
|
|
+ e := db.GetEngine()
|
|
|
+ s := e.SQL(r.buildSql())
|
|
|
+ sData := make([]Marketcalendar, 0)
|
|
|
+ if err := s.Find(&sData); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ return sData, nil
|
|
|
+}
|