From cfe1973bf9c9dd6f58d1a01e0fbddbea9a317e6f Mon Sep 17 00:00:00 2001 From: ziming Date: Thu, 26 Mar 2026 13:57:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E4=B8=BB=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/wechat_notify.go | 5 +++++ internal/service/notify.go | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/biz/wechat_notify.go b/internal/biz/wechat_notify.go index 874207e..4641c65 100644 --- a/internal/biz/wechat_notify.go +++ b/internal/biz/wechat_notify.go @@ -2,7 +2,9 @@ package biz import ( "context" + "errors" "fmt" + "gorm.io/gorm" errPb "voucher/api/err" "voucher/internal/biz/bo" "voucher/internal/biz/vo" @@ -14,6 +16,9 @@ func (this *VoucherBiz) WechatNotifyConsumer(ctx context.Context, ip string, req // 商品数据量较少,先查询商品是否存在,过滤多余的通知信息 _, err := this.ProductRepo.GetByMchStockId(ctx, req.PlainText.StockCreatorMchid, req.PlainText.StockID) if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return nil + } return fmt.Errorf("商品查询错误 error: %w", err) } diff --git a/internal/service/notify.go b/internal/service/notify.go index c8f7429..956e0c3 100644 --- a/internal/service/notify.go +++ b/internal/service/notify.go @@ -2,11 +2,9 @@ package service import ( "encoding/json" - "errors" "fmt" "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/transport/http" - "gorm.io/gorm" "io" http2 "net/http" "voucher/internal/biz" @@ -75,10 +73,6 @@ func (srv *NotifyService) Notify(ctx http.Context) error { headerJson, _ := json.Marshal(headers) log.Errorf("微信回调通知[%s],consumer处理失败:%s\nheaders:%s\nbody:%s\n解析数据:%+v", mchId, err.Error(), headerJson, string(bodyBytes), bizData) - if errors.Is(err, gorm.ErrRecordNotFound) { - return ctx.JSON(http2.StatusOK, nil) - } - return ctx.JSON(http2.StatusBadRequest, map[string]string{ "code": "FAIL", "message": err.Error(),