完善退款审批材料与恢复流程
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m35s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m35s
This commit is contained in:
@@ -3,11 +3,14 @@ package approval
|
||||
|
||||
import (
|
||||
"context"
|
||||
stderrors "errors"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 审批恢复适配器方法见文件末尾。
|
||||
|
||||
// PrepareRequest 是业务写入前执行审批渠道可用性检查的请求。
|
||||
type PrepareRequest struct {
|
||||
BusinessType string
|
||||
@@ -79,3 +82,35 @@ type SubmissionRequestedEvent struct {
|
||||
type SubmissionEventWriter interface {
|
||||
Append(ctx context.Context, tx *gorm.DB, event SubmissionRequestedEvent) error
|
||||
}
|
||||
|
||||
type RecoveryPort interface {
|
||||
EnqueueSubmittedSync(ctx context.Context, tx *gorm.DB, instanceID uint) error
|
||||
EnqueueUnknownConfirm(ctx context.Context, tx *gorm.DB, instanceID uint) error
|
||||
RecoverSubmissionEvent(ctx context.Context, tx *gorm.DB, instanceID uint) (bool, error)
|
||||
}
|
||||
|
||||
// RecoveryAdapter 将恢复动作委托给基础设施实现。
|
||||
type RecoveryAdapter struct {
|
||||
SyncFunc func(context.Context, *gorm.DB, uint) error
|
||||
ConfirmFunc func(context.Context, *gorm.DB, uint) error
|
||||
RecoverFunc func(context.Context, *gorm.DB, uint) (bool, error)
|
||||
}
|
||||
|
||||
func (a RecoveryAdapter) SyncSubmitted(ctx context.Context, tx *gorm.DB, id uint) error {
|
||||
if a.SyncFunc == nil {
|
||||
return stderrors.New("审批原实例同步接缝未配置")
|
||||
}
|
||||
return a.SyncFunc(ctx, tx, id)
|
||||
}
|
||||
func (a RecoveryAdapter) ConfirmUnknown(ctx context.Context, tx *gorm.DB, id uint) error {
|
||||
if a.ConfirmFunc == nil {
|
||||
return stderrors.New("审批结果确认接缝未配置")
|
||||
}
|
||||
return a.ConfirmFunc(ctx, tx, id)
|
||||
}
|
||||
func (a RecoveryAdapter) RecoverSubmissionEvent(ctx context.Context, tx *gorm.DB, id uint) (bool, error) {
|
||||
if a.RecoverFunc == nil {
|
||||
return false, stderrors.New("审批提交事件恢复接缝未配置")
|
||||
}
|
||||
return a.RecoverFunc(ctx, tx, id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user