feat(admin): platform orders filter by subscription id
This commit is contained in:
@@ -358,4 +358,95 @@ class AdminPlatformOrderTest extends TestCase
|
||||
->assertDontSee('PO202603100101')
|
||||
->assertDontSee('PO202603100102');
|
||||
}
|
||||
|
||||
|
||||
public function test_platform_orders_page_can_filter_by_site_subscription_id(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = \App\Models\Merchant::query()->firstOrFail();
|
||||
$plan = \App\Models\Plan::query()->create([
|
||||
'code' => 'po_subid_test',
|
||||
'name' => '订阅ID筛选测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
$sub1 = \App\Models\SiteSubscription::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'activated',
|
||||
'source' => 'manual',
|
||||
'subscription_no' => 'SUB_FILTER_0001',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => 'monthly',
|
||||
'period_months' => 1,
|
||||
'amount' => 10,
|
||||
'starts_at' => now()->subDay(),
|
||||
'ends_at' => now()->addMonth(),
|
||||
'activated_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
$sub2 = \App\Models\SiteSubscription::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'activated',
|
||||
'source' => 'manual',
|
||||
'subscription_no' => 'SUB_FILTER_0002',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => 'monthly',
|
||||
'period_months' => 1,
|
||||
'amount' => 10,
|
||||
'starts_at' => now()->subDay(),
|
||||
'ends_at' => now()->addMonth(),
|
||||
'activated_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
\App\Models\PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'site_subscription_id' => $sub1->id,
|
||||
'order_no' => 'PO_SUBID_0001',
|
||||
'order_type' => 'renewal',
|
||||
'status' => 'activated',
|
||||
'payment_status' => 'paid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => 'monthly',
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 10,
|
||||
'placed_at' => now()->subMinutes(2),
|
||||
'paid_at' => now()->subMinute(),
|
||||
'activated_at' => now(),
|
||||
]);
|
||||
|
||||
\App\Models\PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'site_subscription_id' => $sub2->id,
|
||||
'order_no' => 'PO_SUBID_0002',
|
||||
'order_type' => 'renewal',
|
||||
'status' => 'activated',
|
||||
'payment_status' => 'paid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => 'monthly',
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 10,
|
||||
'placed_at' => now()->subMinutes(2),
|
||||
'paid_at' => now()->subMinute(),
|
||||
'activated_at' => now(),
|
||||
]);
|
||||
|
||||
$this->get('/admin/platform-orders?site_subscription_id=' . $sub1->id)
|
||||
->assertOk()
|
||||
->assertSee('PO_SUBID_0001')
|
||||
->assertDontSee('PO_SUBID_0002');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user