From c3c8389737a170c8cbe7145c5e593dfcb597285f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Thu, 13 Mar 2025 17:29:00 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=9F=A5=E8=AF=A2=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=8E=A5=E5=8F=A3,=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E9=80=9A=E7=9F=A5i=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/data/wechatrepoimpl/cpn.go | 15 +++++++-------- internal/service/cmb.go | 4 ++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/data/wechatrepoimpl/cpn.go b/internal/data/wechatrepoimpl/cpn.go index a34b930..d9fc363 100644 --- a/internal/data/wechatrepoimpl/cpn.go +++ b/internal/data/wechatrepoimpl/cpn.go @@ -62,7 +62,7 @@ func (c *CpnRepoImpl) Order(ctx context.Context, order *bo.OrderBo) (string, err return "", err } - log.Errorf("请求微信返回错误=%s", string(bodyBytes)) + log.Errorf("请求微信返回错误:%s", string(bodyBytes)) if err = json.Unmarshal(bodyBytes, &ErrBody); err != nil { return "", err @@ -107,13 +107,11 @@ func (c *CpnRepoImpl) Query(ctx context.Context, orderWechat *bo.OrderBo) (vo.Or return 0, err } - err = fmt.Errorf(ErrBody.Message) - - return 0, fmt.Errorf("微信返回错误=%s", ErrBody.Message) + return 0, fmt.Errorf("微信返回错误:%s", ErrBody.Message) } if result.Response.StatusCode != CodeSuccess { - return 0, fmt.Errorf("请求错误") + return 0, fmt.Errorf("微信返回错误 Response StatusCode[%s]", result.Response.StatusCode) } return CpnStatus(*resp.Status).GetStatus() @@ -143,12 +141,11 @@ func (c *CpnRepoImpl) QueryProduct(ctx context.Context, stockCreatorMchId, stock return nil, err } - return nil, fmt.Errorf("微信返回错误=%s", ErrBody.Message) + return nil, fmt.Errorf("微信返回错误:%s", ErrBody.Message) } if result.Response.StatusCode != CodeSuccess { - err = fmt.Errorf("查询活动微信返回错误tatus[%s]", result.Response.Status) - return nil, err + return nil, fmt.Errorf("查询活动微信返回错误 Response StatusCode[%s]", result.Response.StatusCode) } return response, nil @@ -178,6 +175,8 @@ func (c *CpnRepoImpl) QueryCallback(ctx context.Context, mchId, mchCertNo string if err != nil { + log.Errorf("请求微信返回错误:%s", err.Error()) + bodyBytes, err := io.ReadAll(result.Response.Body) if err != nil { return nil, err diff --git a/internal/service/cmb.go b/internal/service/cmb.go index 9584f96..7c8f8bf 100644 --- a/internal/service/cmb.go +++ b/internal/service/cmb.go @@ -58,6 +58,8 @@ func (s *VoucherService) cmbOrder(ctx http.Context) (string, error) { return "", err } + log.Warnf("cmbOrder req: %v", string(bodyBytes)) + var req *v1.CmbRequest if err = json.Unmarshal(bodyBytes, &req); err != nil { return "", err @@ -130,6 +132,8 @@ func (s *VoucherService) cmbQuery(ctx http.Context) (*v1.CmbQueryReply, error) { return nil, err } + log.Warnf("cmbQuery req: %v", string(bodyBytes)) + var req *v1.CmbRequest if err = json.Unmarshal(bodyBytes, &req); err != nil { return nil, err