From 13688ddeb2cccb0098d868e01c699b1584b1ae98 Mon Sep 17 00:00:00 2001 From: zhoujunyao Date: Tue, 8 Jul 2025 10:44:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=90=E4=BA=A4=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA=E7=94=A8=E6=88=B7=E5=92=8C?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BB=A3=E7=A0=81-0=E5=85=83=E8=B4=AD?= =?UTF-8?q?=E7=9A=84serial=5Fnumber=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/bundle/common/time.go | 18 ++++++++++++++++++ pkg/service/bundle/pay.go | 2 +- pkg/service/bundle/reconciliation.go | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/service/bundle/common/time.go b/pkg/service/bundle/common/time.go index 93f996e..12b3dc6 100644 --- a/pkg/service/bundle/common/time.go +++ b/pkg/service/bundle/common/time.go @@ -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) +} diff --git a/pkg/service/bundle/pay.go b/pkg/service/bundle/pay.go index f493c68..da73930 100644 --- a/pkg/service/bundle/pay.go +++ b/pkg/service/bundle/pay.go @@ -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) diff --git a/pkg/service/bundle/reconciliation.go b/pkg/service/bundle/reconciliation.go index 979f386..8b0816b 100644 --- a/pkg/service/bundle/reconciliation.go +++ b/pkg/service/bundle/reconciliation.go @@ -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)