This commit is contained in:
laodaming
2023-09-15 14:52:36 +08:00
parent f72a0b9f7d
commit ee92468392
5 changed files with 24 additions and 18 deletions

View File

@@ -5,9 +5,9 @@ import (
"strconv"
)
// 美分转美元
func CentoDollar(price int64) float64 {
str := fmt.Sprintf("%.2f", float64(price)/float64(100))
// 转美元
func CentitoDollar(price int64) float64 {
str := fmt.Sprintf("%.3f", float64(price)/float64(1000))
dollar, _ := strconv.ParseFloat(str, 64)
return dollar
}

View File

@@ -3,20 +3,20 @@ 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)
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
}
for k, v := range stepNum {
if minBuyNum <= v {
if k <= (len(stepPrice) - 1) {
return float64(stepPrice[k]) / float64(100)
return float64(stepPrice[k]) / float64(1000)
}
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
}
}
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
return float64(stepPrice[len(stepPrice)-1]) / float64(1000)
}
// 返回美分
// 返回
func GetCentStepPrice(minBuyNum int, stepNum []int, stepPrice []int) int64 {
if minBuyNum > stepNum[len(stepNum)-1] {
return int64(stepPrice[len(stepPrice)-1])