Commit ec6e1f75 authored by hujiebin's avatar hujiebin

// 保留两位小数

parent ba5681e4
......@@ -2,8 +2,10 @@ package utils
import (
"encoding/json"
"fmt"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/resource/mysql"
"strconv"
"strings"
"time"
)
......@@ -103,3 +105,12 @@ func StripAwsPrefix(url string) string {
newUrl := url[len(config.GetConfigAws().AWS_CDN):]
return newUrl
}
// 保留两位小数
func Decimal(value float64) float64 {
newValue, err := strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
if err != nil {
return value
}
return newValue
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment