CaiWuXiTong/app/Console/Commands/ImportPlantingDetails.php
qiuxiang 28b9271b3c 账单流水数据新增种菜明细表页面与导入
新增「账单流水数据 › 种菜明细表」页面:汇总卡(笔数/财务打款金额/财务售价/扣款/京喜差价)+ 筛选(日期区间/店铺/负责人/类型/标签/关键词)+ 分页 + 按筛选全量导出,样式沿用 upstream-data 黑金令牌。新增 planting_details 表(20 列与源表一一对应,金额保留 4 位小数)、PlantingDetail 模型、PlantingDetailImporter(xlsx/xls/csv,兼容 Excel 序列号日期与千分位金额)与 planting-details:import 命令。补 PlantingDetailsPageTest 覆盖导入、序列号日期、页面渲染、筛选与导出。
2026-09-30 09:50:50 +08:00

39 lines
1.1 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 App\Business\PlantingDetailImporter;
use Illuminate\Console\Command;
use Throwable;
class ImportPlantingDetails extends Command
{
protected $signature = 'planting-details:import
{file : xlsx / xls / csv 文件路径}
{--company=1 : 公司 ID}
{--replace : 先清空该公司已有的种菜明细}';
protected $description = '导入「种菜明细表」数据(账单流水数据 › 种菜明细表)';
public function handle(PlantingDetailImporter $importer): int
{
try {
$result = $importer->import(
(string) $this->argument('file'),
(int) $this->option('company'),
(bool) $this->option('replace'),
null,
'planting-detail-import',
);
} catch (Throwable $exception) {
$this->error($exception->getMessage());
return self::FAILURE;
}
$this->info(json_encode($result, JSON_UNESCAPED_UNICODE));
return self::SUCCESS;
}
}