From 323691d061e07bf2e06998a513794776e89dca19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Mon, 17 Mar 2025 14:10:58 +0800 Subject: [PATCH] wechatNotify --- internal/server/http.go | 2 ++ internal/service/wechat_notify_consume.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/server/http.go b/internal/server/http.go index 1cd1114..830b220 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -34,6 +34,8 @@ func NewHTTPServer( return ctx.String(http2.StatusOK, "pong") }) + r.POST("wechatNotify", voucherService.WechatNotify) + cmb := r.Group("/cmb") v1 := cmb.Group("/v1") diff --git a/internal/service/wechat_notify_consume.go b/internal/service/wechat_notify_consume.go index 8f4acd4..3914a11 100644 --- a/internal/service/wechat_notify_consume.go +++ b/internal/service/wechat_notify_consume.go @@ -3,9 +3,23 @@ package service import ( "context" "encoding/json" + "github.com/go-kratos/kratos/v2/log" + "github.com/go-kratos/kratos/v2/transport/http" + "io" "voucher/internal/biz/bo" ) +func (v *VoucherService) WechatNotify(ctx http.Context) error { + bodyBytes, err := io.ReadAll(ctx.Request().Body) + if err != nil { + return err + } + + log.Warnf("bodyBytes: %s", bodyBytes) + + return ctx.JSON(200, "ok") +} + func (v *VoucherService) WechatUseNotifyConsumer(ctx context.Context, tag, msg string) error { var req *bo.WechatVoucherNotifyBo