添加游戏充值商户后台代码

This commit is contained in:
kongyuebin
2021-05-16 15:21:52 +08:00
parent a56fa52493
commit 8bd7067c2f
35 changed files with 1921 additions and 246 deletions

View File

@@ -0,0 +1,47 @@
package utils
import (
"github.com/beego/beego/v2/core/logs"
"strconv"
"strings"
)
func StringToFloats(s string) []float64 {
fs := make([]float64, 0)
if s == "" || len(s) == 0 {
return fs
}
str := strings.Split(s, ",")
for i := 0; i < len(str); i++ {
s := str[i]
logs.Debug("string to float", s)
if f, err := strconv.ParseFloat(s, 64); err != nil {
logs.Error("string to float64 err", err)
fs = append(fs, 0)
} else {
fs = append(fs, f)
}
}
return fs
}
func StringToInt(s string) []int {
is := make([]int, 0)
if s == "" || len(s) == 0 {
return is
}
ss := strings.Split(s, ",")
for i := 0; i < len(ss); i++ {
if a, err := strconv.Atoi(ss[i]); err != nil {
logs.Error("string to int err", err)
is = append(is, 0)
} else {
is = append(is, a)
}
}
return is
}

12
legend/utils/tableTool.go Normal file
View File

@@ -0,0 +1,12 @@
package utils
/**
** 计算偏移量
*/
func CountOffset(page, limit int) int {
if page > 0 {
return (page - 1) * limit
} else {
return limit
}
}