fix: 提交支持自动创建用户和订单代码-0元购的serial_number调整

This commit is contained in:
周俊耀 2025-07-08 10:44:55 +08:00
parent e734fadfc6
commit 13688ddeb2
3 changed files with 20 additions and 2 deletions

View File

@ -3,9 +3,12 @@ package common
import (
"fmt"
"go.uber.org/zap"
"math/rand"
"time"
)
const source = "0123456789abcdefghijklmnopqrstUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
// GetBeijingTime 获取当前时间的北京时间
func GetBeijingTime() string {
// 获取当前时间
@ -26,3 +29,18 @@ func GetBeijingTime() string {
return beijingTime
}
func GetZeroUuid() string {
id := time.Now().Format("20060102150405") + GetRandomstring(6)
result := "ZERO_" + id
return result
}
func GetRandomstring(length int) string {
rand.Seed(time.Now().UnixNano())
bytes := make([]byte, length)
for i := 0; i < length; i++ {
bytes[i] = source[rand.Intn(62)]
}
return string(bytes)
}

View File

@ -334,7 +334,7 @@ func CreateAntomPay(c *gin.Context) {
PayStatus: 2,
PayTime: common.GetBeijingTime(),
UserID: userInfo.ID,
SerialNumber: "zero-price-serial-number",
SerialNumber: common.GetZeroUuid(),
})
if err != nil {
fmt.Println("=============== antom创建支付创建对账单报错", err)

View File

@ -319,7 +319,7 @@ func AutoCreateUserAndOrder(c *gin.Context) {
PayStatus: 2,
PayTime: unfinishInfo.PayTime,
UserID: uint64(userResp.UserId),
SerialNumber: "zero-price-serial-number",
SerialNumber: unfinishInfo.OrderNo,
})
if err != nil {
fmt.Println("=============== antom创建支付创建对账单报错", err)