From df44886c9a3a131575842f14c9e498af7c46fe61 Mon Sep 17 00:00:00 2001 From: ziming Date: Thu, 3 Apr 2025 16:35:22 +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 --- cmd/main.go | 1 + plugins/wechat_cpn/internal/wechat_cpn.go | 9 +++++++++ plugins/zltx_v2/go.mod | 2 +- plugins/zltx_v2/go.sum | 2 ++ plugins/zltx_v2/internal/transform.go | 20 +++++++++++++++++++- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 7976da3..3d6ccbe 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -6,4 +6,5 @@ func main() { //zltxQuery() //wechatQueryCpn() //alipayQueryRedPack() + wechatOrderCpn() } diff --git a/plugins/wechat_cpn/internal/wechat_cpn.go b/plugins/wechat_cpn/internal/wechat_cpn.go index 78b1416..85d2d2e 100644 --- a/plugins/wechat_cpn/internal/wechat_cpn.go +++ b/plugins/wechat_cpn/internal/wechat_cpn.go @@ -42,6 +42,7 @@ func (p *WeChatCpnService) Order(ctx context.Context, request *proto.OrderReques if result.Response.StatusCode != vo.CodeSuccess.Value() { return nil, proto.ErrorRequestFail(fmt.Sprintf("微信返回错误StatusCode[%d]Status[%s]", result.Response.StatusCode, result.Response.Status)) } + return orderResp(request.GetOrder(), *resp.CouponId), nil } @@ -65,9 +66,11 @@ func (p *WeChatCpnService) Query(ctx context.Context, request *proto.QueryReques if err != nil { return nil, proto.ErrorRequestFail(fmt.Sprintf("微信返回错误:%s", p.err(ctx, err))) } + if result.Response.StatusCode != vo.CodeSuccess.Value() { return nil, proto.ErrorRequestFail(fmt.Sprintf("微信返回错误StatusCode[%d]Status[%s]", result.Response.StatusCode, result.Response.Status)) } + return queryResp(request, resp), nil } @@ -76,21 +79,27 @@ func (p *WeChatCpnService) Notify(ctx context.Context, request *proto.NotifyRequ if err != nil { return nil, err } + if err = verify(ctx, config); err != nil { return nil, err } + return notifyResp(), nil } func (p *WeChatCpnService) err(_ context.Context, err error) error { errStr := err.Error() + startIndex := strings.Index(errStr, "Message: ") + if startIndex == -1 { return err } + endIndex := strings.Index(errStr[startIndex:], "\n") if endIndex == -1 { return err } + return fmt.Errorf(errStr[startIndex+len("Message: ") : startIndex+endIndex]) } diff --git a/plugins/zltx_v2/go.mod b/plugins/zltx_v2/go.mod index 0aa505f..9f58fb3 100644 --- a/plugins/zltx_v2/go.mod +++ b/plugins/zltx_v2/go.mod @@ -6,7 +6,7 @@ replace plugins/utils => ../../utils require ( gitea.cdlsxd.cn/sdk/plugin v1.0.18 - gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2 v0.0.0-20240919023950-493c464e0ed7 + gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2 v1.0.3 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_v2/go.sum b/plugins/zltx_v2/go.sum index 639749c..1935ada 100644 --- a/plugins/zltx_v2/go.sum +++ b/plugins/zltx_v2/go.sum @@ -4,6 +4,8 @@ gitea.cdlsxd.cn/sdk/plugin v1.0.18 h1:YgVJmCSSEu8JAniXlT1rI+h0w3EEGDRWLFqjk/5xBQ 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= 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_v2/internal/transform.go b/plugins/zltx_v2/internal/transform.go index 68b1d5b..3a4a861 100644 --- a/plugins/zltx_v2/internal/transform.go +++ b/plugins/zltx_v2/internal/transform.go @@ -229,7 +229,25 @@ func getNotifyCard(appKey string, cards []notify.Cards) ([]byte, error) { car.Password = pwd } else if t.IsUrl() { - // 无 + + //if len(card.No) > 0 { + // no, err := decryptAES(card.No, appKey) + // if err != nil { + // return nil, proto.ErrorResponseFail(err.Error()) + // } + // car.Number = no + //} + + if len(card.Url) == 0 { + return nil, proto.ErrorResponseFail("url is empty") + } + + pwd, err := decryptAES(card.Url, appKey) + if err != nil { + return nil, proto.ErrorResponseFail(err.Error()) + } + + car.Password = pwd } return car.ToJson(), nil }