43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use Illuminate\Console\Command;
|
||
use Modules\EcommerceFinance\Services\BankBillHeaderImporter;
|
||
use Throwable;
|
||
|
||
class ImportBankBillHeaders extends Command
|
||
{
|
||
protected $signature = 'finance-ledger:import-bank-bill-headers
|
||
{path : 银行批量明细 XLSX/XLS 文件}
|
||
{--bank= : 招商银行或华夏银行}
|
||
{--dry-run : 只检查,不写入表头配置}';
|
||
|
||
protected $description = '导入银行原始账单表头并生成银行账单列配置';
|
||
|
||
public function handle(BankBillHeaderImporter $importer): int
|
||
{
|
||
try {
|
||
$result = $importer->import(
|
||
(string) $this->argument('path'),
|
||
(string) $this->option('bank'),
|
||
(bool) $this->option('dry-run'),
|
||
);
|
||
} catch (Throwable $exception) {
|
||
$this->error($exception->getMessage());
|
||
|
||
return self::FAILURE;
|
||
}
|
||
|
||
$this->info(sprintf(
|
||
'%s%s:%d 列。',
|
||
$result['dry_run'] ? '校验完成,' : '表头已导入,',
|
||
$result['bank'],
|
||
$result['columns'],
|
||
));
|
||
$this->line(implode(' | ', $result['labels']));
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|