dashboard: trend dates link to platform orders filtered by created_at
This commit is contained in:
@@ -99,7 +99,17 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@forelse($trendRows as $row)
|
@forelse($trendRows as $row)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ (string) ($row['date'] ?? '') }}</td>
|
@php
|
||||||
|
$d = (string) ($row['date'] ?? '');
|
||||||
|
$dayOrdersUrl = \App\Support\BackUrl::withBack(
|
||||||
|
'/admin/platform-orders?' . \Illuminate\Support\Arr::query([
|
||||||
|
'created_from' => $d,
|
||||||
|
'created_to' => $d,
|
||||||
|
]),
|
||||||
|
$selfWithoutBack
|
||||||
|
);
|
||||||
|
@endphp
|
||||||
|
<td><a class="link" href="{!! $dayOrdersUrl !!}">{{ $d }}</a></td>
|
||||||
<td>{{ (int) ($row['count'] ?? 0) }}</td>
|
<td>{{ (int) ($row['count'] ?? 0) }}</td>
|
||||||
<td>¥{{ number_format((float) ($row['paid_sum'] ?? 0), 2) }}</td>
|
<td>¥{{ number_format((float) ($row['paid_sum'] ?? 0), 2) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -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 AdminDashboardPlatformOrderTrend7dDateShouldLinkToFilteredOrdersTest 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_platform_order_trend_7d_date_should_link_to_filtered_orders(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchantId = (int) Merchant::query()->value('id');
|
||||||
|
$platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id');
|
||||||
|
|
||||||
|
$po = PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchantId,
|
||||||
|
'plan_id' => null,
|
||||||
|
'site_subscription_id' => null,
|
||||||
|
'created_by_admin_id' => $platformAdminId ?: null,
|
||||||
|
'order_no' => 'PO_TREND_LINK_D3',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'pending',
|
||||||
|
'payment_status' => 'paid',
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 10,
|
||||||
|
]);
|
||||||
|
|
||||||
|
PlatformOrder::query()->where('id', $po->id)->update([
|
||||||
|
'created_at' => now()->subDays(3)->startOfDay(),
|
||||||
|
'updated_at' => now()->subDays(3)->startOfDay(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$d3 = now()->subDays(3)->format('Y-m-d');
|
||||||
|
|
||||||
|
$res = $this->get('/admin');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$expectedUrl = '/admin/platform-orders?' . Arr::query([
|
||||||
|
'created_from' => $d3,
|
||||||
|
'created_to' => $d3,
|
||||||
|
'back' => '/admin',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res->assertSee('data-role="platform-order-trend-7d"', false);
|
||||||
|
$res->assertSee($expectedUrl, false);
|
||||||
|
$res->assertDontSee('&back=', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user