From e6292ac6651765c0e7845cfca99bd63c37c44d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 04:44:43 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E5=A4=B1=E8=B4=A5=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=EF=BC=9Arefund=5Finconsistent=20=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E5=8F=A3=E5=BE=84=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 --- ...rorsRefundInconsistentFilterFieldsTest.php | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderClearSyncErrorsRefundInconsistentFilterFieldsTest.php diff --git a/tests/Feature/AdminPlatformOrderClearSyncErrorsRefundInconsistentFilterFieldsTest.php b/tests/Feature/AdminPlatformOrderClearSyncErrorsRefundInconsistentFilterFieldsTest.php new file mode 100644 index 0000000..fe9a990 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderClearSyncErrorsRefundInconsistentFilterFieldsTest.php @@ -0,0 +1,108 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_clear_sync_errors_filtered_scope_respects_refund_inconsistent_filter(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'clear_sync_errors_refund_inconsistent_plan', + 'name' => '清理失败标记(退款不一致口径)测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // A:退款不一致 + 有同步失败标记(应被清理) + $a = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_CLEAR_ERR_REFUND_INCONS_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' => [ + 'refund_summary' => [ + 'count' => 1, + 'total_amount' => 10.00, + ], + 'subscription_activation_error' => [ + 'message' => '测试错误A', + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + // B:退款一致(无退款)+ 有同步失败标记(不应被清理) + $b = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_CLEAR_ERR_REFUND_INCONS_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' => [ + 'subscription_activation_error' => [ + 'message' => '测试错误B', + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + $this->post('/admin/platform-orders/clear-sync-errors', [ + 'scope' => 'filtered', + 'refund_inconsistent' => '1', + ])->assertRedirect(); + + $a->refresh(); + $b->refresh(); + + $this->assertNull(data_get($a->meta, 'subscription_activation_error.message')); + $this->assertSame('测试错误B', (string) data_get($b->meta, 'subscription_activation_error.message')); + } +}