财务经营报表 › 快递运费 之前是空页面。现在: - 新增 courier_freight_rows 表(来源 / 成品配件 / 交易单号 / 提供成本运费); - 新增 courier-freight:import 命令(xlsx / csv,按表头名匹配,支持 --replace); - 把聚水潭导出用的 xlsx 流式读取器改成通用名 XlsxSheetReader(本次文件 57.8 万行、解压后 115MB,必须流式读); - 页面按来源 / 成品配件 / 交易单号查询,列设置与分页复用通用目录表。
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use App\Business\CourierFreightImporter;
|
||
use Illuminate\Console\Command;
|
||
use Throwable;
|
||
|
||
class ImportCourierFreight extends Command
|
||
{
|
||
protected $signature = 'courier-freight:import
|
||
{file : xlsx / csv 文件路径}
|
||
{--company=1 : 公司 ID}
|
||
{--replace : 先清空该公司已有的快递运费明细}';
|
||
|
||
protected $description = '导入「快递运费」数据(财务经营报表 › 快递运费)';
|
||
|
||
public function handle(CourierFreightImporter $importer): int
|
||
{
|
||
try {
|
||
$result = $importer->import(
|
||
(string) $this->argument('file'),
|
||
(int) $this->option('company'),
|
||
(bool) $this->option('replace'),
|
||
);
|
||
} catch (Throwable $exception) {
|
||
$this->error($exception->getMessage());
|
||
|
||
return self::FAILURE;
|
||
}
|
||
|
||
$sources = $result['sources'];
|
||
$result['sources'] = count($sources);
|
||
$this->info(json_encode($result, JSON_UNESCAPED_UNICODE));
|
||
foreach ($sources as $name => $count) {
|
||
$this->line(sprintf(' %s:%d 行', $name === '' ? '(空来源)' : $name, $count));
|
||
}
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|