作者 lyh

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

@@ -37,18 +37,21 @@ class ThumbProjectImage extends Command @@ -37,18 +37,21 @@ class ThumbProjectImage extends Command
37 37
38 if ($project_info) { 38 if ($project_info) {
39 $thumb_w = $project_info->deploy_build->thumb_w ?? 0; 39 $thumb_w = $project_info->deploy_build->thumb_w ?? 0;
40 - Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) { 40 + Product::select(['id', 'project_id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
41 foreach ($products as $product) { 41 foreach ($products as $product) {
42 $thumb = $product->thumb; 42 $thumb = $product->thumb;
43 if (isset($thumb['url']) && $thumb['url']) { 43 if (isset($thumb['url']) && $thumb['url']) {
44 $new_thumb = thumbImageByUrl($thumb['url'], $thumb_w); 44 $new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
45 if ($new_thumb != $thumb['url']) { 45 if ($new_thumb != $thumb['url']) {
46 $thumb['url'] = $new_thumb; 46 $thumb['url'] = $new_thumb;
47 - $product->timestamps = false;  
48 - $product->thumb = Arr::a2s($thumb);  
49 - $product->save(); 47 + $json_thumb = Arr::a2s($thumb);
  48 + if (strlen($json_thumb) <= 500) {
  49 + $product->timestamps = false;
  50 + $product->thumb = $json_thumb;
  51 + $product->save();
50 52
51 - $this->output('product_id:' . $product->id . ' | success'); 53 + $this->output('project_id:' . $product->project_id . ',product_id:' . $product->id . ' | success');
  54 + }
52 } 55 }
53 } 56 }
54 } 57 }
@@ -61,7 +64,7 @@ class ThumbProjectImage extends Command @@ -61,7 +64,7 @@ class ThumbProjectImage extends Command
61 } else { 64 } else {
62 //所有项目 65 //所有项目
63 $projectModel = new Project(); 66 $projectModel = new Project();
64 - $list = $projectModel->list(['delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc'); 67 + $list = $projectModel->list(['id' => ['>=', 2108], 'delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc');
65 foreach ($list as $k => $v) { 68 foreach ($list as $k => $v) {
66 $project_id = $v['id']; 69 $project_id = $v['id'];
67 70
@@ -71,18 +74,21 @@ class ThumbProjectImage extends Command @@ -71,18 +74,21 @@ class ThumbProjectImage extends Command
71 74
72 if ($project_info) { 75 if ($project_info) {
73 $thumb_w = $project_info->deploy_build->thumb_w ?? 0; 76 $thumb_w = $project_info->deploy_build->thumb_w ?? 0;
74 - Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) { 77 + Product::select(['id', 'project_id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
75 foreach ($products as $product) { 78 foreach ($products as $product) {
76 $thumb = $product->thumb; 79 $thumb = $product->thumb;
77 if (isset($thumb['url']) && $thumb['url']) { 80 if (isset($thumb['url']) && $thumb['url']) {
78 $new_thumb = thumbImageByUrl($thumb['url'], $thumb_w); 81 $new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
79 if ($new_thumb != $thumb['url']) { 82 if ($new_thumb != $thumb['url']) {
80 $thumb['url'] = $new_thumb; 83 $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'); 84 + $json_thumb = Arr::a2s($thumb);
  85 + if (strlen($json_thumb) <= 500) {
  86 + $product->timestamps = false;
  87 + $product->thumb = $json_thumb;
  88 + $product->save();
  89 +
  90 + $this->output('project_id:' . $product->project_id . ',product_id:' . $product->id . ' | success');
  91 + }
86 } 92 }
87 } 93 }
88 } 94 }
@@ -43,7 +43,34 @@ class Temp extends Command @@ -43,7 +43,34 @@ class Temp extends Command
43 43
44 public function handle() 44 public function handle()
45 { 45 {
46 - $this->specialImport(); 46 +
  47 + }
  48 +
  49 + /**
  50 + * 项目缩略图还原
  51 + * @param $project_id
  52 + * @author Akun
  53 + * @date 2025/09/04 10:48
  54 + */
  55 + public function thumbRollBack($project_id)
  56 + {
  57 + $project_info = ProjectServer::useProject($project_id);
  58 + if ($project_info) {
  59 + Product::select(['id', 'gallery'])->chunk(100, function ($products) {
  60 + foreach ($products as $product) {
  61 + $thumb = $product['gallery'][0] ?? [];
  62 + if (!empty($thumb)) {
  63 + $product->timestamps = false;
  64 + $product->thumb = Arr::a2s($thumb);
  65 + $product->save();
  66 +
  67 + $this->output('product_id:' . $product->id . ' | success');
  68 + }
  69 + }
  70 + });
  71 +
  72 + DB::disconnect('custom_mysql');
  73 + }
47 } 74 }
48 75
49 /** 76 /**
@@ -431,7 +431,7 @@ class WebTraffic extends Command @@ -431,7 +431,7 @@ class WebTraffic extends Command
431 $query->whereIn('ip_area', $main_countries); 431 $query->whereIn('ip_area', $main_countries);
432 } 432 }
433 if($filter_countries){ 433 if($filter_countries){
434 - $query->whereNotIn('ip_area', $main_countries); 434 + $query->whereNotIn('ip_area', $filter_countries);
435 } 435 }
436 })->inRandomOrder()->first(); 436 })->inRandomOrder()->first();
437 if(!$ipdata){ 437 if(!$ipdata){
@@ -1491,7 +1491,14 @@ function thumbImageByUrl($url, $width = 360) @@ -1491,7 +1491,14 @@ function thumbImageByUrl($url, $width = 360)
1491 } 1491 }
1492 1492
1493 //获取图片完整访问地址 1493 //获取图片完整访问地址
1494 - $url_complete = getImageUrl($url); 1494 + $url_complete = getImageUrl($url, 0, 0, 0);//先用v6-file地址
  1495 + if (strpos($url_complete, 'v6-file') !== false) {
  1496 + $is_exists = checkRemoteFileExists($url_complete);
  1497 + if (!$is_exists) {
  1498 + //不存在,再用cdn地址
  1499 + $url_complete = getImageUrl($url);
  1500 + }
  1501 + }
1495 1502
1496 //获取与原图存储路径相同的压缩路径 1503 //获取与原图存储路径相同的压缩路径
1497 $path = parse_url($url_complete, PHP_URL_PATH); 1504 $path = parse_url($url_complete, PHP_URL_PATH);
@@ -1525,6 +1532,32 @@ function thumbImageByUrl($url, $width = 360) @@ -1525,6 +1532,32 @@ function thumbImageByUrl($url, $width = 360)
1525 return $url; 1532 return $url;
1526 } 1533 }
1527 1534
  1535 +if (!function_exists('checkRemoteFileExists')) {
  1536 + /**
  1537 + * 判断远程文件是否存在
  1538 + * @param $url
  1539 + * @return bool
  1540 + * @author Akun
  1541 + * @date 2025/09/05 9:58
  1542 + */
  1543 + function checkRemoteFileExists($url)
  1544 + {
  1545 + $curl = curl_init($url);
  1546 + curl_setopt($curl, CURLOPT_NOBODY, true);
  1547 + $result = curl_exec($curl);
  1548 + $found = false;
  1549 + if ($result !== false) {
  1550 + $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  1551 + if ($statusCode == 200) {
  1552 + $found = true;
  1553 + }
  1554 + }
  1555 + curl_close($curl);
  1556 +
  1557 + return $found;
  1558 + }
  1559 +}
  1560 +
1528 if (!function_exists('httpGetSsl')) { 1561 if (!function_exists('httpGetSsl')) {
1529 /** 1562 /**
1530 * 获取通配符证书 1563 * 获取通配符证书