|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package zhios_condition_statistics_utils
-
- import (
- "math"
- )
-
- func CouponFormat(data string) string {
- switch data {
- case "0.00", "0", "":
- return ""
- default:
- return Int64ToStr(FloatToInt64(StrToFloat64(data)))
- }
- }
- func CommissionFormat(data string) string {
- if data != "" && data != "0" {
- return data
- }
-
- return ""
- }
-
- func HideString(src string, hLen int) string {
- str := []rune(src)
- if hLen == 0 {
- hLen = 4
- }
- hideStr := ""
- for i := 0; i < hLen; i++ {
- hideStr += "*"
- }
- hideLen := len(str) / 2
- showLen := len(str) - hideLen
- if hideLen == 0 || showLen == 0 {
- return hideStr
- }
- subLen := showLen / 2
- if subLen == 0 {
- return string(str[:showLen]) + hideStr
- }
- s := string(str[:subLen])
- s += hideStr
- s += string(str[len(str)-subLen:])
- return s
- }
-
- //SaleCountFormat is 格式化销量
- func SaleCountFormat(s string) string {
- return s + "已售"
- }
-
- // 小数格式化
- func FloatFormat(f float64, i int) float64 {
- if i > 14 {
- return f
- }
- p := math.Pow10(i)
- return float64(int64((f+0.000000000000009)*p)) / p
- }
|