From 7e782ee9f8923561850715a7bfb76fabc8d30bba Mon Sep 17 00:00:00 2001 From: ziming Date: Wed, 16 Jul 2025 15:17:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/zltx_card_v1/internal/zltx_card_v1_test.go | 4 +++- plugins/zltx_v2/go.mod | 2 +- plugins/zltx_v2/go.sum | 4 ---- plugins/zltx_v2/internal/transform.go | 5 ++++- plugins/zltx_v2/internal/zltx_v2.go | 1 + plugins/zltx_v2/internal/zltx_v2_test.go | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) 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 0ca88c0..71ada4a 100644 --- a/plugins/zltx_card_v1/internal/zltx_card_v1_test.go +++ b/plugins/zltx_card_v1/internal/zltx_card_v1_test.go @@ -12,6 +12,8 @@ import ( var cardService = &ZLTXCardV1Service{} func config() []byte { + //b := []byte(`{"app_id": "1", "app_key": "1e2bf7a04b8b1e6be5dc78d04e8639c9", "base_uri": "http://test.openapi.1688sup.cn", "notify_url": "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify"}`) + //return b c := &Config{ AppId: "1", AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9", @@ -42,7 +44,7 @@ func TestOrder(t *testing.T) { request := &proto.OrderRequest{ Config: config(), Order: &proto.OrderRequest_Order{ - OrderNo: "test_plugin_zltx_v1_card_3", + OrderNo: "test_plugin_zltx_v1_card_4", Account: "", Quantity: 1, Extra: nil, diff --git a/plugins/zltx_v2/go.mod b/plugins/zltx_v2/go.mod index 9f58fb3..41aa6fa 100644 --- a/plugins/zltx_v2/go.mod +++ b/plugins/zltx_v2/go.mod @@ -10,7 +10,6 @@ require ( github.com/go-playground/validator/v10 v10.22.0 github.com/hashicorp/go-plugin v1.6.1 github.com/stretchr/testify v1.9.0 - google.golang.org/grpc v1.64.0 plugins/utils v0.0.0-00010101000000-000000000000 ) @@ -39,6 +38,7 @@ require ( golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/grpc v1.64.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/zltx_v2/go.sum b/plugins/zltx_v2/go.sum index 1935ada..0003b72 100644 --- a/plugins/zltx_v2/go.sum +++ b/plugins/zltx_v2/go.sum @@ -1,9 +1,5 @@ -gitea.cdlsxd.cn/sdk/plugin v1.0.17 h1:agk+9iA1ZI6fLVLtxEnuOWxcDzSq9QH7VBFvhlZZsbw= -gitea.cdlsxd.cn/sdk/plugin v1.0.17/go.mod h1:O/bYQWg1o9g/cBq9qNA3kLIpuPt7VDZqj1bPE6s04NM= gitea.cdlsxd.cn/sdk/plugin v1.0.18 h1:YgVJmCSSEu8JAniXlT1rI+h0w3EEGDRWLFqjk/5xBQY= gitea.cdlsxd.cn/sdk/plugin v1.0.18/go.mod h1:O/bYQWg1o9g/cBq9qNA3kLIpuPt7VDZqj1bPE6s04NM= -gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2 v0.0.0-20240919023950-493c464e0ed7 h1:2wOzkUfS17P6U/i6CWFjLyXrdLMnW3osk897ZfOUCxY= -gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2 v0.0.0-20240919023950-493c464e0ed7/go.mod h1:aS6ecVHvGLGzYYFIhxBrRWmq69ifo6pt1G92QblSdQQ= gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2 v1.0.3 h1:vzHsHkJwFvobFxVlHQM8lEZY4h07TqR6cakjTqDHCQQ= gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2 v1.0.3/go.mod h1:aS6ecVHvGLGzYYFIhxBrRWmq69ifo6pt1G92QblSdQQ= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= diff --git a/plugins/zltx_v2/internal/transform.go b/plugins/zltx_v2/internal/transform.go index d161165..170afca 100644 --- a/plugins/zltx_v2/internal/transform.go +++ b/plugins/zltx_v2/internal/transform.go @@ -71,7 +71,8 @@ func (c *Config) client() (*sdk.Client, error) { func (c *Config) orderReq(in *proto.OrderRequest) *api.OrderCreateReq { var accountType vo.AccountType - return &api.OrderCreateReq{ + + req := &api.OrderCreateReq{ OutTradeNo: in.Order.OrderNo, // 商户侧订单号长度只能是1-64位 ProductId: in.Product.ProductNo, // 产品编码不能为空 Number: int(in.Order.Quantity), // 部分商品存在限购数量,具体可联系商务 @@ -82,6 +83,8 @@ func (c *Config) orderReq(in *proto.OrderRequest) *api.OrderCreateReq { Attach: "", // 透传参数,当传了此参数时,查询和回调接口中将原样携带此参数 UnitPrice: 0, // 交易商品单价,单位:元(最多保留4位小数) - 0或不传表示不限制 - 当此价格小于采购价时,下单失败 } + + return req } func orderResp(request *proto.OrderRequest, resp *api.OrderCreateResp) *proto.OrderResponse { diff --git a/plugins/zltx_v2/internal/zltx_v2.go b/plugins/zltx_v2/internal/zltx_v2.go index f6c4aa0..08bb9f0 100644 --- a/plugins/zltx_v2/internal/zltx_v2.go +++ b/plugins/zltx_v2/internal/zltx_v2.go @@ -23,6 +23,7 @@ const ( type ZLTXV2Service struct{} func (p *ZLTXV2Service) Order(ctx context.Context, request *proto.OrderRequest) (*proto.OrderResponse, error) { + c, err := transConfig(request.Config) if err != nil { return nil, err diff --git a/plugins/zltx_v2/internal/zltx_v2_test.go b/plugins/zltx_v2/internal/zltx_v2_test.go index 4610e2e..4bf4540 100644 --- a/plugins/zltx_v2/internal/zltx_v2_test.go +++ b/plugins/zltx_v2/internal/zltx_v2_test.go @@ -36,8 +36,8 @@ func TestOrder(t *testing.T) { request := &proto.OrderRequest{ Config: config(), Order: &proto.OrderRequest_Order{ - OrderNo: "test_zltx_v2_7", - Account: "18666173766", + OrderNo: "test_zltx_v2_8", + Account: "18666666666", Quantity: 1, Extra: nil, },