平台订单列表:回执数/退款数跳详情携带 back+锚点
This commit is contained in:
@@ -956,7 +956,10 @@
|
|||||||
$receiptCount = $receiptSummaryCount !== null ? (int) $receiptSummaryCount : count($receipts);
|
$receiptCount = $receiptSummaryCount !== null ? (int) $receiptSummaryCount : count($receipts);
|
||||||
@endphp
|
@endphp
|
||||||
@if($receiptCount > 0)
|
@if($receiptCount > 0)
|
||||||
<a href="/admin/platform-orders/{{ $order->id }}" class="muted">{{ $receiptCount }}</a>
|
@php
|
||||||
|
$receiptCountShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#payment-receipts';
|
||||||
|
@endphp
|
||||||
|
<a href="{!! $receiptCountShowUrl !!}" class="muted">{{ $receiptCount }}</a>
|
||||||
@else
|
@else
|
||||||
<span class="muted">0</span>
|
<span class="muted">0</span>
|
||||||
@endif
|
@endif
|
||||||
@@ -968,7 +971,10 @@
|
|||||||
$refundCount = $refundSummaryCount !== null ? (int) $refundSummaryCount : count($refunds);
|
$refundCount = $refundSummaryCount !== null ? (int) $refundSummaryCount : count($refunds);
|
||||||
@endphp
|
@endphp
|
||||||
@if($refundCount > 0)
|
@if($refundCount > 0)
|
||||||
<a href="/admin/platform-orders/{{ $order->id }}" class="muted">{{ $refundCount }}</a>
|
@php
|
||||||
|
$refundCountShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#refund-receipts';
|
||||||
|
@endphp
|
||||||
|
<a href="{!! $refundCountShowUrl !!}" class="muted">{{ $refundCount }}</a>
|
||||||
@else
|
@else
|
||||||
<span class="muted">0</span>
|
<span class="muted">0</span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexReceiptRefundCountLinksContainBackTest 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_receipt_and_refund_count_links_should_carry_back_and_anchor(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'po_index_receipt_refund_count_back_plan',
|
||||||
|
'name' => '平台订单列表回执/退款数 back 链接测试套餐',
|
||||||
|
'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_INDEX_RC_BACK_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'pending',
|
||||||
|
'payment_status' => 'unpaid',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'quantity' => 1,
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 0,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'payment_receipts' => [
|
||||||
|
['amount' => 10, 'paid_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'],
|
||||||
|
],
|
||||||
|
'refund_receipts' => [
|
||||||
|
['amount' => 1, 'refunded_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 列表页带 back(模拟从其它页跳回),本页生成 selfWithoutBack 时会去掉 back
|
||||||
|
$res = $this->get('/admin/platform-orders?status=pending&back=' . urlencode('/admin/plans'));
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$indexSelfWithoutBack = '/admin/platform-orders?' . Arr::query([
|
||||||
|
'status' => 'pending',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$receiptLink = '/admin/platform-orders/' . $order->id . '?' . Arr::query([
|
||||||
|
'back' => $indexSelfWithoutBack,
|
||||||
|
]) . '#payment-receipts';
|
||||||
|
|
||||||
|
$refundLink = '/admin/platform-orders/' . $order->id . '?' . Arr::query([
|
||||||
|
'back' => $indexSelfWithoutBack,
|
||||||
|
]) . '#refund-receipts';
|
||||||
|
|
||||||
|
$res->assertSee($receiptLink, false);
|
||||||
|
$res->assertSee($refundLink, false);
|
||||||
|
|
||||||
|
// 不允许 back 嵌套
|
||||||
|
$res->assertDontSee('back%3D', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user