修复状态问题

parent 1bf9ad55
......@@ -131,8 +131,7 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
goods.Mpl = int(data.Get("mpl").Int())
goods.Encap = data.Get("encap").String()
goods.SupplierID = int(data.Get("supplier_id").Int())
//goods.Status = int(data.Get("status").Int())
goods.Status = 1
goods.Status = int(data.Get("status").Int())
goods.GoodsType = int(data.Get("goods_type").Int())
goods.AcType = int(data.Get("ac_type").Int())
var ladderPrice []model.LadderPrice
......
......@@ -6,6 +6,7 @@ import (
"bom_server/internal/model"
"context"
"encoding/json"
"github.com/tidwall/gjson"
es "gopkg.in/olivere/elastic.v5"
"strings"
)
......@@ -50,27 +51,23 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
common.PrintDebug(res.Responses)
v, err := json.Marshal(res.Responses)
gjArray := gjson.Get(string(v), "hits.hits.#._source").Array()
if err != nil {
return
}
if len(res.Responses) == 0 {
return
}
//因为是多重查询,所以会有多套结果
for key, responses := range res.Responses {
//有数据进行转换
if responses.Hits != nil {
for _, hit := range responses.Hits.Hits {
var goods model.Goods
err := json.Unmarshal(*hit.Source, &goods)
if err != nil {
return nil, err
}
if goods.GoodsName == "" {
for key, item := range gjArray {
if item.Get("goods_name").String() == "" {
break
}
var goodsMap GoodsMap
goodsMap.GoodsId = hit.Id
goodsMap.GoodsId = item.Get("goods_id").String()
goodsMap.Amount = bomItems[key].Amount
goodsMap.Number = bomItems[key].Number
goodsMap.GoodsName = bomItems[key].GoodsName
......@@ -78,10 +75,40 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
goodsMap.BomId = bomId
goodsMap.DeliveryType = deliveryType
goodsMapList = append(goodsMapList, goodsMap)
common.PrintDebug(goodsMap)
break
}
}
}
////因为是多重查询,所以会有多套结果
//for key, responses := range res.Responses {
// //有数据进行转换
// if responses.Hits != nil {
// for _, hit := range responses.Hits.Hits {
// //var goods model.Goods
// err := json.Unmarshal(*hit.Source, &goods)
// if err != nil {
// return nil, err
// }
// source := *hit.Source
// goodsNameObj := gjson.Get(source, "hit.Source.GoodsName")
// if goodsNameObj.String() == "" {
// break
// }
// var goodsMap GoodsMap
// goodsMap.GoodsId = hit.Id
// goodsMap.Amount = bomItems[key].Amount
// goodsMap.Number = bomItems[key].Number
// goodsMap.GoodsName = bomItems[key].GoodsName
// goodsMap.BomItemId = bomItems[key].BomItemID
// goodsMap.BomId = bomId
// goodsMap.DeliveryType = deliveryType
// goodsMapList = append(goodsMapList, goodsMap)
// break
// }
// }
//}
common.PrintDebug("search end")
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment