31 lines
1.5 KiB
PHP
31 lines
1.5 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use Illuminate\Console\Command;
|
||
use Modules\EcommerceFinance\Services\DouyinAuthoritativeBillImporter;
|
||
use Throwable;
|
||
|
||
class ImportDouyinAuthoritativeBills extends Command
|
||
{
|
||
protected $signature = 'business-mirror:import-douyin-authoritative
|
||
{path : 胜算原始明细 UTF-8 CSV} {month : 所属月份 YYYY-MM}
|
||
{--count= : 核对笔数} {--income= : 核对收入合计} {--expense= : 核对支出合计}
|
||
{--through= : 月初至此日期的完整数据 YYYY-MM-DD,省略时为整月}';
|
||
|
||
protected $description = '校验并原子启用指定月份或月初至截止日的胜算抖音明细,保留旧版本用于回滚';
|
||
|
||
public function handle(DouyinAuthoritativeBillImporter $importer): int
|
||
{
|
||
try {
|
||
$result = $importer->import((string) $this->argument('path'), (string) $this->argument('month'),
|
||
(int) $this->option('count'), (string) $this->option('income'), (string) $this->option('expense'), $this->option('through'));
|
||
} catch (Throwable $e) {
|
||
$this->error('胜算抖音明细未启用,保留上一版数据。' . ($e instanceof \InvalidArgumentException ? $e->getMessage() : '请检查文件和镜像连接。'));
|
||
return self::FAILURE;
|
||
}
|
||
$this->info('胜算抖音明细已启用,范围:[' . $result['period_start'] . ', ' . $result['period_end'] . '),笔数:' . $result['row_count']);
|
||
return self::SUCCESS;
|
||
}
|
||
}
|