diff --git a/internal/biz/order.go b/internal/biz/order.go index 174c181..09154f0 100644 --- a/internal/biz/order.go +++ b/internal/biz/order.go @@ -56,9 +56,9 @@ func (v *VoucherBiz) order(ctx context.Context, req *bo.OrderCreateReqBo, produc } // 注册通知标签 order.MerchantNo 批次创建商户, order.BatchNo 商品批次号 - if err = v.registerNotifyTag(ctx, order.MerchantNo, order.BatchNo); err != nil { - return nil, err - } + //if err = v.registerNotifyTag(ctx, order.MerchantNo, order.BatchNo); err != nil { + // return nil, err + //} // 真实发放 voucherNo, err := v.WechatCpnRepo.Order(ctx, order) @@ -111,6 +111,17 @@ func (v *VoucherBiz) create(ctx context.Context, req *bo.OrderCreateReqBo, produ return v.OrderRepo.Create(ctx, o) } +func (this *VoucherBiz) RegisterTag(ctx context.Context, productNo string) error { + + stock, err := this.ProductRepo.GetByProductNo(ctx, productNo) + if err != nil { + return err + } + + // order.MerchantNo, order.BatchNo + return this.registerNotifyTag(ctx, stock.MchId, stock.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/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 af6e7dc..e61f2e2 100644 --- a/internal/service/cmb.go +++ b/internal/service/cmb.go @@ -95,3 +95,20 @@ 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("product_no is empty") + } + + err := this.VoucherBiz.RegisterTag(ctx, productNo) + if err != nil { + return err + } + + return ctx.JSON(http2.StatusOK, map[string]interface{}{ + "data": productNo, + }) +}