Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
6 个修改的文件
包含
69 行增加
和
37 行删除
| @@ -66,16 +66,32 @@ class Demo extends Command | @@ -66,16 +66,32 @@ class Demo extends Command | ||
| 66 | protected $description = 'demo'; | 66 | protected $description = 'demo'; |
| 67 | 67 | ||
| 68 | public function handle(){ | 68 | public function handle(){ |
| 69 | - | ||
| 70 | - echo date('Y-m-d H:i:s') . 'project_id:' . PHP_EOL; | ||
| 71 | - ProjectServer::useProject(2837); | ||
| 72 | - $this->ceshi(); | ||
| 73 | - DB::disconnect('custom_mysql'); | ||
| 74 | -// $this->countTemplate(); | 69 | + echo date('Y-m-d H:i:s') . 'project_id:' . PHP_EOL; |
| 70 | + ProjectServer::useProject(3092); | ||
| 71 | + $this->delProduct(); | ||
| 72 | + DB::disconnect('custom_mysql'); | ||
| 75 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 73 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 76 | } | 74 | } |
| 77 | 75 | ||
| 78 | /** | 76 | /** |
| 77 | + * @remark :删除product | ||
| 78 | + * @name :delProduct | ||
| 79 | + * @author :lyh | ||
| 80 | + * @method :post | ||
| 81 | + * @time :2025/1/10 9:35 | ||
| 82 | + */ | ||
| 83 | + public function delProduct(){ | ||
| 84 | + $productModel = new Product(); | ||
| 85 | + $list = $productModel->list(['status'=>2]); | ||
| 86 | + foreach ($list as $k => $v){ | ||
| 87 | + $routeModel = new RouteMap(); | ||
| 88 | + $routeModel->del(['source'=>'product','source_id'=>$v['id']]); | ||
| 89 | + } | ||
| 90 | + $productModel->del(['status'=>2]); | ||
| 91 | + return true; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 79 | * @remark :统计当前模版使用情况 | 95 | * @remark :统计当前模版使用情况 |
| 80 | * @name :countTemplate | 96 | * @name :countTemplate |
| 81 | * @author :lyh | 97 | * @author :lyh |
| @@ -295,18 +295,18 @@ class UpdateRoute extends Command | @@ -295,18 +295,18 @@ class UpdateRoute extends Command | ||
| 295 | if(!empty($lists)){ | 295 | if(!empty($lists)){ |
| 296 | foreach ($lists as $v){ | 296 | foreach ($lists as $v){ |
| 297 | if(!empty($v['route'])){ | 297 | if(!empty($v['route'])){ |
| 298 | - $tag = "-product"; | ||
| 299 | - if (!(substr($v['route'], -strlen($tag)) === $tag)) { | ||
| 300 | - echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL; | ||
| 301 | - $route = $v['route'].$tag; | ||
| 302 | - // 如果不是以 '-product' 结尾,则拼接上 '-product' | ||
| 303 | - $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 304 | - $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 305 | - }else{ | ||
| 306 | - echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | ||
| 307 | - $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 308 | - $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 309 | - } | 298 | +// $tag = "-product"; |
| 299 | +// if (!(substr($v['route'], -strlen($tag)) === $tag)) { | ||
| 300 | +// echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL; | ||
| 301 | +// $route = $v['route'].$tag; | ||
| 302 | +// // 如果不是以 '-product' 结尾,则拼接上 '-product' | ||
| 303 | +// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 304 | +// $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 305 | +// }else{ | ||
| 306 | +// echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | ||
| 307 | +// $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 308 | +// $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 309 | +// } | ||
| 310 | // $route = RouteMap::setRoute($v['route'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | 310 | // $route = RouteMap::setRoute($v['route'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); |
| 311 | // $productModel->edit(['route'=>$route],['id'=>$v['id']]); | 311 | // $productModel->edit(['route'=>$route],['id'=>$v['id']]); |
| 312 | // continue; | 312 | // continue; |
| @@ -68,43 +68,58 @@ class FileManageController extends BaseController | @@ -68,43 +68,58 @@ class FileManageController extends BaseController | ||
| 68 | if (!isset($this->param['path']) || empty($this->param['path'])) { | 68 | if (!isset($this->param['path']) || empty($this->param['path'])) { |
| 69 | $this->response('参数错误', Code::SYSTEM_ERROR); | 69 | $this->response('参数错误', Code::SYSTEM_ERROR); |
| 70 | } | 70 | } |
| 71 | + // 获取文件名 | ||
| 71 | $username = basename($this->param['path']); | 72 | $username = basename($this->param['path']); |
| 72 | $parsed_url = parse_url($this->param['path']); | 73 | $parsed_url = parse_url($this->param['path']); |
| 73 | // 构造文件 URL | 74 | // 构造文件 URL |
| 74 | $fileUrl = isset($parsed_url['scheme']) | 75 | $fileUrl = isset($parsed_url['scheme']) |
| 75 | ? $this->param['path'] | 76 | ? $this->param['path'] |
| 76 | : 'https://file.globalso.com' . $this->param['path']; | 77 | : 'https://file.globalso.com' . $this->param['path']; |
| 77 | - // 初始化 curl | 78 | + // 初始化 cURL |
| 78 | $ch = curl_init(); | 79 | $ch = curl_init(); |
| 79 | curl_setopt($ch, CURLOPT_URL, $fileUrl); | 80 | curl_setopt($ch, CURLOPT_URL, $fileUrl); |
| 80 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
| 81 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | 81 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 82 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); | ||
| 82 | curl_setopt($ch, CURLOPT_HEADER, false); | 83 | curl_setopt($ch, CURLOPT_HEADER, false); |
| 83 | - // 跳过 SSL 验证 | ||
| 84 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | 84 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 85 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | 85 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 86 | - // 执行 curl 请求 | ||
| 87 | - $fileContent = curl_exec($ch); | ||
| 88 | - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
| 89 | - $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); | ||
| 90 | - $curlError = curl_error($ch); | ||
| 91 | - curl_close($ch); | ||
| 92 | - // 检查 curl 错误或 HTTP 状态码 | ||
| 93 | - if ($fileContent === false || $httpCode != 200) { | ||
| 94 | - $errorMsg = $fileContent === false ? "Curl Error: $curlError" : "HTTP Error: $httpCode"; | ||
| 95 | - $this->response("文件下载失败 - $errorMsg", Code::SYSTEM_ERROR); | 86 | + curl_setopt($ch, CURLOPT_BUFFERSIZE, 8192); // 设置缓冲区大小 |
| 87 | + curl_setopt($ch, CURLOPT_TIMEOUT, 60); // 设置超时时间 | ||
| 88 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // 连接超时时间 | ||
| 89 | + | ||
| 90 | + // 设置为分块输出 | ||
| 91 | + curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $data) { | ||
| 92 | + echo $data; | ||
| 93 | + flush(); // 强制刷新缓冲区 | ||
| 94 | + return strlen($data); | ||
| 95 | + }); | ||
| 96 | + // 检查文件头信息 | ||
| 97 | + $headers = get_headers($fileUrl, 1); | ||
| 98 | + if ($headers === false || !isset($headers['Content-Length'])) { | ||
| 99 | + $this->response('无法获取文件信息', Code::SYSTEM_ERROR); | ||
| 96 | } | 100 | } |
| 97 | // 设置响应头 | 101 | // 设置响应头 |
| 98 | header('Content-Description: File Transfer'); | 102 | header('Content-Description: File Transfer'); |
| 99 | - header('Content-Type: ' . ($contentType ?: 'application/octet-stream')); | 103 | + header('Content-Type: ' . ($headers['Content-Type'] ?? 'application/octet-stream')); |
| 100 | header('Content-Disposition: attachment; filename="' . $username . '"'); | 104 | header('Content-Disposition: attachment; filename="' . $username . '"'); |
| 101 | - header('Content-Length: ' . strlen($fileContent)); | ||
| 102 | - // 输出文件内容 | ||
| 103 | - echo $fileContent; | 105 | + header('Content-Length: ' . $headers['Content-Length']); |
| 106 | + header('Cache-Control: must-revalidate'); | ||
| 107 | + header('Pragma: public'); | ||
| 108 | + // 执行 cURL | ||
| 109 | + ob_end_clean(); // 清空之前的输出缓冲区 | ||
| 110 | + curl_exec($ch); | ||
| 111 | + | ||
| 112 | + // 检查 cURL 错误 | ||
| 113 | + if (curl_errno($ch)) { | ||
| 114 | + curl_close($ch); | ||
| 115 | + $this->response('文件下载失败: ' . curl_error($ch), Code::SYSTEM_ERROR); | ||
| 116 | + } | ||
| 117 | + curl_close($ch); | ||
| 104 | exit; | 118 | exit; |
| 105 | } | 119 | } |
| 106 | 120 | ||
| 107 | 121 | ||
| 122 | + | ||
| 108 | public function upload(Request $request, FileManage $fileManage){ | 123 | public function upload(Request $request, FileManage $fileManage){ |
| 109 | $request->validate([ | 124 | $request->validate([ |
| 110 | 'file'=>['required'], | 125 | 'file'=>['required'], |
| @@ -76,7 +76,7 @@ class CountLogic extends BaseLogic | @@ -76,7 +76,7 @@ class CountLogic extends BaseLogic | ||
| 76 | $data = [ | 76 | $data = [ |
| 77 | 'total_pv'=>$pv, | 77 | 'total_pv'=>$pv, |
| 78 | 'total_ip'=>$ip, | 78 | 'total_ip'=>$ip, |
| 79 | - 'conversion_rate' => (isset($inquiry_num) && !empty($inquiry_num) && ($ip != 0)) ? round(($inquiry_num / $ip) * 10,2) : 0, | 79 | + 'conversion_rate' => (isset($inquiry_num) && !empty($inquiry_num) && ($ip != 0)) ? round(($inquiry_num / $ip) * 100,2) : 0, |
| 80 | ]; | 80 | ]; |
| 81 | return $this->success($data); | 81 | return $this->success($data); |
| 82 | } | 82 | } |
| @@ -692,7 +692,7 @@ class ProductLogic extends BaseLogic | @@ -692,7 +692,7 @@ class ProductLogic extends BaseLogic | ||
| 692 | 'attrs'=>Arr::a2s($info['attrs']), | 692 | 'attrs'=>Arr::a2s($info['attrs']), |
| 693 | 'attr_id'=>Arr::arrToSet($info['attr_id']), | 693 | 'attr_id'=>Arr::arrToSet($info['attr_id']), |
| 694 | 'category_id'=>!empty($info['category_id']) ? ','.Arr::arrToSet($info['category_id']).',' : '', | 694 | 'category_id'=>!empty($info['category_id']) ? ','.Arr::arrToSet($info['category_id']).',' : '', |
| 695 | - 'keyword_id'=>!empty($info['keyword_id']) ? ','.Arr::arrToSet($info['keyword_id']).',' : '', | 695 | + 'keyword_id'=>'', |
| 696 | 'intro'=>$info['intro'], | 696 | 'intro'=>$info['intro'], |
| 697 | 'content'=>$info['content'], | 697 | 'content'=>$info['content'], |
| 698 | 'describe'=>Arr::a2s($info['describe']), | 698 | 'describe'=>Arr::a2s($info['describe']), |
-
请 注册 或 登录 后发表评论