feat(order): 统一网站自交接订单24小时自动完成倒计时
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user