镜像 ops_jst_orders 只覆盖 2026-04-01 之后,缺的历史区间只能靠财务在聚水潭「导出订单」导文件补。所以:- 新增 JstOrderExportReader:ZipArchive+expat 流式解析聚水潭导出 xlsx。这类文件字符串走 inlineStr、dimension 只写 A1、单文件上万行 ×135 列(解压 78MB),常规读法会读成空表或吃满内存;实测 12286 行 3.5 秒、峰值内存 10MB。 - jst-order-labels:import 新增 --file=:按「线上订单号+标签」去重后拆行写入,可配合 --from/--to 过滤窗口;带 --replace 时先成功读到数据行再清区间,避免文件有问题却先删了线上数据。 - 筛选下拉上限 500 -> 5000:导入 4~7 月后店铺已达 604 个,原来下拉里会缺 104 个店铺;提交筛选值的截断上限同步放开。 - 补两个测试:导出文件去重拆行、窗口过滤+replace。
44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Business\JstOrderLabelImporter;
|
|
use Illuminate\Console\Command;
|
|
use Throwable;
|
|
|
|
class ImportJstOrderLabels extends Command
|
|
{
|
|
protected $signature = 'jst-order-labels:import
|
|
{--from= : 起始下单日期 YYYY-MM-DD}
|
|
{--to= : 结束下单日期 YYYY-MM-DD}
|
|
{--file= : 聚水潭「导出订单」Excel 路径;给了它就从文件导入(镜像没有的历史区间用)}
|
|
{--company=1 : 公司 ID}
|
|
{--replace : 先清空该区间已有行}';
|
|
|
|
protected $description = '把聚水潭订单按标签拆行导入「聚水潭订单标签明细」:默认读共享镜像,给 --file 则读聚水潭导出的订单 Excel';
|
|
|
|
public function handle(JstOrderLabelImporter $importer): int
|
|
{
|
|
$from = (string) $this->option('from');
|
|
$to = (string) $this->option('to');
|
|
$file = trim((string) $this->option('file'));
|
|
|
|
try {
|
|
$companyId = (int) $this->option('company');
|
|
$replace = (bool) $this->option('replace');
|
|
|
|
$result = $file === ''
|
|
? $importer->import($from, $to, $companyId, $replace, 'jst-order-label-import')
|
|
: $importer->importFromFile($file, $from ?: null, $to ?: null, $companyId, $replace);
|
|
} catch (Throwable $exception) {
|
|
$this->error($exception->getMessage());
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->info(json_encode($result, JSON_UNESCAPED_UNICODE));
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|