Commit 39ef3bcc by hcy

Merge remote-tracking branch 'origin/dev' into dev

parents 70e09350 08709aaf
...@@ -95,6 +95,9 @@ type LySku struct { ...@@ -95,6 +95,9 @@ type LySku struct {
LabelOp int `json:"label_op"` LabelOp int `json:"label_op"`
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 {
......
...@@ -266,6 +266,10 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go ...@@ -266,6 +266,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 {
...@@ -332,7 +336,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go ...@@ -332,7 +336,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
sku.LabelOp = activityService.GetLabelOp(sku) sku.LabelOp = activityService.GetLabelOp(sku)
//最后一步,将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