Platform batch show: add spot-check sample link to order anchors

This commit is contained in:
萝卜
2026-03-18 08:41:26 +08:00
parent 6d55850ac8
commit bb564e4876
3 changed files with 145 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ class PlatformBatchController extends Controller
'summary' => null,
'fallbackCounts' => null,
'governanceLinks' => [],
'spotCheck' => ['order_id' => 0, 'url' => '', 'label' => ''],
]);
}
@@ -170,7 +171,51 @@ class PlatformBatchController extends Controller
}
}
return view('admin.platform_batches.show', [
// 抽样复核入口:从“成功集合”里取一单,方便运营 spot-check。
// - BAS优先取已同步且无错误的订单
// - BMPA优先取本批次标记支付成功且无错误的订单
$spotCheck = [
'order_id' => 0,
'url' => '',
'label' => '',
];
$selfWithoutBack = BackUrl::selfWithoutBack();
$sampleQuery = PlatformOrder::query();
$driver3 = $sampleQuery->getQuery()->getConnection()->getDriverName();
if ($driver3 === 'sqlite') {
$sampleQuery->whereRaw("JSON_EXTRACT(meta, '{$keyPrefix}.run_id') = ?", [$runId]);
} else {
$sampleQuery->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(meta, '{$keyPrefix}.run_id')) = ?", [$runId]);
}
if ($type === 'bas') {
$sampleQuery->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation.subscription_id') IS NOT NULL")
->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation_error.message') IS NULL");
$sampleOrder = $sampleQuery->orderByDesc('id')->first(['id']);
if ($sampleOrder) {
$spotCheck['order_id'] = (int) $sampleOrder->id;
$spotCheck['label'] = '抽样复核:查看订阅同步';
$spotCheck['url'] = BackUrl::withBackAndFragment('/admin/platform-orders/' . $sampleOrder->id, $selfWithoutBack, 'subscription-sync');
}
}
if ($type === 'bmpa') {
$sampleQuery->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate.run_id') IS NOT NULL")
->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate_error.message') IS NULL");
$sampleOrder = $sampleQuery->orderByDesc('id')->first(['id']);
if ($sampleOrder) {
$spotCheck['order_id'] = (int) $sampleOrder->id;
$spotCheck['label'] = '抽样复核:查看支付回执';
$spotCheck['url'] = BackUrl::withBackAndFragment('/admin/platform-orders/' . $sampleOrder->id, $selfWithoutBack, 'payment-receipts');
}
}
return view('admin.platform_batches.show', [
'type' => $type,
'runId' => $runId,
'safeBackForLinks' => $safeBackForLinks,
@@ -178,6 +223,7 @@ class PlatformBatchController extends Controller
'summary' => $summary,
'fallbackCounts' => $fallbackCounts,
'governanceLinks' => $governanceLinks,
'spotCheck' => $spotCheck,
]);
}
}