平台订单对账明细导出:支持 include_order_snapshot 并加入口

This commit is contained in:
萝卜
2026-03-13 20:51:29 +00:00
parent c6a8792763
commit a15cc917e1
3 changed files with 42 additions and 3 deletions

View File

@@ -83,15 +83,27 @@ class AdminPlatformOrderExportLedgerTest extends TestCase
$content = $res->streamedContent();
$res2 = $this->get('/admin/platform-orders/' . $order->id . '/export-ledger?include_order_snapshot=1');
$res2->assertOk();
$content2 = $res2->streamedContent();
// UTF-8 BOM
$this->assertStringStartsWith("\xEF\xBB\xBF", $content);
$this->assertStringStartsWith("\xEF\xBB\xBF", $content2);
// 核心表头
$this->assertStringContainsString('record_type,receipt_type,channel,amount,biz_time,created_at,admin_id,note', $content);
$this->assertStringContainsString('record_type,receipt_type,channel,amount,biz_time,created_at,admin_id,note', $content2);
// 至少包含一条 payment 与一条 refund 行(包含 type 字段)
$this->assertStringContainsString('payment,bank_transfer,offline,10', $content);
$this->assertStringContainsString('refund,refund,offline,1', $content);
// include_order_snapshot=1 时应包含更多摘要字段
$this->assertStringContainsString("merchant_id,{$merchant->id}", $content2);
$this->assertStringContainsString('payment_status,unpaid', $content2);
$this->assertStringContainsString('site_subscription_id,', $content2);
}
public function test_show_page_should_render_export_ledger_link(): void
@@ -131,6 +143,8 @@ class AdminPlatformOrderExportLedgerTest extends TestCase
$res->assertOk();
$res->assertSee('/admin/platform-orders/' . $order->id . '/export-ledger', false);
$res->assertSee('/admin/platform-orders/' . $order->id . '/export-ledger?include_order_snapshot=1', false);
$res->assertSee('导出对账明细CSV', false);
$res->assertSee('导出含订单摘要CSV', false);
}
}