From 29d0bc633d197b5be95344815f78bf59164a66e9 Mon Sep 17 00:00:00 2001 From: ziming Date: Fri, 23 May 2025 14:04:07 +0800 Subject: [PATCH] register tag --- internal/biz/notify_tag.go | 10 ++++++++++ internal/biz/order.go | 7 ++++--- internal/server/http.go | 1 + internal/service/cmb.go | 12 ++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/internal/biz/notify_tag.go b/internal/biz/notify_tag.go index efe69c9..b50daf8 100644 --- a/internal/biz/notify_tag.go +++ b/internal/biz/notify_tag.go @@ -10,6 +10,16 @@ import ( "voucher/internal/pkg/lock" ) +func (v *VoucherBiz) RegisterTag(ctx context.Context, productNo string) error { + + product, err := v.ProductRepo.GetByProductNo(ctx, productNo) + if err != nil { + return err + } + + return v.registerNotifyTag(ctx, product.MchId, product.BatchNo) +} + func (v *VoucherBiz) registerNotifyTag(ctx context.Context, stockCreatorMchID, stockID string) error { c := vo.WechatNotifyRegisterTagCacheKey.BuildCache([]string{v.bc.WechatNotifyMQ.Tag, stockCreatorMchID, stockID}) diff --git a/internal/biz/order.go b/internal/biz/order.go index 6a20acc..4ffa416 100644 --- a/internal/biz/order.go +++ b/internal/biz/order.go @@ -103,9 +103,10 @@ func (v *VoucherBiz) order(ctx context.Context, product *bo.ProductBo, bizConten _ = v.cmbToBB(ctx, bizContent) - if err = v.registerNotifyTag(ctx, order.MerchantNo, order.BatchNo); err != nil { - return nil, err - } + //去掉注册步骤回调tag + //if err = v.registerNotifyTag(ctx, order.MerchantNo, order.BatchNo); err != nil { + // return nil, err + //} //voucherNo, err := v.WechatCpnRepo.Order(ctx, order) //if err != nil { diff --git a/internal/server/http.go b/internal/server/http.go index 3e0023e..f573347 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -38,6 +38,7 @@ func NewHTTPServer( srv.Route("/voucher/").GET("notifyRetry/{id}", cmb.NotifyRetry) srv.Route("/voucher/").GET("queryOrder/{order_no}", cmb.QueryOrder) + srv.Route("/voucher/").GET("registerTag/{product_no}", cmb.RegisterTag) v1.RegisterCmbHTTPServer(srv, cmb) diff --git a/internal/service/cmb.go b/internal/service/cmb.go index f968b2f..84d9126 100644 --- a/internal/service/cmb.go +++ b/internal/service/cmb.go @@ -69,3 +69,15 @@ func (this *CmbService) QueryOrder(ctx http.Context) error { "data": str, }) } + +func (this *CmbService) RegisterTag(ctx http.Context) error { + + productNo := ctx.Vars().Get("product_no") + if productNo == "" { + return fmt.Errorf("productNo is empty") + } + + return ctx.JSON(http2.StatusOK, map[string]interface{}{ + "data": this.VoucherBiz.RegisterTag(ctx, productNo), + }) +}