作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into lyh-server

@@ -4,6 +4,7 @@ namespace App\Console\Commands\Project; @@ -4,6 +4,7 @@ namespace App\Console\Commands\Project;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Models\Product\Product; 6 use App\Models\Product\Product;
  7 +use App\Models\Project\Project;
7 use App\Services\ProjectServer; 8 use App\Services\ProjectServer;
8 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
9 use Illuminate\Support\Facades\DB; 10 use Illuminate\Support\Facades\DB;
@@ -30,24 +31,68 @@ class ThumbProjectImage extends Command @@ -30,24 +31,68 @@ class ThumbProjectImage extends Command
30 31
31 if ($project_id > 0) { 32 if ($project_id > 0) {
32 //指定项目 33 //指定项目
33 - ProjectServer::useProject($project_id);  
34 -  
35 - Product::select(['id', 'thumb'])->chunk(100, function ($products) {  
36 - foreach ($products as $product) {  
37 - $thumb = $product->thumb;  
38 - if (isset($thumb['url']) && $thumb['url']) {  
39 - $thumb['url'] = thumbImageByUrl($thumb['url']);  
40 - $product->thumb = Arr::a2s($thumb);  
41 - $product->save(); 34 + $this->output('project_id:' . $project_id . ' | start');
  35 +
  36 + $project_info = ProjectServer::useProject($project_id);
  37 +
  38 + if ($project_info) {
  39 + $thumb_w = $project_info->deploy_build->thumb_w ?? 0;
  40 + Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
  41 + foreach ($products as $product) {
  42 + $thumb = $product->thumb;
  43 + if (isset($thumb['url']) && $thumb['url']) {
  44 + $new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
  45 + if ($new_thumb != $thumb['url']) {
  46 + $thumb['url'] = $new_thumb;
  47 + $product->timestamps = false;
  48 + $product->thumb = Arr::a2s($thumb);
  49 + $product->save();
  50 +
  51 + $this->output('product_id:' . $product->id . ' | success');
  52 + }
  53 + }
42 } 54 }
43 - }  
44 - }); 55 + });
45 56
46 - DB::disconnect('custom_mysql'); 57 + DB::disconnect('custom_mysql');
  58 + }
47 59
48 - $this->output('project_id:' . $project_id . ' | success'); 60 + $this->output('project_id:' . $project_id . ' | end');
49 } else { 61 } else {
50 - //TODO:所有项目 62 + //所有项目
  63 + $projectModel = new Project();
  64 + $list = $projectModel->list(['delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc');
  65 + foreach ($list as $k => $v) {
  66 + $project_id = $v['id'];
  67 +
  68 + $this->output('project_id:' . $project_id . ' | start');
  69 +
  70 + $project_info = ProjectServer::useProject($project_id);
  71 +
  72 + if ($project_info) {
  73 + $thumb_w = $project_info->deploy_build->thumb_w ?? 0;
  74 + Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
  75 + foreach ($products as $product) {
  76 + $thumb = $product->thumb;
  77 + if (isset($thumb['url']) && $thumb['url']) {
  78 + $new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
  79 + if ($new_thumb != $thumb['url']) {
  80 + $thumb['url'] = $new_thumb;
  81 + $product->timestamps = false;
  82 + $product->thumb = Arr::a2s($thumb);
  83 + $product->save();
  84 +
  85 + $this->output('product_id:' . $product->id . ' | success');
  86 + }
  87 + }
  88 + }
  89 + });
  90 +
  91 + DB::disconnect('custom_mysql');
  92 + }
  93 +
  94 + $this->output('project_id:' . $project_id . ' | end');
  95 + }
51 } 96 }
52 } 97 }
53 98
@@ -137,6 +137,7 @@ class ProjectUpdate extends Command @@ -137,6 +137,7 @@ class ProjectUpdate extends Command
137 137
138 //设置数据库 138 //设置数据库
139 $project = ProjectServer::useProject($project_id); 139 $project = ProjectServer::useProject($project_id);
  140 + $thumb_w = $project_info->deploy_build->thumb_w ?? 0;//缩略图压缩宽度
