feat(queue): add run_id for batch activation job traceability

This commit is contained in:
萝卜
2026-03-17 12:49:52 +08:00
parent 53a024ae4c
commit 7723dd8daf
2 changed files with 82 additions and 1 deletions

View File

@@ -52,6 +52,9 @@ class BatchActivateSubscriptionsJob implements ShouldQueue
public function handle(SubscriptionActivationService $service): void
{
// 批次号:用于把一次队列批量执行关联起来,便于后续追溯/筛选/可观测。
$runId = 'BAS' . now()->format('YmdHis') . str_pad((string) random_int(1, 9999), 4, '0', STR_PAD_LEFT);
foreach ($this->orderIds as $orderId) {
/** @var PlatformOrder|null $order */
$order = PlatformOrder::query()->find($orderId);
@@ -81,7 +84,8 @@ class BatchActivateSubscriptionsJob implements ShouldQueue
'admin_id' => $this->adminId,
'subscription_id' => $subscription->id,
'filters' => $this->filterSummary,
'note' => '批量同步订阅queue, limit=' . $this->limit . ', matched=' . $this->matchedTotal . ', processed=' . $this->processed . ')',
'run_id' => $runId,
'note' => '批量同步订阅queue, run_id=' . $runId . ', limit=' . $this->limit . ', matched=' . $this->matchedTotal . ', processed=' . $this->processed . ')',
];
data_set($meta, 'audit', $audit);
@@ -91,6 +95,7 @@ class BatchActivateSubscriptionsJob implements ShouldQueue
'admin_id' => $this->adminId,
'scope' => $this->scope,
'mode' => 'queue',
'run_id' => $runId,
]);
$order->meta = $meta;