48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Dealer;
|
|
|
|
use App\Admin\Imports\DealerOrderImport;
|
|
use App\Models\ImportJobLog;
|
|
use Illuminate\Console\Command;
|
|
|
|
class ImportDealerOrder extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'dealer:import-order {fileUri}';
|
|
|
|
protected $fileUri = '';
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = '导入批零订单';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
if ($this->hasArgument('fileUri')) {
|
|
$this->fileUri = $this->argument('fileUri');
|
|
}
|
|
$import = new DealerOrderImport();
|
|
$res = $import->readFileByUrl($this->fileUri);
|
|
|
|
ImportJobLog::insert(array_map(function ($value) {
|
|
return array_merge($value, [
|
|
'job_id'=> 0,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
}, $res['errors']));
|
|
}
|
|
}
|