diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 7436cc4..52c622e 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -1239,6 +1239,7 @@ 同步时间 失败原因 最近批量同步 + 最近批量BMPA 最近批量生效 回执总额 对账差额 @@ -1563,6 +1564,41 @@ - @endif + + @php + // 优先使用扁平字段 meta.batch_mark_paid_and_activate(便于筛选/统计,也避免遍历 audit) + $batchBmpa = (array) (data_get($order->meta, 'batch_mark_paid_and_activate', []) ?? []); + $bmpaAt = (string) (data_get($batchBmpa, 'at') ?? ''); + $bmpaAdminId = data_get($batchBmpa, 'admin_id'); + $bmpaRunId = (string) (data_get($batchBmpa, 'run_id') ?? ''); + + $bmpaLastResult = (array) (data_get($batchBmpa, 'last_result', []) ?? []); + $blrRunId = (string) (data_get($bmpaLastResult, 'run_id') ?? ''); + $blrSuccess = (int) (data_get($bmpaLastResult, 'success') ?? 0); + $blrFailed = (int) (data_get($bmpaLastResult, 'failed') ?? 0); + $blrTopReason = (string) (data_get($bmpaLastResult, 'top_reasons.0.reason') ?? ''); + $blrTopReasonCount = (int) (data_get($bmpaLastResult, 'top_reasons.0.count') ?? 0); + @endphp + @if($bmpaAt !== '') +
{{ $bmpaAt }}
+
管理员:{{ $bmpaAdminId ?: '-' }}
+ + @if($bmpaRunId !== '') +
批次: + {{ $bmpaRunId }} +
+ @endif + + @if($blrRunId !== '') +
结果:成功{{ $blrSuccess }} / 失败{{ $blrFailed }}
+ @if($blrTopReason !== '') +
Top:{{ mb_substr($blrTopReason, 0, 40) }}({{ $blrTopReasonCount }})
+ @endif + @endif + @else + - + @endif + @php // 优先使用扁平字段 meta.batch_mark_activated(便于筛选/统计,也避免遍历 audit) diff --git a/tests/Feature/AdminPlatformOrderIndexBatchBmpaLastResultShouldRenderTest.php b/tests/Feature/AdminPlatformOrderIndexBatchBmpaLastResultShouldRenderTest.php new file mode 100644 index 0000000..d46baf6 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexBatchBmpaLastResultShouldRenderTest.php @@ -0,0 +1,82 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_page_should_render_batch_bmpa_last_result_summary_when_present(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_batch_bmpa_last_result_render_plan', + 'name' => '批量BMPA last_result 渲染测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_BATCH_BMPA_LAST_RESULT_RENDER_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now()->subMinutes(10), + 'meta' => [ + 'batch_mark_paid_and_activate' => [ + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + 'scope' => 'filtered', + 'mode' => 'sync', + 'run_id' => 'BMPA_TEST_0001', + 'last_result' => [ + 'run_id' => 'BMPA_TEST_0001', + 'success' => 3, + 'failed' => 1, + 'matched' => 10, + 'processed' => 4, + 'top_reasons' => [ + ['reason' => '模拟失败:回执金额不一致', 'count' => 1], + ], + 'at' => now()->toDateTimeString(), + ], + ], + ], + ]); + + $this->get('/admin/platform-orders') + ->assertOk() + ->assertSee('结果:成功3 / 失败1') + ->assertSee('模拟失败:回执金额不一致'); + } +}