Commit 30795bf2 by mushishixian

阶梯取值问题

parent 21e8ae00
Showing with 16 additions and 2 deletions
......@@ -514,15 +514,29 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data[key].Purchases = price.Purchases
//找出对应的阶梯,从$priceRatioList找到对应的售价组系数
//这个是为了怕后台存的数据格式不对导致无法获取到对应的系数
//这里去取对应的售价利润阶梯的时候,是往下匹配的,比如 阶梯价是 1,2,3 售价组利润是 1,2,3,4,5,那么123对应的是售价组利润的345
//而且当原始阶梯价为10个的时候,超过了售价利润组的9个,就要去取第9个售价利润组
var priceRatio model.PriceRatio
if len(priceRatioList) > key {
priceRatio = priceRatioList[key]
//先找出一共有多少个阶梯
ladderCount := len(sku.LadderPrice)
ratioCount := len(priceRatioList)
if ladderCount > key && key < ratioCount {
margin := ratioCount - ladderCount
if margin < 0 {
margin = 0
}
fmt.Println(key + margin)
priceRatio = priceRatioList[key+margin]
} else if key >= ratioCount {
priceRatio = priceRatioList[ratioCount-1]
fmt.Println("超过了售价利润组的9个,取到的售价组是 : ", priceRatio)
} else {
priceRatio = model.PriceRatio{
Ratio: 1,
RatioUsd: 1,
}
}
fmt.Println("当前循环售价组 : ", priceRatio)
//美金成本价
priceCostUs := c.MulFloat(price.PriceUs, usDiscountRatio)
priceCostUs = c.MyRound(priceCostUs, 4)
......
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