fix(internal/dto/order_test): 更新生成时间以反映最新的时间戳

- 在 Params 结构体的测试中,将 GeneratedTime 的值更新为 1746202250,以确保测试数据的时效性。
- 新增 order_test.go 文件,包含 CreatedOrder 的 ToMap 方法测试,验证请求参数的正确性。
- 在 sign_verify.go 中,增加日志记录以输出生成的签名字符串,提升调试信息的可用性。
This commit is contained in:
danial
2025-05-03 13:31:10 +08:00
parent 58a91a17f3
commit 62df2067e2
3 changed files with 26 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ import (
func TestParams_Encrypt(t *testing.T) {
orderParams := Params{
GeneratedTime: 1745838830,
GeneratedTime: 1746202250,
Duration: 24,
PayKey: "kkkkcvf8e9bl5mqs739h2j3g",
OrderNo: "FF6704071815701178777",

View File

@@ -0,0 +1,24 @@
package request
import (
"context"
"gateway/internal/utils"
"testing"
)
func TestCreatedOrder_ToMap(t *testing.T) {
// 报文:{"notifyUrl":"http://103.194.184.146:56700/notify/axfeiyupay/notify_res.htm","orderNo":"P01202505030010503660000","orderPeriod":24,"orderPrice":"100","payKey":"kkkkd0ae1rbl5mqs73af1b70","productCode":"1031","sign":"6cf522a960f72b7e15abca0944e66aee","timestamp":1746202250},请求状态:200,耗时:0.465,结果:{"code":-1,"msg":"sign验证错误","data":null}
createdOrder := CreatedOrder{
PayKey: "kkkkd0ae1rbl5mqs73af1b70",
OrderNo: "P01202505030010503660000",
OrderPrice: 100,
OrderPeriod: 24,
NotifyUrl: "http://103.194.184.146:56700/notify/axfeiyupay/notify_res.htm",
Sign: "6cf522a960f72b7e15abca0944e66aee",
ProductCode: "1031",
Timestamp: 1746202250,
}
createdOrder.ToMap()
utils.Md5MFVerify(context.Background(), createdOrder.ToMap(), "ssssd0ae1rbl5mqs73af1b7g")
}

View File

@@ -103,5 +103,6 @@ func GetMD5SignMF(params map[string]any, paySecret string) string {
}
}
signStr += paySecret
otelTrace.Logger.WithContext(context.Background()).Info("signStr=%s", zap.String("signStr", signStr))
return GetMD5LOWER(signStr)
}