正在显示
1 个修改的文件
包含
68 行增加
和
0 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :ProductFileUpload.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/6/18 15:43 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Test; | ||
| 11 | + | ||
| 12 | +use App\Models\Product\Product; | ||
| 13 | +use App\Services\ProjectServer; | ||
| 14 | +use Illuminate\Console\Command; | ||
| 15 | +use Illuminate\Support\Facades\DB; | ||
| 16 | + | ||
| 17 | +class ProductFileUpload extends Command | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * The name and signature of the console command. | ||
| 21 | + * | ||
| 22 | + * @var string | ||
| 23 | + */ | ||
| 24 | + protected $signature = 'files_upload {project_id}'; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * The console command description. | ||
| 28 | + * | ||
| 29 | + * @var string | ||
| 30 | + */ | ||
| 31 | + protected $description = '重新上传文件获取文件后缀'; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @remark : | ||
| 35 | + * @name :handle | ||
| 36 | + * @author :lyh | ||
| 37 | + * @method :post | ||
| 38 | + * @time :2024/6/18 15:46 | ||
| 39 | + */ | ||
| 40 | + public function handle(){ | ||
| 41 | + $project_id = $this->argument('project_id'); | ||
| 42 | + ProjectServer::useProject($project_id); | ||
| 43 | + $productModel = new Product(); | ||
| 44 | + $lists = $productModel->list(['status'=>1,'id'=>['<=',109]]); | ||
| 45 | + foreach ($lists as $k => $v){ | ||
| 46 | + if(!empty($v['files']) && !empty($v['files']['url'])){ | ||
| 47 | + $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 | + } | ||
| 51 | + DB::disconnect('custom_mysql'); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * @remark :指定同步文件到獨立177服務器 | ||
| 56 | + * @name :synchronizationFile | ||
| 57 | + * @author :lyh | ||
| 58 | + * @method :post | ||
| 59 | + * @time :2024/4/8 11:10 | ||
| 60 | + */ | ||
| 61 | + public function synchronizationFile($path_name){ | ||
| 62 | + //同步到大文件 | ||
| 63 | + $file_path = config('filesystems.disks.cos')['cdn1'].$path_name; | ||
| 64 | + $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'; | ||
| 66 | + return shell_exec($cmd); | ||
| 67 | + } | ||
| 68 | +} |
-
请 注册 或 登录 后发表评论