mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-09-17 22:09:14 +08:00
添加游戏充值商户后台代码
This commit is contained in:
47
legend/utils/strongToFloat.go
Normal file
47
legend/utils/strongToFloat.go
Normal 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
12
legend/utils/tableTool.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package utils
|
||||
|
||||
/**
|
||||
** 计算偏移量
|
||||
*/
|
||||
func CountOffset(page, limit int) int {
|
||||
if page > 0 {
|
||||
return (page - 1) * limit
|
||||
} else {
|
||||
return limit
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user