代码调整
This commit is contained in:
parent
bf28ed8e63
commit
df44886c9a
|
@ -6,4 +6,5 @@ func main() {
|
|||
//zltxQuery()
|
||||
//wechatQueryCpn()
|
||||
//alipayQueryRedPack()
|
||||
wechatOrderCpn()
|
||||
}
|
||||
|
|
|
@ -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])
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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=
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue