From ae42844eb679e74335ccb8677b59725e5f435f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 15:03:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E7=AD=9B=E9=80=89=E5=8F=A3=E5=BE=84?= =?UTF-8?q?=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...RefundInconsistentFilterShouldWorkTest.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexRefundInconsistentFilterShouldWorkTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexRefundInconsistentFilterShouldWorkTest.php b/tests/Feature/AdminPlatformOrderIndexRefundInconsistentFilterShouldWorkTest.php new file mode 100644 index 0000000..3e5f8aa --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexRefundInconsistentFilterShouldWorkTest.php @@ -0,0 +1,100 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_refund_inconsistent_filter_should_include_and_exclude_expected_orders(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_refund_inconsistent_filter_plan', + 'name' => '退款不一致筛选测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // A: payment_status=refunded 但 refund_total < paid_amount(应命中) + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_REFUND_INCONSISTENT_YES_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'refunded', + 'payable_amount' => 10, + 'paid_amount' => 10, + 'meta' => [ + 'refund_summary' => [ + 'total_amount' => 9, + ], + ], + ]); + + // B: payment_status=paid 且 refund_total >= paid_amount + 容差(应命中:状态非 refunded 但退款已覆盖已付,口径按系统容差) + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_REFUND_INCONSISTENT_YES_0002', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'paid', + 'payable_amount' => 10, + 'paid_amount' => 10, + 'meta' => [ + 'refund_summary' => [ + // 默认容差为 0.01,因此这里用 10.02 确保命中“退款已覆盖已付 + 容差” + 'total_amount' => 10.02, + ], + ], + ]); + + // C: payment_status=paid 且 refund_total < paid_amount(不命中) + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_REFUND_INCONSISTENT_NO_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'paid', + 'payable_amount' => 10, + 'paid_amount' => 10, + 'meta' => [ + 'refund_summary' => [ + 'total_amount' => 1, + ], + ], + ]); + + $res = $this->get('/admin/platform-orders?refund_inconsistent=1'); + $res->assertOk(); + + $res->assertSee('PO_REFUND_INCONSISTENT_YES_0001', false); + $res->assertSee('PO_REFUND_INCONSISTENT_YES_0002', false); + $res->assertDontSee('PO_REFUND_INCONSISTENT_NO_0001', false); + } +}