fusenapi/utils/step_price/price.go

34 lines
888 B
Go
Raw Normal View History

2023-06-13 09:47:48 +00:00
package step_price
2023-06-27 10:35:26 +00:00
// 返回美元
2023-06-13 09:47:48 +00:00
func GetStepPrice(minBuyNum int, stepNum []int, stepPrice []int) float64 {
if minBuyNum > stepNum[len(stepNum)-1] {
2023-09-15 06:52:36 +00:00
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
2023-06-13 09:47:48 +00:00
}
for k, v := range stepNum {
if minBuyNum <= v {
if k <= (len(stepPrice) - 1) {
2023-09-15 06:52:36 +00:00
return float64(stepPrice[k]) / float64(1000)
2023-06-13 09:47:48 +00:00
}
2023-09-15 06:52:36 +00:00
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
2023-06-13 09:47:48 +00:00
}
}
2023-09-15 06:52:36 +00:00
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
2023-06-13 09:47:48 +00:00
}
2023-06-27 10:35:26 +00:00
2023-09-15 06:52:36 +00:00
// 返回厘
2023-06-27 10:35:26 +00:00
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])
}