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
+24
View File
@@ -462,6 +462,30 @@ func pendingPaymentTimeoutMinutes(tx *gorm.DB) int {
return value
}
func autoCompleteHandoffTimeoutMinutesForOrder(tx *gorm.DB, order model.RentalOrder) int {
var row model.SystemConfig
query := tx.Where("`key` = ?", "handoff.auto_complete_timeout_minutes")
tenantID := order.BuyerTenantID
if tenantID == 0 && tx.Statement != nil && tx.Statement.Context != nil {
tenantID = tenancy.IDFromContext(tx.Statement.Context)
}
if tenantID == 0 {
tenantID = order.SourceTenantID
}
if tenantID > 0 {
query = query.Where("tenant_id = ?", tenantID)
}
err := query.First(&row).Error
if err != nil {
return defaultAutoCompleteHandoffTimeoutMinutes
}
value, err := strconv.Atoi(row.Value)
if err != nil || value < 0 {
return defaultAutoCompleteHandoffTimeoutMinutes
}
return value
}
func applyPaymentDeadline(dto *OrderDTO, order model.RentalOrder, timeoutMinutes int) {
if dto == nil || order.Status != orderStatusPendingPayment || timeoutMinutes <= 0 {
return