接口调整
This commit is contained in:
parent
e9c99d7542
commit
0de4d12b85
|
|
@ -3,6 +3,7 @@ package cmb
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"time"
|
||||
err2 "voucher/api/err"
|
||||
|
|
@ -13,6 +14,10 @@ import (
|
|||
|
||||
func (v *Cmb) Notify(ctx context.Context, order *bo.OrderBo) (*bo.OrderNotifyBo, error) {
|
||||
|
||||
if order.Status.IsCanNotify() {
|
||||
return nil, fmt.Errorf("订单状态不允许通知,orderNo:%s,orderStatusText:%s", order.OrderNo, order.Status.GetText())
|
||||
}
|
||||
|
||||
event, err := order.Status.GetOrderNotifyEvent()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func (s OrderStatus) IsExpired() bool {
|
|||
return s == OrderStatusExpired
|
||||
}
|
||||
|
||||
func (s OrderStatus) CanNotify() bool {
|
||||
func (s OrderStatus) IsCanNotify() bool {
|
||||
return s.IsSuccess() || s.IsUse() || s.IsExpired()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,22 +45,34 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req *
|
|||
|
||||
if order.Type.IsCmb() {
|
||||
|
||||
if orderNotify, err2 := v.Cmb.Notify(ctx, order); err2 != nil {
|
||||
|
||||
if !errPb.IsNeedRetryNotify(err2) {
|
||||
return err2
|
||||
}
|
||||
// 第一次通知失败重试入队
|
||||
// 状态回调接口失败需要支持重试 重试间隔为1分钟、2分钟、12分钟、60分钟、360分钟
|
||||
return v.PushNotifyRetryDelayMQ(ctx, 60, orderNotify.ID)
|
||||
|
||||
}
|
||||
return v.cmbNotify(ctx, order.ID)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) cmbNotify(ctx context.Context, orderId uint64) error {
|
||||
|
||||
order, err := v.OrderRepo.GetByID(ctx, orderId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if orderNotify, err := v.Cmb.Notify(ctx, order); err != nil {
|
||||
|
||||
if !errPb.IsNeedRetryNotify(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
// 第一次通知失败重试入队
|
||||
// 状态回调接口失败需要支持重试 重试间隔为1分钟、2分钟、12分钟、60分钟、360分钟
|
||||
return v.PushNotifyRetryDelayMQ(ctx, 60, orderNotify.ID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) used(ctx context.Context, order *bo.OrderBo) error {
|
||||
|
||||
if order.Status.IsUse() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue