From 3dec3db75bab44d70818ac5aca7d26bf04659da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 15:41:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=AF=B9=E8=B4=A6=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E5=AF=BC=E5=87=BA=E5=AE=B9=E5=B7=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=8A=A4=E6=A0=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rtReconcileMismatchToleranceConfigTest.php | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderExportReconcileMismatchToleranceConfigTest.php diff --git a/tests/Feature/AdminPlatformOrderExportReconcileMismatchToleranceConfigTest.php b/tests/Feature/AdminPlatformOrderExportReconcileMismatchToleranceConfigTest.php new file mode 100644 index 0000000..20892e4 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderExportReconcileMismatchToleranceConfigTest.php @@ -0,0 +1,101 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_export_reconcile_mismatch_filter_respects_configured_tolerance(): void + { + $this->loginAsPlatformAdmin(); + + config(['saasshop.amounts.tolerance' => 0.05]); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'export_reconcile_mismatch_tol_cfg_test', + 'name' => '导出对账不一致容差测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // A:差额 0.04(在 tol=0.05 内)=> 不应命中 + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_EXP_RECON_TOL_A', + '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' => 9.96, + ], + ], + ]); + + // B:差额 0.06(超出 tol=0.05)=> 应命中 + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_EXP_RECON_TOL_B', + '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' => 9.94, + ], + ], + ]); + + $res = $this->get('/admin/platform-orders/export?download=1&reconcile_mismatch=1'); + $res->assertOk(); + + $content = $res->streamedContent(); + + $this->assertStringNotContainsString('PO_EXP_RECON_TOL_A', $content); + $this->assertStringContainsString('PO_EXP_RECON_TOL_B', $content); + } +}