diff --git a/public/js/admin.js b/public/js/admin.js index d43fcd4..c68b76e 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -57,6 +57,7 @@ var h = String(window.location.hash || ''); var map = { '#add-payment-receipt': 'details#add-payment-receipt', + '#add-refund-receipt': 'details#add-refund-receipt', '#refund-receipts': 'details#add-refund-receipt', }; diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 943ca14..3351d81 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -380,6 +380,8 @@ 进入集合 去核对退款 + + 去补退款记录 @endif @if((string) $po->order_type === 'renewal' && empty($po->site_subscription_id)) diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index ad6e77c..cbc1cf6 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -691,7 +691,7 @@

暂无退款记录。

@endif -
+
追加一条退款记录(会自动推进支付状态)
@csrf diff --git a/tests/Feature/AdminDashboardRecentPlatformOrdersRefundInconsistentShouldIncludeFixRefundReceiptLinkTest.php b/tests/Feature/AdminDashboardRecentPlatformOrdersRefundInconsistentShouldIncludeFixRefundReceiptLinkTest.php new file mode 100644 index 0000000..3a903b2 --- /dev/null +++ b/tests/Feature/AdminDashboardRecentPlatformOrdersRefundInconsistentShouldIncludeFixRefundReceiptLinkTest.php @@ -0,0 +1,66 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_recent_platform_orders_refund_inconsistent_should_include_fix_refund_receipt_link(): void + { + $this->loginAsPlatformAdmin(); + + $merchantId = (int) Merchant::query()->value('id'); + $platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id'); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchantId, + 'plan_id' => null, + 'site_subscription_id' => null, + 'created_by_admin_id' => $platformAdminId ?: null, + 'order_no' => 'PO_DASH_REFUND_FIX_RECEIPT_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'refunded', + 'payable_amount' => 9, + 'paid_amount' => 9, + 'meta' => [ + 'refund_summary' => [ + 'total_amount' => 8, + ], + ], + ]); + + $this->assertTrue($order->isRefundInconsistent()); + + $res = $this->get('/admin'); + $res->assertOk(); + + $res->assertSee('退款不一致', false); + $res->assertSee('去补退款记录', false); + + $fixUrl = '/admin/platform-orders/' . $order->id . '?' . Arr::query([ + 'back' => '/admin', + ]) . '#add-refund-receipt'; + + $res->assertSee($fixUrl, false); + $res->assertDontSee('&back=', false); + } +} diff --git a/tests/Feature/AdminJsShouldAutoOpenRefundReceiptDetailsWhenHashPresentTest.php b/tests/Feature/AdminJsShouldAutoOpenRefundReceiptDetailsWhenHashPresentTest.php index 0724ac1..b433fef 100644 --- a/tests/Feature/AdminJsShouldAutoOpenRefundReceiptDetailsWhenHashPresentTest.php +++ b/tests/Feature/AdminJsShouldAutoOpenRefundReceiptDetailsWhenHashPresentTest.php @@ -10,8 +10,9 @@ class AdminJsShouldAutoOpenRefundReceiptDetailsWhenHashPresentTest extends TestC { $js = (string) file_get_contents(public_path('js/admin.js')); - // 护栏:当 hash 为 #refund-receipts 时,应自动展开 details#add-refund-receipt(追加退款记录面板)。 + // 护栏:当 hash 为 #refund-receipts 或 #add-refund-receipt 时,应自动展开 details#add-refund-receipt(追加退款记录面板)。 $this->assertStringContainsString("'#refund-receipts': 'details#add-refund-receipt'", $js); + $this->assertStringContainsString("'#add-refund-receipt': 'details#add-refund-receipt'", $js); $this->assertStringContainsString('if (map[h])', $js); $this->assertStringContainsString('d.open = true', $js); } diff --git a/tests/Feature/AdminPlatformOrderShowRefundReceiptDetailsShouldHaveIdTest.php b/tests/Feature/AdminPlatformOrderShowRefundReceiptDetailsShouldHaveIdTest.php new file mode 100644 index 0000000..7ae4af3 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowRefundReceiptDetailsShouldHaveIdTest.php @@ -0,0 +1,63 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_refund_receipt_details_should_have_id(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_show_refund_details_id_plan', + 'name' => '退款 details id 测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SHOW_REFUND_DETAILS_ID_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + '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(), + 'meta' => [], + ]); + + $this->get('/admin/platform-orders/' . $order->id) + ->assertOk() + ->assertSee('details class="mt-12" id="add-refund-receipt"', false); + } +}