32 lines
795 B
PHP
32 lines
795 B
PHP
<?php
|
|
|
|
namespace app\queue\redis;
|
|
|
|
use app\support\MaterialBatchPackageService;
|
|
use support\Log;
|
|
use Webman\RedisQueue\Consumer;
|
|
|
|
class MaterialBatchPackageConsumer implements Consumer
|
|
{
|
|
public string $queue = MaterialBatchPackageService::QUEUE_NAME;
|
|
public string $connection = 'default';
|
|
|
|
public function consume($data): void
|
|
{
|
|
$batchId = (int)($data['batch_id'] ?? 0);
|
|
if ($batchId <= 0) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
(new MaterialBatchPackageService())->generateForBatchId($batchId);
|
|
} catch (\Throwable $e) {
|
|
Log::error('material batch package generation failed', [
|
|
'batch_id' => $batchId,
|
|
'message' => $e->getMessage(),
|
|
]);
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|