Commit eff729bf by mushishixian

接入商品更新队列

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