CaiWuXiTong/app/Console/Commands/ProcessPayablesUnpricedCycle.php
苏木 baed64ec3d feat: 增加历史未定价当月定价批次页面 (#1176)
Co-authored-by: 苏木 <594326199@qq.com>
Co-committed-by: 苏木 <594326199@qq.com>
2026-11-15 10:44:58 +08:00

39 lines
1.3 KiB
PHP
Raw Permalink 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 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;
}
}