|
@@ -310,8 +310,8 @@ func (r *ErmcpDeliveryGoodsDetailEx) addMgList(lst []Ermcp3MiddleGoodsDetail, wc
|
|
|
|
|
|
|
|
// Ermcp3MiddleGoodsDetail 套保品种详情
|
|
// Ermcp3MiddleGoodsDetail 套保品种详情
|
|
|
type Ermcp3MiddleGoodsDetail struct {
|
|
type Ermcp3MiddleGoodsDetail struct {
|
|
|
- Mg ErmcpMiddleGoodsModel `json:"mg"` // 套保商品信息
|
|
|
|
|
- GList []Ermcp3GoodsEx `json:"glist"` // 关联商品列表
|
|
|
|
|
|
|
+ Mg ErmcpMiddleGoodsModel `json:"mg"` // 套保商品信息
|
|
|
|
|
+ GPList []Ermcp3GoodsGroupEx `json:"gplist"` // 关联商品组列表
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GetData 获取套保品种详情(不含现货列表)
|
|
// GetData 获取套保品种详情(不含现货列表)
|
|
@@ -321,7 +321,7 @@ func (r *Ermcp3MiddleGoodsDetail) GetData() ([]Ermcp3MiddleGoodsDetail, error) {
|
|
|
mMg := ErmcpMiddleGoodsModel{AREAUSERID: r.Mg.AREAUSERID, MIDDLEGOODSID: r.Mg.MIDDLEGOODSID, ISVALID: 1}
|
|
mMg := ErmcpMiddleGoodsModel{AREAUSERID: r.Mg.AREAUSERID, MIDDLEGOODSID: r.Mg.MIDDLEGOODSID, ISVALID: 1}
|
|
|
if mgLst, err := mMg.GetData2(); err == nil {
|
|
if mgLst, err := mMg.GetData2(); err == nil {
|
|
|
for i := range mgLst {
|
|
for i := range mgLst {
|
|
|
- sData = append(sData, Ermcp3MiddleGoodsDetail{Mg: mgLst[i], GList: make([]Ermcp3GoodsEx, 0)})
|
|
|
|
|
|
|
+ sData = append(sData, Ermcp3MiddleGoodsDetail{Mg: mgLst[i], GPList: make([]Ermcp3GoodsGroupEx, 0)})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if len(sData) == 0 {
|
|
if len(sData) == 0 {
|
|
@@ -330,14 +330,58 @@ func (r *Ermcp3MiddleGoodsDetail) GetData() ([]Ermcp3MiddleGoodsDetail, error) {
|
|
|
mGoods := Ermcp3GoodsEx{AREAUSERID: r.Mg.AREAUSERID}
|
|
mGoods := Ermcp3GoodsEx{AREAUSERID: r.Mg.AREAUSERID}
|
|
|
if gLst, err := mGoods.GetData(); err == nil {
|
|
if gLst, err := mGoods.GetData(); err == nil {
|
|
|
for i := range sData {
|
|
for i := range sData {
|
|
|
- for _, ex := range gLst {
|
|
|
|
|
- if sData[i].Mg.MIDDLEGOODSID == ex.MIDDLEGOODSID {
|
|
|
|
|
- sData[i].GList = append(sData[i].GList, ex)
|
|
|
|
|
|
|
+ sData[i].addGoodsGroup(gLst)
|
|
|
|
|
+ }
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].addGoods(gLst)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, nil
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *Ermcp3MiddleGoodsDetail) addGoodsGroup(gpLst []Ermcp3GoodsEx) {
|
|
|
|
|
+ for i := range gpLst {
|
|
|
|
|
+ if gpLst[i].MIDDLEGOODSID == r.Mg.MIDDLEGOODSID {
|
|
|
|
|
+ bExist := false
|
|
|
|
|
+ for _, v := range r.GPList {
|
|
|
|
|
+ if v.GOODSGROUPID == gpLst[i].GOODSGROUPID {
|
|
|
|
|
+ bExist = true
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if !bExist {
|
|
|
|
|
+ val := Ermcp3GoodsGroupEx{
|
|
|
|
|
+ GOODSGROUPID: gpLst[i].GOODSGROUPID,
|
|
|
|
|
+ MIDDLEGOODSID: gpLst[i].MIDDLEGOODSID,
|
|
|
|
|
+ CONVERTRATIO: gpLst[i].CONVERTRATIO,
|
|
|
|
|
+ EXEXCHANGECODE: gpLst[i].EXEXCHANGECODE,
|
|
|
|
|
+ GOODSGROUPNAME: gpLst[i].GOODSGROUPNAME,
|
|
|
|
|
+ ENUMDICNAME: gpLst[i].ENUMDICNAME,
|
|
|
|
|
+ GList: make([]Ermcp3Goods, 0),
|
|
|
|
|
+ }
|
|
|
|
|
+ r.GPList = append(r.GPList, val)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *Ermcp3MiddleGoodsDetail) addGoods(gpLst []Ermcp3GoodsEx) {
|
|
|
|
|
+ for i := range gpLst {
|
|
|
|
|
+ if gpLst[i].MIDDLEGOODSID == r.Mg.MIDDLEGOODSID {
|
|
|
|
|
+ for k := range r.GPList {
|
|
|
|
|
+ if r.GPList[k].GOODSGROUPID == gpLst[i].GOODSGROUPID {
|
|
|
|
|
+ r.GPList[k].GList = append(r.GPList[k].GList, Ermcp3Goods{
|
|
|
|
|
+ GOODSID: gpLst[i].GOODSID,
|
|
|
|
|
+ GOODSNAME: gpLst[i].GOODSNAME,
|
|
|
|
|
+ GOODSCODE: gpLst[i].GOODSCODE,
|
|
|
|
|
+ AGREEUNIT: gpLst[i].AGREEUNIT,
|
|
|
|
|
+ EXEXCHANGECODE: gpLst[i].EXEXCHANGECODE,
|
|
|
|
|
+ ENUMDICNAME: gpLst[i].ENUMDICNAME,
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return sData, nil
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ermcp3MiddleGoodsDetailEx 套保品种详情(含现货列表)
|
|
// Ermcp3MiddleGoodsDetailEx 套保品种详情(含现货列表)
|
|
@@ -384,6 +428,27 @@ func (r *Ermcp3MiddleGoodsDetailEx) GetDataEx() (interface{}, error) {
|
|
|
return sData, nil
|
|
return sData, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Ermcp3GoodsGroupEx 商品组(含商品列表)
|
|
|
|
|
+type Ermcp3GoodsGroupEx struct {
|
|
|
|
|
+ MIDDLEGOODSID uint32 `json:"middlegoodsid" xorm:"'middlegoodsid'"` // 套保商品id
|
|
|
|
|
+ GOODSGROUPID int32 `json:"goodsgroupid" xorm:"'goodsgroupid'"` // 商品组id
|
|
|
|
|
+ CONVERTRATIO float64 `json:"convertratio" xorm:"'convertratio'"` // 折算系数(品种系数)
|
|
|
|
|
+ EXEXCHANGECODE string `json:"exexchangecode" xorm:"'exexchangecode'"` // 交易所代码
|
|
|
|
|
+ GOODSGROUPNAME string `json:"goodsgroupname" xorm:"'goodsgroupname'"` // 商品组名称
|
|
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
|
|
+ GList []Ermcp3Goods `json:"glist"` // 合约列表
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// Ermcp3Goods 商品信息
|
|
|
|
|
+type Ermcp3Goods struct {
|
|
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"'goodsid'"` // 期货商品id
|
|
|
|
|
+ GOODSCODE string `json:"goodscode" xorm:"'goodscode'"` // 期货商品代码
|
|
|
|
|
+ GOODSNAME string `json:"goodsname" xorm:"'goodsname'"` // 期货商品名称
|
|
|
|
|
+ AGREEUNIT float32 `json:"agreeunit" xorm:"'agreeunit'"` // 合约单位(合约乘数)
|
|
|
|
|
+ EXEXCHANGECODE string `json:"exexchangecode" xorm:"'exexchangecode'"` // 交易所代码
|
|
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// Ermcp3GoodsEx 套保品关联的期货商品(少量字段)
|
|
// Ermcp3GoodsEx 套保品关联的期货商品(少量字段)
|
|
|
type Ermcp3GoodsEx struct {
|
|
type Ermcp3GoodsEx struct {
|
|
|
MIDDLEGOODSID uint32 `json:"middlegoodsid" xorm:"'middlegoodsid'"` // 套保商品id
|
|
MIDDLEGOODSID uint32 `json:"middlegoodsid" xorm:"'middlegoodsid'"` // 套保商品id
|
|
@@ -392,14 +457,20 @@ type Ermcp3GoodsEx struct {
|
|
|
GOODSNAME string `json:"goodsname" xorm:"'goodsname'"` // 期货商品名称
|
|
GOODSNAME string `json:"goodsname" xorm:"'goodsname'"` // 期货商品名称
|
|
|
GOODUNITID int32 `json:"goodunitid" xorm:"'goodunitid'"` // 期货商品单位id
|
|
GOODUNITID int32 `json:"goodunitid" xorm:"'goodunitid'"` // 期货商品单位id
|
|
|
CONVERTRATIO float64 `json:"convertratio" xorm:"'convertratio'"` // 折算系数(品种系数)
|
|
CONVERTRATIO float64 `json:"convertratio" xorm:"'convertratio'"` // 折算系数(品种系数)
|
|
|
|
|
+ GOODSGROUPID int32 `json:"goodsgroupid" xorm:"'goodsgroupid'"` // 商品组id
|
|
|
EXEXCHANGECODE string `json:"exexchangecode" xorm:"'exexchangecode'"` // 交易所代码
|
|
EXEXCHANGECODE string `json:"exexchangecode" xorm:"'exexchangecode'"` // 交易所代码
|
|
|
|
|
+ GOODSGROUPNAME string `json:"goodsgroupname" xorm:"'goodsgroupname'"` // 商品组名称
|
|
|
|
|
+ GPUNITID int32 `json:"gpunitid" xorm:"'gpunitid'"` // 商品组单位id
|
|
|
|
|
+ AGREEUNIT float32 `json:"agreeunit" xorm:"'agreeunit'"` // 合约单位(合约乘数)
|
|
|
|
|
|
|
|
- ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
|
|
- AREAUSERID int64 `json:"-"` // 所属机构id
|
|
|
|
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
|
|
+ GPENUMDICNAME string `json:"enumdicname"` // 商品组单位名称
|
|
|
|
|
+ AREAUSERID int64 `json:"-"` // 所属机构id
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (r *Ermcp3GoodsEx) calc() {
|
|
func (r *Ermcp3GoodsEx) calc() {
|
|
|
r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
|
|
r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
|
|
|
|
|
+ r.GPENUMDICNAME = mtpcache.GetEnumDicitemName(r.GPUNITID)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (r *Ermcp3GoodsEx) buildSql() string {
|
|
func (r *Ermcp3GoodsEx) buildSql() string {
|
|
@@ -409,8 +480,12 @@ func (r *Ermcp3GoodsEx) buildSql() string {
|
|
|
" g.goodscode," +
|
|
" g.goodscode," +
|
|
|
" g.goodsname," +
|
|
" g.goodsname," +
|
|
|
" g.goodunitid," +
|
|
" g.goodunitid," +
|
|
|
|
|
+ " g.goodsgroupid," +
|
|
|
|
|
+ " g.agreeunit," +
|
|
|
" gc.convertratio," +
|
|
" gc.convertratio," +
|
|
|
- " ex.exexchangecode" +
|
|
|
|
|
|
|
+ " ex.exexchangecode," +
|
|
|
|
|
+ " gp.goodsgroupname," +
|
|
|
|
|
+ " gp.goodunitid gpunitid" +
|
|
|
" from erms_middlegoods mg" +
|
|
" from erms_middlegoods mg" +
|
|
|
" inner join ERMCP_GGConvertConfig gc" +
|
|
" inner join ERMCP_GGConvertConfig gc" +
|
|
|
" on mg.goodsgroupid = gc.destgoodsgroupid" +
|
|
" on mg.goodsgroupid = gc.destgoodsgroupid" +
|