Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4a7f6a13
authored
Jan 29, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新比价
parent
208f5105
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
service/parity_service.go
service/query/parity_query.go
service/parity_service.go
View file @
4a7f6a13
...
@@ -42,12 +42,16 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse)
...
@@ -42,12 +42,16 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse)
results
.
ErrorMsg
=
"目标比价型号不得为空"
results
.
ErrorMsg
=
"目标比价型号不得为空"
return
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"
//所有索引参与比价
indexTarget
:=
config
.
Get
(
"es.search_supplier"
)
.
String
()
+
",liexin_ziying"
//所有索引参与比价
//查询es
//查询es
esResult
,
err
:=
es
.
CurlE
sPrimary
(
indexTarget
,
queryString
)
esResult
,
err
:=
es
.
CurlE
S
(
indexTarget
,
queryString
)
if
err
!=
nil
{
if
err
!=
nil
{
results
.
ErrorCode
=
1002
;
results
.
ErrorCode
=
1002
;
results
.
ErrorMsg
=
err
.
Error
()
results
.
ErrorMsg
=
err
.
Error
()
...
@@ -79,6 +83,10 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse)
...
@@ -79,6 +83,10 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse)
var
slic
[]
model
.
DullGoodsData
var
slic
[]
model
.
DullGoodsData
goodsList
,
_
:=
GetGoodsInfo
(
ctx
,
goodsIds
)
goodsList
,
_
:=
GetGoodsInfo
(
ctx
,
goodsIds
)
for
_
,
v
:=
range
goodsList
{
for
_
,
v
:=
range
goodsList
{
if
v
.
Stock
<
stockCheck
{
continue
}
GoodsUrl
:=
""
GoodsUrl
:=
""
BrandUrl
:=
""
BrandUrl
:=
""
referer
:=
ctx
.
GetHeader
(
"Referer"
)
referer
:=
ctx
.
GetHeader
(
"Referer"
)
...
...
service/query/parity_query.go
View file @
4a7f6a13
...
@@ -10,8 +10,9 @@ import (
...
@@ -10,8 +10,9 @@ import (
/*
/*
比价拼接查询语句
比价拼接查询语句
@param target_goods_name 目标比价型号名称,多个型号名称(类似型号一样这样拼接传) 以€分隔,如:LM358DT€LM358SK
@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
()
query
:=
elastic
.
NewBoolQuery
()
subQuery
:=
elastic
.
NewBoolQuery
()
subQuery
:=
elastic
.
NewBoolQuery
()
...
@@ -30,12 +31,12 @@ func GetParityQuery(ctx *gin.Context,target_goods_name string,target_goods_type
...
@@ -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
(
"goods_status"
,
1
))
query
.
Must
(
elastic
.
NewTermQuery
(
"status"
,
1
))
query
.
Must
(
elastic
.
NewTermQuery
(
"status"
,
1
))
query
.
Must
(
elastic
.
NewRangeQuery
(
"stock"
)
.
Gt
(
0
))
query
.
Must
(
elastic
.
NewRangeQuery
(
"stock"
)
.
Gt
e
(
number
))
query
.
Must
(
subQuery
)
query
.
Must
(
subQuery
)
source
:=
elastic
.
NewSearchSource
()
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
.
Size
(
200
)
source
.
From
(
0
)
source
.
From
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment