Commit 45a36ffb by 杨树贤

Merge branch 'master' into dev

# Conflicts:
#	service/service_price.go
parents ff16a3b6 66089517
...@@ -263,7 +263,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -263,7 +263,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//获取标签信息 //获取标签信息
var TagService TagsService var TagService TagsService
sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0) sku.GoodsTag = TagService.GetLyTags(sku)
//获取关税以及价格转换 //获取关税以及价格转换
sku = ls.GetTariffAndPrice(sku) sku = ls.GetTariffAndPrice(sku)
......
package service package service
import ( import (
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/model" "go_sku_server/model"
c "go_sku_server/pkg/common" c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis" "go_sku_server/pkg/gredis"
...@@ -8,11 +12,6 @@ import ( ...@@ -8,11 +12,6 @@ import (
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
) )
type PriceService struct { type PriceService struct {
...@@ -790,7 +789,13 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku { ...@@ -790,7 +789,13 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
//sku.AcType = 0 //sku.AcType = 0
//continue //continue
} }
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
var tempAcPrice float64
if sku.OrgId == 3 {
tempAcPrice = c.MyRound(c.MulFloat(sku.LadderPrice[0].PriceCn, sku.Ratio/100), 0)
} else {
tempAcPrice = c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
}
//价格与原价一样 //价格与原价一样
if price.PriceCn == tempAcPrice && index < 2 { if price.PriceCn == tempAcPrice && index < 2 {
//flag++ //flag++
...@@ -800,7 +805,12 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku { ...@@ -800,7 +805,12 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
//} //}
} }
price.PriceAc = tempAcPrice price.PriceAc = tempAcPrice
priceAcUs := c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4) var priceAcUs float64
if sku.OrgId == 3 {
priceAcUs = c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 0)
} else {
priceAcUs = c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
}
price.PriceAcUs = priceAcUs price.PriceAcUs = priceAcUs
sku.LadderPrice[index].PriceAc = tempAcPrice sku.LadderPrice[index].PriceAc = tempAcPrice
......
...@@ -18,7 +18,7 @@ type TagsService struct { ...@@ -18,7 +18,7 @@ type TagsService struct {
const TagZiyingSku = 4 const TagZiyingSku = 4
//获取Spu的属性 //获取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") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
goodsTagsStr, _ := redis.String(redisCon.Do("HGET", "goods_tag", skuId)) goodsTagsStr, _ := redis.String(redisCon.Do("HGET", "goods_tag", skuId))
...@@ -33,13 +33,6 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag ...@@ -33,13 +33,6 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
goodsLabel = goodsLabelMap[goodsLabelType] goodsLabel = goodsLabelMap[goodsLabelType]
goodsTags.GoodsLabelName = goodsLabel goodsTags.GoodsLabelName = goodsLabel
goodsTags.GoodsLabel = goodsLabelType 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() customerTag := gjson.Get(goodsTagsStr, "customer_tag").String()
if customerTag != "" { if customerTag != "" {
...@@ -50,7 +43,7 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag ...@@ -50,7 +43,7 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
} }
} }
//如果是自营商品Id,就写死当天发货标签 //如果是自营商品Id,就写死当天发货标签
if len(skuId) < 10 && self_supplier_type == 1 { if len(skuId) < 10 && selfSupplierType == 1 {
if !php2go.InArray(TagZiyingSku, tags) { if !php2go.InArray(TagZiyingSku, tags) {
tags = append(tags, TagZiyingSku) tags = append(tags, TagZiyingSku)
tagNames = append(tagNames, vars.GoodsTags[TagZiyingSku]) tagNames = append(tagNames, vars.GoodsTags[TagZiyingSku])
...@@ -63,3 +56,41 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag ...@@ -63,3 +56,41 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
goodsTags.GoodsTag = tags goodsTags.GoodsTag = tags
return goodsTags 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