feat: 扩展奖池、风控与报表能力,新增对账补偿、广播和人工操作接口

This commit is contained in:
2026-05-18 15:09:10 +08:00
parent 9157dcb6a1
commit 6ef41cee76
46 changed files with 1889 additions and 98 deletions

View File

@@ -62,6 +62,68 @@ test('report job create list show and audit log index work for super admin', fun
expect(AuditLog::query()->where('module_code', 'report_jobs')->exists())->toBeTrue();
});
test('report jobs support module 13 report types and downloadable csv with bom', function (): void {
$token = phase15SuperToken();
$create = $this->withHeader('Authorization', 'Bearer '.$token)
->postJson('/api/v1/admin/report-jobs', [
'report_type' => 'daily_profit_summary',
'export_format' => 'csv',
'parameters' => [
'date_from' => '2026-05-01',
'date_to' => '2026-05-07',
],
]);
$create->assertOk()
->assertJsonPath('code', ErrorCode::Success->value)
->assertJsonPath('data.export_format', 'csv');
$id = (int) $create->json('data.id');
expect($id)->toBeGreaterThan(0);
$row = ReportJob::query()->whereKey($id)->firstOrFail();
expect($row->output_path)->toContain('每日盈亏汇总_2026-05-01_2026-05-07')
->and($row->output_path)->toEndWith('.csv');
$download = $this->withHeader('Authorization', 'Bearer '.$token)
->get('/api/v1/admin/report-jobs/'.$id.'/download');
$download->assertOk()
->assertHeader('content-type', 'text/csv; charset=UTF-8');
$content = $download->streamedContent();
expect(substr($content, 0, 3))->toBe("\xEF\xBB\xBF");
});
test('report jobs support xlsx export filename convention', function (): void {
$token = phase15SuperToken();
$create = $this->withHeader('Authorization', 'Bearer '.$token)
->postJson('/api/v1/admin/report-jobs', [
'report_type' => 'audit_operation_report',
'export_format' => 'xlsx',
'parameters' => [
'date_from' => '2026-05-01',
'date_to' => '2026-05-31',
],
]);
$create->assertOk()
->assertJsonPath('code', ErrorCode::Success->value)
->assertJsonPath('data.export_format', 'xlsx');
$id = (int) $create->json('data.id');
$row = ReportJob::query()->whereKey($id)->firstOrFail();
expect($row->output_path)->toContain('后台操作审计报表_2026-05-01_2026-05-31')
->and($row->output_path)->toEndWith('.xlsx');
$this->withHeader('Authorization', 'Bearer '.$token)
->get('/api/v1/admin/report-jobs/'.$id.'/download')
->assertOk()
->assertHeader('content-type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
});
test('reconcile job create with items and nested items index', function (): void {
$token = phase15SuperToken();