Commit ca209b30 by mushishixian

修复价格排序

parent b4392473
......@@ -22,7 +22,7 @@ func init() {
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":48,"delivery_type":1,"sort":1}`
//str := `{"bom_id":236,"delivery_type":1,"sort":3}`
//rabbitmq.Send(queueExchange, str)
}
......
......@@ -30,6 +30,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
}
goodsIdsStr := strings.Join(goodsIds, ",")
goodsList, err := GetGoodsInfo(goodsIdsStr)
if len(goodsMapList)!=0 {
bomId = goodsMapList[0].BomId
}
//fmt.Println(goodsIdsStr)
if err != nil {
return
......@@ -123,31 +126,6 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
}
}
}
//var responseDataTemp model.ApiGoodsResponseTemp
//if err = resp.ToJSON(&responseDataTemp); err != nil {
// err = errors.New(err.Error())
// return
//}
//responseData.Data = make(map[string]model.ApiGoods, 200)
//for goodsId, goods := range responseDataTemp.Data {
// //不是bool值的,才去给数据,商品服务的商品信息有可能是bool值,蛋疼
// if reflect.ValueOf(goods).Type().String() != "bool" {
// var goodsStr []byte
// goodsStr, err = json.Marshal(goods)
// if err != nil {
// return
// }
// var apiGoods model.ApiGoods
// err = json.Unmarshal(goodsStr, &apiGoods)
// if err != nil {
// return
// }
// responseData.Data[goodsId] = apiGoods
// }
//}
//responseData.Errmsg = responseDataTemp.Errmsg
//responseData.Errcode = responseDataTemp.Errcode
return
}
......
......@@ -30,7 +30,7 @@ func MatchGoods(message model.BomMessage) (err error) {
return errors.New("没有商品的bom单")
}
bomItems := bom.BomItems
perGoDealNumber := 200
perGoDealNumber := 40
//开启协程处理搜索.每50个开启一个协程
var wg sync.WaitGroup
//判断是否有余数
......@@ -222,15 +222,23 @@ func getUpdateGoodsData(bomId int, bomItems []model.BomItem, deliveryType, sort
//构建请求参数
func getSearchParams(goodsName, brandName string, sort, number int, flag bool) (searchRequest *es.SearchRequest) {
query := getTermQuery(goodsName, brandName, number, flag)
source := es.NewSearchSource().IndexBoost("liexin_ziying", 2).Query(query).
Sort("_score", false).Sort("sort", false).From(0).Size(1)
source := es.NewSearchSource().IndexBoost("liexin_ziying", 2).Query(query)
if sort == 1 {
source.Sort("sort", false)
source.Sort("_score", false)
source.Sort("stock", false)
source.Sort("single_price", true)
}
//要去判断sort,sort=2是按照价格排序
if sort == 2 {
source.Sort("single_price_sort", false)
source.Sort("single_price", true)
//sort=3是按照库存排序
} else if sort == 3 {
source.Sort("stock_sort", false)
source.Sort("stock", false)
}
source = source.From(0).Size(1)
searchRequest = es.NewSearchRequest().Source(source)
return searchRequest
}
......
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