CaiWuXiTong/app/Console/Commands/SyncUnshippedWaybills.php

29 lines
964 B
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::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;
}
}