Enhance: platform order show merchant/plan links keep back to show
This commit is contained in:
@@ -4,6 +4,21 @@
|
||||
@section('page_title', '平台订单详情')
|
||||
|
||||
@section('content')
|
||||
@php
|
||||
// 用于构建“保留当前上下文”的平台订单列表跳转链接(从详情跳回列表后可一键返回本订单详情)
|
||||
$orderShowSelf = '/' . ltrim(request()->path(), '/');
|
||||
$orderShowQuery = request()->query();
|
||||
unset($orderShowQuery['back']);
|
||||
if (count($orderShowQuery) > 0) {
|
||||
$orderShowSelf .= '?' . \Illuminate\Support\Arr::query($orderShowQuery);
|
||||
}
|
||||
|
||||
$makePlatformOrderIndexUrl = function (array $query) use ($orderShowSelf) {
|
||||
$query = $query + ['back' => $orderShowSelf];
|
||||
|
||||
return '/admin/platform-orders?' . \Illuminate\Support\Arr::query($query);
|
||||
};
|
||||
@endphp
|
||||
<div class="card mb-20">
|
||||
<p class="muted muted-tight">这里用于运营排查:订单核心字段、关联订阅、以及订阅同步元数据(meta)。</p>
|
||||
</div>
|
||||
@@ -18,7 +33,7 @@
|
||||
<th>站点</th>
|
||||
<td>
|
||||
@if($order->merchant)
|
||||
<a class="link" href="/admin/platform-orders?merchant_id={{ $order->merchant->id }}">{{ $order->merchant->name }}</a>
|
||||
<a class="link" href="{!! $makePlatformOrderIndexUrl(['merchant_id' => $order->merchant->id]) !!}">{{ $order->merchant->name }}</a>
|
||||
@else
|
||||
未关联站点
|
||||
@endif
|
||||
@@ -29,7 +44,7 @@
|
||||
<td>
|
||||
@php $planName = $order->plan_name ?: ($order->plan?->name ?? '-'); @endphp
|
||||
@if($order->plan)
|
||||
<a class="link" href="/admin/platform-orders?plan_id={{ $order->plan->id }}">{{ $planName }}</a>
|
||||
<a class="link" href="{!! $makePlatformOrderIndexUrl(['plan_id' => $order->plan->id]) !!}">{{ $planName }}</a>
|
||||
@else
|
||||
{{ $planName }}
|
||||
@endif
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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 AdminPlatformOrderShowMerchantPlanLinksContainBackTest 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_page_merchant_and_plan_links_should_contain_back_to_order_show(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'po_show_merchant_plan_back_test',
|
||||
'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_SHOW_MERCHANT_PLAN_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' => [],
|
||||
]);
|
||||
|
||||
$res = $this->get('/admin/platform-orders/' . $order->id);
|
||||
$res->assertOk();
|
||||
|
||||
$back = '/admin/platform-orders/' . $order->id;
|
||||
|
||||
$expectedMerchantUrl = '/admin/platform-orders?' . Arr::query([
|
||||
'merchant_id' => $merchant->id,
|
||||
'back' => $back,
|
||||
]);
|
||||
|
||||
$expectedPlanUrl = '/admin/platform-orders?' . Arr::query([
|
||||
'plan_id' => $plan->id,
|
||||
'back' => $back,
|
||||
]);
|
||||
|
||||
$res->assertSee($expectedMerchantUrl, false);
|
||||
$res->assertSee($expectedPlanUrl, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user