- 早上 7:28 的补拉在白天副本库高负载时频繁超时断开、未写入任何数据,改为每晚 21:28 拉最近 3 天; 两次同步输出追加到 storage/logs/jst-sync-shipping.log,便于排查。 - 订单商品表中平台原始商品行(数量 0、金额 0)没有实际出库,聚水潭工作平台也不显示; 包裹已有实发商品时不再写入,避免多出一个"条码"(实为平台商品编号)。 - 上游偶有超长值(如组合装商品ID 78 位)导致整批写入失败,写入前按 jst_oms_shipping 列宽截断。 > 开工时标题使用 `WIP: <任务名称>` 并先填写“任务占用与边界”。Codex 完成独立合并前自审后补齐其余内容并移除 `WIP:`。 ## 任务占用与边界 - 任务名称: - 实际开发者: - 任务来源/团队分工: - 目标结果: - 预计修改路径: - 将写入的公共契约(路由、Controller 方法、Repository、表/视图、`source_key`、`scope`、权限名、菜单键或共享组件): - 仅复用、明确不修改的公共契约: - 数据源、表/视图和字段: - 上游 `source_key` / `scope`: - 权限名、菜单键或共享组件: - 明确不修改的范围: ## 开工碰撞检查 - [ ] Codex 已执行 `scripts/codex-task-preflight.ps1` - [ ] 已检查最新 `main` 和所有远程任务分支 - [ ] 已搜索主线既有页面、接口、Repository 和数据查询 - [ ] 已把“将写入”和“仅复用、不修改”的公共契约分开;仅复用项不作为单独阻断条件 - [ ] 未发现实际写入重叠;或已在下方写明相关分支、具体重叠项和协调结论 相关分支、重叠项与协调结论: ## 实际改动 - 完成内容: - Codex 实际修改的文件: - 新增或变更的公共契约: - 与原计划的差异: ## 验证证据 - 正常流程: - 空数据/错误输入/无权限场景: - 受影响旧功能: - 自动测试及结果: - 实际页面、接口或只读业务查询结果: ## 风险检查 - [ ] 不涉及金额、权限、审批、数据库迁移、生产配置或数据修复 - [ ] 如涉及上述高风险内容,已在下方写明影响、回滚和所需授权 - [ ] 未提交 `.env`、密码、Token、私钥、真实财务数据、生产日志或构建产物 - [ ] 前端改动符合 `DESIGN.md`;无前端改动则写“不适用” 高风险影响、回滚和授权状态: ## 合并前复查 - [ ] 已重新拉取远程引用并用实际修改范围再次运行碰撞检查 - [ ] PR 不再是 `WIP:`,所有测试结果已经补齐 - [ ] Codex 已重新读取原始需求和验收标准,并逐文件审核 `origin/main...任务分支` 的完整 diff - [ ] Codex 自审确认无越界修改、重复实现、敏感内容、未处理冲突和未验证结果 - [ ] 合并顺序不会覆盖其他未合并任务 - [ ] 已授权当前任务的 Codex 执行 Squash merge、验证 `main` 并清理任务分支 - [ ] 如涉及生产迁移、数据修复、删除、覆盖配置或部署,已另行取得对应高风险授权 Reviewed-on: #707
149 lines
5.7 KiB
PHP
149 lines
5.7 KiB
PHP
<?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:archive-store-information')
|
||
->dailyAt('07:00')
|
||
->timezone('Asia/Shanghai')
|
||
->withoutOverlapping(120)
|
||
->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();
|
||
|
||
// 店铺违规预警推送:P0/P1 每天 09:00 起每 5 分钟检查;P2 每日 10:00 汇总。
|
||
$schedule->command('store-violations:push-instant')
|
||
->cron('*/5 9-21 * * *')
|
||
->withoutOverlapping(5)
|
||
->runInBackground();
|
||
|
||
$schedule->command('store-violations:push-digest')
|
||
->dailyAt('10:00')
|
||
->withoutOverlapping(30)
|
||
->runInBackground();
|
||
|
||
// 财务台账:从 AI 库 rpt 同步动账明细,按日重算账户流水。
|
||
// 生产宿主机 cron 仍需配置对应的 finance-ledger:sync-rpt 入口。
|
||
$schedule->command('finance-ledger:sync-rpt --days=7 --merge')
|
||
->dailyAt('02:30')
|
||
->timezone('Asia/Shanghai')
|
||
->withoutOverlapping(120)
|
||
->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();
|
||
}
|
||
|
||
// 聚水潭发货数据:凌晨重拉最近 40 天。聚水潭常在发货后数天到数周内换单/改快递公司/作废采购退货出库,
|
||
// 只拉最近几天会让上月数据停在旧值(快递名称不一致、已作废的单仍在);40 天覆盖上月结算期。
|
||
// 默认关闭(JST_SYNC_ENABLED=false);填好凭证并完成迁移后再打开。
|
||
if ((bool) env('JST_SYNC_ENABLED', false)) {
|
||
$schedule->command('jushuitan:sync-shipping --days=40')
|
||
->dailyAt('01:28')
|
||
->withoutOverlapping(300)
|
||
->appendOutputTo(storage_path('logs/jst-sync-shipping.log'))
|
||
->runInBackground();
|
||
// 凌晨副本库最近一两天的商品明细常未到齐(出库单常在发货次日下午才确认,视图随后才有商品);
|
||
// 白天副本库负载高、查询常超时断开,补拉放到晚上:每天 21:28 再拉最近 3 天,
|
||
// 补齐凌晨只写入单号、缺商品明细的包裹。
|
||
$schedule->command('jushuitan:sync-shipping --days=3')
|
||
->dailyAt('21:28')
|
||
->withoutOverlapping(120)
|
||
->appendOutputTo(storage_path('logs/jst-sync-shipping.log'))
|
||
->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');
|
||
}
|
||
}
|