From bf39bccbee1ec750a54cb7aa5d900c8bf364f69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 00:15:25 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=EF=BC=9A=E5=AF=B9=E8=B4=A6/=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=97=B6=E7=A6=81=E7=94=A8=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=B9=B6=E7=BB=99=E6=B2=BB=E7=90=86=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/show.blade.php | 46 +++++----- ...ttonDisabledWhenGovernanceMismatchTest.php | 84 +++++++++++++++++++ 2 files changed, 111 insertions(+), 19 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderShowActivateSubscriptionButtonDisabledWhenGovernanceMismatchTest.php diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index fd6e250..9aabe01 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -209,29 +209,37 @@ @endif + @php + $syncBlockedByGovernance = $order->isReconcileMismatch() || $order->isRefundInconsistent(); + @endphp
@csrf - +
- @if($order->isReconcileMismatch() || $order->isRefundInconsistent()) -
- 提示:当前订单命中「对账不一致/退款不一致」,为避免带病同步,请先完成金额/状态治理(补回执/核对退款/修正状态)后再同步订阅。 - @if($order->isReconcileMismatch()) - @php - $fixReceiptUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $orderShowSelf]) . '#add-payment-receipt'; - @endphp - 去补回执 - @endif - @if($order->isReconcileMismatch() && $order->isRefundInconsistent()) - - @endif - @if($order->isRefundInconsistent()) - @php - $fixRefundUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $orderShowSelf]) . '#refund-receipts'; - @endphp - 去核对退款 - @endif + @if($syncBlockedByGovernance) +
+
同步订阅治理提示(当前不建议/不可直接同步)
+
+
原因:订单命中「对账不一致/退款不一致」。为避免把“带病订单”同步到订阅,请先完成金额/状态治理。
+
+ @if($order->isReconcileMismatch()) + @php + $fixReceiptUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $orderShowSelf]) . '#add-payment-receipt'; + @endphp + 去补回执 + @endif + @if($order->isReconcileMismatch() && $order->isRefundInconsistent()) + + @endif + @if($order->isRefundInconsistent()) + @php + $fixRefundUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $orderShowSelf]) . '#refund-receipts'; + @endphp + 去核对退款 + @endif +
+
@endif diff --git a/tests/Feature/AdminPlatformOrderShowActivateSubscriptionButtonDisabledWhenGovernanceMismatchTest.php b/tests/Feature/AdminPlatformOrderShowActivateSubscriptionButtonDisabledWhenGovernanceMismatchTest.php new file mode 100644 index 0000000..3a7a24f --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowActivateSubscriptionButtonDisabledWhenGovernanceMismatchTest.php @@ -0,0 +1,84 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_activate_subscription_button_should_be_disabled_and_show_governance_block_when_reconcile_mismatch(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_show_disable_sync_reconcile_mismatch_plan', + 'name' => '同步订阅禁用-对账不一致测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // 已支付+已生效,但回执总额=9,paid_amount=10 => reconcile_mismatch=true + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SHOW_DISABLE_SYNC_RECON_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_summary' => [ + 'count' => 1, + 'total_amount' => 9, + ], + 'payment_receipts' => [ + [ + 'type' => 'bank_transfer', + 'channel' => 'offline', + 'amount' => 9, + 'paid_at' => now()->toDateTimeString(), + 'created_at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ], + ]); + + $res = $this->get('/admin/platform-orders/' . $order->id); + $res->assertOk(); + + $res->assertSee('同步订阅治理提示', false); + $res->assertSee('去补回执', false); + $res->assertSee('href="/admin/platform-orders/' . $order->id, false); // should include a link back to this page + anchor + $res->assertSee('disabled', false); + } +}