作者 lms

合并分支 'lms' 到 'master'

v6优化程序



查看合并请求 !274
@@ -3,11 +3,10 @@ @@ -3,11 +3,10 @@
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 use App\Http\Controllers\File\FileController; 5 use App\Http\Controllers\File\FileController;
6 -use App\Models\ProjectAssociation\ProjectAssociation;  
7 use App\Models\File\DataFile; 6 use App\Models\File\DataFile;
  7 +use App\Models\ProjectAssociation\ProjectAssociation;
8 use App\Services\CosService; 8 use App\Services\CosService;
9 -use Dompdf\Dompdf;  
10 -use Dompdf\Options; 9 +use Barryvdh\DomPDF\Facade\Pdf;
11 use Illuminate\Console\Command; 10 use Illuminate\Console\Command;
12 use Illuminate\Http\File; 11 use Illuminate\Http\File;
13 12
@@ -57,6 +56,17 @@ class ProjectFilePDF extends Command @@ -57,6 +56,17 @@ class ProjectFilePDF extends Command
57 parent::__construct(); 56 parent::__construct();
58 } 57 }
59 58
  59 +// public function handle()
  60 +// {
  61 +// $project_data = [];
  62 +// $html = $this->html($project_data);
  63 +// $filename = hash('md5', $this->time . '-' . '$project_id' . '-' . '$friend_id' . '-' . '$user_id');
  64 +// $this->savePDF($html, $filename);
  65 +//// $this->testStreamPdf($html, $filename);
  66 +//// $file_path = $this->savePDF2($html, $filename);
  67 +// return 0;
  68 +// }
  69 +
