CaiWuXiTong/app/Console/Kernel.php
limeng c8eb6e2e5f fix(发货数据): 早上补跑一次发货同步,副本库超时重连改为逐次拉长等待
- 凌晨 01:28 同步时副本库最近一两天的订单/商品明细常未到齐,10-12 凌晨一轮写入 4,669 个只有单号、缺商品明细的包裹
  (10.10/10.11);工作平台导出为实时查询不受影响。新增每天 07:28 再拉最近 3 天,补齐商品明细。
- selectWithReconnect:副本库超时/游标失败的重试由 2 次(间隔 0.25 秒)改为 5 次,等待 2/5/10/20/30 秒,
  白天整月重跑不再因单次超时中断(单测环境不等待)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nvGZkg27YMEdhry6eiuwf
2026-10-12 14:39:11 +08:00

119 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// Not installed yet
if (!config('app.installed')) {
return;
}
$schedule_time = config('app.schedule_time');
$schedule->command('reminder:invoice')->dailyAt($schedule_time);
$schedule->command('reminder:bill')->dailyAt($schedule_time);
$schedule->command('recurring:check')->dailyAt($schedule_time)->runInBackground();
$schedule->command('storage-temp:clear')->dailyAt('17:00');
$schedule->command('model:prune')->dailyAt('17:00');
// 线上代发价格:每天凌晨 05:00 刷新钉钉审批、采购单和订单关联镜像。
// 生产环境由 business-mirror:sync-tables 的 cron 持续增量覆盖,此处保证
// 一个固定的每日刷新入口;命令本身在非刷新环境会安全跳过。
$schedule->command('business-mirror:sync-ding-online-daifa-price')
->dailyAt('05:00')
->withoutOverlapping(60)
->runInBackground();
$schedule->command('business-mirror:sync-product-purchase-prices')
->dailyAt('05:00')
->withoutOverlapping(60)
->runInBackground();
$schedule->command('business-mirror:sync-tables operations_replica.rpt.jst_Orders')
->dailyAt('05:00')
->withoutOverlapping(60)
->runInBackground();
$schedule->command('business-mirror:sync-supplier-management')
->dailyAt('08:15')
->timezone('Asia/Shanghai')
->withoutOverlapping(60)
->runInBackground();
// 店铺违规信息预警:每天同步副本库抓取结果到统一表(本地补充字段不覆盖)。
$schedule->command('store-violations:sync')
->dailyAt('05:30')
->withoutOverlapping(60)
->runInBackground();
$schedule->command('business-mirror:sync-third-party-warehouse-storage --max-batches=0')
->dailyAt('00:00')
->withoutOverlapping(180)
->runInBackground();
if ((bool) config('services.esign.polling_enabled', false)) {
$schedule->command('esign:poll-signatures --quiet')
->cron('*/2 * * * *')
->withoutOverlapping(5)
->runInBackground();
}
// 聚水潭发货数据每日重拉最近三天,覆盖副本库迟到更新。
// 默认关闭(JST_SYNC_ENABLED=false);填好凭证并完成迁移后再打开。
if ((bool) env('JST_SYNC_ENABLED', false)) {
$schedule->command('jushuitan:sync-shipping --days=3')
->dailyAt('01:28')
->withoutOverlapping(120)
->runInBackground();
// 凌晨副本库最近一两天的订单/商品明细常未到齐(视图、订单商品表滞后),
// 早上再拉一次最近 3 天,补齐凌晨只写入单号、缺商品明细的包裹。
$schedule->command('jushuitan:sync-shipping --days=3')
->dailyAt('07:28')
->withoutOverlapping(120)
->runInBackground();
}
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
$this->load(__DIR__ . '/Commands');
}
/**
* Get the timezone that should be used by default for scheduled events.
*
* @return \DateTimeZone|string|null
*/
protected function scheduleTimezone()
{
return config('app.timezone');
}
}