package cmb import ( "context" "encoding/json" "github.com/go-kratos/kratos/v2/log" v1 "voucher/api/v1" "voucher/internal/biz/bo" "voucher/internal/biz/vo" ) func (v *Cmb) NotifyConsume(ctx context.Context, order *bo.OrderBo, orderOutRequestNo string) (*bo.OrderNotifyBo, error) { event, err := order.Status.GetOrderNotifyEvent() if err != nil { return nil, err } req := &bo.OrderNotifyBo{ OrderNo: order.OrderNo, OutRequestNo: orderOutRequestNo, NotifyUrl: order.NotifyUrl, Channel: order.Channel, Event: event, Type: order.Type, Request: "", } request, orderNotify, err := v.notifyCreate(ctx, req) if err != nil { return nil, err } x, err := v.CmbMixRepo.Request(ctx, request, order.NotifyUrl) if err != nil { return orderNotify, v.notifyFail(ctx, orderNotify.ID, err.Error()) } bizStr, err := v.CmbMixRepo.VerifyResponse(ctx, x) if err != nil { log.Errorf("NotifyConsume CmbMixRepo.VerifyResponse error:%s", err.Error()) return orderNotify, v.notifyFail(ctx, orderNotify.ID, err.Error()) } var reply *v1.CmbNotifyReply if err = json.Unmarshal([]byte(bizStr), &reply); err != nil { return orderNotify, v.notifyFail(ctx, orderNotify.ID, err.Error()) } if reply.RespCode != vo.CmbResponseStatusSuccess.GetValue() { return orderNotify, v.notifyFail(ctx, orderNotify.ID, reply.RespMsg) } return orderNotify, v.notifySuccess(ctx, orderNotify.ID, bizStr) }