diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index dfe5ef4..245cff3 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -321,9 +321,16 @@ $bmpaFailedListUrl = \App\Support\BackUrl::withBack('/admin/platform-orders?bmpa_failed_only=1', $selfWithoutBack); // 运营扫描用的“治理状态摘要”(不替代下方的治理提示入口,只用于快速判断) - $receiptStatusText = $hasReceiptEvidence ? '有' : '无'; - $reconcileStatusText = $hasReceiptEvidence ? ($po->isReconcileMismatch() ? '不一致' : '一致') : '-'; - $refundStatusText = $po->isRefundInconsistent() ? '异常' : '正常'; + // 注意:为避免对“未支付订单”造成误导,回执/对账/退款在非 paid/refunded 时显示 "-"。 + $isPaid = ((string) $po->payment_status === 'paid'); + $isRefunded = ((string) $po->payment_status === 'refunded'); + + $receiptStatusText = $isPaid ? ($hasReceiptEvidence ? '有' : '无') : '-'; + $reconcileStatusText = ($isPaid && $hasReceiptEvidence) + ? ($po->isReconcileMismatch() ? '不一致' : '一致') + : '-'; + $refundStatusText = ($isPaid || $isRefunded) ? ($po->isRefundInconsistent() ? '异常' : '正常') : '-'; + $syncStatusText = $syncErrMsg !== '' ? '失败' : '正常'; $bmpaStatusText = $bmpaErrMsg !== '' ? '失败' : '正常'; $subscriptionStatusText = ((string) $po->order_type === 'renewal') diff --git a/tests/Feature/AdminDashboardRecentPlatformOrdersScanlineShouldHideReceiptAndReconcileWhenNotPaidTest.php b/tests/Feature/AdminDashboardRecentPlatformOrdersScanlineShouldHideReceiptAndReconcileWhenNotPaidTest.php new file mode 100644 index 0000000..e26be1b --- /dev/null +++ b/tests/Feature/AdminDashboardRecentPlatformOrdersScanlineShouldHideReceiptAndReconcileWhenNotPaidTest.php @@ -0,0 +1,72 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_recent_platform_orders_scanline_should_hide_receipt_and_reconcile_when_not_paid(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id'); + + $plan = Plan::query()->create([ + 'code' => 'dash_recent_order_scanline_not_paid_plan', + 'name' => '仪表盘扫描行未支付口径测试套餐', + '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, + 'site_subscription_id' => null, + 'created_by_admin_id' => $platformAdminId ?: null, + 'order_no' => 'PO_DASH_SCANLINE_NOT_PAID_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'pending', + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [ + // 即使 meta 里意外有 payment_summary,也不应该在未支付订单的扫描行里显示回执/对账 + 'payment_summary' => ['total_amount' => 1], + ], + ]); + + $res = $this->get('/admin'); + $res->assertOk(); + + $res->assertSee('PO_DASH_SCANLINE_NOT_PAID_0001'); + $res->assertSee('data-role="recent-platform-order-scanline"', false); + + $res->assertSee('回执:-', false); + $res->assertSee('对账:-', false); + $res->assertSee('退款:-', false); + } +}