Files
quyun-v2/backend/app/jobs/args/order_refund.go

46 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package args
import (
"quyun/v2/providers/job"
. "github.com/riverqueue/river"
"go.ipao.vip/atom/contracts"
)
var _ contracts.JobArgs = OrderRefundJob{}
// OrderRefundJob 表示“订单退款处理”的一次性异步任务。
//
// 设计说明:
// - 该任务用于将订单从 refunding 推进到 refunded/failed由 worker 执行核心退款逻辑)。
// - 幂等由 River Unique + 业务侧 DB 幂等ledger idempotency、状态机共同保证。
type OrderRefundJob struct {
// TenantID 租户ID用于多租户隔离与唯一性维度
TenantID int64 `json:"tenant_id" river:"unique"`
// OrderID 订单ID用于唯一性维度
OrderID int64 `json:"order_id" river:"unique"`
// OperatorUserID 退款操作人用户ID租户管理员/系统),用于 worker 在必要时回填审计字段。
OperatorUserID int64 `json:"operator_user_id"`
// Force 是否强制退款(绕过时间窗)。
Force bool `json:"force"`
// Reason 退款原因用于审计worker 可用于补齐订单字段)。
Reason string `json:"reason"`
}
func (OrderRefundJob) Kind() string { return "order_refund" }
func (a OrderRefundJob) UniqueID() string { return a.Kind() }
func (OrderRefundJob) InsertOpts() InsertOpts {
return InsertOpts{
Queue: job.QueueDefault,
Priority: job.PriorityDefault,
// 失败可重试;由 worker 判断不可重试的场景并 JobCancel。
MaxAttempts: 10,
UniqueOpts: UniqueOpts{
ByArgs: true,
},
}
}