Commit 685089af by mushishixian

自营品牌切换

parent 139261da
Showing with 29 additions and 10 deletions
package service package service
import ( import (
"github.com/gin-gonic/gin"
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/model" "go_sku_server/model"
"go_sku_server/pkg/common" "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis" "go_sku_server/pkg/gredis"
"strings" "strings"
"sync" "sync"
"github.com/gin-gonic/gin"
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
) )
type ZiyingService struct { type ZiyingService struct {
...@@ -67,7 +68,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c ...@@ -67,7 +68,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
A.Set("goods_id", common.MyInt64(goodsId)) A.Set("goods_id", common.MyInt64(goodsId))
A.Set("goods_type", gjson.Get(info, "goods_type").Int()) //查询总条数 A.Set("goods_type", gjson.Get(info, "goods_type").Int()) //查询总条数
A.Set("supplier_id", gjson.Get(info, "supplier_id").Int()) //查询总条数 A.Set("supplier_id", gjson.Get(info, "supplier_id").Int()) //查询总条数
A.Set("brand_id", gjson.Get(info, "brand_id").Int()) // // A.Set("brand_id", gjson.Get(info, "brand_id").Int()) //
otherAttrs := gjson.Get(info, "other_attrs").String() otherAttrs := gjson.Get(info, "other_attrs").String()
if otherAttrs == "" { if otherAttrs == "" {
...@@ -101,6 +102,23 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c ...@@ -101,6 +102,23 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
classId2Name = gjson.Get(classId2Info, "class_name").String() classId2Name = gjson.Get(classId2Info, "class_name").String()
} }
//迁移品牌获取,以前是读的自营品牌库,现在改成了读spu的品牌(其实就是联营品牌)以及获取标准品牌信息
spuId := gjson.Get(info, "spu_id").Int()
var standardBrand model.StandardBrand
var brandId int64
var brandName string
if spuId != 0 {
spuStr, _ := gredis.String(redisConn.Do("HGET", "spu", spuId))
brandId = gjson.Get(spuStr, "brand_id").Int()
brandName, _ = gredis.String(redisConn.Do("HGET", "brand", brandId))
var ly LyService
standardBrand = ly.GetStandardBrand(brandId)
}
A.Set("brand_id", brandId)
A.Set("brand_name", brandName)
A.Set("standard_brand", standardBrand)
A.Set("class_id1", classId1) // A.Set("class_id1", classId1) //
A.Set("class_id2", classId2) // A.Set("class_id2", classId2) //
A.Set("class_id1_name", classId1Name) // A.Set("class_id1_name", classId1Name) //
...@@ -118,6 +136,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c ...@@ -118,6 +136,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
A.Set("update_time", gjson.Get(info, "update_time").Int()) // A.Set("update_time", gjson.Get(info, "update_time").Int()) //
A.Set("sku_name", strings.Trim(gjson.Get(info, "sku_name").String(), " ")) // A.Set("sku_name", strings.Trim(gjson.Get(info, "sku_name").String(), " ")) //
A.Set("mpl", gjson.Get(info, "mpl").Int()) // A.Set("mpl", gjson.Get(info, "mpl").Int()) //
A.Set("spu_id", spuId) //
//处理库存 //处理库存
A.Set("stock", 0) //默认库存为0 A.Set("stock", 0) //默认库存为0
...@@ -150,10 +169,10 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c ...@@ -150,10 +169,10 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
} }
A.Set("cn_delivery_time", cnDeliveryTime) // 货期 A.Set("cn_delivery_time", cnDeliveryTime) // 货期
//查询品牌名称 //查询品牌名称(作废,现在改成读联营的品牌库,之前有关联自营商品到spu_id)
brand_id := gjson.Get(info, "brand_id").Int() // brand_id := gjson.Get(info, "brand_id").Int()
brand_info, _ := gredis.String(redisConn.Do("HGET", "Self_Brand", brand_id)) // brand_info, _ := gredis.String(redisConn.Do("HGET", "Self_Brand", brand_id))
A.Set("brand_name", gjson.Get(brand_info, "brand_name").String()) // // A.Set("brand_name", gjson.Get(brand_info, "brand_name").String())
if fast != "1" { //不是快速查询 if fast != "1" { //不是快速查询
// 供应商名称 // 供应商名称
...@@ -291,7 +310,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c ...@@ -291,7 +310,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
//获取标签信息 //获取标签信息
var tagService TagsService var tagService TagsService
A.Set("goods_tag", tagService.GetTags(goodsId,gjson.Get(info, "self_supplier_type").Int())) A.Set("goods_tag", tagService.GetTags(goodsId, gjson.Get(info, "self_supplier_type").Int()))
//最后写入sync map //最后写入sync map
(GoodsRes).Store(goodsId, A) (GoodsRes).Store(goodsId, A)
......
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