PlatformOrder show: render order_type label with code
This commit is contained in:
@@ -335,6 +335,7 @@ class PlatformOrderController extends Controller
|
||||
->values(),
|
||||
'statusLabels' => $this->statusLabels(),
|
||||
'paymentStatusLabels' => $this->paymentStatusLabels(),
|
||||
'orderTypeLabels' => $this->orderTypeLabels(),
|
||||
'summaryStats' => [
|
||||
'total_orders' => (clone $baseQuery)->count(),
|
||||
'paid_orders' => (clone $baseQuery)->where('payment_status', 'paid')->count(),
|
||||
@@ -461,6 +462,7 @@ class PlatformOrderController extends Controller
|
||||
'order' => $order,
|
||||
'statusLabels' => $this->statusLabels(),
|
||||
'paymentStatusLabels' => $this->paymentStatusLabels(),
|
||||
'orderTypeLabels' => $this->orderTypeLabels(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,10 @@
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th>订单类型</th><td>{{ $order->order_type }}</td></tr>
|
||||
<tr>
|
||||
<th>订单类型</th>
|
||||
<td>{{ $orderTypeLabels[$order->order_type] ?? $order->order_type }} <span class="muted">({{ $order->order_type }})</span></td>
|
||||
</tr>
|
||||
<tr><th>订单状态</th><td>{{ $statusLabels[$order->status] ?? $order->status }} <span class="muted">({{ $order->status }})</span></td></tr>
|
||||
<tr><th>支付状态</th><td>{{ $paymentStatusLabels[$order->payment_status] ?? $order->payment_status }} <span class="muted">({{ $order->payment_status }})</span></td></tr>
|
||||
<tr><th>应付/已付</th><td>¥{{ number_format((float) $order->payable_amount, 2) }} / ¥{{ number_format((float) $order->paid_amount, 2) }}</td></tr>
|
||||
|
||||
63
tests/Feature/AdminPlatformOrderShowOrderTypeLabelTest.php
Normal file
63
tests/Feature/AdminPlatformOrderShowOrderTypeLabelTest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Plan;
|
||||
use App\Models\PlatformOrder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderShowOrderTypeLabelTest 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_should_render_order_type_label_and_code(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'po_show_type_label_plan',
|
||||
'name' => '订单类型展示测试套餐',
|
||||
'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_TYPE_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(),
|
||||
]);
|
||||
|
||||
$this->get('/admin/platform-orders/' . $order->id)
|
||||
->assertOk()
|
||||
->assertSee('订单类型')
|
||||
->assertSee('新购', false)
|
||||
->assertSee('(new_purchase)', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user