代码调整

This commit is contained in:
ziming 2025-07-16 15:17:31 +08:00
parent 874d773152
commit 7e782ee9f8
6 changed files with 11 additions and 9 deletions

View File

@ -12,6 +12,8 @@ import (
var cardService = &ZLTXCardV1Service{} var cardService = &ZLTXCardV1Service{}
func config() []byte { 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{ c := &Config{
AppId: "1", AppId: "1",
AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9", AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9",
@ -42,7 +44,7 @@ func TestOrder(t *testing.T) {
request := &proto.OrderRequest{ request := &proto.OrderRequest{
Config: config(), Config: config(),
Order: &proto.OrderRequest_Order{ Order: &proto.OrderRequest_Order{
OrderNo: "test_plugin_zltx_v1_card_3", OrderNo: "test_plugin_zltx_v1_card_4",
Account: "", Account: "",
Quantity: 1, Quantity: 1,
Extra: nil, Extra: nil,

View File

@ -10,7 +10,6 @@ require (
github.com/go-playground/validator/v10 v10.22.0 github.com/go-playground/validator/v10 v10.22.0
github.com/hashicorp/go-plugin v1.6.1 github.com/hashicorp/go-plugin v1.6.1
github.com/stretchr/testify v1.9.0 github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.64.0
plugins/utils v0.0.0-00010101000000-000000000000 plugins/utils v0.0.0-00010101000000-000000000000
) )
@ -39,6 +38,7 @@ require (
golang.org/x/sys v0.22.0 // indirect golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.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/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 google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

View File

@ -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 h1:YgVJmCSSEu8JAniXlT1rI+h0w3EEGDRWLFqjk/5xBQY=
gitea.cdlsxd.cn/sdk/plugin v1.0.18/go.mod h1:O/bYQWg1o9g/cBq9qNA3kLIpuPt7VDZqj1bPE6s04NM= 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 h1:vzHsHkJwFvobFxVlHQM8lEZY4h07TqR6cakjTqDHCQQ=
gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2 v1.0.3/go.mod h1:aS6ecVHvGLGzYYFIhxBrRWmq69ifo6pt1G92QblSdQQ= 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= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=

View File

@ -71,7 +71,8 @@ func (c *Config) client() (*sdk.Client, error) {
func (c *Config) orderReq(in *proto.OrderRequest) *api.OrderCreateReq { func (c *Config) orderReq(in *proto.OrderRequest) *api.OrderCreateReq {
var accountType vo.AccountType var accountType vo.AccountType
return &api.OrderCreateReq{
req := &api.OrderCreateReq{
OutTradeNo: in.Order.OrderNo, // 商户侧订单号长度只能是1-64位 OutTradeNo: in.Order.OrderNo, // 商户侧订单号长度只能是1-64位
ProductId: in.Product.ProductNo, // 产品编码不能为空 ProductId: in.Product.ProductNo, // 产品编码不能为空
Number: int(in.Order.Quantity), // 部分商品存在限购数量,具体可联系商务 Number: int(in.Order.Quantity), // 部分商品存在限购数量,具体可联系商务
@ -82,6 +83,8 @@ func (c *Config) orderReq(in *proto.OrderRequest) *api.OrderCreateReq {
Attach: "", // 透传参数,当传了此参数时,查询和回调接口中将原样携带此参数 Attach: "", // 透传参数,当传了此参数时,查询和回调接口中将原样携带此参数
UnitPrice: 0, // 交易商品单价单位最多保留4位小数 - 0或不传表示不限制 - 当此价格小于采购价时,下单失败 UnitPrice: 0, // 交易商品单价单位最多保留4位小数 - 0或不传表示不限制 - 当此价格小于采购价时,下单失败
} }
return req
} }
func orderResp(request *proto.OrderRequest, resp *api.OrderCreateResp) *proto.OrderResponse { func orderResp(request *proto.OrderRequest, resp *api.OrderCreateResp) *proto.OrderResponse {

View File

@ -23,6 +23,7 @@ const (
type ZLTXV2Service struct{} type ZLTXV2Service struct{}
func (p *ZLTXV2Service) Order(ctx context.Context, request *proto.OrderRequest) (*proto.OrderResponse, error) { func (p *ZLTXV2Service) Order(ctx context.Context, request *proto.OrderRequest) (*proto.OrderResponse, error) {
c, err := transConfig(request.Config) c, err := transConfig(request.Config)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -36,8 +36,8 @@ func TestOrder(t *testing.T) {
request := &proto.OrderRequest{ request := &proto.OrderRequest{
Config: config(), Config: config(),
Order: &proto.OrderRequest_Order{ Order: &proto.OrderRequest_Order{
OrderNo: "test_zltx_v2_7", OrderNo: "test_zltx_v2_8",
Account: "18666173766", Account: "18666666666",
Quantity: 1, Quantity: 1,
Extra: nil, Extra: nil,
}, },