60 public function start(): int 70 public function start(): int
61 { 71 {
62 # 0 - 未生成 72 # 0 - 未生成
@@ -115,37 +125,21 @@ class ProjectFilePDF extends Command @@ -115,37 +125,21 @@ class ProjectFilePDF extends Command
115 */ 125 */
116 public function savePDF($html, $filename) 126 public function savePDF($html, $filename)
117 { 127 {
118 -  
119 $pdf_path = public_path('PDF/'); 128 $pdf_path = public_path('PDF/');
120 if (!file_exists($pdf_path)) { 129 if (!file_exists($pdf_path)) {
121 mkdir($pdf_path, 0777, true); 130 mkdir($pdf_path, 0777, true);
122 } 131 }
123 -  
124 // 指定保存路径和文件名 132 // 指定保存路径和文件名
125 $savePath = $pdf_path . $filename . '.pdf'; 133 $savePath = $pdf_path . $filename . '.pdf';
126 if (file_exists($savePath)) { 134 if (file_exists($savePath)) {
127 echo '文件已经存在'; 135 echo '文件已经存在';
128 -// return 0; 136 + return 0;
129 } 137 }
130 - // todo 生成中文有问题  
131 - # 实例化并使用dompdf类  
132 -// $options = new Options();  
133 -// $options->setDefaultFont('arial');  
134 -// $dompdf = new Dompdf($options);  
135 - $dompdf = new Dompdf();  
136 - $dompdf->loadHtml($html);  
137 - #(可选)设置纸张大小和方向  
138 - $dompdf->setPaper('A4', 'landscape');  
139 -  
140 - # 将HTML渲染为PDF  
141 - $dompdf->render();  
142 -  
143 - // 获取PDF内容  
144 - $pdfContent = $dompdf->output();  
145 - $path = '/V6/PDF/' . $this->time;  
146 -  
147 - // 将PDF内容保存到文件  
148 - @file_put_contents($savePath, $pdfContent); 138 +
  139 + $pdf = PDF::loadHTML($html);
  140 + $pdf->save($savePath);
  141 +
  142 + $path = '/V6/PDF/' . $this->time;
149 // 创建一个文件实例 143 // 创建一个文件实例
150 $file = new File($savePath); 144 $file = new File($savePath);
151 return $this->CosService->uploadFile($file, $path, $filename . '.pdf'); 145 return $this->CosService->uploadFile($file, $path, $filename . '.pdf');
@@ -158,12 +152,7 @@ class ProjectFilePDF extends Command @@ -158,12 +152,7 @@ class ProjectFilePDF extends Command
158 */ 152 */
159 protected function html($item) 153 protected function html($item)
160 { 154 {
161 - $html = '<html>';  
162 - $html .= '<body style="font-family:arial">';  
163 - $html .= '<h1>Hello, World!</h1>';  
164 - $html .= '<p>中文内容ffffff</p>';  
165 - $html .= '</body>';  
166 - $html .= '</html>';  
167 - return $html; 155 + $font_path = storage_path('fonts\msyh.ttf');
  156 + return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>';
168 } 157 }
169 } 158 }
@@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
5 "keywords": ["framework", "laravel"], 5 "keywords": ["framework", "laravel"],
6 "license": "MIT", 6 "license": "MIT",
7 "require": { 7 "require": {
  8 + "barryvdh/laravel-dompdf": "^2.0",
8 "bensampo/laravel-enum": "^4.2", 9 "bensampo/laravel-enum": "^4.2",
9 "beyondcode/laravel-websockets": "^1.14", 10 "beyondcode/laravel-websockets": "^1.14",
10 "doctrine/dbal": "^3.6", 11 "doctrine/dbal": "^3.6",
11 - "dompdf/dompdf": "^2.0",  
12 "fruitcake/laravel-cors": "^2.0", 12 "fruitcake/laravel-cors": "^2.0",
13 "guzzlehttp/guzzle": "^7.0.1", 13 "guzzlehttp/guzzle": "^7.0.1",
14 "hashids/hashids": "^4.1", 14 "hashids/hashids": "^4.1",
@@ -19,11 +19,10 @@ @@ -19,11 +19,10 @@
19 "mongodb/mongodb": "^1.6", 19 "mongodb/mongodb": "^1.6",
20 "mrgoon/aliyun-sms": "^2.0", 20 "mrgoon/aliyun-sms": "^2.0",
21 "phpoffice/phpspreadsheet": "^1.28", 21 "phpoffice/phpspreadsheet": "^1.28",
22 - "swooletw/laravel-swoole": "^2.13",  
23 - "qcloud/cos-sdk-v5": "^v2.6.6" 22 + "qcloud/cos-sdk-v5": "^v2.6.6",
  23 + "swooletw/laravel-swoole": "^2.13"
24 }, 24 },
25 "require-dev": { 25 "require-dev": {
26 - "barryvdh/laravel-ide-helper": "^2.13",  
27 "facade/ignition": "^2.5", 26 "facade/ignition": "^2.5",
28 "fakerphp/faker": "^1.9.1", 27 "fakerphp/faker": "^1.9.1",
29 "laravel/sail": "^1.0.1", 28 "laravel/sail": "^1.0.1",
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 */ 4 */
5 5
6 use App\Http\Controllers\Aside; 6 use App\Http\Controllers\Aside;
  7 +use App\Http\Controllers\Bside\ProjectAssociation\ProjectAssociationController;
7 use Illuminate\Support\Facades\Route; 8 use Illuminate\Support\Facades\Route;
8 9
9 10
@@ -13,7 +14,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -13,7 +14,7 @@ Route::middleware(['aloginauth'])->group(function () {
13 Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white'); 14 Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white');
14 Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); 15 Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white');
15 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 16 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
16 - Route::post('/aicc/wechat', [\App\Http\Controllers\Bside\ProjectAssociation\ProjectAssociationController::class, 'saveWeChatData'])->name('admin.aicc.wechat'); 17 +
17 //会员相关 18 //会员相关
18 Route::prefix('user')->group(function () { 19 Route::prefix('user')->group(function () {
19 //会员管理 20 //会员管理
@@ -70,6 +71,8 @@ Route::middleware(['aloginauth'])->group(function () { @@ -70,6 +71,8 @@ Route::middleware(['aloginauth'])->group(function () {
70 Route::any('/del', [Aside\Ai\AiCommandController::class, 'del'])->name('admin.ai_del'); 71 Route::any('/del', [Aside\Ai\AiCommandController::class, 'del'])->name('admin.ai_del');
71 //发送记录 72 //发送记录
72 Route::any('/log', [Aside\Ai\AiLogController::class, 'lists'])->name('admin.lists'); 73 Route::any('/log', [Aside\Ai\AiLogController::class, 'lists'])->name('admin.lists');
  74 + // 绑定AICC微信应用
  75 + Route::post('/wechat', [ProjectAssociationController::class, 'saveWeChatData'])->name('admin.aicc.wechat');
73 }); 76 });
74 //特殊模块权限设置 77 //特殊模块权限设置
75 Route::prefix('special')->group(function () { 78 Route::prefix('special')->group(function () {