fix
This commit is contained in:
parent
cef191a6e4
commit
0ea48b53c8
|
@ -157,22 +157,18 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(tag model.FsTags, product
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(stepNum) > len(stepPrice) {
|
if len(stepNum) == 0 || len(stepPrice) == 0 {
|
||||||
return nil, errors.New(fmt.Sprintf("stepNum count not eq stepPrice count: product size id :%d ,product price id :%d", productSize.Id, price.Id))
|
return nil, errors.New(fmt.Sprintf("stepNum count or stepPrice count is empty: product size id :%d ,product price id :%d", productSize.Id, price.Id))
|
||||||
}
|
}
|
||||||
for i := 0; i < 3; i++ {
|
index := 0
|
||||||
// 最小购买数量小于 最大阶梯数量+5
|
// 最小购买数量小于 最大阶梯数量+5
|
||||||
if int(price.MinBuyNum) < (stepNum[len(stepNum)-1] + 5) {
|
for int(price.MinBuyNum) < (stepNum[len(stepNum)-1]+5) && index < 3 {
|
||||||
priceList = append(priceList, types.PriceObj{
|
priceList = append(priceList, types.PriceObj{
|
||||||
Num: int(price.MinBuyNum * price.EachBoxNum),
|
Num: int(price.MinBuyNum * price.EachBoxNum),
|
||||||
Price: l.GetPrice(int(price.MinBuyNum), stepNum, stepPrice),
|
Price: l.GetPrice(int(price.MinBuyNum), stepNum, stepPrice),
|
||||||
})
|
})
|
||||||
}
|
|
||||||
price.MinBuyNum++
|
price.MinBuyNum++
|
||||||
}
|
index++
|
||||||
//如果不够三个则追加伪数据
|
|
||||||
for len(priceList) < 3 {
|
|
||||||
priceList = append(priceList, types.PriceObj{Num: 1, Price: 0})
|
|
||||||
}
|
}
|
||||||
data := types.ChildrenObj{
|
data := types.ChildrenObj{
|
||||||
Id: productSize.Id,
|
Id: productSize.Id,
|
||||||
|
@ -184,9 +180,15 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(tag model.FsTags, product
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (l *GetSizeByProductLogic) GetPrice(minBuyNum int, stepNum []int, stepPrice []int) float64 {
|
func (l *GetSizeByProductLogic) GetPrice(minBuyNum int, stepNum []int, stepPrice []int) float64 {
|
||||||
|
if minBuyNum > stepNum[len(stepNum)-1] {
|
||||||
|
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||||
|
}
|
||||||
for k, v := range stepNum {
|
for k, v := range stepNum {
|
||||||
if minBuyNum <= v {
|
if minBuyNum <= v {
|
||||||
return float64(stepPrice[k]) / float64(100)
|
if k <= (len(stepPrice) - 1) {
|
||||||
|
return float64(stepPrice[k]) / float64(100)
|
||||||
|
}
|
||||||
|
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user