正在显示
2 个修改的文件
包含
80 行增加
和
1 行删除
app/Console/Commands/Test/SyncVideo.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :SyncVideo.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/8/14 13:50 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Test; | ||
| 11 | + | ||
| 12 | +use App\Models\File\ErrorFile; | ||
| 13 | +use Illuminate\Console\Command; | ||
| 14 | + | ||
| 15 | +class SyncVideo extends Command | ||
| 16 | +{ | ||
| 17 | + /** | ||
| 18 | + * The name and signature of the console command. | ||
| 19 | + * | ||
| 20 | + * @var string | ||
| 21 | + */ | ||
| 22 | + protected $signature = 'sync_video {file}'; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * The console command description. | ||
| 26 | + * | ||
| 27 | + * @var string | ||
| 28 | + */ | ||
| 29 | + protected $description = '同步图片与文件'; | ||
| 30 | + public function handle() | ||
| 31 | + { | ||
| 32 | + $file = $this->argument('file'); | ||
| 33 | + $file_path = $this->getUrl($file, 0,$this->param['location']); | ||
| 34 | + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php'; | ||
| 35 | + echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL; | ||
| 36 | + $code = shell_exec($cmd); | ||
| 37 | + if(200 != (int)$code){ | ||
| 38 | + $errorFileModel = new ErrorFile(); | ||
| 39 | + $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]); | ||
| 40 | + } | ||
| 41 | + return true; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :获取图片文件链接 | ||
| 46 | + * @name :getUrl | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2024/5/22 11:53 | ||
| 50 | + */ | ||
| 51 | + public function getUrl($path,$storage_type,$location){ | ||
| 52 | + if(is_array($path)){ | ||
| 53 | + $url =[]; | ||
| 54 | + foreach ($path as $v){ | ||
| 55 | + $url[] = $this->getUrl($v,$storage_type,$location); | ||
| 56 | + } | ||
| 57 | + }else{ | ||
| 58 | + if(empty($path)){ | ||
| 59 | + return ''; | ||
| 60 | + } | ||
| 61 | + if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){ | ||
| 62 | + return $path; | ||
| 63 | + } | ||
| 64 | + if(substr($path,0,2) == '//'){ | ||
| 65 | + return 'https:'.$path; | ||
| 66 | + } | ||
| 67 | + if($location == 0){ | ||
| 68 | + $cos = config('filesystems.disks.cos'); | ||
| 69 | + $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1']; | ||
| 70 | + $url = $cosCdn.$path; | ||
| 71 | + }else{ | ||
| 72 | + $s3 = config('filesystems.disks.s3'); | ||
| 73 | + $cdn = $s3['cdn']; | ||
| 74 | + $url = $cdn.$path; | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + return $url; | ||
| 78 | + } | ||
| 79 | +} |
| @@ -50,7 +50,7 @@ class AyrReleaseLogic extends BaseLogic | @@ -50,7 +50,7 @@ class AyrReleaseLogic extends BaseLogic | ||
| 50 | $this->model->add($this->param); | 50 | $this->model->add($this->param); |
| 51 | }else{ | 51 | }else{ |
| 52 | $result_data = json_decode($this->param['result_data']); | 52 | $result_data = json_decode($this->param['result_data']); |
| 53 | - if(isset($result_data['status']) && $result_data['status'] == 'success'){ | 53 | + if(isset($result_data->status) && $result_data->status == 'success'){ |
| 54 | $this->model->edit($this->param,['id'=>$info['id']]); | 54 | $this->model->edit($this->param,['id'=>$info['id']]); |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
-
请 注册 或 登录 后发表评论