voucher/internal/service/qixing.go

36 lines
878 B
Go

package service
import (
"encoding/json"
"fmt"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/transport/http"
"io"
"voucher/internal/biz"
"voucher/internal/biz/bo"
)
type TripartiteService struct {
multiBiz *biz.MultiBiz
}
func NewTripartiteService(multiBiz *biz.MultiBiz) *TripartiteService {
return &TripartiteService{multiBiz: multiBiz}
}
func (srv *TripartiteService) QiXingNotify(ctx http.Context) error {
bodyBytes, err := io.ReadAll(ctx.Request().Body)
if err != nil {
return fmt.Errorf("read body error: %v", err)
}
var req *bo.WechatVoucherNotifyBo
if err = json.Unmarshal(bodyBytes, &req); err != nil {
log.Errorf("qixing notify error:%v,body:%s", err, string(bodyBytes))
return fmt.Errorf("json unmarshal bodyBytes error: %v", err)
}
return srv.multiBiz.Notify(ctx, "qixing_"+req.PlainText.StockCreatorMchid, req)
}