Commit 08709aaf by 杨树贤

Merge branch 'master' into dev

parents 8a41de6d d689bf08
...@@ -94,6 +94,9 @@ type LySku struct { ...@@ -94,6 +94,9 @@ type LySku struct {
AbilityLevel int `json:"ability_level"` AbilityLevel int `json:"ability_level"`
BrandPack string `json:"brand_pack"` BrandPack string `json:"brand_pack"`
OnwayStock int `json:"onway_stock"` OnwayStock int `json:"onway_stock"`
CompareRatio float64 `json:"compare_ratio"`
//兼容自营下单的字段,取成本价的第一个阶梯的人民币
Cost float64 `json:"cost"`
} }
type DiscountRatio struct { type DiscountRatio struct {
......
...@@ -265,6 +265,10 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go ...@@ -265,6 +265,10 @@ 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)
//仅提供价格和库存 //仅提供价格和库存
if fast != "1" { if fast != "1" {
if sku.SupplierId != 0 { if sku.SupplierId != 0 {
...@@ -329,7 +333,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go ...@@ -329,7 +333,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
} }
//最后一步,将sku的全部信息放到有序map里面 //最后一步,将sku的全部信息放到有序map里面
GoodsRes.Store(goodsId, sku) GoodsRes.Store(goodsId, sku)
//(*goodsRes)[goodsId] = A
} }
// 发送结果时也要检查 context,避免在超时后阻塞 // 发送结果时也要检查 context,避免在超时后阻塞
......
...@@ -919,3 +919,38 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku { ...@@ -919,3 +919,38 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
} }
return sku return sku
} }
// compare_price_ratio
func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
redisCon := gredis.Conn("default_r")
//判断是否存在
compareData, _ := redis.String(redisCon.Do("HGET", "compare_price_ratio", sku.GoodsId))
if compareData == "" {
return sku
}
priceLimitOn := gjson.Get(compareData, "price_limit_on").Int()
ratio := gjson.Get(compareData, "ratio").Float()
//最后价格还要处理一遍
ladderPrice := sku.LadderPrice
for index, ladder := range ladderPrice {
if priceLimitOn == 2 && ladder.PriceAc != 0 {
ladder.PriceAc = c.MyRound(c.MulFloat(ladder.PriceAc, ratio), 4)
} else {
ladder.PriceCn = c.MyRound(c.MulFloat(ladder.PriceCn, ratio), 4)
}
sku.LadderPrice[index] = ladder
}
sku.CompareRatio = ratio
sku.LadderPriceResult = sku.LadderPrice
return sku
}
// 获取自营成本价
func (ps *PriceService) GetCostForZiying(sku model.LySku) model.LySku {
if len(sku.OriginalPrice) != 0 {
sku.Cost = sku.OriginalPrice[0].PriceCn
}
return sku
}
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