feat(admin-dashboard): recent platform orders show merchant and plan meta
This commit is contained in:
@@ -192,6 +192,7 @@ class DashboardController extends Controller
|
||||
}
|
||||
|
||||
$recentPlatformOrders = PlatformOrder::query()
|
||||
->with(['merchant', 'plan'])
|
||||
->orderByDesc('id')
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
@@ -339,7 +339,14 @@
|
||||
@endphp
|
||||
<tr data-role="recent-platform-order-row" data-order-no="{{ $po->order_no }}">
|
||||
<td><a class="link" href="{!! $poShowUrl !!}">{{ $po->order_no }}</a></td>
|
||||
<td>{{ $po->orderTypeLabel() }}</td>
|
||||
<td>
|
||||
{{ $po->orderTypeLabel() }}
|
||||
<div class="muted muted-xs">
|
||||
{{ (string) (optional($po->merchant)->name ?: ('站点#' . (int) ($po->merchant_id ?? 0))) }}
|
||||
<span class="muted">|</span>
|
||||
{{ (string) (optional($po->plan)->name ?: ((int) ($po->plan_id ?? 0) > 0 ? ('套餐#' . (int) $po->plan_id) : '-')) }}
|
||||
</div>
|
||||
</td>
|
||||
<td>¥{{ number_format((float) $po->payable_amount, 2) }}</td>
|
||||
<td>
|
||||
{{ $po->payment_status }}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Admin;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Plan;
|
||||
use App\Models\PlatformOrder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminDashboardRecentPlatformOrdersShouldShowMerchantAndPlanMetaTest 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_recent_platform_orders_should_show_merchant_and_plan_meta(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
$platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id');
|
||||
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'dash_recent_order_meta_plan',
|
||||
'name' => '仪表盘最近订单元信息测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'site_subscription_id' => null,
|
||||
'created_by_admin_id' => $platformAdminId ?: null,
|
||||
'order_no' => 'PO_DASH_RECENT_META_0001',
|
||||
'order_type' => 'new_purchase',
|
||||
'status' => 'pending',
|
||||
'payment_status' => 'paid',
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 10,
|
||||
'placed_at' => now(),
|
||||
'meta' => [],
|
||||
]);
|
||||
|
||||
$res = $this->get('/admin');
|
||||
$res->assertOk();
|
||||
|
||||
$res->assertSee('PO_DASH_RECENT_META_0001');
|
||||
$res->assertSee($merchant->name, false);
|
||||
$res->assertSee($plan->name, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user