CaiWuXiTong/app/Console/Commands/ImportTaobaoAlipayBills.php

37 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Business\TaobaoAlipayBillSpreadsheetImporter;
use Illuminate\Console\Command;
use Throwable;
class ImportTaobaoAlipayBills extends Command
{
protected $signature = 'business:import-taobao-alipay-bills
{file : 淘系支付宝账户 Excel 文件路径}
{--company=1 : 数据所属公司 ID}';
protected $description = '从标准附件导入店铺收款账户账单的淘系支付宝账户数据';
public function handle(TaobaoAlipayBillSpreadsheetImporter $importer): int
{
try {
$result = $importer->import(
(string) $this->argument('file'),
max(1, (int) $this->option('company')),
);
} catch (Throwable $e) {
$this->components->error($e->getMessage());
return self::FAILURE;
}
$this->components->info(
"导入完成:新增 {$result['inserted']} 条,更新 {$result['updated']} 条,跳过 {$result['skipped']} 条。"
);
return self::SUCCESS;
}
}