Commit 4a7f6a13 by hcy001

更新比价

parent 208f5105
......@@ -42,12 +42,16 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse)
results.ErrorMsg = "目标比价型号不得为空"
return
}
if number == "" {
number = "1";
}
stockCheck := gconv.Int(number); //比价数量
//获取查询条件
queryString := query.GetParityQuery(ctx,target_goods_name,target_goods_type)
queryString := query.GetParityQuery(ctx,target_goods_name,target_goods_type,stockCheck)
indexTarget := config.Get("es.search_supplier").String()+",liexin_ziying" //所有索引参与比价
//查询es
esResult, err := es.CurlEsPrimary(indexTarget, queryString)
esResult, err := es.CurlES(indexTarget, queryString)
if err != nil {
results.ErrorCode = 1002;
results.ErrorMsg = err.Error()
......@@ -79,6 +83,10 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse)
var slic []model.DullGoodsData
goodsList, _ := GetGoodsInfo(ctx,goodsIds)
for _,v := range goodsList{
if v.Stock < stockCheck {
continue
}
GoodsUrl := ""
BrandUrl := ""
referer := ctx.GetHeader("Referer")
......
......@@ -10,8 +10,9 @@ import (
/*
比价拼接查询语句
@param target_goods_name 目标比价型号名称,多个型号名称(类似型号一样这样拼接传) 以€分隔,如:LM358DT€LM358SK
@param number 比价数量
*/
func GetParityQuery(ctx *gin.Context,target_goods_name string,target_goods_type int) (param string){
func GetParityQuery(ctx *gin.Context,target_goods_name string,target_goods_type int,number int) (param string){
query := elastic.NewBoolQuery()
subQuery := elastic.NewBoolQuery()
......@@ -30,12 +31,12 @@ func GetParityQuery(ctx *gin.Context,target_goods_name string,target_goods_type
}
query.Must(elastic.NewTermQuery("goods_status", 1))
query.Must(elastic.NewTermQuery("status", 1))
query.Must(elastic.NewRangeQuery("stock").Gt(0))
query.Must(elastic.NewRangeQuery("stock").Gte(number))
query.Must(subQuery)
source := elastic.NewSearchSource()
source.FetchSourceContext(elastic.NewFetchSourceContext(true).Include("goods_id","goods_name")) //显示字段
source.FetchSourceContext(elastic.NewFetchSourceContext(true).Include("goods_id","goods_name","stock")) //显示字段
source.Size(200)
source.From(0)
......
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