From cb76dfdd9e756cb4cd7872197900c1cb807b7d25 Mon Sep 17 00:00:00 2001 From: ziming Date: Thu, 4 Sep 2025 18:30:17 +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 --- Makefile | 2 +- plugins/alipay_cpn/internal/alipay_cpn.go | 28 +++++++++++++++++-- .../alipay_redpack/internal/alipay_redpack.go | 28 +++++++++++++++++-- plugins/wechat_cpn/internal/wechat_cpn.go | 27 ++++++++++++++++-- plugins/zltx_card_v1/internal/zltx_card_v1.go | 9 +++++- plugins/zltx_v1/internal/zltx_v1.go | 27 ++++++++++++++++-- plugins/zltx_v2/internal/zltx_v2.go | 26 +++++++++++++++-- 7 files changed, 130 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 70e44cb..5ce05a5 100644 --- a/Makefile +++ b/Makefile @@ -78,4 +78,4 @@ union_pay_redpack: make build-win name=union_pay_redpack .PHONY: all -all: zltx_v1 zltx_card_v1 alipay_cpn alipay_redpack wechat_cpn wechat_redpack union_pay_cpn union_pay_redpack \ No newline at end of file +all: zltx_v1 zltx_card_v1 zltx_v2 alipay_cpn alipay_redpack wechat_cpn wechat_redpack \ No newline at end of file diff --git a/plugins/alipay_cpn/internal/alipay_cpn.go b/plugins/alipay_cpn/internal/alipay_cpn.go index 76d51b4..29a9f11 100644 --- a/plugins/alipay_cpn/internal/alipay_cpn.go +++ b/plugins/alipay_cpn/internal/alipay_cpn.go @@ -3,6 +3,7 @@ package internal import ( "context" "encoding/json" + "fmt" "gitea.cdlsxd.cn/sdk/plugin/proto" "plugins/alipay_cpn/internal/po" ) @@ -26,7 +27,14 @@ const ( type AlipayCpnService struct{} -func (s *AlipayCpnService) Order(ctx context.Context, request *proto.OrderRequest) (*proto.OrderResponse, error) { +func (s *AlipayCpnService) Order(ctx context.Context, request *proto.OrderRequest) (resp2 *proto.OrderResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err @@ -60,7 +68,14 @@ func (s *AlipayCpnService) Order(ctx context.Context, request *proto.OrderReques return orderResp(request, response), nil } -func (s *AlipayCpnService) Query(ctx context.Context, request *proto.QueryRequest) (*proto.QueryResponse, error) { +func (s *AlipayCpnService) Query(ctx context.Context, request *proto.QueryRequest) (resp2 *proto.QueryResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err @@ -94,7 +109,14 @@ func (s *AlipayCpnService) Query(ctx context.Context, request *proto.QueryReques return queryResp(request, response), nil } -func (s *AlipayCpnService) Notify(_ context.Context, request *proto.NotifyRequest) (*proto.NotifyResponse, error) { +func (s *AlipayCpnService) Notify(_ context.Context, request *proto.NotifyRequest) (resp2 *proto.NotifyResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err diff --git a/plugins/alipay_redpack/internal/alipay_redpack.go b/plugins/alipay_redpack/internal/alipay_redpack.go index d698922..073bc71 100644 --- a/plugins/alipay_redpack/internal/alipay_redpack.go +++ b/plugins/alipay_redpack/internal/alipay_redpack.go @@ -3,6 +3,7 @@ package internal import ( "context" "encoding/json" + "fmt" "gitea.cdlsxd.cn/sdk/plugin/proto" "plugins/alipay_redpack/internal/po" "plugins/utils/alipay" @@ -26,7 +27,14 @@ const ( type AlipayRedPackService struct{} -func (s *AlipayRedPackService) Order(ctx context.Context, request *proto.OrderRequest) (*proto.OrderResponse, error) { +func (s *AlipayRedPackService) Order(ctx context.Context, request *proto.OrderRequest) (resp2 *proto.OrderResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err @@ -60,7 +68,14 @@ func (s *AlipayRedPackService) Order(ctx context.Context, request *proto.OrderRe return orderResp(request, response), nil } -func (s *AlipayRedPackService) Query(ctx context.Context, request *proto.QueryRequest) (*proto.QueryResponse, error) { +func (s *AlipayRedPackService) Query(ctx context.Context, request *proto.QueryRequest) (resp2 *proto.QueryResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err @@ -89,7 +104,14 @@ func (s *AlipayRedPackService) Query(ctx context.Context, request *proto.QueryRe return queryResp(request, response), nil } -func (s *AlipayRedPackService) Notify(_ context.Context, request *proto.NotifyRequest) (*proto.NotifyResponse, error) { +func (s *AlipayRedPackService) Notify(_ context.Context, request *proto.NotifyRequest) (resp2 *proto.NotifyResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err diff --git a/plugins/wechat_cpn/internal/wechat_cpn.go b/plugins/wechat_cpn/internal/wechat_cpn.go index 5fccdc6..419bd18 100644 --- a/plugins/wechat_cpn/internal/wechat_cpn.go +++ b/plugins/wechat_cpn/internal/wechat_cpn.go @@ -19,7 +19,14 @@ const ( type WeChatCpnService struct{} -func (p *WeChatCpnService) Order(ctx context.Context, request *proto.OrderRequest) (*proto.OrderResponse, error) { +func (p *WeChatCpnService) Order(ctx context.Context, request *proto.OrderRequest) (resp2 *proto.OrderResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + config, err := transConfig(request.Config) if err != nil { return nil, err @@ -47,7 +54,14 @@ func (p *WeChatCpnService) Order(ctx context.Context, request *proto.OrderReques return orderResp(request.GetOrder(), *resp.CouponId), nil } -func (p *WeChatCpnService) Query(ctx context.Context, request *proto.QueryRequest) (*proto.QueryResponse, error) { +func (p *WeChatCpnService) Query(ctx context.Context, request *proto.QueryRequest) (resp2 *proto.QueryResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + config, err := transConfig(request.Config) if err != nil { return nil, err @@ -75,7 +89,14 @@ func (p *WeChatCpnService) Query(ctx context.Context, request *proto.QueryReques return queryResp(request, resp), nil } -func (p *WeChatCpnService) Notify(ctx context.Context, request *proto.NotifyRequest) (*proto.NotifyResponse, error) { +func (p *WeChatCpnService) Notify(ctx context.Context, request *proto.NotifyRequest) (resp2 *proto.NotifyResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + config, err := transConfig(request.Config) if err != nil { return nil, err diff --git a/plugins/zltx_card_v1/internal/zltx_card_v1.go b/plugins/zltx_card_v1/internal/zltx_card_v1.go index 6c6ba2b..665e9ab 100644 --- a/plugins/zltx_card_v1/internal/zltx_card_v1.go +++ b/plugins/zltx_card_v1/internal/zltx_card_v1.go @@ -59,7 +59,14 @@ func (p *ZLTXCardV1Service) Order(ctx context.Context, request *proto.OrderReque return orderResp(request, resp), nil } -func (p *ZLTXCardV1Service) Query(ctx context.Context, request *proto.QueryRequest) (*proto.QueryResponse, error) { +func (p *ZLTXCardV1Service) Query(ctx context.Context, request *proto.QueryRequest) (resp2 *proto.QueryResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err diff --git a/plugins/zltx_v1/internal/zltx_v1.go b/plugins/zltx_v1/internal/zltx_v1.go index 662f40f..8f53ac4 100644 --- a/plugins/zltx_v1/internal/zltx_v1.go +++ b/plugins/zltx_v1/internal/zltx_v1.go @@ -21,7 +21,14 @@ const ( type ZLTXV1Service struct{} -func (p *ZLTXV1Service) Order(ctx context.Context, request *proto.OrderRequest) (*proto.OrderResponse, error) { +func (p *ZLTXV1Service) Order(ctx context.Context, request *proto.OrderRequest) (resp2 *proto.OrderResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err @@ -52,7 +59,14 @@ func (p *ZLTXV1Service) Order(ctx context.Context, request *proto.OrderRequest) return orderResp(request, resp), nil } -func (p *ZLTXV1Service) Query(ctx context.Context, request *proto.QueryRequest) (*proto.QueryResponse, error) { +func (p *ZLTXV1Service) Query(ctx context.Context, request *proto.QueryRequest) (resp2 *proto.QueryResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err @@ -75,7 +89,14 @@ func (p *ZLTXV1Service) Query(ctx context.Context, request *proto.QueryRequest) return queryResp(request, resp) } -func (p *ZLTXV1Service) Notify(ctx context.Context, request *proto.NotifyRequest) (*proto.NotifyResponse, error) { +func (p *ZLTXV1Service) Notify(ctx context.Context, request *proto.NotifyRequest) (resp2 *proto.NotifyResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err diff --git a/plugins/zltx_v2/internal/zltx_v2.go b/plugins/zltx_v2/internal/zltx_v2.go index 08bb9f0..c3db3d9 100644 --- a/plugins/zltx_v2/internal/zltx_v2.go +++ b/plugins/zltx_v2/internal/zltx_v2.go @@ -22,7 +22,13 @@ const ( 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) (resp2 *proto.OrderResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() c, err := transConfig(request.Config) if err != nil { @@ -46,7 +52,14 @@ func (p *ZLTXV2Service) Order(ctx context.Context, request *proto.OrderRequest) return orderResp(request, response), nil } -func (p *ZLTXV2Service) Query(ctx context.Context, request *proto.QueryRequest) (*proto.QueryResponse, error) { +func (p *ZLTXV2Service) Query(ctx context.Context, request *proto.QueryRequest) (resp2 *proto.QueryResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + c, err := transConfig(request.Config) if err != nil { return nil, err @@ -69,7 +82,14 @@ func (p *ZLTXV2Service) Query(ctx context.Context, request *proto.QueryRequest) return queryResp(c.AppKey, request, response) } -func (p *ZLTXV2Service) Notify(_ context.Context, request *proto.NotifyRequest) (*proto.NotifyResponse, error) { +func (p *ZLTXV2Service) Notify(_ context.Context, request *proto.NotifyRequest) (resp2 *proto.NotifyResponse, respErr error) { + + defer func() { + if err := recover(); err != nil { + respErr = fmt.Errorf("panic: %v", err) + } + }() + httpHeaders := make(http.Header) if err := json.Unmarshal(request.Headers, &httpHeaders); err != nil { return nil, proto.ErrorParamFail(fmt.Sprintf("headers Unmarshal err [%v]", err))