From c6f35e550c41d3d087137b90daf7dbd8420b3c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=9C=A8?= <594326199@qq.com> Date: Tue, 3 Nov 2026 11:13:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=81=BF=E5=85=8D=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E4=B8=BB=E6=A1=A3=E9=87=8D=E5=A4=8D=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Kernel.php | 7 ++----- .../SupplierManagementMirrorSyncCommandTest.php | 14 ++------------ 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ff973a19..60e2fb94 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -60,11 +60,8 @@ class Kernel extends ConsoleKernel ->withoutOverlapping(120) ->runInBackground(); - $schedule->command('business-mirror:sync-supplier-management') - ->dailyAt('08:15') - ->timezone('Asia/Shanghai') - ->withoutOverlapping(60) - ->runInBackground(); + // 供应商主档由 /etc/cron.d/caiwu-jiansun-snapshots 在 08:15 使用 + // 全局上游同步锁执行,不能在这里重复调度,避免两个完整同步互相覆盖。 // 店铺违规信息预警:每天同步副本库抓取结果到统一表(本地补充字段不覆盖)。 $schedule->command('store-violations:sync') diff --git a/tests/Feature/Console/SupplierManagementMirrorSyncCommandTest.php b/tests/Feature/Console/SupplierManagementMirrorSyncCommandTest.php index 17be2102..09c8b3a9 100644 --- a/tests/Feature/Console/SupplierManagementMirrorSyncCommandTest.php +++ b/tests/Feature/Console/SupplierManagementMirrorSyncCommandTest.php @@ -4,7 +4,6 @@ namespace Tests\Feature\Console; use Illuminate\Contracts\Console\Kernel; use Illuminate\Console\Scheduling\Schedule; -use Illuminate\Support\Carbon; use Mockery; use Modules\EcommerceFinance\Services\BusinessMirrorDatasetRegistry; use Modules\EcommerceFinance\Services\BusinessMirrorSynchronizer; @@ -76,22 +75,13 @@ class SupplierManagementMirrorSyncCommandTest extends TestCase $this->artisan('business-mirror:sync-supplier-management')->assertSuccessful(); } - public function test_schedule_runs_at_0815_shanghai_even_when_app_timezone_is_utc(): void + public function test_schedule_does_not_duplicate_the_host_cron_supplier_sync(): void { config(['app.installed' => true, 'app.schedule_time' => '09:00', 'app.timezone' => 'UTC']); $schedule = new Schedule('UTC'); (new \ReflectionMethod(\App\Console\Kernel::class, 'schedule'))->invoke($this->app->make(Kernel::class), $schedule); $events = collect($schedule->events()) ->filter(fn ($event) => str_contains($event->command ?? '', 'business-mirror:sync-supplier-management')); - $this->assertCount(1, $events); - $event = $events->first(); - try { - foreach (['00:14' => false, '00:15' => true, '00:16' => false] as $time => $due) { - Carbon::setTestNow(Carbon::parse('2026-10-12 ' . $time . ':00', 'UTC')); - $this->assertSame($due, $event->isDue($this->app), $time); - } - } finally { - Carbon::setTestNow(); - } + $this->assertCount(0, $events, '供应商主档只能由带全局上游锁的主机 cron 调度。'); } } -- 2.47.2