feat(order): 统一网站自交接订单24小时自动完成倒计时

This commit is contained in:
yml
2026-11-30 17:05:49 +08:00
parent 295c88dd2f
commit 2992885a6d
32 changed files with 996 additions and 23 deletions
@@ -231,6 +231,12 @@ func (r *Repository) AdminResetHandoff(ctx context.Context, adminID uint64, orde
order.HandoffStatus = target.HandoffStatus
if target.RefreshStageTime {
order.HandoffStartedAt = &now
if !isPlatformHandoffOrder(order) && !isPlatformSettlementOrder(order) && order.HandoffDeadlineAt != nil {
if timeoutMinutes := autoCompleteHandoffTimeoutMinutesForOrder(tx, order); timeoutMinutes > 0 {
deadline := now.Add(time.Duration(timeoutMinutes) * time.Minute)
order.HandoffDeadlineAt = &deadline
}
}
}
if target.RecalculateEnd {
durationHours := estimateOrderDurationHours(order.AccountSnapshot)
@@ -503,6 +509,13 @@ func (r *Repository) AdminRejectRefund(ctx context.Context, orderID uint64, acti
if order.HandoffStatus == handoffStatusCancelled || order.HandoffStatus == handoffStatusRenterConfirmTimeout {
order.HandoffStatus = handoffStatusPendingOwner
}
if !isPlatformHandoffOrder(*order) && !isPlatformSettlementOrder(*order) && order.HandoffDeadlineAt != nil {
if timeoutMinutes := autoCompleteHandoffTimeoutMinutesForOrder(tx, *order); timeoutMinutes > 0 {
now := time.Now()
deadline := now.Add(time.Duration(timeoutMinutes) * time.Minute)
order.HandoffDeadlineAt = &deadline
}
}
order.SettlementStatus = settlementStatusUnsettled
order.SettledAt = nil
reserveListingForOrder(listing)