作者 lyh

gx

@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Console\Commands\Test; 10 namespace App\Console\Commands\Test;
11 11
  12 +use App\Models\File\File;
12 use App\Models\Product\Product; 13 use App\Models\Product\Product;
13 use App\Services\ProjectServer; 14 use App\Services\ProjectServer;
14 use Illuminate\Console\Command; 15 use Illuminate\Console\Command;
@@ -41,11 +42,18 @@ class ProductFileUpload extends Command @@ -41,11 +42,18 @@ class ProductFileUpload extends Command
41 $project_id = $this->argument('project_id'); 42 $project_id = $this->argument('project_id');
42 ProjectServer::useProject($project_id); 43 ProjectServer::useProject($project_id);
43 $productModel = new Product(); 44 $productModel = new Product();
44 - $lists = $productModel->list(['status'=>1,'id'=>['<=',109]]); 45 + $lists = $productModel->list(['status'=>1,'id'=>['<=',106]]);
45 foreach ($lists as $k => $v){ 46 foreach ($lists as $k => $v){
46 if(!empty($v['files']) && !empty($v['files']['url'])){ 47 if(!empty($v['files']) && !empty($v['files']['url'])){
47 $url = str_replace_url($v['files']['url']); 48 $url = str_replace_url($v['files']['url']);
48 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND); 49 + //获取当前图片的原名称
  50 + $files = new File();
  51 + $fileInfo = $files->read(['url'=>$url]);
  52 + if($fileInfo === false){
  53 + continue;
  54 + }
  55 + $newName = rtrim($url, '/').'/'.$fileInfo['name'];
  56 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($newName, true) . PHP_EOL, FILE_APPEND);
49 } 57 }
50 } 58 }
51 DB::disconnect('custom_mysql'); 59 DB::disconnect('custom_mysql');
@@ -58,11 +66,11 @@ class ProductFileUpload extends Command @@ -58,11 +66,11 @@ class ProductFileUpload extends Command
58 * @method :post 66 * @method :post
59 * @time :2024/4/8 11:10 67 * @time :2024/4/8 11:10
60 */ 68 */
61 - public function synchronizationFile($path_name){ 69 + public function synchronizationFile($path_name,$newName){
62 //同步到大文件 70 //同步到大文件
63 $file_path = config('filesystems.disks.cos')['cdn1'].$path_name; 71 $file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
64 $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME); 72 $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
65 - $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php'; 73 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$newName.'" https://v6-file.globalso.com/upload.php';
66 return shell_exec($cmd); 74 return shell_exec($cmd);
67 } 75 }
68 } 76 }