RegisterTag

This commit is contained in:
ziming 2025-05-28 19:09:10 +08:00
parent 3120c34de5
commit b0a1fdaef7
3 changed files with 32 additions and 3 deletions

View File

@ -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})

View File

@ -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)

View File

@ -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,
})
}