接入订单结账确认流程

This commit is contained in:
yml
2026-05-24 16:52:15 +08:00
parent 1693ee3167
commit 03e5d211dc
13 changed files with 818 additions and 124 deletions
+12 -12
View File
@@ -318,16 +318,16 @@ func (j *Job) handleReturnOverdue(ctx context.Context, now time.Time, cfg thresh
notification.Entry{
UserID: order.RenterID,
Type: "timeout",
Title: "订单已逾期未归还",
Content: "订单已超过预计截止时间,请尽快提交归还说明,避免进入申诉处理。",
Title: "订单已逾期未结账",
Content: "订单已超过预计截止时间,请尽快发起结账,避免进入申诉处理。",
BizType: "order",
BizID: &orderID,
},
notification.Entry{
UserID: order.OwnerID,
Type: "timeout",
Title: "租客逾期未归还",
Content: "租客未在预计截止后及时归还,你可以发起申诉或等待客服处理。",
Title: "租客逾期未结账",
Content: "租客未在预计截止后及时发起结账,你可以发起申诉或等待客服处理。",
BizType: "order",
BizID: &orderID,
},
@@ -346,7 +346,7 @@ func (j *Job) handleReturnOverdue(ctx context.Context, now time.Time, cfg thresh
func (j *Job) handleOwnerReturnConfirmTimeout(ctx context.Context, now time.Time, cfg thresholds) (int, error) {
var rows []model.RentalOrder
err := j.db.WithContext(ctx).
Where("status = ? AND handoff_status = ? AND updated_at <= ?", "pending_return_confirm", "pending_owner_return_confirm", now.Add(-time.Duration(cfg.OwnerReturnConfirmTimeoutMinutes)*time.Minute)).
Where("status = ? AND handoff_status = ? AND updated_at <= ?", "pending_checkout_confirm", "pending_owner_checkout", now.Add(-time.Duration(cfg.OwnerReturnConfirmTimeoutMinutes)*time.Minute)).
Order("id ASC").
Limit(100).
Find(&rows).Error
@@ -355,28 +355,28 @@ func (j *Job) handleOwnerReturnConfirmTimeout(ctx context.Context, now time.Time
}
count := 0
for _, row := range rows {
if err := j.updateOrder(ctx, row.ID, "order.timeout.owner_return_confirm", func(tx *gorm.DB, order *model.RentalOrder) (string, error) {
if order.Status != "pending_return_confirm" || order.HandoffStatus != "pending_owner_return_confirm" {
if err := j.updateOrder(ctx, row.ID, "order.timeout.owner_checkout_confirm", func(tx *gorm.DB, order *model.RentalOrder) (string, error) {
if order.Status != "pending_checkout_confirm" || order.HandoffStatus != "pending_owner_checkout" {
return "", nil
}
before := snapshot(order)
order.Status = "abnormal"
order.HandoffStatus = "owner_return_confirm_timeout"
order.HandoffStatus = "owner_checkout_confirm_timeout"
orderID := order.ID
if err := notification.Append(tx,
notification.Entry{
UserID: order.RenterID,
Type: "timeout",
Title: "号主确认归还超时",
Content: "号主未在规定时间内确认归还,订单已进入客服复核状态。",
Title: "号主确认结账超时",
Content: "号主未在规定时间内确认结账,订单已进入客服复核状态。",
BizType: "order",
BizID: &orderID,
},
notification.Entry{
UserID: order.OwnerID,
Type: "timeout",
Title: "确认归还已超时",
Content: "你未在规定时间内确认归还,订单已进入客服复核状态。",
Title: "确认结账已超时",
Content: "你未在规定时间内确认结账,订单已进入客服复核状态。",
BizType: "order",
BizID: &orderID,
},