140 if ($project) { 141 if ($project) {
141 if ($api_type == 'category') { 142 if ($api_type == 'category') {
142 //产品分类 143 //产品分类
@@ -332,6 +333,12 @@ class ProjectUpdate extends Command @@ -332,6 +333,12 @@ class ProjectUpdate extends Command
332 $gallery[] = ['alt' => '', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]; 333 $gallery[] = ['alt' => '', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
333 } 334 }
334 } 335 }
  336 + //缩略图
  337 + $thumb = $gallery[0] ?? [];
  338 + if (isset($thumb['url']) && $thumb['url']) {
  339 + //生成缩略图
  340 + $thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
  341 + }
335 //关键词 342 //关键词
336 $keyword_id = ''; 343 $keyword_id = '';
337 if ($item['tags'] ?? []) { 344 if ($item['tags'] ?? []) {
@@ -371,7 +378,7 @@ class ProjectUpdate extends Command @@ -371,7 +378,7 @@ class ProjectUpdate extends Command
371 'content' => $content, 378 'content' => $content,
372 'category_id' => $category_id, 379 'category_id' => $category_id,
373 'keyword_id' => $keyword_id, 380 'keyword_id' => $keyword_id,
374 - 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 381 + 'thumb' => Arr::a2s($thumb),
375 'gallery' => Arr::a2s($gallery), 382 'gallery' => Arr::a2s($gallery),
376 'attrs' => Arr::a2s($attrs), 383 'attrs' => Arr::a2s($attrs),
377 'seo_mate' => Arr::a2s([ 384 'seo_mate' => Arr::a2s([
@@ -417,7 +424,7 @@ class ProjectUpdate extends Command @@ -417,7 +424,7 @@ class ProjectUpdate extends Command
417 'content' => $content, 424 'content' => $content,
418 'category_id' => $category_id, 425 'category_id' => $category_id,
419 'keyword_id' => $keyword_id, 426 'keyword_id' => $keyword_id,
420 - 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 427 + 'thumb' => Arr::a2s($thumb),
421 'gallery' => Arr::a2s($gallery), 428 'gallery' => Arr::a2s($gallery),
422 'attrs' => Arr::a2s($attrs), 429 'attrs' => Arr::a2s($attrs),
423 'seo_mate' => Arr::a2s([ 430 'seo_mate' => Arr::a2s([
@@ -1482,15 +1482,19 @@ function thumbImageByUrl($url, $width = 360) @@ -1482,15 +1482,19 @@ function thumbImageByUrl($url, $width = 360)
1482 return $url; 1482 return $url;
1483 } 1483 }
1484 1484
  1485 + if ($width == 0) {
  1486 + return $url;
  1487 + }
  1488 +
1485 if (strpos($url, '_thumb') !== false) { 1489 if (strpos($url, '_thumb') !== false) {
1486 return $url; 1490 return $url;
1487 } 1491 }
1488 1492
1489 //获取图片完整访问地址 1493 //获取图片完整访问地址
1490 - $url = getImageUrl($url); 1494 + $url_complete = getImageUrl($url);
1491 1495
1492 //获取与原图存储路径相同的压缩路径 1496 //获取与原图存储路径相同的压缩路径
1493 - $path = parse_url($url, PHP_URL_PATH); 1497 + $path = parse_url($url_complete, PHP_URL_PATH);
1494 $path_arr = explode('.', $path); 1498 $path_arr = explode('.', $path);
1495 if (count($path_arr) != 2) { 1499 if (count($path_arr) != 2) {
1496 return $url; 1500 return $url;
@@ -1499,7 +1503,7 @@ function thumbImageByUrl($url, $width = 360) @@ -1499,7 +1503,7 @@ function thumbImageByUrl($url, $width = 360)
1499 $key = implode('.', $path_arr); 1503 $key = implode('.', $path_arr);
1500 1504
1501 try { 1505 try {
1502 - $img = \Intervention\Image\Facades\Image::make($url); 1506 + $img = \Intervention\Image\Facades\Image::make($url_complete);
1503 1507
1504 //宽度按设定,高度自动调整 1508 //宽度按设定,高度自动调整
1505 $img->resize($width, null, function ($constraint) { 1509 $img->resize($width, null, function ($constraint) {
@@ -1520,3 +1524,37 @@ function thumbImageByUrl($url, $width = 360) @@ -1520,3 +1524,37 @@ function thumbImageByUrl($url, $width = 360)
1520 1524
1521 return $url; 1525 return $url;
1522 } 1526 }
  1527 +
  1528 +if (!function_exists('httpGetSsl')) {
  1529 + /**
  1530 + * 获取通配符证书
  1531 + * @param $domain
  1532 + * @return mixed
  1533 + * @author Akun
  1534 + * @date 2025/04/21 16:51
  1535 + */
  1536 + function httpGetSsl($domain)
  1537 + {
  1538 + $header = array(
  1539 + "Accept:application/json",
  1540 + "Content-Type:application/json;charset=utf-8",
  1541 + "X-CmerApi-Host:" . env('GET_SSL_HOST'),
  1542 + "Apikey:" . env('GET_SSL_KEY'),
  1543 + );
  1544 + $ch = curl_init();
  1545 + curl_setopt($ch, CURLOPT_URL, env('GET_SSL_URL') . '?domain=' . $domain);
  1546 + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  1547 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1548 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1549 + curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1550 + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  1551 + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  1552 + curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
  1553 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1554 + $res = curl_exec($ch);
  1555 + curl_close($ch);
  1556 +
  1557 + $result = json_decode($res, true);
  1558 + return is_array($result) ? $result : $res;
  1559 + }
  1560 +}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Controllers\Api; 3 namespace App\Http\Controllers\Api;
4 4
5 use App\Exceptions\InquiryFilterException; 5 use App\Exceptions\InquiryFilterException;
  6 +use App\Models\Domain\DomainInfo;
6 use App\Models\Mail\Mail; 7 use App\Models\Mail\Mail;
7 use App\Models\Project\DeployBuild; 8 use App\Models\Project\DeployBuild;
8 use App\Models\Project\Project; 9 use App\Models\Project\Project;
@@ -69,7 +70,7 @@ class SelfSiteController extends BaseController @@ -69,7 +70,7 @@ class SelfSiteController extends BaseController
69 $cos = new CosService(); 70 $cos = new CosService();
70 $fileName = uniqid() . rand(10000, 99999) . '.' . $file['ext']; 71 $fileName = uniqid() . rand(10000, 99999) . '.' . $file['ext'];
71 $file_data = base64_decode($file['data']); 72 $file_data = base64_decode($file['data']);
72 - $path = $cos->uploadFile($file_data, '/inquiry/' . date('Ymd'), $fileName,true); 73 + $path = $cos->uploadFile($file_data, '/inquiry/' . date('Ymd'), $fileName, true);
73 $data[$key] = [ 74 $data[$key] = [
74 'path' => $path, 75 'path' => $path,
75 'original_name' => $file['name'], 76 'original_name' => $file['name'],
@@ -191,4 +192,50 @@ class SelfSiteController extends BaseController @@ -191,4 +192,50 @@ class SelfSiteController extends BaseController
191 192
192 return $this->success([]); 193 return $this->success([]);
193 } 194 }
  195 +
  196 + /**
  197 + * 自建站获取通配符证书接口
  198 + * @param Request $request
  199 + * @return false|string
  200 + * @author Akun
  201 + * @date 2025/09/02 16:55
  202 + */
  203 + public function selfSiteSsl(Request $request)
  204 + {
  205 + $token = $request->header('token');//token
  206 + $pid = $request->header('pid');//项目id
  207 +
  208 + if (empty($token) || empty($pid)) {
  209 + return $this->error('token无效', 401);
  210 + }
  211 +
  212 + //判断token是否有效
  213 + $project_model = new Project();
  214 + $project_info = $project_model->read(['id' => $pid, 'site_token' => $token]);
  215 + if (!$project_info) {
  216 + return $this->error('token无效', 401);
  217 + }
  218 +
  219 + //获取域名信息
  220 + $domain_model = new DomainInfo();
  221 + $domain_info = $domain_model->read(['project_id' => $pid]);
  222 + if (!$domain_info) {
  223 + return $this->error('获取域名失败', 401);
  224 + }
  225 +
  226 + //获取通配符证书
  227 + $top_domain = getTopDomain($domain_info['domain']);
  228 + $ssl_re = httpGetSsl($top_domain);
  229 + $return = [
  230 + 'ssl_key' => '',
  231 + 'ssl_cert' => ''
  232 + ];
  233 + if (isset($ssl_re['status']) && $ssl_re['status'] == 2) {
  234 + //获取成功
  235 + $return['ssl_key'] = $ssl_re['ssl_key'];
  236 + $return['ssl_cert'] = $ssl_re['ssl_cert'];
  237 + }
  238 +
  239 + return $this->success($return);
  240 + }
194 } 241 }
@@ -359,7 +359,7 @@ class ProductLogic extends BaseLogic @@ -359,7 +359,7 @@ class ProductLogic extends BaseLogic
359 $thumb = $param['gallery'][0] ?? []; 359 $thumb = $param['gallery'][0] ?? [];
360 if(isset($thumb['url']) && $thumb['url']){ 360 if(isset($thumb['url']) && $thumb['url']){
361 //生成缩略图 361 //生成缩略图
362 - $thumb['url'] = thumbImageByUrl($thumb['url']); 362 + $thumb['url'] = thumbImageByUrl($thumb['url'],$this->user['thumb_w']??0);
363 } 363 }
364 $param['thumb'] = Arr::a2s($thumb); 364 $param['thumb'] = Arr::a2s($thumb);
365 $param['gallery'] = Arr::a2s($param['gallery'] ?? []); 365 $param['gallery'] = Arr::a2s($param['gallery'] ?? []);
@@ -322,6 +322,8 @@ class UserLoginLogic @@ -322,6 +322,8 @@ class UserLoginLogic
322 $info['import_products_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/products.csv'; 322 $info['import_products_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/products.csv';
323 $info['import_news_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/news.csv'; 323 $info['import_news_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/news.csv';
324 $info['import_blogs_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/blogs.csv'; 324 $info['import_blogs_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/blogs.csv';
  325 + //缩略图宽度
  326 + $info['thumb_w'] = $project['deploy_build']['thumb_w'] ?? 0;
325 return $info; 327 return $info;
326 } 328 }
327 329
@@ -66,6 +66,7 @@ Route::any('get_monitor_keyword', [\App\Http\Controllers\Api\PrivateController:: @@ -66,6 +66,7 @@ Route::any('get_monitor_keyword', [\App\Http\Controllers\Api\PrivateController::
66 Route::post('selfSiteApi', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteApi']); 66 Route::post('selfSiteApi', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteApi']);
67 Route::post('selfSiteNotify', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteNotify']); 67 Route::post('selfSiteNotify', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteNotify']);
68 Route::post('selfSiteVerify', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteVerify']); 68 Route::post('selfSiteVerify', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteVerify']);
  69 +Route::post('selfSiteSsl', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteSsl']);
69 70
70 //创建301跳转任务 71 //创建301跳转任务
71 Route::any('/addRedirect',[\App\Http\Controllers\Api\NoticeController::class,'addRedirect']); 72 Route::any('/addRedirect',[\App\Http\Controllers\Api\NoticeController::class,'addRedirect']);