feat(platform-orders): 增加回执状态筛选(有回执/无回执)

This commit is contained in:
萝卜
2026-03-10 22:44:48 +00:00
parent 4d41313f8f
commit 829a418d3b
3 changed files with 151 additions and 0 deletions

View File

@@ -0,0 +1,122 @@
<?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 AdminPlatformOrderReceiptStatusFilterTest 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_platform_orders_page_can_filter_by_receipt_status_has_and_none(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'receipt_status_filter_test',
'name' => '回执状态筛选测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
// 有回执:仅 receipts
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_RECEIPT_HAS_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,
'paid_amount' => 10,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [
'payment_receipts' => [
['amount' => 10.00, 'paid_at' => now()->toDateTimeString()],
],
],
]);
// 有回执summary
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_RECEIPT_HAS_0002',
'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,
'paid_amount' => 10,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [
'payment_summary' => [
'total_amount' => 10.00,
'count' => 1,
],
],
]);
// 无回执:两者都没有
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_RECEIPT_NONE_0003',
'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,
'paid_amount' => 10,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [],
]);
$this->get('/admin/platform-orders?receipt_status=has')
->assertOk()
->assertSee('PO_RECEIPT_HAS_0001')
->assertSee('PO_RECEIPT_HAS_0002')
->assertDontSee('PO_RECEIPT_NONE_0003');
$this->get('/admin/platform-orders?receipt_status=none')
->assertOk()
->assertSee('PO_RECEIPT_NONE_0003')
->assertDontSee('PO_RECEIPT_HAS_0001')
->assertDontSee('PO_RECEIPT_HAS_0002');
}
}