Commit 0f6e18b7 by 杨树贤

Merge branch 'master' into dev

parents 221d7cf6 9e449996
...@@ -104,6 +104,7 @@ type LySku struct { ...@@ -104,6 +104,7 @@ type LySku struct {
//兼容自营下单的字段,取成本价的第一个阶梯的人民币 //兼容自营下单的字段,取成本价的第一个阶梯的人民币
Cost float64 `json:"cost"` Cost float64 `json:"cost"`
CostUs float64 `json:"cost_us"` CostUs float64 `json:"cost_us"`
IsZiying int `json:"is_ziying"`
} }
type DiscountRatio struct { type DiscountRatio struct {
...@@ -287,6 +288,12 @@ func InitSkuData(sku string) (data LySku) { ...@@ -287,6 +288,12 @@ func InitSkuData(sku string) (data LySku) {
data.Encoded = "10142-L" data.Encoded = "10142-L"
} }
//判断是否自营
data.IsZiying = 0
if supplierId == 17 && (data.Canal == "L0018319" || data.Canal == "L0018562" || data.Canal == "L0003270") {
data.IsZiying = 1
}
cpTime := gjson.Get(sku, "cp_time").Int() cpTime := gjson.Get(sku, "cp_time").Int()
data.CpTime = cpTime data.CpTime = cpTime
......
...@@ -266,8 +266,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go ...@@ -266,8 +266,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
sku = priceService.GetActivityPrice(sku) sku = priceService.GetActivityPrice(sku)
} }
// sku = priceService.GetComparePrice(sku)
sku = priceService.GetCostForZiying(sku) sku = priceService.GetCostForZiying(sku)
//仅提供价格和库存 //仅提供价格和库存
...@@ -327,6 +325,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go ...@@ -327,6 +325,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
//获取关税以及价格转换 //获取关税以及价格转换
sku = ls.GetTariffAndPrice(sku) sku = ls.GetTariffAndPrice(sku)
sku = priceService.GetComparePrice(sku)
//获取新的限制库存信息 //获取新的限制库存信息
has, limitStock := ls.getLimitStock(sku.GoodsId) has, limitStock := ls.getLimitStock(sku.GoodsId)
if has { if has {
......
...@@ -932,6 +932,7 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku { ...@@ -932,6 +932,7 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
// compare_price_ratio // compare_price_ratio
func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku { func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close()
//判断是否存在 //判断是否存在
compareData, _ := redis.String(redisCon.Do("HGET", "compare_price_ratio", sku.GoodsId)) compareData, _ := redis.String(redisCon.Do("HGET", "compare_price_ratio", sku.GoodsId))
if compareData == "" { if compareData == "" {
...@@ -943,7 +944,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku { ...@@ -943,7 +944,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
ladderPrice := sku.LadderPrice ladderPrice := sku.LadderPrice
for index, ladder := range ladderPrice { for index, ladder := range ladderPrice {
if priceLimitOn == 2 && ladder.PriceAc != 0 { if priceLimitOn == 1 && ladder.PriceAc != 0 {
ladder.PriceAc = c.MyRound(c.MulFloat(ladder.PriceAc, ratio), 4) ladder.PriceAc = c.MyRound(c.MulFloat(ladder.PriceAc, ratio), 4)
} else { } else {
ladder.PriceCn = c.MyRound(c.MulFloat(ladder.PriceCn, ratio), 4) ladder.PriceCn = c.MyRound(c.MulFloat(ladder.PriceCn, ratio), 4)
......
...@@ -77,6 +77,18 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) { ...@@ -77,6 +77,18 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
goodsTags.GoodsLabelName = goodsLabel goodsTags.GoodsLabelName = goodsLabel
goodsTags.GoodsLabel = goodsLabelType goodsTags.GoodsLabel = goodsLabelType
//系统打的标签
systemTagArr := gjson.Get(goodsTagsStr, "tags").Array()
if len(systemTagArr) > 0 {
for _, tagIdResult := range systemTagArr {
tagId := int(tagIdResult.Int())
tags = append(tags, tagId)
if tagName, ok := vars.GoodsTags[tagId]; ok {
tagNames = append(tagNames, tagName)
}
}
}
//自定义标签 //自定义标签
customerTag := gjson.Get(goodsTagsStr, "customer_tag").String() customerTag := gjson.Get(goodsTagsStr, "customer_tag").String()
if customerTag != "" { if customerTag != "" {
......
...@@ -185,7 +185,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams ...@@ -185,7 +185,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams
A.Set("stock", 0) //默认库存为0 A.Set("stock", 0) //默认库存为0
dbStock := gjson.Get(info, "stock").Int() //当前db库存 dbStock := gjson.Get(info, "stock").Int() //当前db库存
if dbStock > 0 { if dbStock > 0 {
lockStock := qs.skuLockNum(&redisConn, goodsId) //当前锁库库存 lockStock := SkuLockNum(goodsId) //当前锁库库存
stockG := dbStock - lockStock //当前可购买库存 stockG := dbStock - lockStock //当前可购买库存
if stockG > 0 { if stockG > 0 {
A.Set("actual_stock", dbStock) //锁定库存 A.Set("actual_stock", dbStock) //锁定库存
...@@ -367,6 +367,8 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams ...@@ -367,6 +367,8 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams
Stock: gconv.Int64(nowstock), Stock: gconv.Int64(nowstock),
AbilityLevel: 2, AbilityLevel: 2,
StandardBrand: standardBrand, StandardBrand: standardBrand,
Moq: moq,
Mpq: mpq,
GoodsName: gjson.Get(info, "goods_name").String(), GoodsName: gjson.Get(info, "goods_name").String(),
SpuId: gconv.String(spuId), SpuId: gconv.String(spuId),
ClassID1: gconv.Int(spuClassId1), ClassID1: gconv.Int(spuClassId1),
......
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"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"
"strconv"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap" "github.com/iancoleman/orderedmap"
...@@ -12,8 +13,21 @@ import ( ...@@ -12,8 +13,21 @@ import (
) )
//自营公共函数类 //自营公共函数类
/*
获取自营锁库数量
*/
func SkuLockNum(goodsId string) int64 {
//获取总锁库库存
redisCon := gredis.Conn("spu")
defer redisCon.Close()
stockStr, _ := redis.String(redisCon.Do("HGET", "sku_lock_stock", goodsId))
lockStock, _ := strconv.ParseInt(stockStr, 10, 64)
return lockStock
}
/* /*
计算单个sku总锁库数量 计算单个sku总锁库数量-废弃
*/ */
func (qs *ZiyingService) skuLockNum(c *redis.Conn, goodsId string) int64 { func (qs *ZiyingService) skuLockNum(c *redis.Conn, goodsId string) int64 {
reply, err := redis.Values((*c).Do("hvals", "Self_StockLock"+goodsId)) reply, err := redis.Values((*c).Do("hvals", "Self_StockLock"+goodsId))
......
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