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

43 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands\Concerns;
use Illuminate\Support\Carbon;
use Modules\EcommerceFinance\Services\BillPerformanceResyncDispatcher;
use Throwable;
trait QueuesBillPerformanceResync
{
protected function queueBillPerformanceResync(
BillPerformanceResyncDispatcher $dispatcher,
string $platform,
array $result,
bool $periodEndExclusive = false,
): bool {
try {
$periodEnd = (string) ($result['period_end'] ?? '');
if ($periodEndExclusive && $periodEnd !== '') {
$periodEnd = Carbon::parse($periodEnd)->subDay()->toDateString();
}
$queued = $dispatcher->dispatch(
$platform,
(string) ($result['period_start'] ?? ''),
$periodEnd,
);
} catch (Throwable $exception) {
report($exception);
$this->error('账单已导入,但业绩明细重算任务排队失败;请重新执行本导入命令以重试排队。');
return false;
}
$this->line(
'业绩明细重算已排队:'
. implode('、', $queued['months'])
. '(新增 ' . $queued['jobs'] . ' 个任务)'
);
return true;
}
}