Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson
2023-06-28 19:33:00 +08:00
14 changed files with 507 additions and 41 deletions

View 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
}

View File

@@ -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])
}