增加了手机操作端

This commit is contained in:
wushumin
2026-05-15 14:01:36 +08:00
parent 9aac78b8da
commit dd56e0861b
107 changed files with 23547 additions and 346 deletions

View File

@@ -0,0 +1,31 @@
<?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;
}
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace app\queue\redis;
use app\support\MaterialTagQrCodeService;
use app\support\MaterialBatchPackageService;
use support\Log;
use Webman\RedisQueue\Consumer;
class MaterialTagQrCodeConsumer implements Consumer
{
public string $queue = MaterialTagQrCodeService::QUEUE_NAME;
public string $connection = 'default';
public function consume($data): void
{
$tagIds = array_values(array_filter(array_map('intval', (array)($data['tag_ids'] ?? []))));
if (!$tagIds) {
return;
}
$service = new MaterialTagQrCodeService();
$errors = [];
foreach ($tagIds as $tagId) {
try {
$service->generateForTagId($tagId);
} catch (\Throwable $e) {
$errors[] = sprintf('#%d %s', $tagId, $e->getMessage());
Log::error('material tag QR image generation failed', [
'tag_id' => $tagId,
'batch_id' => (int)($data['batch_id'] ?? 0),
'message' => $e->getMessage(),
]);
}
}
if ($errors) {
throw new \RuntimeException('物料二维码图片生成失败:' . implode('; ', array_slice($errors, 0, 3)));
}
$batchId = (int)($data['batch_id'] ?? 0);
if ($batchId > 0) {
try {
(new MaterialBatchPackageService())->enqueueIfReady($batchId);
} catch (\Throwable $e) {
Log::error('material batch package job enqueue failed after QR generation', [
'batch_id' => $batchId,
'message' => $e->getMessage(),
]);
throw $e;
}
}
}
}