CaiWuXiTong/app/Console/Commands/ImportDouyinAuthoritativeBills.php
qiuxiang 37b9a17b65 修复原始账单更新后自动重算业绩明细
京东、京喜、抖音原始账单导入后自动排队重算业绩明细;补齐 10 月最新数据。
2026-11-26 11:53:47 +08:00

42 lines
1.8 KiB
PHP
Raw 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 App\Console\Commands\Concerns\QueuesBillPerformanceResync;
use Illuminate\Console\Command;
use Modules\EcommerceFinance\Services\BillPerformanceResyncDispatcher;
use Modules\EcommerceFinance\Services\DouyinAuthoritativeBillImporter;
use Throwable;
class ImportDouyinAuthoritativeBills extends Command
{
use QueuesBillPerformanceResync;
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,
BillPerformanceResyncDispatcher $performanceResync,
): 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']);
if (! $this->queueBillPerformanceResync($performanceResync, 'douyin', $result, true)) {
return self::FAILURE;
}
return self::SUCCESS;
}
}