From 4ca7aec6371e110459ed7b4ae262f9415807474f Mon Sep 17 00:00:00 2001 From: ziming Date: Fri, 20 Jun 2025 10:02:49 +0800 Subject: [PATCH] Warnf --- internal/server/http.go | 1 + internal/service/script.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/server/http.go b/internal/server/http.go index 5948356..0936257 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -38,6 +38,7 @@ func NewHTTPServer( srv.Route("/voucher/").POST("notifyRetry/{id}", cmb.NotifyRetry) srv.Route("/voucher/").POST("queryOrder/{order_no}", cmb.QueryOrder) + srv.Route("/voucher/").POST("queryStock/{product_no}", cmb.QueryStock) srv.Route("/voucher/").POST("registerTag/{batch_no}", cmb.RegisterTag) srv.Route("/voucher/").POST("pushWechatQuery", cmb.PushWechatQuery) srv.Route("/voucher/").POST("timeSliceQueryPush", cmb.TimeSliceQueryPush) diff --git a/internal/service/script.go b/internal/service/script.go index e4083af..09d83fb 100644 --- a/internal/service/script.go +++ b/internal/service/script.go @@ -41,6 +41,21 @@ func (this *CmbService) QueryOrder(ctx http.Context) error { }) } +func (this *CmbService) QueryStock(ctx http.Context) error { + + no := ctx.Vars().Get("product_no") + if no == "" { + return fmt.Errorf("product_no is empty") + } + + resp, err := this.VoucherBiz.CmbProductQuery(ctx, no) + if err != nil { + return err + } + + return ctx.JSON(http2.StatusOK, resp) +} + func (this *CmbService) PushWechatQuery(ctx http.Context) error { bodyBytes, err := io.ReadAll(ctx.Request().Body)