Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
bom_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
ca209b30
authored
Jun 02, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复价格排序
parent
b4392473
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
29 deletions
cmd/queue/bom.go
internal/logic/goods.go
internal/logic/match.go
cmd/queue/bom.go
View file @
ca209b30
...
@@ -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":
48,"delivery_type":1,"sort":1
}`
//str := `{"bom_id":
236,"delivery_type":1,"sort":3
}`
//rabbitmq.Send(queueExchange, str)
//rabbitmq.Send(queueExchange, str)
}
}
...
...
internal/logic/goods.go
View file @
ca209b30
...
@@ -30,6 +30,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
...
@@ -30,6 +30,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
}
}
goodsIdsStr
:=
strings
.
Join
(
goodsIds
,
","
)
goodsIdsStr
:=
strings
.
Join
(
goodsIds
,
","
)
goodsList
,
err
:=
GetGoodsInfo
(
goodsIdsStr
)
goodsList
,
err
:=
GetGoodsInfo
(
goodsIdsStr
)
if
len
(
goodsMapList
)
!=
0
{
bomId
=
goodsMapList
[
0
]
.
BomId
}
//fmt.Println(goodsIdsStr)
//fmt.Println(goodsIdsStr)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
...
@@ -123,31 +126,6 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
...
@@ -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
return
}
}
...
...
internal/logic/match.go
View file @
ca209b30
...
@@ -30,7 +30,7 @@ func MatchGoods(message model.BomMessage) (err error) {
...
@@ -30,7 +30,7 @@ func MatchGoods(message model.BomMessage) (err error) {
return
errors
.
New
(
"没有商品的bom单"
)
return
errors
.
New
(
"没有商品的bom单"
)
}
}
bomItems
:=
bom
.
BomItems
bomItems
:=
bom
.
BomItems
perGoDealNumber
:=
20
0
perGoDealNumber
:=
4
0
//开启协程处理搜索.每50个开启一个协程
//开启协程处理搜索.每50个开启一个协程
var
wg
sync
.
WaitGroup
var
wg
sync
.
WaitGroup
//判断是否有余数
//判断是否有余数
...
@@ -222,15 +222,23 @@ func getUpdateGoodsData(bomId int, bomItems []model.BomItem, deliveryType, sort
...
@@ -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
)
{
func
getSearchParams
(
goodsName
,
brandName
string
,
sort
,
number
int
,
flag
bool
)
(
searchRequest
*
es
.
SearchRequest
)
{
query
:=
getTermQuery
(
goodsName
,
brandName
,
number
,
flag
)
query
:=
getTermQuery
(
goodsName
,
brandName
,
number
,
flag
)
source
:=
es
.
NewSearchSource
()
.
IndexBoost
(
"liexin_ziying"
,
2
)
.
Query
(
query
)
.
source
:=
es
.
NewSearchSource
()
.
IndexBoost
(
"liexin_ziying"
,
2
)
.
Query
(
query
)
Sort
(
"_score"
,
false
)
.
Sort
(
"sort"
,
false
)
.
From
(
0
)
.
Size
(
1
)
if
sort
==
1
{
source
.
Sort
(
"sort"
,
false
)
source
.
Sort
(
"_score"
,
false
)
source
.
Sort
(
"stock"
,
false
)
source
.
Sort
(
"single_price"
,
true
)
}
//要去判断sort,sort=2是按照价格排序
//要去判断sort,sort=2是按照价格排序
if
sort
==
2
{
if
sort
==
2
{
source
.
Sort
(
"single_price_sort"
,
false
)
source
.
Sort
(
"single_price"
,
true
)
source
.
Sort
(
"single_price"
,
true
)
//sort=3是按照库存排序
//sort=3是按照库存排序
}
else
if
sort
==
3
{
}
else
if
sort
==
3
{
source
.
Sort
(
"stock_sort"
,
false
)
source
.
Sort
(
"stock"
,
false
)
source
.
Sort
(
"stock"
,
false
)
}
}
source
=
source
.
From
(
0
)
.
Size
(
1
)
searchRequest
=
es
.
NewSearchRequest
()
.
Source
(
source
)
searchRequest
=
es
.
NewSearchRequest
()
.
Source
(
source
)
return
searchRequest
return
searchRequest
}
}
...
...
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