兼容接入订单租期字段
This commit is contained in:
@@ -296,8 +296,12 @@ func (j *Job) handleRenterConfirmTimeout(ctx context.Context, now time.Time, cfg
|
||||
|
||||
func (j *Job) handleReturnOverdue(ctx context.Context, now time.Time, cfg thresholds) (int, error) {
|
||||
var rows []model.RentalOrder
|
||||
overdueBefore := now.Add(-time.Duration(cfg.ReturnOverdueGraceMinutes) * time.Minute)
|
||||
err := j.db.WithContext(ctx).
|
||||
Where("status = ? AND rent_end_at IS NOT NULL AND rent_end_at <= ?", "renting", now.Add(-time.Duration(cfg.ReturnOverdueGraceMinutes)*time.Minute)).
|
||||
Where(`status = ? AND (
|
||||
(rented_at IS NOT NULL AND TIMESTAMPADD(HOUR, COALESCE(NULLIF(estimated_duration_hours, 0), 24), rented_at) <= ?)
|
||||
OR (rented_at IS NULL AND rent_end_at IS NOT NULL AND rent_end_at <= ?)
|
||||
)`, "renting", overdueBefore, overdueBefore).
|
||||
Order("id ASC").
|
||||
Limit(100).
|
||||
Find(&rows).Error
|
||||
|
||||
Reference in New Issue
Block a user