作者 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
if ($project_info) {
$thumb_w = $project_info->deploy_build->thumb_w ?? 0;
Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
Product::select(['id', 'project_id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
foreach ($products as $product) {
$thumb = $product->thumb;
if (isset($thumb['url']) && $thumb['url']) {
$new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
if ($new_thumb != $thumb['url']) {
$thumb['url'] = $new_thumb;
$product->timestamps = false;
$product->thumb = Arr::a2s($thumb);
$product->save();
$json_thumb = Arr::a2s($thumb);
if (strlen($json_thumb) <= 500) {
$product->timestamps = false;
$product->thumb = $json_thumb;
$product->save();
$this->output('product_id:' . $product->id . ' | success');
$this->output('project_id:' . $product->project_id . ',product_id:' . $product->id . ' | success');
}
}
}
}
... ... @@ -61,7 +64,7 @@ class ThumbProjectImage extends Command
} else {
//所有项目
$projectModel = new Project();
$list = $projectModel->list(['delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc');
$list = $projectModel->list(['id' => ['>=', 2108], 'delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc');
foreach ($list as $k => $v) {
$project_id = $v['id'];
... ... @@ -71,18 +74,21 @@ class ThumbProjectImage extends Command
if ($project_info) {
$thumb_w = $project_info->deploy_build->thumb_w ?? 0;
Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
Product::select(['id', 'project_id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
foreach ($products as $product) {
$thumb = $product->thumb;
if (isset($thumb['url']) && $thumb['url']) {
$new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
if ($new_thumb != $thumb['url']) {
$thumb['url'] = $new_thumb;
$product->timestamps = false;
$product->thumb = Arr::a2s($thumb);
$product->save();
$this->output('product_id:' . $product->id . ' | success');
$json_thumb = Arr::a2s($thumb);
if (strlen($json_thumb) <= 500) {
$product->timestamps = false;
$product->thumb = $json_thumb;
$product->save();
$this->output('project_id:' . $product->project_id . ',product_id:' . $product->id . ' | success');
}
}
}
}
... ...
... ... @@ -43,7 +43,34 @@ class Temp extends Command
public function handle()
{
$this->specialImport();
}
/**
* 项目缩略图还原
* @param $project_id
* @author Akun
* @date 2025/09/04 10:48
*/
public function thumbRollBack($project_id)
{
$project_info = ProjectServer::useProject($project_id);
if ($project_info) {
Product::select(['id', 'gallery'])->chunk(100, function ($products) {
foreach ($products as $product) {
$thumb = $product['gallery'][0] ?? [];
if (!empty($thumb)) {
$product->timestamps = false;
$product->thumb = Arr::a2s($thumb);
$product->save();
$this->output('product_id:' . $product->id . ' | success');
}
}
});
DB::disconnect('custom_mysql');
}
}
/**
... ...
... ... @@ -431,7 +431,7 @@ class WebTraffic extends Command
$query->whereIn('ip_area', $main_countries);
}
if($filter_countries){
$query->whereNotIn('ip_area', $main_countries);
$query->whereNotIn('ip_area', $filter_countries);
}
})->inRandomOrder()->first();
if(!$ipdata){
... ...
... ... @@ -1491,7 +1491,14 @@ function thumbImageByUrl($url, $width = 360)
}
//获取图片完整访问地址
$url_complete = getImageUrl($url);
$url_complete = getImageUrl($url, 0, 0, 0);//先用v6-file地址
if (strpos($url_complete, 'v6-file') !== false) {
$is_exists = checkRemoteFileExists($url_complete);
if (!$is_exists) {
//不存在,再用cdn地址
$url_complete = getImageUrl($url);
}
}
//获取与原图存储路径相同的压缩路径
$path = parse_url($url_complete, PHP_URL_PATH);
... ... @@ -1525,6 +1532,32 @@ function thumbImageByUrl($url, $width = 360)
return $url;
}
if (!function_exists('checkRemoteFileExists')) {
/**
* 判断远程文件是否存在
* @param $url
* @return bool
* @author Akun
* @date 2025/09/05 9:58
*/
function checkRemoteFileExists($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_NOBODY, true);
$result = curl_exec($curl);
$found = false;
if ($result !== false) {
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($statusCode == 200) {
$found = true;
}
}
curl_close($curl);
return $found;
}
}
if (!function_exists('httpGetSsl')) {
/**
* 获取通配符证书
... ...