39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use Illuminate\Console\Command;
|
||
use Modules\EcommerceFinance\Services\PayablesUnpricedCycleProcessor;
|
||
|
||
class ProcessPayablesUnpricedCycle extends Command
|
||
{
|
||
protected $signature = 'payables:unpriced-cycle
|
||
{price-file : 工作平台定价/变价文件路径}
|
||
{--period= : 货款账期,格式 YYYY-MM,默认上月}
|
||
{--cutoff= : 定价快照截止日,格式 YYYY-MM-DD,默认今天}
|
||
{--company=1 : 公司 ID}
|
||
{--user= : 操作用户 ID}';
|
||
|
||
protected $description = '匹配历史未定价并补入当月新增未定价';
|
||
|
||
public function handle(PayablesUnpricedCycleProcessor $processor): int
|
||
{
|
||
$period = (string) ($this->option('period') ?: now()->subMonthNoOverflow()->format('Y-m'));
|
||
$cutoff = (string) ($this->option('cutoff') ?: now()->format('Y-m-d'));
|
||
$companyId = max(1, (int) $this->option('company'));
|
||
$userId = $this->option('user') !== null ? (int) $this->option('user') : null;
|
||
|
||
$result = $processor->process(
|
||
(string) $this->argument('price-file'),
|
||
$period,
|
||
$cutoff,
|
||
$companyId,
|
||
$userId,
|
||
);
|
||
|
||
$this->line(json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|