优化pdf

This commit is contained in:
2026-01-19 10:23:31 +08:00
parent fcea0627e7
commit 4e3bbb2774
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -157,7 +157,7 @@ class UsedCarController extends BaseController
'crawl_series_id' => $info['series_id'], 'crawl_series_id' => $info['series_id'],
'crawl_series' => $info['series_name'], 'crawl_series' => $info['series_name'],
'used_car_id' => $info['used_car_id'], 'used_car_id' => $info['used_car_id'],
'crawl_year' => $info['crawl_year'], 'crawl_year' => $info['year'],
'plate_time' => $info['plate_time'], 'plate_time' => $info['plate_time'],
]; ];
@@ -229,7 +229,7 @@ class UsedCarController extends BaseController
$field = $this->field($lang);//字段相关外文 $field = $this->field($lang);//字段相关外文
$field['currency'] = $this->currency[$currency]; $field['currency'] = $this->currency[$currency];
$data['product_name'] = $data['crawl_brand'].' '.$data['crawl_series'].' '.$data['crawl_title']; $data['product_name'] = $data['crawl_brand'].' '.$data['crawl_series'].' '. $data['crawl_year'] .'款 '.$data['crawl_title'];
$data = $this->fanyi($data, $lang);//车辆字段翻译外文 $data = $this->fanyi($data, $lang);//车辆字段翻译外文
$contactField = $this->contact($lang); //名片相关外文 $contactField = $this->contact($lang); //名片相关外文
$data['trade'] = $trade; $data['trade'] = $trade;
@@ -261,7 +261,7 @@ class UsedCarController extends BaseController
return response()->download( return response()->download(
$filePath, $filePath,
$raw['product_name'].'-'.$raw['id'].'.pdf' // 下载时显示的文件名 $raw['product_name']. '-' .$raw['code'].'-'.$raw['id'].'.pdf' // 下载时显示的文件名
); );
} }
@@ -466,7 +466,7 @@ class UsedCarController extends BaseController
return $this->success([ return $this->success([
'pdf_url' => $url, 'pdf_url' => $url,
'file_name' => $raw['product_name'] . '-' . $raw['id'] . '.pdf' 'file_name' => $raw['product_name']. '-' .$raw['code']. '-' . $raw['id'] . '.pdf'
]); ]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return $this->error($e->getMessage()); return $this->error($e->getMessage());
+1 -1
View File
@@ -186,7 +186,7 @@ class MpdfDriver
$pdf = $mpdf->Output('车辆详情.pdf', 'S'); $pdf = $mpdf->Output('车辆详情.pdf', 'S');
$dir = runtime_path('pdf'); $dir = runtime_path('pdf');
if (!is_dir($dir)) mkdir($dir, 0777, true); if (!is_dir($dir)) mkdir($dir, 0777, true);
$pdfName = 'invoice-' . date('YmdHis').'-'.$car['id'] . '-' . $lang . '.pdf'; $pdfName = 'invoice-' . $car['code'].'-'.$car['id'] . '-' . $lang . '.pdf';
$path = $dir . '/' . $pdfName; $path = $dir . '/' . $pdfName;
file_put_contents($path, $pdf); file_put_contents($path, $pdf);