Commit fed36481 by mushishixian

fix bug

parent 77160b4c
Showing with 9 additions and 3 deletions
...@@ -22,7 +22,7 @@ func init() { ...@@ -22,7 +22,7 @@ func init() {
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/", // "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//} //}
// //
//str := `{"bom_id":237,"delivery_type":1,"sort":2}` //str := `{"bom_id":369,"delivery_type":1,"sort":2}`
//rabbitmq.Send(queueExchange, str) //rabbitmq.Send(queueExchange, str)
} }
......
...@@ -209,6 +209,7 @@ func removeZiyingMatchBomItem(ziyingGoodsMapList []GoodsMap, bomItems []model.Bo ...@@ -209,6 +209,7 @@ func removeZiyingMatchBomItem(ziyingGoodsMapList []GoodsMap, bomItems []model.Bo
func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sort int, client *es.Client, rawSearch bool) (goodsMapList []GoodsMap, err error) { func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sort int, client *es.Client, rawSearch bool) (goodsMapList []GoodsMap, err error) {
//先去自营查一遍 //先去自营查一遍
search := client.MultiSearch().Index(index) search := client.MultiSearch().Index(index)
searchFlag := false
//多重搜索,第一次先去精确匹配 //多重搜索,第一次先去精确匹配
for _, bom := range bomItems { for _, bom := range bomItems {
//如果是模糊查询,还要去截取字符串 //如果是模糊查询,还要去截取字符串
...@@ -220,8 +221,13 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor ...@@ -220,8 +221,13 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
} }
//构建一个goods_name对应的bomItems列表 //构建一个goods_name对应的bomItems列表
searchRequest := getSearchParams(index, bom.GoodsName, bom.BrandName, sort, bom.Number, rawSearch) searchRequest := getSearchParams(index, bom.GoodsName, bom.BrandName, sort, bom.Number, rawSearch)
searchFlag = true
search.Add(searchRequest) search.Add(searchRequest)
} }
//没有搜索条件的话,直接返回空值即可
if !searchFlag {
return nil, err
}
res, err := search.Do(context.Background()) res, err := search.Do(context.Background())
if err != nil { if err != nil {
return return
...@@ -305,8 +311,8 @@ func getTermQuery(goodsName, brandName string, number int, flag bool) (query *es ...@@ -305,8 +311,8 @@ func getTermQuery(goodsName, brandName string, number int, flag bool) (query *es
field := "auto_goods_name" field := "auto_goods_name"
query = query.Must(es.NewTermQuery(field, goodsName)) query = query.Must(es.NewTermQuery(field, goodsName))
} }
query = query.Filter(es.NewRangeQuery("single_price").Gt(0)) //query = query.Filter(es.NewRangeQuery("single_price").Gt(0))
query = query.Filter(es.NewRangeQuery("stock").Gt(0)) //query = query.Filter(es.NewRangeQuery("stock").Gt(0))
query = query.Filter(es.NewTermQuery("status", 1)) query = query.Filter(es.NewTermQuery("status", 1))
//query = query.Filter(es.NewRangeQuery("single_price").Gt(0)) //query = query.Filter(es.NewRangeQuery("single_price").Gt(0))
//src, err := query.Source() //src, err := query.Source()
......
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