|
|
@@ -222,7 +222,9 @@ func (r *RelatedGoodsEx) buildSql() string {
|
|
|
" on gc.srcgoodsgroupid = g.goodsgroupid" +
|
|
|
" where 1=1"
|
|
|
sqlId.And("t.areauserid", r.AREAUSERID)
|
|
|
- sqlId.And("t.wrstandardid", r.WRSTANDARDID)
|
|
|
+ if r.WRSTANDARDID > 0 {
|
|
|
+ sqlId.And("t.wrstandardid", r.WRSTANDARDID)
|
|
|
+ }
|
|
|
sqlId.Join(" order by g.goodsid")
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
@@ -249,15 +251,23 @@ type ErmcpWrstandDetail struct {
|
|
|
}
|
|
|
|
|
|
// GetData 查询现货商品详细
|
|
|
-func (r *ErmcpWrstandDetail) GetData() (ErmcpWrstandDetail, error) {
|
|
|
+func (r *ErmcpWrstandDetail) GetData() ([]ErmcpWrstandDetail, error) {
|
|
|
+ if r.Wrd.WRSTANDARDID > 0 {
|
|
|
+ return r.GetByWrstandId()
|
|
|
+ }
|
|
|
+ return r.GetAll()
|
|
|
+}
|
|
|
+
|
|
|
+// GetByWrstandId 指定现货商品id获取
|
|
|
+func (r *ErmcpWrstandDetail) GetByWrstandId() ([]ErmcpWrstandDetail, error) {
|
|
|
// 获取基本信息
|
|
|
m := ErmcpWrstandard{AREAUSERID: r.Wrd.AREAUSERID, WRSTANDARDID: r.Wrd.WRSTANDARDID, ISVALID: -1}
|
|
|
d, err := m.GetData()
|
|
|
if err != nil {
|
|
|
- return ErmcpWrstandDetail{}, err
|
|
|
+ return []ErmcpWrstandDetail{}, err
|
|
|
}
|
|
|
if d == nil || len(d) == 0 {
|
|
|
- return ErmcpWrstandDetail{}, fmt.Errorf("no record")
|
|
|
+ return []ErmcpWrstandDetail{}, fmt.Errorf("no record")
|
|
|
}
|
|
|
rsp := ErmcpWrstandDetail{}
|
|
|
rsp.Wrd = d[0]
|
|
|
@@ -291,5 +301,80 @@ func (r *ErmcpWrstandDetail) GetData() (ErmcpWrstandDetail, error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ rsp2 := make([]ErmcpWrstandDetail, 0)
|
|
|
+ rsp2 = append(rsp2, rsp)
|
|
|
+
|
|
|
+ return rsp2, nil
|
|
|
+}
|
|
|
+
|
|
|
+// GetAll 获取所有
|
|
|
+func (r *ErmcpWrstandDetail) GetAll() ([]ErmcpWrstandDetail, error) {
|
|
|
+ // 获取基本信息
|
|
|
+ m := ErmcpWrstandard{AREAUSERID: r.Wrd.AREAUSERID, ISVALID: -1}
|
|
|
+ d, err := m.GetData()
|
|
|
+ if err != nil {
|
|
|
+ return []ErmcpWrstandDetail{}, err
|
|
|
+ }
|
|
|
+ if d == nil || len(d) == 0 {
|
|
|
+ return []ErmcpWrstandDetail{}, fmt.Errorf("no record")
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取型号信息
|
|
|
+ gt := GoodsTypeModel{AREAUSERID: r.Wrd.AREAUSERID}
|
|
|
+ gtList, _ := gt.GetData()
|
|
|
+
|
|
|
+ // 获取品牌信息
|
|
|
+ gb := GoodsBrand{AREAUSERID: r.Wrd.AREAUSERID}
|
|
|
+ gbList, _ := gb.GetData()
|
|
|
+
|
|
|
+ // 获取套保信息
|
|
|
+ wrs := WRSConverTDetail{}
|
|
|
+ wrsList, _ := wrs.GetData()
|
|
|
+
|
|
|
+ var glist []RelatedGoodsEx
|
|
|
+ // 获取关联交易商品
|
|
|
+ if r.QueryGoods {
|
|
|
+ goodsLst := RelatedGoodsEx{AREAUSERID: r.Wrd.AREAUSERID}
|
|
|
+ if val, err := goodsLst.GetData(); err == nil {
|
|
|
+ glist = val
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ rsp := make([]ErmcpWrstandDetail, 0)
|
|
|
+ for i := range d {
|
|
|
+ val := ErmcpWrstandDetail{
|
|
|
+ Wrd: d[i],
|
|
|
+ GtList: make([]GoodsTypeModel, 0),
|
|
|
+ GbList: make([]GoodsBrand, 0),
|
|
|
+ WrsList: make([]WRSConverTDetail, 0),
|
|
|
+ GoodsList: make([]RelatedGoodsEx, 0),
|
|
|
+ }
|
|
|
+
|
|
|
+ for k := range gtList {
|
|
|
+ if gtList[k].WRSTANDARDID == d[i].WRSTANDARDID {
|
|
|
+ val.GtList = append(val.GtList, gtList[k])
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for k := range gbList {
|
|
|
+ if gbList[k].WRSTANDARDID == d[i].WRSTANDARDID {
|
|
|
+ val.GbList = append(val.GbList, gbList[k])
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for k := range wrsList {
|
|
|
+ if wrsList[k].WRSTANDARDID == d[i].WRSTANDARDID {
|
|
|
+ val.WrsList = append(val.WrsList, wrsList[k])
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for k := range glist {
|
|
|
+ if glist[k].WRSTANDARDID == d[i].WRSTANDARDID {
|
|
|
+ val.GoodsList = append(val.GoodsList, glist[k])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rsp = append(rsp, val)
|
|
|
+ }
|
|
|
+
|
|
|
return rsp, nil
|
|
|
}
|