Commit 8121d69d by mushishixian

修复json值类型不确定的问题

parent 6cb45872
The file could not be displayed because it is too large.
......@@ -3,7 +3,6 @@ package main
import (
"bom_server/cmd/queue"
"bom_server/configs"
"bom_server/internal/logic"
"bom_server/internal/model"
"flag"
)
......@@ -14,6 +13,5 @@ func main() {
flag.Parse()
configs.Setup(path)
model.Setup()
logic.MatchGoods(46)
queue.Sync()
}
......@@ -2,14 +2,42 @@ package queue
import (
"bom_server/configs"
"bom_server/internal/logic"
"fmt"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"strconv"
"time"
)
type RecvPro struct {
}
func init(){
queueExchange := rabbitmq.QueueExchange{
"bom_match",
"bom_match",
"bom",
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}
rabbitmq.Send(queueExchange, "1")
}
func (t *RecvPro) Consumer(dataByte []byte) error {
start := time.Now()
bomIdStr := string(dataByte)
bomId, err := strconv.ParseInt(bomIdStr, 10, 64)
fmt.Println(bomId)
if err != nil {
fmt.Println(err)
}
err = logic.MatchGoods(int(bomId))
if err != nil {
fmt.Println(err)
}
duration := time.Now().Sub(start)
fmt.Println(duration)
return nil
}
......
......@@ -81,7 +81,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
if value == "string" {
tempNumber, _ := strconv.ParseInt(price.Purchases.(string), 10, 10)
purchases = int(tempNumber)
} else {
} else if value == "float64" {
purchases = int(price.Purchases.(float64))
}else{
purchases = price.Purchases.(int)
}
if goodsMap.Number <= purchases {
......
......@@ -21,7 +21,7 @@ import (
4.得到具体的商品数据以后,针对对应的商品进行修改
**/
func MatchGoods(bomId int) {
func MatchGoods(bomId int) (err error) {
//获取bom
bom := GetBomInfoWithItems(bomId)
bomItems := bom.BomItems
......@@ -55,7 +55,7 @@ func MatchGoods(bomId int) {
// Number: 1,
// },
//}
SearchGoods(bomId, bomItems)
return SearchGoods(bomId, bomItems)
}
//去es搜索商品,得到对应的商品对应关系
......
......@@ -11,7 +11,7 @@ type Goods struct {
ClassID1 int `json:"class_id1"`
ClassID2 int `json:"class_id2"`
ClassID3 int `json:"class_id3"`
SpuID string `json:"spu_id"`
//SpuID string `json:"spu_id"`
SaleTime int `json:"sale_time"`
GoodsDetails string `json:"goods_details"`
CreateTime int `json:"create_time"`
......@@ -39,7 +39,7 @@ type Data map[string]ApiGoods
type ApiGoods struct {
GoodsID string `json:"goods_id"`
GoodsSn string `json:"goods_sn"`
SpuID string `json:"spu_id"`
//SpuID string `json:"spu_id"`
UpdateTime int `json:"update_time"`
GoodsStatus int `json:"goods_status"`
GoodsName string `json:"goods_name"`
......@@ -102,5 +102,5 @@ type ApiGoods struct {
SpuBrief string `json:"spu_brief"`
SpuDetail string `json:"spu_detail"`
ClassName string `json:"class_name"`
ErpTax bool `json:"erp_tax"`
//ErpTax bool `json:"erp_tax"`
}
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