From 9c8f64a35a0408b1c7d5e6d9acbb43e823123b9b Mon Sep 17 00:00:00 2001 From: ziming Date: Wed, 25 Mar 2026 15:50:54 +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/register_tag.go | 15 +++++++++++++-- internal/server/http.go | 1 + internal/service/notify.go | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/biz/register_tag.go b/internal/biz/register_tag.go index aa27147..5a4c902 100644 --- a/internal/biz/register_tag.go +++ b/internal/biz/register_tag.go @@ -25,8 +25,10 @@ func (this *VoucherBiz) RegisterTag(ctx context.Context, id int32) error { return err } - if err = this.registerNotifyTag(ctx, stock.MchId, stock.BatchNo); err != nil { - return err + if this.IsNotifyRegisterTag(stock) { + if err = this.registerNotifyTag(ctx, stock.MchId, stock.BatchNo); err != nil { + return err + } } _, err = this.ProductRepo.GetByProductNo(ctx, stock.ProductNo) @@ -34,6 +36,15 @@ func (this *VoucherBiz) RegisterTag(ctx context.Context, id int32) error { return err } +func (this *VoucherBiz) IsNotifyRegisterTag(product *bo.ProductBo) bool { + for _, subject := range this.bc.WechatSubject { + if subject.MchID == product.MchId { + return false + } + } + return true +} + func (this *VoucherBiz) registerNotifyTag(ctx context.Context, stockCreatorMchID, stockID string) error { cl := vo.WechatNotifyRegisterTagCacheLockKey.BuildCache([]string{this.bc.WechatNotifyMQ.Tag, stockCreatorMchID, stockID}) diff --git a/internal/server/http.go b/internal/server/http.go index dbe207f..cf919ee 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -46,6 +46,7 @@ func NewHTTPServer( // https://voucher.86698.cn/voucher/v1/notify/123456 123456为微信主体商户号 正式环境 srv.Route("/voucher/").POST("/v1/notify/{mch_id}", notifyService.Notify) + // ---脚本-- // 订单通知重试 -- 不健全 srv.Route("/voucher/").POST("orderNotifyRetry", cmb.OrderNotifyRetry) // 重试订单通知,查询微信状态再通知下游招行 diff --git a/internal/service/notify.go b/internal/service/notify.go index 38610bc..a347b71 100644 --- a/internal/service/notify.go +++ b/internal/service/notify.go @@ -54,7 +54,7 @@ func (srv *NotifyService) Notify(ctx http.Context) error { }) } - log.Warnf("微信回调通知[%s],headers:%+v,body:%s", mchId, headers, string(bodyBytes)) + log.Warnf("微信回调通知[%s],数据,headers:%+v,body:%s", mchId, headers, string(bodyBytes)) response, err := srv.WechatBiz.CallBack(ctx, mchId, &headers, bodyBytes) if err != nil { @@ -68,7 +68,7 @@ func (srv *NotifyService) Notify(ctx http.Context) error { if err = srv.VoucherBiz.WechatNotifyConsumer(ctx, ip, "WECHAT_NOTIFY", response); err != nil { - log.Errorf("微信回调通知[%s],headers:%+v,body:%s,err:%s", mchId, headers, string(bodyBytes), err.Error()) + log.Errorf("微信回调通知[%s],处理失败,headers:%+v,body:%s,err:%s", mchId, headers, string(bodyBytes), err.Error()) return ctx.JSON(http2.StatusBadRequest, map[string]string{ "code": "FAIL", "message": err.Error(),