platform_orders index: compact view money format hides trailing .00

This commit is contained in:
萝卜
2026-03-14 12:49:22 +00:00
parent b89789faf1
commit c8b119c000
2 changed files with 98 additions and 2 deletions

View File

@@ -0,0 +1,73 @@
<?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 AdminPlatformOrderIndexCompactViewMoneyFormatTest 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_compact_view_money_hides_trailing_zeros_but_full_view_keeps_two_decimals(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'po_index_compact_money_format_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,
'order_no' => 'PO_INDEX_MONEY_FORMAT_0001',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10.00,
'paid_amount' => 9.50,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [],
]);
// 精简视图:整数不显示 .00
$this->get('/admin/platform-orders')
->assertOk()
->assertSee('¥10', false)
->assertDontSee('¥10.00', false);
// full 视图:保持两位小数
$this->get('/admin/platform-orders?view=full')
->assertOk()
->assertSee('¥10.00', false)
->assertSee('¥9.50', false);
}
}