Commit 66089517 by 杨树贤

联营tags单独获取

parent 8dc5a759
Showing with 41 additions and 10 deletions
......@@ -263,7 +263,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//获取标签信息
var TagService TagsService
sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0)
sku.GoodsTag = TagService.GetLyTags(sku)
//获取关税以及价格转换
sku = ls.GetTariffAndPrice(sku)
......
......@@ -18,7 +18,7 @@ type TagsService struct {
const TagZiyingSku = 4
//获取Spu的属性
func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTags model.GoodsTag) {
func (ts *TagsService) GetTags(skuId string, selfSupplierType int64) (goodsTags model.GoodsTag) {
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
goodsTagsStr, _ := redis.String(redisCon.Do("HGET", "goods_tag", skuId))
......@@ -33,13 +33,6 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
goodsLabel = goodsLabelMap[goodsLabelType]
goodsTags.GoodsLabelName = goodsLabel
goodsTags.GoodsLabel = goodsLabelType
//for _, tagResult := range gjson.Get(goodsTagsStr, "tags").Array() {
// tagName := vars.GoodsTags[int(tagResult.Int())]
// tagNames = append(tagNames, tagName)
// tags = append(tags, int(tagResult.Int()))
//}
//自定义标签
customerTag := gjson.Get(goodsTagsStr, "customer_tag").String()
if customerTag != "" {
......@@ -50,7 +43,7 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
}
}
//如果是自营商品Id,就写死当天发货标签
if len(skuId) < 10 && self_supplier_type == 1 {
if len(skuId) < 10 && selfSupplierType == 1 {
if !php2go.InArray(TagZiyingSku, tags) {
tags = append(tags, TagZiyingSku)
tagNames = append(tagNames, vars.GoodsTags[TagZiyingSku])
......@@ -63,3 +56,41 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
goodsTags.GoodsTag = tags
return goodsTags
}
//获取联营tags
func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
skuId := sku.GoodsId
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
goodsTagsStr, _ := redis.String(redisCon.Do("HGET", "goods_tag", skuId))
goodsLabel := ""
//goods_tag
var tags []int
var tagNames []string
if goodsTagsStr != "" {
//goods_label
goodsLabelType := int(gjson.Get(goodsTagsStr, "goods_label").Int())
goodsLabelMap := vars.GoodsLabel
goodsLabel = goodsLabelMap[goodsLabelType]
goodsTags.GoodsLabelName = goodsLabel
goodsTags.GoodsLabel = goodsLabelType
//自定义标签
customerTag := gjson.Get(goodsTagsStr, "customer_tag").String()
if customerTag != "" {
customerTagArr := php2go.Explode(" ", php2go.Trim(customerTag))
for _, cname := range customerTagArr {
//如果是爱智的话,去掉可议价标签
if sku.OrgId ==3 && cname == "可议价" {
continue
}
tagNames = append(tagNames, cname)
}
}
}
goodsTags.GoodsTagNames = tagNames
goodsTags.GoodsTag = tags
return goodsTags
}
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