CaiWuXiTong/app/Console/Commands/ImportBankBillHeaders.php

43 lines
1.2 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 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;
}
}