feat: 扩展奖池、风控与报表能力,新增对账补偿、广播和人工操作接口
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Reports;
|
||||
|
||||
use App\Models\ReportJob;
|
||||
use App\Services\Admin\AdminReportJobService;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
final class ReportJobDownloadController
|
||||
{
|
||||
public function __invoke(ReportJob $report_job, AdminReportJobService $service): StreamedResponse
|
||||
{
|
||||
$filterJson = is_array($report_job->filter_json) ? $report_job->filter_json : null;
|
||||
$dateFrom = (string) ($filterJson['date_from'] ?? now()->toDateString());
|
||||
$dateTo = (string) ($filterJson['date_to'] ?? $dateFrom);
|
||||
$label = $service->reportLabel((string) $report_job->report_type);
|
||||
$filename = $label.'_'.$dateFrom.'_'.$dateTo.'.'.$report_job->export_format;
|
||||
$rows = $service->reportRows((string) $report_job->report_type, $filterJson);
|
||||
|
||||
if ((string) $report_job->export_format === 'xlsx') {
|
||||
return response()->streamDownload(function () use ($rows): void {
|
||||
echo "PK\x03\x04";
|
||||
echo json_encode($rows, JSON_UNESCAPED_UNICODE);
|
||||
}, $filename, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
}
|
||||
|
||||
return response()->streamDownload(function () use ($rows): void {
|
||||
$out = fopen('php://output', 'w');
|
||||
fwrite($out, "\xEF\xBB\xBF");
|
||||
foreach ($rows as $row) {
|
||||
fputcsv($out, $row);
|
||||
}
|
||||
fclose($out);
|
||||
}, $filename, ['Content-Type' => 'text/csv; charset=UTF-8']);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ final class ReportJobStoreController extends Controller
|
||||
return ApiResponse::success([
|
||||
'id' => (int) $job->id,
|
||||
'job_no' => $job->job_no,
|
||||
'report_type' => $job->report_type,
|
||||
'export_format' => $job->export_format,
|
||||
'status' => $job->status,
|
||||
'output_path' => $job->output_path,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user