29 lines
964 B
PHP
29 lines
964 B
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use App\Support\UnshippedWaybills;
|
||
use Illuminate\Console\Command;
|
||
|
||
final class SyncUnshippedWaybills extends Command
|
||
{
|
||
protected $signature = 'courier:sync-unshipped-waybills';
|
||
protected $description = '从共享镜像和已导入订单日志重算未发出明细';
|
||
|
||
public function handle(UnshippedWaybills $waybills): int
|
||
{
|
||
$failed = false;
|
||
foreach (UnshippedWaybills::SOURCES as $source => $label) {
|
||
if (!$waybills->sync($source)) {
|
||
$this->warn($label.':未就绪或同步失败。');
|
||
$failed = true;
|
||
} else {
|
||
$state = $waybills->connection()->table('courier_unshipped_sync')->where('source', $source)->first();
|
||
$this->info($label.':'.$state->row_count.' 行,缺单号 '.$state->missing_count.' 行。');
|
||
}
|
||
}
|
||
|
||
return $failed ? self::FAILURE : self::SUCCESS;
|
||
}
|
||
}
|