连续同步失败后触发重试时间点

This commit is contained in:
root
2026-07-13 23:06:53 +08:00
parent 76692e0021
commit 98fc6d9e3d
17 changed files with 759 additions and 13 deletions
+49 -3
View File
@@ -6,6 +6,7 @@ namespace app\admin\model\split;
use app\common\service\SplitSyncConfigService;
use app\common\service\SplitTicketRuleService;
use app\common\service\SplitTicketSyncFailRetryService;
use app\common\service\SplitTicketSyncLockService;
use think\Db;
use think\Model;
@@ -176,10 +177,23 @@ class Ticket extends Model
if ((string) ($data['status'] ?? '') !== 'normal') {
return false;
}
$retryService = new SplitTicketSyncFailRetryService();
if ($retryService->isPermanentlyStopped($data)) {
return true;
}
if ($retryService->isInRetryMode($data)) {
return true;
}
$threshold = SplitSyncConfigService::getFailPauseThreshold();
if ($threshold <= 0) {
return false;
}
if (SplitSyncConfigService::hasFailRetrySchedule()) {
return false;
}
return (int) ($data['sync_fail_count'] ?? 0) >= $threshold;
}
@@ -191,9 +205,26 @@ class Ticket extends Model
*/
public function getSyncDisplayTextAttr($value, $data): string
{
$retryService = new SplitTicketSyncFailRetryService();
if ($retryService->isPermanentlyStopped($data)) {
return (string) __('Sync display auto sync stopped');
}
if ($retryService->isInRetryMode($data)) {
$nextAt = $retryService->getNextRetryAt($data);
$attempt = (int) ($data['sync_fail_retry_index'] ?? 0) + 1;
if ($nextAt !== null) {
return sprintf(
(string) __('Sync display retry waiting'),
date('H:i', $nextAt),
$attempt
);
}
}
if (self::isAutoSyncPaused($data)) {
$threshold = SplitSyncConfigService::getFailPauseThreshold();
return sprintf((string) __('Sync display auto paused'), $threshold);
return (string) __('Sync display auto paused');
}
$status = (string) ($data['sync_status'] ?? 'pending');
@@ -216,7 +247,22 @@ class Ticket extends Model
public function getSyncTooltipTextAttr($value, $data): string
{
$parts = [];
if (self::isAutoSyncPaused($data)) {
$retryService = new SplitTicketSyncFailRetryService();
if ($retryService->isPermanentlyStopped($data)) {
$parts[] = (string) __('Sync tooltip auto sync stopped');
} elseif ($retryService->isInRetryMode($data)) {
$nextAt = $retryService->getNextRetryAt($data);
$attempt = (int) ($data['sync_fail_retry_index'] ?? 0) + 1;
if ($nextAt !== null) {
$parts[] = sprintf(
(string) __('Sync tooltip retry waiting'),
(int) ($data['sync_fail_count'] ?? 0),
date('Y-m-d H:i:s', $nextAt),
$attempt
);
}
} elseif (self::isAutoSyncPaused($data)) {
$threshold = SplitSyncConfigService::getFailPauseThreshold();
$parts[] = sprintf(
(string) __('Sync tooltip auto paused'),