Commit a4bc9f85 by 杨树贤

sku_name的展示

parent 494a5de2
Showing with 11 additions and 8 deletions
......@@ -45,7 +45,6 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
github.com/shopspring/decimal v1.0.1
)
......
......@@ -6,7 +6,7 @@ import (
"github.com/tidwall/gjson"
)
//联营sku结构体
// 联营sku结构体
type LySku struct {
LadderPrice []LadderPrice `json:"-"`
SpuId string `json:"spu_id"`
......@@ -31,6 +31,7 @@ type LySku struct {
Packing string `json:"packing"`
GoodsId string `json:"goods_id"`
GoodsName string `json:"goods_name"`
SkuName string `json:"sku_name"`
BrandName string `json:"brand_name"`
SupplierName string `json:"supplier_name"`
Attrs interface{} `json:"attrs"`
......@@ -131,7 +132,7 @@ type StockInfo struct {
Stock int `json:"stock" bson:"stock"`
}
//为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
// 为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
func InitSkuData(sku string) (data LySku) {
goodsSn := gjson.Get(sku, "goods_sn").String()
data.GoodsSn = goodsSn
......@@ -148,15 +149,18 @@ func InitSkuData(sku string) (data LySku) {
goodsStatus := gjson.Get(sku, "goods_status").Int()
data.GoodsStatus = goodsStatus
supplierId := gjson.Get(sku, "supplier_id").Int()
data.SupplierId = supplierId
goodsName := gjson.Get(sku, "goods_name").String()
data.GoodsName = goodsName
skuName := gjson.Get(sku, "goods_name").String()
data.SkuName = skuName
goodsType := gjson.Get(sku, "goods_type").Int()
data.GoodsType = goodsType
supplierId := gjson.Get(sku, "supplier_id").Int()
data.SupplierId = supplierId
encoded := gjson.Get(sku, "encoded").String()
data.Encoded = encoded
......@@ -225,7 +229,7 @@ func InitSkuData(sku string) (data LySku) {
return
}
//获取联营商品的阶梯价
// 获取联营商品的阶梯价
func getLadderPrice(ladderPriceStr string) (ladderPrice []LadderPrice) {
ladderPriceArr := gjson.Parse(ladderPriceStr).Array()
for _, price := range ladderPriceArr {
......@@ -246,7 +250,7 @@ func getLadderPrice(ladderPriceStr string) (ladderPrice []LadderPrice) {
return
}
//获取原始价格
// 获取原始价格
func getOriginPrice(ladderPriceStr string) (ladderPrice []OriginPrice) {
ladderPriceArr := gjson.Parse(ladderPriceStr).Array()
for _, price := range ladderPriceArr {
......
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