diff --git a/app/Http/Controllers/Admin/PlatformBatchController.php b/app/Http/Controllers/Admin/PlatformBatchController.php index 991a109..20ce573 100644 --- a/app/Http/Controllers/Admin/PlatformBatchController.php +++ b/app/Http/Controllers/Admin/PlatformBatchController.php @@ -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, ]); } } diff --git a/resources/views/admin/platform_batches/show.blade.php b/resources/views/admin/platform_batches/show.blade.php index e437c2d..d5da1ea 100644 --- a/resources/views/admin/platform_batches/show.blade.php +++ b/resources/views/admin/platform_batches/show.blade.php @@ -119,7 +119,19 @@ -