38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Console;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Modules\EcommerceFinance\Services\DingInvoiceSyncService;
|
|
use Throwable;
|
|
|
|
class SyncDingInvoices extends Command
|
|
{
|
|
protected $signature = 'ding-invoices:sync
|
|
{--month= : 付款月份 YYYY-MM}
|
|
{--limit=20 : 本轮最多扫描的流程数}
|
|
{--force : 已扫描流程也重新抓取附件}';
|
|
|
|
protected $description = '抓取钉钉 OA 审批附件并识别发票,写入发票数据镜像';
|
|
|
|
public function handle(DingInvoiceSyncService $service): int
|
|
{
|
|
try {
|
|
$result = $service->syncMonth(
|
|
(string) ($this->option('month') ?: now()->format('Y-m')),
|
|
(int) $this->option('limit'),
|
|
(bool) $this->option('force'),
|
|
);
|
|
} catch (Throwable $exception) {
|
|
report($exception);
|
|
$this->error($exception->getMessage());
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->info(json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|