feat(admin-dashboard): refund inconsistent hint links to add refund receipt panel
This commit is contained in:
@@ -57,6 +57,7 @@
|
|||||||
var h = String(window.location.hash || '');
|
var h = String(window.location.hash || '');
|
||||||
var map = {
|
var map = {
|
||||||
'#add-payment-receipt': 'details#add-payment-receipt',
|
'#add-payment-receipt': 'details#add-payment-receipt',
|
||||||
|
'#add-refund-receipt': 'details#add-refund-receipt',
|
||||||
'#refund-receipts': 'details#add-refund-receipt',
|
'#refund-receipts': 'details#add-refund-receipt',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -380,6 +380,8 @@
|
|||||||
<a class="link" href="{!! $refundInconsistentUrl !!}">进入集合</a>
|
<a class="link" href="{!! $refundInconsistentUrl !!}">进入集合</a>
|
||||||
<span class="muted">|</span>
|
<span class="muted">|</span>
|
||||||
<a class="link" href="{!! \App\Support\BackUrl::withBackAndFragment('/admin/platform-orders/' . $po->id, $selfWithoutBack, 'refund-receipts') !!}">去核对退款</a>
|
<a class="link" href="{!! \App\Support\BackUrl::withBackAndFragment('/admin/platform-orders/' . $po->id, $selfWithoutBack, 'refund-receipts') !!}">去核对退款</a>
|
||||||
|
<span class="muted">|</span>
|
||||||
|
<a class="link" href="{!! \App\Support\BackUrl::withBackAndFragment('/admin/platform-orders/' . $po->id, $selfWithoutBack, 'add-refund-receipt') !!}">去补退款记录</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if((string) $po->order_type === 'renewal' && empty($po->site_subscription_id))
|
@if((string) $po->order_type === 'renewal' && empty($po->site_subscription_id))
|
||||||
|
|||||||
@@ -691,7 +691,7 @@
|
|||||||
<p class="muted">暂无退款记录。</p>
|
<p class="muted">暂无退款记录。</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<details class="mt-12">
|
<details class="mt-12" id="add-refund-receipt">
|
||||||
<summary class="muted">追加一条退款记录(会自动推进支付状态)</summary>
|
<summary class="muted">追加一条退款记录(会自动推进支付状态)</summary>
|
||||||
<form method="post" action="/admin/platform-orders/{{ $order->id }}/add-refund-receipt" class="mt-10" data-action="disable-on-submit" onsubmit="return confirm('确认追加退款记录?该操作会写入退款轨迹,并可能推进支付状态为部分退款/已退款');">
|
<form method="post" action="/admin/platform-orders/{{ $order->id }}/add-refund-receipt" class="mt-10" data-action="disable-on-submit" onsubmit="return confirm('确认追加退款记录?该操作会写入退款轨迹,并可能推进支付状态为部分退款/已退款');">
|
||||||
@csrf
|
@csrf
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Admin;
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminDashboardRecentPlatformOrdersRefundInconsistentShouldIncludeFixRefundReceiptLinkTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,8 +10,9 @@ class AdminJsShouldAutoOpenRefundReceiptDetailsWhenHashPresentTest extends TestC
|
|||||||
{
|
{
|
||||||
$js = (string) file_get_contents(public_path('js/admin.js'));
|
$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("'#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('if (map[h])', $js);
|
||||||
$this->assertStringContainsString('d.open = true', $js);
|
$this->assertStringContainsString('d.open = true', $js);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderShowRefundReceiptDetailsShouldHaveIdTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user