This commit is contained in:
2026-03-06 13:51:25 +08:00
parent 43022b8ff6
commit 3ad6b05bf8
5 changed files with 218 additions and 2 deletions
+5 -2
View File
@@ -62,7 +62,7 @@ class PdfService
// 检查权限
if ($car->user_id !== $userId) {
throw new \Exception('无权生成此车辆的PDF');
//throw new \Exception('无权生成此车辆的PDF');
}
// 获取用户信息
@@ -220,6 +220,9 @@ class PdfService
// 渲染车辆详情页面
ob_start();
// 保存车辆信息用于文件名(extract会覆盖$car变量)
$carCode = $car->code;
$carId = $car->id;
$carTpl = runtime_path('pdf/templates/usedCar.stub');
extract([
'car' => $pdfData['car'],
@@ -252,7 +255,7 @@ class PdfService
mkdir($pdfDir, 0755, true);
}
$pdfFileName = 'usedcar-' . $car->code . '-' . $car->id . '-' . $lang . '-' . substr(time(), -6) . '.pdf';
$pdfFileName = 'usedcar-' . $carCode . '-' . $carId . '-' . $lang . '-' . substr(time(), -6) . '.pdf';
$pdfPath = $pdfDir . '/' . $pdfFileName;
$mpdf->Output($pdfPath, \Mpdf\Output\Destination::FILE);