改造接口
This commit is contained in:
parent
9f768f037c
commit
ee9203f7d6
|
|
@ -21,6 +21,7 @@ type MultiNotifyLogBo struct {
|
||||||
TransactionID string
|
TransactionID string
|
||||||
RequestURL string
|
RequestURL string
|
||||||
RequestStatus int32
|
RequestStatus int32
|
||||||
|
OriginReq string
|
||||||
Request string
|
Request string
|
||||||
Response string
|
Response string
|
||||||
OrderCreateTime *time.Time
|
OrderCreateTime *time.Time
|
||||||
|
|
|
||||||
|
|
@ -141,12 +141,12 @@ func (biz *MultiBiz) RetryRunByMultiNotifyDataId(ctx context.Context, multiNotif
|
||||||
|
|
||||||
func (biz *MultiBiz) run(ctx context.Context, req *bo.WechatVoucherNotifyBo, mnd *bo.MultiNotifyDataBo, order *bo.OrderBo) error {
|
func (biz *MultiBiz) run(ctx context.Context, req *bo.WechatVoucherNotifyBo, mnd *bo.MultiNotifyDataBo, order *bo.OrderBo) error {
|
||||||
|
|
||||||
nl, err := biz.nlCreate(ctx, req, mnd, order)
|
nl, request, err := biz.nlCreate(ctx, req, mnd, order)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("创建通知日志错误 error: %v", err)
|
return fmt.Errorf("创建通知日志错误 error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = biz.Request(ctx, mnd, nl, order); err != nil {
|
if err = biz.Request(ctx, mnd, nl, request); err != nil {
|
||||||
return fmt.Errorf("请求错误 error: %v", err)
|
return fmt.Errorf("请求错误 error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,10 +195,10 @@ func (biz *MultiBiz) mndCreate(ctx context.Context, ip, source string, req *bo.W
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (biz *MultiBiz) nlCreate(ctx context.Context, req *bo.WechatVoucherNotifyBo, mnd *bo.MultiNotifyDataBo, order *bo.OrderBo) (*bo.MultiNotifyLogBo, error) {
|
func (biz *MultiBiz) nlCreate(ctx context.Context, req *bo.WechatVoucherNotifyBo, mnd *bo.MultiNotifyDataBo, order *bo.OrderBo) (*bo.MultiNotifyLogBo, *v1.CmbRequest, error) {
|
||||||
|
|
||||||
if biz.bc.Cmb.MultiNotifyUrl == "" {
|
if biz.bc.Cmb.MultiNotifyUrl == "" {
|
||||||
return nil, fmt.Errorf("CMB多笔立减金通知地址为空")
|
return nil, nil, fmt.Errorf("CMB多笔立减金通知地址为空")
|
||||||
}
|
}
|
||||||
|
|
||||||
nl := &bo.MultiNotifyLogBo{
|
nl := &bo.MultiNotifyLogBo{
|
||||||
|
|
@ -220,22 +220,23 @@ func (biz *MultiBiz) nlCreate(ctx context.Context, req *bo.WechatVoucherNotifyBo
|
||||||
CouponCreateTime: &req.PlainText.CreateTime,
|
CouponCreateTime: &req.PlainText.CreateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
request, err := biz.GetRequest(ctx, nl, order)
|
request, cmbRequestBo, err := biz.GetRequest(ctx, nl, order)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, _ := json.Marshal(request)
|
b, _ := json.Marshal(request)
|
||||||
|
nl.OriginReq = cmbRequestBo.BizContent
|
||||||
nl.Request = string(b)
|
nl.Request = string(b)
|
||||||
|
|
||||||
res, err := biz.MultiNotifyLogRepo.Create(ctx, nl)
|
res, err := biz.MultiNotifyLogRepo.Create(ctx, nl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("创建通知日志错误 error: %v", err)
|
return nil, nil, fmt.Errorf("创建通知日志错误 error: %v", err)
|
||||||
}
|
}
|
||||||
// 创建出来的核销时间精度有差距,重新赋值返回出去
|
// 创建出来的核销时间精度有差距,重新赋值返回出去
|
||||||
res.ConsumeTime = mnd.ConsumeTime
|
res.ConsumeTime = mnd.ConsumeTime
|
||||||
|
|
||||||
return res, nil
|
return res, request, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (biz *MultiBiz) bizContent(nl *bo.MultiNotifyLogBo, order *bo.OrderBo) (string, error) {
|
func (biz *MultiBiz) bizContent(nl *bo.MultiNotifyLogBo, order *bo.OrderBo) (string, error) {
|
||||||
|
|
@ -268,25 +269,26 @@ func (biz *MultiBiz) bizContent(nl *bo.MultiNotifyLogBo, order *bo.OrderBo) (str
|
||||||
return string(bizJsonBytes), nil
|
return string(bizJsonBytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (biz *MultiBiz) GetRequest(ctx context.Context, nl *bo.MultiNotifyLogBo, order *bo.OrderBo) (*v1.CmbRequest, error) {
|
func (biz *MultiBiz) GetRequest(ctx context.Context, nl *bo.MultiNotifyLogBo, order *bo.OrderBo) (*v1.CmbRequest, *bo.CmbRequestBo, error) {
|
||||||
|
|
||||||
bizContent, err := biz.bizContent(nl, order)
|
bizContent, err := biz.bizContent(nl, order)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
request, err := biz.CmbMixRepo.GetRequest(ctx, &bo.CmbRequestBo{
|
r := &bo.CmbRequestBo{
|
||||||
FuncName: vo.CmbNotifyFuncNameUpdateCodeStatusForMulti,
|
FuncName: vo.CmbNotifyFuncNameUpdateCodeStatusForMulti,
|
||||||
BizContent: bizContent,
|
BizContent: bizContent,
|
||||||
})
|
}
|
||||||
|
request, err := biz.CmbMixRepo.GetRequest(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return request, nil
|
return request, r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (biz *MultiBiz) Request(ctx context.Context, mmd *bo.MultiNotifyDataBo, nl *bo.MultiNotifyLogBo, order *bo.OrderBo) error {
|
func (biz *MultiBiz) Request(ctx context.Context, mmd *bo.MultiNotifyDataBo, nl *bo.MultiNotifyLogBo, request *v1.CmbRequest) error {
|
||||||
|
|
||||||
if nl.RequestURL == "" {
|
if nl.RequestURL == "" {
|
||||||
if err := biz.notifyFail(ctx, nl, "回调通知招行地址为空,不做通知"); err != nil {
|
if err := biz.notifyFail(ctx, nl, "回调通知招行地址为空,不做通知"); err != nil {
|
||||||
|
|
@ -296,11 +298,6 @@ func (biz *MultiBiz) Request(ctx context.Context, mmd *bo.MultiNotifyDataBo, nl
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
request, err := biz.GetRequest(ctx, nl, order)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
reply, err := biz.CmbMixRepo.Request(ctx, request, nl.RequestURL)
|
reply, err := biz.CmbMixRepo.Request(ctx, request, nl.RequestURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err3 := biz.notifyFail(ctx, nl, err.Error()); err3 != nil {
|
if err3 := biz.notifyFail(ctx, nl, err.Error()); err3 != nil {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ type MultiNotifyLog struct {
|
||||||
TransactionID string `gorm:"column:transaction_id;not null;comment:微信支付系统生成的订单号" json:"transaction_id"` // 微信支付系统生成的订单号
|
TransactionID string `gorm:"column:transaction_id;not null;comment:微信支付系统生成的订单号" json:"transaction_id"` // 微信支付系统生成的订单号
|
||||||
RequestURL string `gorm:"column:request_url;not null;comment:请求地址" json:"request_url"` // 请求地址
|
RequestURL string `gorm:"column:request_url;not null;comment:请求地址" json:"request_url"` // 请求地址
|
||||||
RequestStatus int32 `gorm:"column:request_status;not null;comment:请求状态" json:"request_status"` // 请求状态
|
RequestStatus int32 `gorm:"column:request_status;not null;comment:请求状态" json:"request_status"` // 请求状态
|
||||||
|
OriginReq string `gorm:"column:origin_req;not null;comment:请求数据" json:"origin_req"` // 请求数据
|
||||||
Request string `gorm:"column:request;not null;comment:请求数据" json:"request"` // 请求数据
|
Request string `gorm:"column:request;not null;comment:请求数据" json:"request"` // 请求数据
|
||||||
Response string `gorm:"column:response;not null;comment:响应结果" json:"response"` // 响应结果
|
Response string `gorm:"column:response;not null;comment:响应结果" json:"response"` // 响应结果
|
||||||
OrderCreateTime *time.Time `gorm:"column:order_create_time;not null;comment:券收单时间-蓝色兄弟" json:"order_create_time"` // 券收单时间-蓝色兄弟
|
OrderCreateTime *time.Time `gorm:"column:order_create_time;not null;comment:券收单时间-蓝色兄弟" json:"order_create_time"` // 券收单时间-蓝色兄弟
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ func (p *MultiNotifyLogRepoImpl) Create(ctx context.Context, req *bo.MultiNotify
|
||||||
ConsumeAmount: req.ConsumeAmount,
|
ConsumeAmount: req.ConsumeAmount,
|
||||||
ConsumeTime: req.ConsumeTime,
|
ConsumeTime: req.ConsumeTime,
|
||||||
TransactionID: req.TransactionID,
|
TransactionID: req.TransactionID,
|
||||||
|
OriginReq: req.OriginReq,
|
||||||
Request: req.Request,
|
Request: req.Request,
|
||||||
RequestURL: req.RequestURL,
|
RequestURL: req.RequestURL,
|
||||||
RequestStatus: vo.MultiNotifyLogStatusWait.GetValue(),
|
RequestStatus: vo.MultiNotifyLogStatusWait.GetValue(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue