Commit 99d38893 by 杨树贤

价格展示问题

parent 54266907
Showing with 38 additions and 3 deletions
...@@ -19,6 +19,8 @@ type PriceService struct { ...@@ -19,6 +19,8 @@ type PriceService struct {
// 构建专营的阶梯价,现在专营只会存一个简单的成本价,阶梯数量是1,所以我这边要根据专营的阶梯系数去构建具体的阶梯价 // 构建专营的阶梯价,现在专营只会存一个简单的成本价,阶梯数量是1,所以我这边要根据专营的阶梯系数去构建具体的阶梯价
func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//需要展示的价格系数
var showPriceRatioList []model.PriceRatio
//先去找到对应的价格系数 //先去找到对应的价格系数
var ratioDataKey string var ratioDataKey string
if sku.Moq <= 50 { if sku.Moq <= 50 {
...@@ -167,7 +169,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -167,7 +169,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
} }
priceRatioSort = -1 priceRatioSort = -1
} }
sku.PriceRatio = priceRatioList
sku.PriceRatioSort = priceRatioSort sku.PriceRatioSort = priceRatioSort
//这是用来展示在商品服务的价格系数,专营的系数和代购的不一样,所以要转换一下展示形式 //这是用来展示在商品服务的价格系数,专营的系数和代购的不一样,所以要转换一下展示形式
...@@ -213,16 +214,21 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -213,16 +214,21 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
fixedPurchases = []int{moq, 200, 500, 1000, 2000} fixedPurchases = []int{moq, 200, 500, 1000, 2000}
break break
} }
for index, purchase := range fixedPurchases { for index, purchases := range fixedPurchases {
//costLadderPriceRatio这个redis是字典,下标从0开始的,所以要从第5个开始取 //costLadderPriceRatio这个redis是字典,下标从0开始的,所以要从第5个开始取
ratio := priceRatioList[4+index].Ratio ratio := priceRatioList[4+index].Ratio
ratioUsd := priceRatioList[4+index].RatioUsd ratioUsd := priceRatioList[4+index].RatioUsd
//同时还要构建价格系数展示在商品服务 //同时还要构建价格系数展示在商品服务
generatedLadderPrice = append(generatedLadderPrice, model.LadderPrice{ generatedLadderPrice = append(generatedLadderPrice, model.LadderPrice{
Purchases: int64(purchase), Purchases: int64(purchases),
PriceCn: c.MyRound(c.MulFloat(costPriceCn, ratio), 4), PriceCn: c.MyRound(c.MulFloat(costPriceCn, ratio), 4),
PriceUs: c.MyRound(c.MulFloat(costPriceUs, ratioUsd), 4), PriceUs: c.MyRound(c.MulFloat(costPriceUs, ratioUsd), 4),
}) })
showPriceRatioList = append(showPriceRatioList, model.PriceRatio{
Ratio: ratio,
RatioUsd: ratioUsd,
Purchases: int64(purchases),
})
} }
} else { } else {
...@@ -247,6 +253,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -247,6 +253,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn: c.MyRound(c.MulFloat(costPriceCn, ratio), 4), PriceCn: c.MyRound(c.MulFloat(costPriceCn, ratio), 4),
PriceUs: c.MyRound(c.MulFloat(costPriceUs, ratio), 4), PriceUs: c.MyRound(c.MulFloat(costPriceUs, ratio), 4),
}) })
showPriceRatioList = append(showPriceRatioList, model.PriceRatio{
Ratio: ratio,
RatioUsd: ratio,
Purchases: int64(purchases),
})
} }
} }
...@@ -254,6 +265,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -254,6 +265,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
return generatedLadderPrice[i].Purchases < generatedLadderPrice[j].Purchases return generatedLadderPrice[i].Purchases < generatedLadderPrice[j].Purchases
}) })
sku.LadderPrice = generatedLadderPrice sku.LadderPrice = generatedLadderPrice
sku.PriceRatio = showPriceRatioList
return sku return sku
} }
fmt.Println("是成本价") fmt.Println("是成本价")
...@@ -296,6 +309,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -296,6 +309,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn: c.MyRound(c.MulFloat(costPriceCn, priceCnRatio), 4), PriceCn: c.MyRound(c.MulFloat(costPriceCn, priceCnRatio), 4),
PriceUs: c.MyRound(c.MulFloat(costPriceUs, priceUsRatio), 4), PriceUs: c.MyRound(c.MulFloat(costPriceUs, priceUsRatio), 4),
}) })
showPriceRatioList = append(showPriceRatioList, model.PriceRatio{
Ratio: priceCnRatio,
RatioUsd: priceUsRatio,
Purchases: int64(costPurchases),
})
} }
} else { } else {
//价格阶梯数量超过最利润点的层级的情况 //价格阶梯数量超过最利润点的层级的情况
...@@ -315,9 +333,15 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -315,9 +333,15 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn: c.MyRound(c.MulFloat(costPriceCn, priceCnRatio), 4), PriceCn: c.MyRound(c.MulFloat(costPriceCn, priceCnRatio), 4),
PriceUs: c.MyRound(c.MulFloat(costPriceUs, priceUsRatio), 4), PriceUs: c.MyRound(c.MulFloat(costPriceUs, priceUsRatio), 4),
}) })
showPriceRatioList = append(showPriceRatioList, model.PriceRatio{
Ratio: priceCnRatio,
RatioUsd: priceUsRatio,
Purchases: int64(costPurchases),
})
} }
} }
sku.LadderPrice = generatedLadderPrice sku.LadderPrice = generatedLadderPrice
sku.PriceRatio = showPriceRatioList
return sku return sku
} else { } else {
//fmt.Println(ladderPriceRatio) //fmt.Println(ladderPriceRatio)
...@@ -344,6 +368,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -344,6 +368,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn: c.MyRound(c.MulFloat(ladder.PriceCn, priceCnRatio), 4), PriceCn: c.MyRound(c.MulFloat(ladder.PriceCn, priceCnRatio), 4),
PriceUs: c.MyRound(c.MulFloat(ladder.PriceUs, priceUsRatio), 4), PriceUs: c.MyRound(c.MulFloat(ladder.PriceUs, priceUsRatio), 4),
}) })
showPriceRatioList = append(showPriceRatioList, model.PriceRatio{
Ratio: priceCnRatio,
RatioUsd: priceUsRatio,
Purchases: int64(ladder.Purchases),
})
} }
} else { } else {
...@@ -360,8 +389,14 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -360,8 +389,14 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn: c.MyRound(c.MulFloat(ladder.PriceCn, priceCnRatio), 4), PriceCn: c.MyRound(c.MulFloat(ladder.PriceCn, priceCnRatio), 4),
PriceUs: c.MyRound(c.MulFloat(ladder.PriceUs, priceUsRatio), 4), PriceUs: c.MyRound(c.MulFloat(ladder.PriceUs, priceUsRatio), 4),
}) })
showPriceRatioList = append(showPriceRatioList, model.PriceRatio{
Ratio: priceCnRatio,
RatioUsd: priceUsRatio,
Purchases: int64(ladder.Purchases),
})
} }
} }
sku.PriceRatio = showPriceRatioList
sku.LadderPrice = generatedLadderPrice sku.LadderPrice = generatedLadderPrice
return sku 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