diff --git a/model/pending_sync_record.go b/model/pending_sync_record.go index 587bcc5..043eb24 100644 --- a/model/pending_sync_record.go +++ b/model/pending_sync_record.go @@ -87,9 +87,10 @@ func SettlePendingSyncRecord(requestId string, actualQuota int) (bool, error) { } // GetPendingRecordsForSync 获取待同步记录(只同步 settled 和 failed) +// 优先同步 quota > 0 的记录,quota=0 的旧记录不会阻塞正常扣费同步 func GetPendingRecordsForSync(limit, maxRetry int) []PendingSyncRecord { var records []PendingSyncRecord - DB.Where("status IN ? AND retry_count < ?", + DB.Where("status IN ? AND retry_count < ? AND quota > 0", []string{PendingSyncStatusSettled, PendingSyncStatusFailed}, maxRetry). Limit(limit).