修复GetPricePercentage中的bug
This commit is contained in:
@@ -279,7 +279,7 @@ func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercenta
|
||||
mid := 0
|
||||
for low <= high {
|
||||
mid = low + (high-low)/2
|
||||
if mid == 0 || mid == itemLen-1 {
|
||||
if mid < 0 || mid >= itemLen-1 {
|
||||
break
|
||||
}
|
||||
if price >= l[mid].BeginPrice {
|
||||
@@ -292,8 +292,10 @@ func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercenta
|
||||
high = mid - 1
|
||||
}
|
||||
}
|
||||
pricePercentage = l[mid].PricePercentage
|
||||
priceAdd = l[mid].PriceAdd
|
||||
if mid >= 0 && mid <= itemLen-1 && low <= high {
|
||||
pricePercentage = l[mid].PricePercentage
|
||||
priceAdd = l[mid].PriceAdd
|
||||
}
|
||||
}
|
||||
return pricePercentage, priceAdd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user