Commit eff729bf by mushishixian

接入商品更新队列

parent 635dd3d6
......@@ -7,6 +7,7 @@ bom_server
*.properties
*.iml
*.exe
*.exe~
/logs
/components
/storage/app
......@@ -24,6 +25,7 @@ cmd/cmd.exe~
cmd/cmd
/cmd/dong/logs/*.log
server/server
server.exe
/sh
*.ini
gowatch.yml
......@@ -22,7 +22,7 @@ func init() {
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":642,"delivery_type":1,"sort":1}`
//str := `{"bom_id":666,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
}
......
......@@ -153,17 +153,8 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
//切割参数
func splitAttrs(attrs string) (result []string) {
result = strings.Split(attrs, " ")
if len(result) > 1 {
return
}
result = strings.Split(attrs, ",")
if len(result) > 1 {
return
}
result = strings.Split(attrs, "|")
if len(result) > 1 {
return
}
result = strings.Split(attrs, ",")
if len(result) > 1 {
return
......
......@@ -32,6 +32,7 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
bomIdStr := strconv.FormatInt(int64(bomId), 10)
tableEnd := string(bomIdStr[len(bomIdStr)-1])
tableName := "lie_bom_item_matching_" + tableEnd
//批量更新每一条记录之前,要去批量更新item表的item_status
for _, matching := range matchingList {
//先去数据库查询是否存在该记录,有的话修改,没有就新增
......@@ -60,6 +61,8 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
if err != nil {
return
}
//更新商品价格和库存的队列
go UpdateGoodsPriceAndStockQueue(matching.GoodsName)
}
return nil
}
......
......@@ -4,6 +4,7 @@ import (
"bom_server/configs"
"bom_server/internal/model"
"encoding/json"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"strings"
......@@ -225,3 +226,14 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model.
}
return
}
func UpdateGoodsPriceAndStockQueue(goodsName string){
queueExchange := rabbitmq.QueueExchange{
"keyword_search_queue",
"",
"",
"direct",
configs.RabbitMQSetting.Url,
}
rabbitmq.Send(queueExchange, goodsName)
}
The file could not be displayed because it is too large.
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