|
...
|
...
|
@@ -33,13 +33,15 @@ class ThumbProjectImage extends Command |
|
|
|
//指定项目
|
|
|
|
$this->output('project_id:' . $project_id . ' | start');
|
|
|
|
|
|
|
|
ProjectServer::useProject($project_id);
|
|
|
|
$project_info = ProjectServer::useProject($project_id);
|
|
|
|
|
|
|
|
Product::select(['id', 'thumb'])->chunk(100, function ($products) {
|
|
|
|
if ($project_info) {
|
|
|
|
$thumb_w = $project_info->deploy_build->thumb_w ?? 0;
|
|
|
|
Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
|
|
|
|
foreach ($products as $product) {
|
|
|
|
$thumb = $product->thumb;
|
|
|
|
if (isset($thumb['url']) && $thumb['url']) {
|
|
|
|
$thumb['url'] = thumbImageByUrl($thumb['url']);
|
|
|
|
$thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
|
|
|
|
$product->timestamps = false;
|
|
|
|
$product->thumb = Arr::a2s($thumb);
|
|
|
|
$product->save();
|
|
...
|
...
|
@@ -48,6 +50,7 @@ class ThumbProjectImage extends Command |
|
|
|
});
|
|
|
|
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->output('project_id:' . $project_id . ' | end');
|
|
|
|
} else {
|
|
...
|
...
|
@@ -59,13 +62,15 @@ class ThumbProjectImage extends Command |
|
|
|
|
|
|
|
$this->output('project_id:' . $project_id . ' | start');
|
|
|
|
|
|
|
|
ProjectServer::useProject($project_id);
|
|
|
|
$project_info = ProjectServer::useProject($project_id);
|
|
|
|
|
|
|
|
Product::select(['id', 'thumb'])->chunk(100, function ($products) {
|
|
|
|
if ($project_info) {
|
|
|
|
$thumb_w = $project_info->deploy_build->thumb_w ?? 0;
|
|
|
|
Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
|
|
|
|
foreach ($products as $product) {
|
|
|
|
$thumb = $product->thumb;
|
|
|
|
if (isset($thumb['url']) && $thumb['url']) {
|
|
|
|
$thumb['url'] = thumbImageByUrl($thumb['url']);
|
|
|
|
$thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
|
|
|
|
$product->timestamps = false;
|
|
|
|
$product->thumb = Arr::a2s($thumb);
|
|
|
|
$product->save();
|
|
...
|
...
|
@@ -74,6 +79,7 @@ class ThumbProjectImage extends Command |
|
|
|
});
|
|
|
|
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->output('project_id:' . $project_id . ' | end');
|
|
|
|
}
|
...
|
...
|
|