From 96b7fa817bccdd6f657382889aeb4fc6237676cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Tue, 19 Nov 2024 14:12:20 +0800 Subject: [PATCH] merchant id int64 --- plugins/zltx_card_v1/go.mod | 2 +- plugins/zltx_card_v1/go.sum | 2 ++ plugins/zltx_card_v1/internal/transform.go | 2 +- plugins/zltx_card_v1/internal/zltx_card_v1.go | 8 +++----- plugins/zltx_card_v1/internal/zltx_card_v1_test.go | 6 +++--- plugins/zltx_v1/go.mod | 2 +- plugins/zltx_v1/go.sum | 2 ++ plugins/zltx_v1/internal/transform.go | 2 +- plugins/zltx_v1/internal/zltx_v1.go | 4 +--- plugins/zltx_v1/internal/zltx_v1_test.go | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/zltx_card_v1/go.mod b/plugins/zltx_card_v1/go.mod index 5f3ea4a..ef7bab1 100644 --- a/plugins/zltx_card_v1/go.mod +++ b/plugins/zltx_card_v1/go.mod @@ -3,7 +3,7 @@ module plugins/zltx_card_v1 go 1.22.2 require ( - gitea.cdlsxd.cn/sdk/plugin v1.0.11 + gitea.cdlsxd.cn/sdk/plugin v1.0.12 github.com/go-playground/validator/v10 v10.22.0 github.com/hashicorp/go-plugin v1.6.1 github.com/stretchr/testify v1.9.0 diff --git a/plugins/zltx_card_v1/go.sum b/plugins/zltx_card_v1/go.sum index ffd8ac6..d06eb38 100644 --- a/plugins/zltx_card_v1/go.sum +++ b/plugins/zltx_card_v1/go.sum @@ -2,6 +2,8 @@ gitea.cdlsxd.cn/sdk/plugin v1.0.10 h1:l+8/Lwp2uPsjPu+iGRI1t4d86dNljuMLrACz6Pg29o gitea.cdlsxd.cn/sdk/plugin v1.0.10/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA= gitea.cdlsxd.cn/sdk/plugin v1.0.11 h1:NMMgw2p7ZF7EbWjkSO7ttM62BLhsG0bGmPdGGS1gpJc= gitea.cdlsxd.cn/sdk/plugin v1.0.11/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA= +gitea.cdlsxd.cn/sdk/plugin v1.0.12 h1:gA7zRagOro38rbRVIfFgGRuGOr+Wig8EjeqQkYedFXc= +gitea.cdlsxd.cn/sdk/plugin v1.0.12/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/plugins/zltx_card_v1/internal/transform.go b/plugins/zltx_card_v1/internal/transform.go index 79ed26c..f4c06f0 100644 --- a/plugins/zltx_card_v1/internal/transform.go +++ b/plugins/zltx_card_v1/internal/transform.go @@ -14,7 +14,7 @@ type Config struct { AppKey string `json:"app_key" validate:"required"` BaseUri string `json:"base_uri" validate:"required"` NotifyUrl string `json:"notify_url" validate:"required"` - MerchantId string `json:"merchant_id" validate:"required"` + MerchantId int64 `json:"merchant_id" validate:"required"` } func (c *Config) validate() error { diff --git a/plugins/zltx_card_v1/internal/zltx_card_v1.go b/plugins/zltx_card_v1/internal/zltx_card_v1.go index 7b0c471..087ba9c 100644 --- a/plugins/zltx_card_v1/internal/zltx_card_v1.go +++ b/plugins/zltx_card_v1/internal/zltx_card_v1.go @@ -8,7 +8,6 @@ import ( "gitea.cdlsxd.cn/sdk/plugin/proto" "io" "net/http" - "strings" ) // 插件通信信息,若不对应则会报错panic @@ -77,11 +76,10 @@ func (p *ZLTXCardV1Service) Notify(ctx context.Context, request *proto.NotifyReq } newHeaders := make(http.Header) for key, values := range httpHeaders { - newKey := strings.ToTitle(strings.ToLower(key)) - newHeaders[newKey] = values + newHeaders[key] = values } - req := &http.Request{ + httpRequest := &http.Request{ Header: newHeaders, Body: io.NopCloser(bytes.NewBuffer(request.Body)), } @@ -91,7 +89,7 @@ func (p *ZLTXCardV1Service) Notify(ctx context.Context, request *proto.NotifyReq return nil, err } - resp, cardCode, err := dctW.Notify(ctx, req) + resp, cardCode, err := dctW.Notify(ctx, httpRequest) if err != nil { return nil, err } diff --git a/plugins/zltx_card_v1/internal/zltx_card_v1_test.go b/plugins/zltx_card_v1/internal/zltx_card_v1_test.go index a7d24d0..980684e 100644 --- a/plugins/zltx_card_v1/internal/zltx_card_v1_test.go +++ b/plugins/zltx_card_v1/internal/zltx_card_v1_test.go @@ -17,7 +17,7 @@ func config() []byte { AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9", BaseUri: "http://test.openapi.1688sup.cn", NotifyUrl: "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify", - MerchantId: "23329", + MerchantId: 23329, } marshal, _ := json.Marshal(c) return marshal @@ -82,8 +82,8 @@ func TestNotify(t *testing.T) { in := &proto.NotifyRequest{ Config: config(), Queries: nil, - Headers: []byte(`{"Accept-Encoding":["gzip, deflate, br"],"Authorization":["MD5 appid=1,sign=B6FB2AA068866CEFE88B864CA9055BC6"],"Connection":["close"],"Content-Length":["116"],"Content-Type":["application/json"],"Cookie":[""],"User-Agent":["GuzzleHttp/6.5.5 curl/7.69.1 PHP/7.2.34"],"X-Remoteaddr":["172.21.0.1"]}`), - Body: []byte(`{"merchantId":"23329","outTradeNo":"test_plugin_zltx_v1_card_2","status":"01","cardCode":"iCtn0Lix8y/+cEwVayEOPg=="}`), + Headers: []byte(`{"Accept-Encoding":["gzip, deflate, br"],"Authorization":["MD5 appid=1,sign=B8DD605A67EDFF68C83626A4529E5B99"],"Connection":["close"],"Content-Length":["140"],"Content-Type":["application/json"],"Cookie":[""],"User-Agent":["GuzzleHttp/6.5.5 curl/7.69.1 PHP/7.2.34"],"X-Remoteaddr":["172.21.0.1"]}`), + Body: []byte(`{"merchantId":23329,"outTradeNo":"test_v1_card_zltx_002","tradeNo":"713390676754186241","status":"01","cardCode":"i548vESCHR7GkTeJwg8vHA=="}`), } t.Run("TestNotify", func(t *testing.T) { got, err := zltx.Notify(context.Background(), in) diff --git a/plugins/zltx_v1/go.mod b/plugins/zltx_v1/go.mod index a75f603..4346206 100644 --- a/plugins/zltx_v1/go.mod +++ b/plugins/zltx_v1/go.mod @@ -3,7 +3,7 @@ module plugins/zltx_v1 go 1.22.2 require ( - gitea.cdlsxd.cn/sdk/plugin v1.0.11 + gitea.cdlsxd.cn/sdk/plugin v1.0.12 github.com/go-playground/validator/v10 v10.22.0 github.com/hashicorp/go-plugin v1.6.1 github.com/stretchr/testify v1.9.0 diff --git a/plugins/zltx_v1/go.sum b/plugins/zltx_v1/go.sum index 6fc3ad0..867f9a8 100644 --- a/plugins/zltx_v1/go.sum +++ b/plugins/zltx_v1/go.sum @@ -1,5 +1,7 @@ gitea.cdlsxd.cn/sdk/plugin v1.0.11 h1:NMMgw2p7ZF7EbWjkSO7ttM62BLhsG0bGmPdGGS1gpJc= gitea.cdlsxd.cn/sdk/plugin v1.0.11/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA= +gitea.cdlsxd.cn/sdk/plugin v1.0.12 h1:gA7zRagOro38rbRVIfFgGRuGOr+Wig8EjeqQkYedFXc= +gitea.cdlsxd.cn/sdk/plugin v1.0.12/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/plugins/zltx_v1/internal/transform.go b/plugins/zltx_v1/internal/transform.go index 162b5f5..ba89a8d 100644 --- a/plugins/zltx_v1/internal/transform.go +++ b/plugins/zltx_v1/internal/transform.go @@ -14,7 +14,7 @@ type Config struct { AppKey string `json:"app_key" validate:"required"` BaseUri string `json:"base_uri" validate:"required"` NotifyUrl string `json:"notify_url" validate:"required"` - MerchantId string `json:"merchant_id" validate:"required"` + MerchantId int64 `json:"merchant_id" validate:"required"` } func (c *Config) validate() error { diff --git a/plugins/zltx_v1/internal/zltx_v1.go b/plugins/zltx_v1/internal/zltx_v1.go index 6701d7c..25be73b 100644 --- a/plugins/zltx_v1/internal/zltx_v1.go +++ b/plugins/zltx_v1/internal/zltx_v1.go @@ -9,7 +9,6 @@ import ( "gitea.cdlsxd.cn/sdk/plugin/proto" "io" "net/http" - "strings" ) // 插件通信信息,若不对应则会报错panic @@ -85,8 +84,7 @@ func (p *ZLTXV1Service) Notify(ctx context.Context, request *proto.NotifyRequest } newHeaders := make(http.Header) for key, values := range httpHeaders { - newKey := strings.ToTitle(strings.ToLower(key)) - newHeaders[newKey] = values + newHeaders[key] = values } req := &http.Request{ diff --git a/plugins/zltx_v1/internal/zltx_v1_test.go b/plugins/zltx_v1/internal/zltx_v1_test.go index 49794ec..b742323 100644 --- a/plugins/zltx_v1/internal/zltx_v1_test.go +++ b/plugins/zltx_v1/internal/zltx_v1_test.go @@ -17,7 +17,7 @@ func config() []byte { AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9", BaseUri: "http://test.openapi.1688sup.cn", NotifyUrl: "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify", - MerchantId: "25537", + MerchantId: 25537, } marshal, _ := json.Marshal(c) return marshal