Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
14
utils/id_generator/snowflake.go
Normal file
14
utils/id_generator/snowflake.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package id_generator
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
)
|
||||
|
||||
func GenSnowFlakeId() (string, error) {
|
||||
//暂时只用一个节点
|
||||
n, err := snowflake.NewNode(1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return n.Generate().Base58(), nil
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package step_price
|
||||
|
||||
// 返回美元
|
||||
func GetStepPrice(minBuyNum int, stepNum []int, stepPrice []int) float64 {
|
||||
if minBuyNum > stepNum[len(stepNum)-1] {
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||
@@ -14,3 +15,19 @@ func GetStepPrice(minBuyNum int, stepNum []int, stepPrice []int) float64 {
|
||||
}
|
||||
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
|
||||
}
|
||||
|
||||
// 返回美分
|
||||
func GetCentStepPrice(minBuyNum int, stepNum []int, stepPrice []int) int64 {
|
||||
if minBuyNum > stepNum[len(stepNum)-1] {
|
||||
return int64(stepPrice[len(stepPrice)-1])
|
||||
}
|
||||
for k, v := range stepNum {
|
||||
if minBuyNum <= v {
|
||||
if k <= (len(stepPrice) - 1) {
|
||||
return int64(stepPrice[k])
|
||||
}
|
||||
return int64(stepPrice[len(stepPrice)-1])
|
||||
}
|
||||
}
|
||||
return int64(stepPrice[len(stepPrice)-1])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user