平台订单导出:支持对账不一致筛选测试护栏

This commit is contained in:
萝卜
2026-03-11 07:47:52 +00:00
parent ec5c0cd54b
commit 5091d381dc

View File

@@ -0,0 +1,98 @@
<?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 AdminPlatformOrderExportReconcileMismatchFilterTest 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_export_can_filter_reconcile_mismatch(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'export_reconcile_mismatch_filter_test',
'name' => '导出对账不一致筛选测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
// 不一致回执总额payment_summary.total_amount与已付金额 paid_amount 差额>=0.01
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_EXPORT_RECON_MISMATCH_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_summary' => [
'count' => 1,
'total_amount' => 9.98,
],
],
]);
// 一致:回执总额=已付金额
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_EXPORT_RECON_OK_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' => [
'count' => 1,
'total_amount' => 10.00,
],
],
]);
$res = $this->get('/admin/platform-orders/export?reconcile_mismatch=1');
$res->assertOk();
$content = $res->streamedContent();
$this->assertStringContainsString('PO_EXPORT_RECON_MISMATCH_0001', $content);
$this->assertStringNotContainsString('PO_EXPORT_RECON_OK_0002', $content);
}
}