|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :ProductFileUpload.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/18 15:43
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Console\Commands\Test;
|
|
|
|
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class ProductFileUpload extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'files_upload {project_id}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '重新上传文件获取文件后缀';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :handle
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/18 15:46
|
|
|
|
*/
|
|
|
|
public function handle(){
|
|
|
|
$project_id = $this->argument('project_id');
|
|
|
|
ProjectServer::useProject($project_id);
|
|
|
|
$productModel = new Product();
|
|
|
|
$lists = $productModel->list(['status'=>1,'id'=>['<=',109]]);
|
|
|
|
foreach ($lists as $k => $v){
|
|
|
|
if(!empty($v['files']) && !empty($v['files']['url'])){
|
|
|
|
$url = str_replace_url($v['files']['url']);
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :指定同步文件到獨立177服務器
|
|
|
|
* @name :synchronizationFile
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/4/8 11:10
|
|
|
|
*/
|
|
|
|
public function synchronizationFile($path_name){
|
|
|
|
//同步到大文件
|
|
|
|
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
|
|
|
|
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
|
|
|
|
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
|
|
|
|
return shell_exec($cmd);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|