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)