From b0ee9b629011175594eef6b6ccc2ce0d1cb869f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 13 Mar 2026 15:21:53 +0000 Subject: [PATCH] =?UTF-8?q?admin:=20=E8=AE=A2=E9=98=85=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E5=B7=AE=E9=A2=9D=E6=8F=90=E7=A4=BA=E6=8C=89?= =?UTF-8?q?=E5=AE=B9=E5=B7=AE=E9=85=8D=E7=BD=AE=E5=88=A4=E6=96=AD=E5=B9=B6?= =?UTF-8?q?=E8=A1=A5=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 --- .../admin/site_subscriptions/show.blade.php | 7 +- ...onReconciliationDeltaToleranceHintTest.php | 91 +++++++++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 tests/Feature/AdminSiteSubscriptionReconciliationDeltaToleranceHintTest.php diff --git a/resources/views/admin/site_subscriptions/show.blade.php b/resources/views/admin/site_subscriptions/show.blade.php index 9678834..c9059ac 100644 --- a/resources/views/admin/site_subscriptions/show.blade.php +++ b/resources/views/admin/site_subscriptions/show.blade.php @@ -223,16 +223,17 @@ 对账不一致订单: {{ $summaryStats['reconcile_mismatch_orders'] ?? 0 }} + @php $tol = (float) config('saasshop.amounts.tolerance', 0.01); @endphp @if(((int) ($summaryStats['reconcile_mismatch_orders'] ?? 0)) > 0)
提示:存在「回执总额 vs 已付金额」不一致订单。 进入对账不一致订单列表 (建议先逐单核对回执轨迹与订单金额,再决定是否补回执/修正订单金额口径)。
- @elseif(abs($delta) >= 0.01) -
提示:差额非 0,可能存在回执金额与订单已付金额不一致。
+ @elseif(abs($delta) >= $tol) +
提示:差额超过容差(tol={{ number_format($tol, 2) }}),可能存在回执金额与订单已付金额不一致。
@else -
差额为 0(当前订阅维度)
+
差额在容差范围内(tol={{ number_format($tol, 2) }},当前订阅维度)
@endif diff --git a/tests/Feature/AdminSiteSubscriptionReconciliationDeltaToleranceHintTest.php b/tests/Feature/AdminSiteSubscriptionReconciliationDeltaToleranceHintTest.php new file mode 100644 index 0000000..8f209b7 --- /dev/null +++ b/tests/Feature/AdminSiteSubscriptionReconciliationDeltaToleranceHintTest.php @@ -0,0 +1,91 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_subscription_show_delta_hint_respects_tolerance_config(): void + { + $this->loginAsPlatformAdmin(); + + config(['saasshop.amounts.tolerance' => 0.05]); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'sub_delta_tol_01', + 'name' => '订阅对账差额容差提示测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $sub = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'activated', + 'source' => 'manual', + 'subscription_no' => 'SUB_DELTA_TOL_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now()->subDay(), + 'ends_at' => now()->addMonth(), + 'activated_at' => now()->subDay(), + ]); + + // paid_amount=10.00,回执=10.02,差额=0.02,在容差 0.05 内,应展示“在容差范围内”而非危险提示 + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'site_subscription_id' => $sub->id, + 'created_by_admin_id' => 1, + 'order_no' => 'PO_SUB_DELTA_TOL_0001', + 'order_type' => 'renewal', + '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()->subMinutes(10), + 'paid_at' => now()->subMinutes(9), + 'activated_at' => now()->subMinutes(8), + 'meta' => [ + 'payment_summary' => [ + 'count' => 1, + 'total_amount' => 10.02, + ], + ], + ]); + + $this->get('/admin/site-subscriptions/' . $sub->id) + ->assertOk() + ->assertSee('差额在容差范围内', false) + ->assertDontSee('差额超过容差', false); + } +}