Commit 33b6c8dd by mushishixian

fix

parent deb44092
Showing with 6 additions and 9 deletions
...@@ -91,7 +91,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) ( ...@@ -91,7 +91,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (
source.Sort("_score", false) source.Sort("_score", false)
source.Sort("moq", true) source.Sort("moq", true)
} }
//要去判断sort,sort=2是按照价格排序 //要去判断sort,sort=2是按照价格(价格有问题,目前按起订量)排序
if sort == 2 { if sort == 2 {
source.Sort("_score", false) source.Sort("_score", false)
source.Sort("moq", true) source.Sort("moq", true)
...@@ -159,7 +159,6 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue ...@@ -159,7 +159,6 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
query = query.Must(es.NewTermQuery("attr_bom", "FZ€"+bomItem.Encap)) query = query.Must(es.NewTermQuery("attr_bom", "FZ€"+bomItem.Encap))
} }
//搜索库存 //搜索库存
//fmt.Println("总数量:", bomItem.Number, bomItem.Amount)
query = query.Should(es.NewRangeQuery("stock").Gte(bomItem.Number * bomItem.Amount)) query = query.Should(es.NewRangeQuery("stock").Gte(bomItem.Number * bomItem.Amount))
} else { } else {
query = query.Must(es.NewTermQuery("auto_goods_name", bomItem.GoodsName)) query = query.Must(es.NewTermQuery("auto_goods_name", bomItem.GoodsName))
...@@ -167,13 +166,11 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue ...@@ -167,13 +166,11 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
//只显示库存大于0的数据 //只显示库存大于0的数据
query.Must(es.NewRangeQuery("stock").Gt(0)) query.Must(es.NewRangeQuery("stock").Gt(0))
//按价格排序 //按价格排序
if sort == 2 || sort == 1 { //if sort == 2 || sort == 1 {
query = query.Filter(es.NewRangeQuery("single_price").Gt(0)) // query = query.Filter(es.NewRangeQuery("single_price").Gt(0))
} //}
//库存排序 //只显示起订量大于0
if sort == 3 { query.Must(es.NewRangeQuery("moq").Gt(0))
query = query.Filter(es.NewRangeQuery("stock").Gt(0))
}
if configs.ApiSetting.Mode != "debug" { if configs.ApiSetting.Mode != "debug" {
query = query.Filter(es.NewTermQuery("status", 1)) query = query.Filter(es.NewTermQuery("status", 1))
} }
......
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