voucher/internal/service/wechat_notify_consume.go

33 lines
681 B
Go

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
if err := json.Unmarshal([]byte(msg), &req); err != nil {
return err
}
return v.VoucherBiz.WechatNotifyConsumer(ctx, tag, req)
}