|
|
@@ -30,7 +30,7 @@ const (
|
|
|
ZONE_MASK64_MULTI = 0x000000000000FFC0
|
|
|
)
|
|
|
|
|
|
-//role uuid
|
|
|
+// role uuid
|
|
|
func GenerateUid() uint64 {
|
|
|
serviceConfig := service.GetServiceConfig()
|
|
|
zone := serviceConfig.Node.Zone
|
|
|
@@ -120,7 +120,7 @@ func GUIDCreateTest(zone, id int) uint64 {
|
|
|
return uid
|
|
|
}
|
|
|
|
|
|
-//item id
|
|
|
+// item id
|
|
|
var uuidLow uint32 = 0
|
|
|
var uuidHigh uint32 = 1
|
|
|
|
|
|
@@ -135,7 +135,7 @@ func UUIDCreate() uint64 {
|
|
|
return uuid
|
|
|
}
|
|
|
|
|
|
-//是否同一天(24点)
|
|
|
+// 是否同一天(24点)
|
|
|
func IsSameDay(source int64) bool {
|
|
|
loc := util.GetLoc()
|
|
|
nowTime := time.Unix(util.GetTimeSeconds(), 0).In(loc)
|
|
|
@@ -148,7 +148,7 @@ func IsSameDay(source int64) bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-//是否是同一天(24点)
|
|
|
+// 是否是同一天(24点)
|
|
|
func IsSameDayMs(sourceMs uint64) int {
|
|
|
loc := util.GetLoc()
|
|
|
timeS := int64(sourceMs / 1000)
|
|
|
@@ -163,7 +163,7 @@ func IsSameDayMs(sourceMs uint64) int {
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
-//判断是否是同一天true不天, false同一天(凌晨晨5点)
|
|
|
+// 判断是否是同一天true不天, false同一天(凌晨晨5点)
|
|
|
func IsDailyResetHour5(sourceMs uint64) bool {
|
|
|
if sourceMs <= 0 {
|
|
|
return false
|
|
|
@@ -264,6 +264,16 @@ func Str2Res(str string) (int32, int32) {
|
|
|
}
|
|
|
return 0, 0
|
|
|
}
|
|
|
+
|
|
|
+func Str2ResFloat(str string) (int32, float32) {
|
|
|
+ resList := strings.Split(str, ":")
|
|
|
+ if len(resList) > 1 {
|
|
|
+ resType, _ := Str2Num(resList[0])
|
|
|
+ resValue, _ := Str2Float32(resList[1])
|
|
|
+ return int32(resType), resValue
|
|
|
+ }
|
|
|
+ return 0, 0
|
|
|
+}
|
|
|
func Str2ResBySep(str string, sep string) (int32, int32) {
|
|
|
resList := strings.Split(str, sep)
|
|
|
if len(resList) > 1 {
|
|
|
@@ -309,7 +319,7 @@ func Str2Res_5(str string) (int32, int32, int32, int32, int32) {
|
|
|
return 0, 0, 0, 0, 0
|
|
|
}
|
|
|
|
|
|
-//最小堆
|
|
|
+// 最小堆
|
|
|
type MinHeap struct {
|
|
|
ItemList []int32
|
|
|
}
|
|
|
@@ -334,7 +344,7 @@ func (h *MinHeap) Pop() (ret interface{}) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//随机打乱数组Fisher-Yates随机置乱算法
|
|
|
+// 随机打乱数组Fisher-Yates随机置乱算法
|
|
|
func GenRandomArray(selfArray []int32) []int32 {
|
|
|
if len(selfArray) <= 0 {
|
|
|
return nil
|
|
|
@@ -364,7 +374,7 @@ func GenRandomArrayByLen(numLen int) []int32 {
|
|
|
return selfArray
|
|
|
}
|
|
|
|
|
|
-//字符串相似度算法
|
|
|
+// 字符串相似度算法
|
|
|
func MessageLD(s, t string, ignoreCase bool) int {
|
|
|
if ignoreCase {
|
|
|
s = strings.ToLower(s)
|
|
|
@@ -400,7 +410,7 @@ func MessageLD(s, t string, ignoreCase bool) int {
|
|
|
return d[len(s)][len(t)]
|
|
|
}
|
|
|
|
|
|
-//二倍均值算法,count剩余个数,amount剩余金额
|
|
|
+// 二倍均值算法,count剩余个数,amount剩余金额
|
|
|
func DoubleAverage(count, amount int64) int64 {
|
|
|
//最小钱
|
|
|
min := int64(1)
|