Commit 1270a276 by hcy

Merge branch 'master' into hcy/2025.1.12-增加控制商品按钮

parents 70e09350 a6b6da9a
...@@ -95,6 +95,10 @@ type LySku struct { ...@@ -95,6 +95,10 @@ 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"`
CostNoTax float64 `json:"cost_no_tax"`
} }
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,避免在超时后阻塞
......
...@@ -248,6 +248,9 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) { ...@@ -248,6 +248,9 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
if len(sku.LadderPrice) == 0 { if len(sku.LadderPrice) == 0 {
return return
} }
if sku.AbilityLevel == 0 {
return
}
if sku.Stock == 0 { if sku.Stock == 0 {
return return
} }
...@@ -309,13 +312,22 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -309,13 +312,22 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
ladderPrice := sku.LadderPrice ladderPrice := sku.LadderPrice
//这里是存了一些特殊供应商价格的判断,数据库里不是所有供应商都是存的人民币/美金 //这里是存了一些特殊供应商价格的判断,数据库里不是所有供应商都是存的人民币/美金
sku = priceService.TransformSpecialSupplierPrice(sku) sku = priceService.TransformSpecialSupplierPrice(sku)
//这里还有两个个特殊判断 //这里还有两个个特殊判断
//猎芯自营 L0018319 WMS同步过来的未税成本单价(人民币),需乘以关税,再填入到基石该SKU的 成本价——国内含税(¥) //猎芯自营 L0018319 WMS同步过来的未税成本单价(人民币),需乘以关税,再填入到基石该SKU的 成本价——国内含税(¥)
// 香港自营(L0018562)WMS同步过来的未税成本单价(美金) // 香港自营(L0018562)WMS同步过来的未税成本单价(美金)
//需更新到 基石该SKU的 成本价——香港交货($)且也需乘美金转人民币汇率, 再乘以关税,填入到基石该SKU的 成本价——国内含税(¥)价 //需更新到 基石该SKU的 成本价——香港交货($)且也需乘美金转人民币汇率, 再乘以关税,填入到基石该SKU的 成本价——国内含税(¥)价
if sku.Canal == "L0018319" { //这里要获取一个第一个阶梯的未税成本价
for _, price := range sku.OriginalPrice { // L0003270 这个供应商的话
var costNoTax float64
if sku.Canal == "L0018319" || sku.Canal == "L0003270" {
for index, price := range sku.OriginalPrice {
priceCnNoTax := price.PriceCn
if index == 0 {
costNoTax = priceCnNoTax
if costNoTax == 0 {
continue
}
}
originalPrice = append(originalPrice, model.OriginPrice{ originalPrice = append(originalPrice, model.OriginPrice{
Purchases: price.Purchases, Purchases: price.Purchases,
PriceCn: c.MyRound(c.MulFloat(price.PriceCn, tax), 4), PriceCn: c.MyRound(c.MulFloat(price.PriceCn, tax), 4),
...@@ -327,23 +339,33 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -327,23 +339,33 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
} }
} }
if sku.Canal == "L0018562" { if sku.Canal == "L0018562" || sku.Canal == "L0003270" {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
usdRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", 2)) usdRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", 2))
for _, price := range sku.OriginalPrice { for index, price := range sku.OriginalPrice {
priceCnNoTax := c.MulFloat(price.PriceUs, usdRatio)
if index == 0 {
costNoTax = priceCnNoTax
if costNoTax == 0 {
continue
}
}
originalPrice = append(originalPrice, model.OriginPrice{ originalPrice = append(originalPrice, model.OriginPrice{
Purchases: price.Purchases, Purchases: price.Purchases,
PriceCn: c.MyRound(c.MulFloat(price.PriceUs, usdRatio*tax), 4), PriceCn: c.MyRound(c.MulFloat(priceCnNoTax, tax), 4),
PriceUs: price.PriceUs, PriceUs: price.PriceUs,
}) })
} }
for index, price := range sku.LadderPrice { for index, price := range sku.LadderPrice {
if costNoTax == 0 {
continue
}
ladderPrice[index].PriceCn = c.MyRound(c.MulFloat(price.PriceUs, usdRatio*tax), 4) ladderPrice[index].PriceCn = c.MyRound(c.MulFloat(price.PriceUs, usdRatio*tax), 4)
} }
} }
sku.CostNoTax = costNoTax
//判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价 //判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价
//如果没有成本价字段,就要去生成阶梯价格 //如果没有成本价字段,就要去生成阶梯价格
if len(ladderPrice) > 0 { if len(ladderPrice) > 0 {
...@@ -380,7 +402,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -380,7 +402,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data[key].PriceCostCn = price.PriceCostCn data[key].PriceCostCn = price.PriceCostCn
} }
//判断原始价格有变化,那就要覆盖 //判断原始价格有变化,那就要覆盖
if len(originalPrice) > 0 { if len(originalPrice) > 0 {
sku.OriginalPrice = originalPrice sku.OriginalPrice = originalPrice
......
...@@ -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