chore(admin): 平台订单下单页展示来源线索上下文提示
This commit is contained in:
@@ -8,6 +8,35 @@
|
|||||||
<p class="muted muted-tight">用于总台运营手工创建一笔平台订单(演示/补单/线下收款录入)。</p>
|
<p class="muted muted-tight">用于总台运营手工创建一笔平台订单(演示/补单/线下收款录入)。</p>
|
||||||
<p class="muted">创建后可在「平台订单」列表中继续推进:标记支付并生效 → 同步订阅(形成最小收费闭环)。</p>
|
<p class="muted">创建后可在「平台订单」列表中继续推进:标记支付并生效 → 同步订阅(形成最小收费闭环)。</p>
|
||||||
|
|
||||||
|
@php
|
||||||
|
$leadId = (int) old('lead_id', $defaults['lead_id'] ?? 0);
|
||||||
|
$incomingBackForLead = (string) ($defaults['back'] ?? '');
|
||||||
|
$leadBack = (str_starts_with($incomingBackForLead, '/')
|
||||||
|
&& !preg_match('/["\'<>]/', $incomingBackForLead)
|
||||||
|
&& !preg_match('/(?:^|[?&])back=/', $incomingBackForLead))
|
||||||
|
? $incomingBackForLead
|
||||||
|
: '';
|
||||||
|
|
||||||
|
$viewLeadOrdersQuery = [
|
||||||
|
'lead_id' => $leadId,
|
||||||
|
];
|
||||||
|
if ($leadBack !== '') {
|
||||||
|
$viewLeadOrdersQuery['back'] = $leadBack;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewLeadOrdersUrl = '/admin/platform-orders';
|
||||||
|
if ($leadId > 0) {
|
||||||
|
$viewLeadOrdersUrl .= '?' . \Illuminate\Support\Arr::query($viewLeadOrdersQuery);
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@if($leadId > 0)
|
||||||
|
<div class="mt-10 actions">
|
||||||
|
<span class="badge">来源线索:#{{ $leadId }}</span>
|
||||||
|
<a class="btn-secondary btn-sm" href="{!! $viewLeadOrdersUrl !!}">查看该线索关联订单</a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if(($siteSubscription ?? null) && $siteSubscription->id)
|
@if(($siteSubscription ?? null) && $siteSubscription->id)
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
<div class="muted">本订单将关联订阅:</div>
|
<div class="muted">本订单将关联订阅:</div>
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformLead;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderFormShouldShowLeadContextHintTest 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_create_form_should_show_lead_context_badge_and_view_orders_link(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'lead_context_form_plan',
|
||||||
|
'name' => '下单页线索提示测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$lead = PlatformLead::query()->create([
|
||||||
|
'name' => '线索提示',
|
||||||
|
'mobile' => '',
|
||||||
|
'email' => '',
|
||||||
|
'company' => '',
|
||||||
|
'source' => 'test',
|
||||||
|
'status' => 'new',
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'meta' => ['merchant_id' => $merchant->id],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders/create?' . Arr::query([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'lead_id' => $lead->id,
|
||||||
|
'back' => '/admin/platform-leads',
|
||||||
|
]));
|
||||||
|
|
||||||
|
$res->assertOk();
|
||||||
|
$res->assertSee('来源线索:#' . $lead->id, false);
|
||||||
|
|
||||||
|
// 入口应指向 platform-orders?lead_id=xxx(可带 back)
|
||||||
|
$res->assertSee('/admin/platform-orders?lead_id=' . $lead->id, false);
|
||||||
|
$res->assertSee('查看该线索关联订单', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user