chore(admin): 平台订单列表行展示来源线索入口
This commit is contained in:
@@ -914,7 +914,22 @@
|
|||||||
@php
|
@php
|
||||||
$orderShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]);
|
$orderShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]);
|
||||||
@endphp
|
@endphp
|
||||||
<td><a href="{!! $orderShowUrl !!}">{{ $order->order_no }}</a></td>
|
<td>
|
||||||
|
<a href="{!! $orderShowUrl !!}">{{ $order->order_no }}</a>
|
||||||
|
@php
|
||||||
|
$rowLeadId = (int) (data_get($order->meta, 'platform_lead_id') ?? 0);
|
||||||
|
$rowLeadUrl = '';
|
||||||
|
if ($rowLeadId > 0) {
|
||||||
|
$rowLeadUrl = '/admin/platform-leads?' . \Illuminate\Support\Arr::query([
|
||||||
|
'lead_id' => $rowLeadId,
|
||||||
|
'back' => $selfWithoutBack,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
@if($rowLeadId > 0)
|
||||||
|
<div class="muted muted-xs">线索:<a class="link" href="{!! $rowLeadUrl !!}">#{{ $rowLeadId }}</a></div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if($order->merchant)
|
@if($order->merchant)
|
||||||
<a href="{!! request()->fullUrlWithQuery(['merchant_id' => $order->merchant->id, 'page' => null]) !!}" class="link">{{ $order->merchant->name }}</a>
|
<a href="{!! request()->fullUrlWithQuery(['merchant_id' => $order->merchant->id, 'page' => null]) !!}" class="link">{{ $order->merchant->name }}</a>
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformLead;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexShowsLeadBadgeForRowTest 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_index_should_render_lead_link_when_order_meta_has_platform_lead_id(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'index_row_lead_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' => ['from' => 'test'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$order = PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'site_subscription_id' => null,
|
||||||
|
'created_by_admin_id' => 1,
|
||||||
|
'order_no' => 'PO_INDEX_LEAD_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'pending',
|
||||||
|
'payment_status' => 'unpaid',
|
||||||
|
'payment_channel' => null,
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'quantity' => 1,
|
||||||
|
'list_amount' => 10,
|
||||||
|
'discount_amount' => 0,
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 0,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'plan_snapshot' => ['plan_id' => $plan->id],
|
||||||
|
'meta' => ['platform_lead_id' => $lead->id],
|
||||||
|
'remark' => 'from lead',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$back = '/admin/platform-orders?' . Arr::query(['payment_status' => 'unpaid']);
|
||||||
|
$res = $this->get('/admin/platform-orders?back=' . urlencode($back));
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$expectedLeadUrl = '/admin/platform-leads?' . Arr::query([
|
||||||
|
'lead_id' => $lead->id,
|
||||||
|
'back' => '/admin/platform-orders',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res->assertSee('PO_INDEX_LEAD_0001');
|
||||||
|
$res->assertSee('线索:', false);
|
||||||
|
$res->assertSee('href="' . $expectedLeadUrl . '"', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user