CaiWuXiTong/app/Console/Commands/ImportBankDirectBalances.php
92451 58506f45a7 feat(账户总览): 接入银企直联期末余额 (#1285)
按银行账号接入银企直联可用余额快照,并用于账户总览期末余额。
Co-authored-by: 92451 <924518135@qq.com>
Co-committed-by: 92451 <924518135@qq.com>
2026-11-19 17:47:43 +08:00

49 lines
1.7 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Modules\EcommerceFinance\Services\BankDirectBalanceWorkbookImporter;
use Throwable;
class ImportBankDirectBalances extends Command
{
protected $signature = 'finance-ledger:import-bank-direct-balances
{path : 银企直联余额 XLSX/XLS 文件}
{--balance-date= : 指定余额日期,格式 YYYY-MM-DD}
{--dry-run : 只校验和统计,不写入共享业务库}';
protected $description = '导入银企直联账户可用余额及期末余额快照';
public function handle(BankDirectBalanceWorkbookImporter $importer): int
{
try {
$result = $importer->import(
(string) $this->argument('path'),
$this->option('balance-date') === null
? null
: (string) $this->option('balance-date'),
(bool) $this->option('dry-run'),
);
} catch (Throwable $exception) {
$this->error($exception->getMessage());
return self::FAILURE;
}
$this->table(['项目', '值'], [
['余额日期', $result['balance_date']],
['账户数', $result['total']],
['银行数', $result['bank_count']],
['可用余额合计', number_format($result['available_total'], 2, '.', '')],
['替换原快照', $result['replaced']],
['模式', $result['dry_run'] ? '校验' : '写入'],
]);
$this->info($result['dry_run']
? '银企直联余额校验完成,未写入共享业务库。'
: '银企直联余额导入完成,期末余额已接入账户总览。');
return self::SUCCESS;
}
}