|
|
@@ -10,6 +10,7 @@ import (
|
|
|
"fmt"
|
|
|
"mtp2_if/db"
|
|
|
"mtp2_if/logger"
|
|
|
+ "mtp2_if/utils"
|
|
|
)
|
|
|
|
|
|
// 现货商品表
|
|
|
@@ -54,7 +55,7 @@ func (r *ErmcpWrstandard) buildSql() string {
|
|
|
if r.WRSTANDARDID > 0 {
|
|
|
sqlId = sqlId + fmt.Sprintf(" and WRSTANDARDID=%v", r.WRSTANDARDID)
|
|
|
}
|
|
|
- if r.ISVALID >= 0{
|
|
|
+ if r.ISVALID >= 0 {
|
|
|
sqlId = sqlId + fmt.Sprintf(" and t.ISVALID=%v", r.ISVALID)
|
|
|
}
|
|
|
return sqlId
|
|
|
@@ -197,12 +198,52 @@ func (r *WRSConverTDetail) GetData() ([]WRSConverTDetail, error) {
|
|
|
return sData, nil
|
|
|
}
|
|
|
|
|
|
+// 现货关联的交易商品
|
|
|
+type RelatedGoodsEx struct {
|
|
|
+ GoodsId int `json:"goodsid" xorm:"'GoodsId'"` // 商品id
|
|
|
+ GoodsCode string `json:"goodscode" xorm:"'GoodsCode'"` // 商品代码
|
|
|
+ GoodsName string `json:"goodsname" xorm:"'GoodsName'"` // 商品名称
|
|
|
+
|
|
|
+ WRSTANDARDID int64 `json:"-" xorm:"'WRSTANDARDID'"` // 现货商品ID
|
|
|
+ AREAUSERID int `json:"-" xorm:"'AREAUSERID'"` // 所属机构
|
|
|
+}
|
|
|
+
|
|
|
+func (r *RelatedGoodsEx) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = "select distinct g.goodsid, g.goodscode, g.goodsname" +
|
|
|
+ " from wrstandard t" +
|
|
|
+ " inner join ERMS2_WRSConvertDetail w" +
|
|
|
+ " on t.wrstandardid = w.wrstandardid" +
|
|
|
+ " inner join erms_middlegoods m" +
|
|
|
+ " on w.middlegoodsid = m.middlegoodsid" +
|
|
|
+ " inner join ERMCP_GGConvertConfig gc" +
|
|
|
+ " on m.goodsgroupid = gc.destgoodsgroupid" +
|
|
|
+ " inner join goods g" +
|
|
|
+ " on gc.srcgoodsgroupid = g.goodsgroupid" +
|
|
|
+ " where 1=1"
|
|
|
+ sqlId.And("t.areauserid", r.AREAUSERID)
|
|
|
+ sqlId.And("t.wrstandardid", r.WRSTANDARDID)
|
|
|
+ sqlId.Join(" order by g.goodsid")
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *RelatedGoodsEx) GetData() ([]RelatedGoodsEx, error) {
|
|
|
+ sData := make([]RelatedGoodsEx, 0)
|
|
|
+ if err := db.GetEngine().SQL(r.buildSql()).Find(&sData); err != nil {
|
|
|
+ logger.GetLogger().Errorf("query RelatedGoodsEx fail, %v", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return sData, nil
|
|
|
+}
|
|
|
+
|
|
|
// 现货商品详细
|
|
|
type ErmcpWrstandDetail struct {
|
|
|
- Wrd ErmcpWrstandard `json:"wrd"` // 基本信息
|
|
|
- GtList []GoodsTypeModel `json:"gtList"` // 型号列表
|
|
|
- GbList []GoodsBrand `json:"gbList"` // 品牌列表
|
|
|
- WrsList []WRSConverTDetail `json:"wrsList"` // 套保信息列表
|
|
|
+ Wrd ErmcpWrstandard `json:"wrd"` // 基本信息
|
|
|
+ GtList []GoodsTypeModel `json:"gtList"` // 型号列表
|
|
|
+ GbList []GoodsBrand `json:"gbList"` // 品牌列表
|
|
|
+ WrsList []WRSConverTDetail `json:"wrsList"` // 套保信息列表
|
|
|
+ GoodsList []RelatedGoodsEx `json:"goodsList"` // 关联交易商品列表
|
|
|
+
|
|
|
+ QueryGoods bool `json:"-"`
|
|
|
}
|
|
|
|
|
|
// 查询现货商品详细
|
|
|
@@ -218,6 +259,10 @@ func (r *ErmcpWrstandDetail) GetData() (ErmcpWrstandDetail, error) {
|
|
|
}
|
|
|
rsp := ErmcpWrstandDetail{}
|
|
|
rsp.Wrd = d[0]
|
|
|
+ rsp.GtList = make([]GoodsTypeModel, 0)
|
|
|
+ rsp.GbList = make([]GoodsBrand, 0)
|
|
|
+ rsp.WrsList = make([]WRSConverTDetail, 0)
|
|
|
+ rsp.GoodsList = make([]RelatedGoodsEx, 0)
|
|
|
// 获取型号信息
|
|
|
gt := GoodsTypeModel{AREAUSERID: rsp.Wrd.AREAUSERID, WRSTANDARDID: rsp.Wrd.WRSTANDARDID}
|
|
|
if val, err := gt.GetData(); err == nil {
|
|
|
@@ -236,5 +281,13 @@ func (r *ErmcpWrstandDetail) GetData() (ErmcpWrstandDetail, error) {
|
|
|
rsp.WrsList = val
|
|
|
}
|
|
|
|
|
|
+ // 获取关联交易商品
|
|
|
+ if r.QueryGoods {
|
|
|
+ goodsLst := RelatedGoodsEx{AREAUSERID: r.Wrd.AREAUSERID, WRSTANDARDID: r.Wrd.WRSTANDARDID}
|
|
|
+ if val, err := goodsLst.GetData(); err == nil {
|
|
|
+ rsp.GoodsList = val
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return rsp, nil
|
|
|
}
|