Commit f0f76118 by mushishixian

修复类型

parent c6f3f3f1
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
//联营sku结构体 //联营sku结构体
type LySku struct { type LySku struct {
LadderPrice []LadderPrice `json:"-"` LadderPrice []LadderPrice `json:"-"`
SpuId int64 `json:"spu_id"` SpuId string `json:"spu_id"`
OldGoodsId int64 `json:"old_goods_id"` OldGoodsId int64 `json:"old_goods_id"`
UpdateTime int64 `json:"update_time"` UpdateTime int64 `json:"update_time"`
CpTime int64 `json:"cp_time"` CpTime int64 `json:"cp_time"`
...@@ -71,7 +71,7 @@ func InitSkuData(sku string) (data LySku) { ...@@ -71,7 +71,7 @@ func InitSkuData(sku string) (data LySku) {
goodsSn := gjson.Get(sku, "goods_sn").String() goodsSn := gjson.Get(sku, "goods_sn").String()
data.GoodsSn = goodsSn data.GoodsSn = goodsSn
spuId := gjson.Get(sku, "spu_id").Int() spuId := gjson.Get(sku, "spu_id").String()
data.SpuId = spuId data.SpuId = spuId
oldGoodsId := gjson.Get(sku, "old_goods_id").Int() oldGoodsId := gjson.Get(sku, "old_goods_id").Int()
......
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
"go_sku_server/pkg/common" "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis" "go_sku_server/pkg/gredis"
"sort" "sort"
"strconv"
"sync" "sync"
) )
...@@ -62,8 +61,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -62,8 +61,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//A := orderedmap.New() //A := orderedmap.New()
sku := model.InitSkuData(skuStr) sku := model.InitSkuData(skuStr)
sku.GoodsId = goodsId sku.GoodsId = goodsId
spuIdStr:= strconv.Itoa(int(sku.SpuId)) spu := spuList[sku.SpuId]
spu := spuList[spuIdStr]
//读取包装字段的缓存 //读取包装字段的缓存
if sku.SupplierId == 7 { if sku.SupplierId == 7 {
//sku_raw_map哪里写入(成意写的) //sku_raw_map哪里写入(成意写的)
......
...@@ -17,6 +17,7 @@ import ( ...@@ -17,6 +17,7 @@ import (
"gopkg.in/mgo.v2" "gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson" "gopkg.in/mgo.v2/bson"
_ "gopkg.in/mgo.v2/bson" _ "gopkg.in/mgo.v2/bson"
"strconv"
"strings" "strings"
) )
...@@ -95,14 +96,15 @@ type SpuAttr struct { ...@@ -95,14 +96,15 @@ type SpuAttr struct {
} }
//获取Spu的属性 //获取Spu的属性
func (ls *LyService) GetSpuAttr(spuId int64) (attrsResult interface{}) { func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
var spuAttr SpuAttr var spuAttr SpuAttr
var attrsList []interface{} var attrsList []interface{}
mongodb := mongo.Conn("default") mongodb := mongo.Conn("default")
defer func() { defer func() {
mongodb.Close() mongodb.Close()
}() }()
err := mongodb.DB("ichunt").C("spu_attrs").Find(bson.M{"spu_id": spuId}).One(&spuAttr) spuIdInt, _ := strconv.Atoi(spuId)
err := mongodb.DB("ichunt").C("spu_attrs").Find(bson.M{"spu_id": spuIdInt}).One(&spuAttr)
//err := mongo.Conn("default").DB("ichunt").C("spu_attrs").Find(bson.M{"spu_id": spuId}).One(&spuAttr) //err := mongo.Conn("default").DB("ichunt").C("spu_attrs").Find(bson.M{"spu_id": spuId}).One(&spuAttr)
if err != nil && err != mgo.ErrNotFound { if err != nil && err != mgo.ErrNotFound {
fmt.Println("mongodb连接错误:") fmt.Println("mongodb连接错误:")
......
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