后台系统配置列表现在只返回当前真实使用的配置项

This commit is contained in:
yml2213
2026-05-27 08:40:03 +08:00
parent 80c7bb18bb
commit 8cbd06dca4
8 changed files with 144 additions and 18 deletions
+13 -1
View File
@@ -110,7 +110,7 @@ func (j *Job) loadThresholds(ctx context.Context) (thresholds, error) {
}
for _, row := range rows {
value, err := strconv.Atoi(row.Value)
if err != nil || value <= 0 {
if err != nil || value < 0 {
continue
}
switch row.Key {
@@ -130,6 +130,9 @@ func (j *Job) loadThresholds(ctx context.Context) (thresholds, error) {
}
func (j *Job) handlePendingPaymentTimeout(ctx context.Context, now time.Time, cfg thresholds) (int, error) {
if cfg.PendingPaymentTimeoutMinutes <= 0 {
return 0, nil
}
var rows []model.RentalOrder
err := j.db.WithContext(ctx).
Where("status = ? AND created_at <= ?", "pending_payment", now.Add(-time.Duration(cfg.PendingPaymentTimeoutMinutes)*time.Minute)).
@@ -189,6 +192,9 @@ func (j *Job) handlePendingPaymentTimeout(ctx context.Context, now time.Time, cf
}
func (j *Job) handleOwnerSubmitTimeout(ctx context.Context, now time.Time, cfg thresholds) (int, error) {
if cfg.OwnerSubmitTimeoutMinutes <= 0 {
return 0, nil
}
var rows []model.RentalOrder
err := j.db.WithContext(ctx).
Where("status = ? AND handoff_status = ? AND created_at <= ?", "pending_handoff", "pending_owner", now.Add(-time.Duration(cfg.OwnerSubmitTimeoutMinutes)*time.Minute)).
@@ -237,6 +243,9 @@ func (j *Job) handleOwnerSubmitTimeout(ctx context.Context, now time.Time, cfg t
}
func (j *Job) handleRenterConfirmTimeout(ctx context.Context, now time.Time, cfg thresholds) (int, error) {
if cfg.RenterConfirmTimeoutMinutes <= 0 {
return 0, nil
}
var rows []model.RentalOrder
err := j.db.WithContext(ctx).
Where("status = ? AND handoff_status = ?", "pending_handoff", "pending_renter_confirm").
@@ -345,6 +354,9 @@ 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) {
if cfg.OwnerReturnConfirmTimeoutMinutes <= 0 {
return 0, nil
}
var rows []model.RentalOrder
err := j.db.WithContext(ctx).
Where("status = ? AND handoff_status = ? AND updated_at <= ?", "pending_checkout_confirm", "pending_owner_checkout", now.Add(-time.Duration(cfg.OwnerReturnConfirmTimeoutMinutes)*time.Minute)).