CaiWuXiTong/app/Console/Commands/SyncUnshippedWaybills.php

30 lines
1.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\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;
}
}