From 0e7a2f083a7e79091cdc8187780e94cd944c5867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 07:59:16 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=EF=BC=9A=E5=9B=9E=E6=89=A7=E6=9C=89=E6=97=A0(ReceiptS?= =?UTF-8?q?tatus)=E7=AD=9B=E9=80=89=E6=B5=8B=E8=AF=95=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...formOrderExportReceiptStatusFilterTest.php | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderExportReceiptStatusFilterTest.php diff --git a/tests/Feature/AdminPlatformOrderExportReceiptStatusFilterTest.php b/tests/Feature/AdminPlatformOrderExportReceiptStatusFilterTest.php new file mode 100644 index 0000000..31038ea --- /dev/null +++ b/tests/Feature/AdminPlatformOrderExportReceiptStatusFilterTest.php @@ -0,0 +1,124 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_export_can_filter_by_receipt_status_has_and_none(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'export_receipt_status_filter_test', + 'name' => '导出回执筛选测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // 有回执:payment_receipts + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_EXPORT_RECEIPT_HAS_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [ + 'payment_receipts' => [ + ['amount' => 10.00, 'paid_at' => now()->toDateTimeString()], + ], + ], + ]); + + // 有回执:payment_summary + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_EXPORT_RECEIPT_HAS_0002', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [ + 'payment_summary' => [ + 'count' => 1, + 'total_amount' => 10.00, + ], + ], + ]); + + // 无回执 + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_EXPORT_RECEIPT_NONE_0003', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [], + ]); + + $res1 = $this->get('/admin/platform-orders/export?receipt_status=has'); + $res1->assertOk(); + $content1 = $res1->streamedContent(); + $this->assertStringContainsString('PO_EXPORT_RECEIPT_HAS_0001', $content1); + $this->assertStringContainsString('PO_EXPORT_RECEIPT_HAS_0002', $content1); + $this->assertStringNotContainsString('PO_EXPORT_RECEIPT_NONE_0003', $content1); + + $res2 = $this->get('/admin/platform-orders/export?receipt_status=none'); + $res2->assertOk(); + $content2 = $res2->streamedContent(); + $this->assertStringContainsString('PO_EXPORT_RECEIPT_NONE_0003', $content2); + $this->assertStringNotContainsString('PO_EXPORT_RECEIPT_HAS_0001', $content2); + $this->assertStringNotContainsString('PO_EXPORT_RECEIPT_HAS_0002', $content2); + } +}