30 lines
1.1 KiB
PHP
30 lines
1.1 KiB
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::SYNC_SOURCES as $source => $label) {
|
||
if (!$waybills->sync($source)) {
|
||
$warning = $waybills->connection()->table('courier_unshipped_sync')->where('source', $source)->value('warning');
|
||
$this->warn($label.':'.$warning);
|
||
$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;
|
||
}
|
||
}
|