|
@@ -33,13 +33,15 @@ class ThumbProjectImage extends Command |
|
@@ -33,13 +33,15 @@ class ThumbProjectImage extends Command |
|
33
|
//指定项目
|
33
|
//指定项目
|
|
34
|
$this->output('project_id:' . $project_id . ' | start');
|
34
|
$this->output('project_id:' . $project_id . ' | start');
|
|
35
|
|
35
|
|
|
36
|
- ProjectServer::useProject($project_id);
|
36
|
+ $project_info = ProjectServer::useProject($project_id);
|
|
37
|
|
37
|
|
|
38
|
- Product::select(['id', 'thumb'])->chunk(100, function ($products) {
|
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) {
|
|
39
|
foreach ($products as $product) {
|
41
|
foreach ($products as $product) {
|
|
40
|
$thumb = $product->thumb;
|
42
|
$thumb = $product->thumb;
|
|
41
|
if (isset($thumb['url']) && $thumb['url']) {
|
43
|
if (isset($thumb['url']) && $thumb['url']) {
|
|
42
|
- $thumb['url'] = thumbImageByUrl($thumb['url']);
|
44
|
+ $thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
|
|
43
|
$product->timestamps = false;
|
45
|
$product->timestamps = false;
|
|
44
|
$product->thumb = Arr::a2s($thumb);
|
46
|
$product->thumb = Arr::a2s($thumb);
|
|
45
|
$product->save();
|
47
|
$product->save();
|
|
@@ -48,6 +50,7 @@ class ThumbProjectImage extends Command |
|
@@ -48,6 +50,7 @@ class ThumbProjectImage extends Command |
|
48
|
});
|
50
|
});
|
|
49
|
|
51
|
|
|
50
|
DB::disconnect('custom_mysql');
|
52
|
DB::disconnect('custom_mysql');
|
|
|
|
53
|
+ }
|
|
51
|
|
54
|
|
|
52
|
$this->output('project_id:' . $project_id . ' | end');
|
55
|
$this->output('project_id:' . $project_id . ' | end');
|
|
53
|
} else {
|
56
|
} else {
|
|
@@ -59,13 +62,15 @@ class ThumbProjectImage extends Command |
|
@@ -59,13 +62,15 @@ class ThumbProjectImage extends Command |
|
59
|
|
62
|
|
|
60
|
$this->output('project_id:' . $project_id . ' | start');
|
63
|
$this->output('project_id:' . $project_id . ' | start');
|
|
61
|
|
64
|
|
|
62
|
- ProjectServer::useProject($project_id);
|
65
|
+ $project_info = ProjectServer::useProject($project_id);
|
|
63
|
|
66
|
|
|
64
|
- Product::select(['id', 'thumb'])->chunk(100, function ($products) {
|
67
|
+ if ($project_info) {
|
|
|
|
68
|
+ $thumb_w = $project_info->deploy_build->thumb_w ?? 0;
|
|
|
|
69
|
+ Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
|
|
65
|
foreach ($products as $product) {
|
70
|
foreach ($products as $product) {
|
|
66
|
$thumb = $product->thumb;
|
71
|
$thumb = $product->thumb;
|
|
67
|
if (isset($thumb['url']) && $thumb['url']) {
|
72
|
if (isset($thumb['url']) && $thumb['url']) {
|
|
68
|
- $thumb['url'] = thumbImageByUrl($thumb['url']);
|
73
|
+ $thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
|
|
69
|
$product->timestamps = false;
|
74
|
$product->timestamps = false;
|
|
70
|
$product->thumb = Arr::a2s($thumb);
|
75
|
$product->thumb = Arr::a2s($thumb);
|
|
71
|
$product->save();
|
76
|
$product->save();
|
|
@@ -74,6 +79,7 @@ class ThumbProjectImage extends Command |
|
@@ -74,6 +79,7 @@ class ThumbProjectImage extends Command |
|
74
|
});
|
79
|
});
|
|
75
|
|
80
|
|
|
76
|
DB::disconnect('custom_mysql');
|
81
|
DB::disconnect('custom_mysql');
|
|
|
|
82
|
+ }
|
|
77
|
|
83
|
|
|
78
|
$this->output('project_id:' . $project_id . ' | end');
|
84
|
$this->output('project_id:' . $project_id . ' | end');
|
|
79
|
}
|
85
|
}
|