fusenapi/utils/step_price/price.go
laodaming 19f41f6dbc fix
2023-06-27 18:35:26 +08:00

34 lines
887 B
Go

package step_price
// 返回美元
func GetStepPrice(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 {
if minBuyNum <= v {
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)
}
// 返回美分
func GetCentStepPrice(minBuyNum int, stepNum []int, stepPrice []int) int64 {
if minBuyNum > stepNum[len(stepNum)-1] {
return int64(stepPrice[len(stepPrice)-1])
}
for k, v := range stepNum {
if minBuyNum <= v {
if k <= (len(stepPrice) - 1) {
return int64(stepPrice[k])
}
return int64(stepPrice[len(stepPrice)-1])
}
}
return int64(stepPrice[len(stepPrice)-1])
}