CaiWuXiTong/app/Console/Commands/ImportJstOrderLabels.php
qiuxiang e5d6c76f27 账单流水数据新增聚水潭订单标签明细页
新增「账单流水数据 › 聚水潭订单标签明细」(紧邻种菜明细表):四列(线上订单号/店铺名称/下单时间/标签),按标签拆行(一个标签一行)、订单不去重、标签不汇总,无标签订单记为「(无标签)」。新增 jst_order_labels 表(含公司/时间/标签/店铺索引)、JstOrderLabel 模型、JstOrderLabelImporter(从镜像 ops_jst_orders 按区间拆行导入,--replace 只清同区间)与 jst-order-labels:import 命令、导出路由与用例。页面筛选:下单时间区间(点整块开日历、可单独清除)、店铺、标签、线上订单号。
2026-09-30 16:40:16 +08:00

43 lines
1.2 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}
{--company=1 : 公司 ID}
{--replace : 先清空该区间已有行}';
protected $description = '把聚水潭订单按标签拆行导入「聚水潭订单标签明细」(账单流水数据页)';
public function handle(JstOrderLabelImporter $importer): int
{
$from = (string) $this->option('from');
$to = (string) $this->option('to');
try {
$result = $importer->import(
$from,
$to,
(int) $this->option('company'),
(bool) $this->option('replace'),
'jst-order-label-import',
);
} catch (Throwable $exception) {
$this->error($exception->getMessage());
return self::FAILURE;
}
$this->info(json_encode($result, JSON_UNESCAPED_UNICODE));
return self::SUCCESS;
}
}