|
@@ -33,21 +33,24 @@ class ThumbProjectImage extends Command |
|
@@ -33,21 +33,24 @@ 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);
|
|
|
|
37
|
-
|
|
|
|
38
|
- Product::select(['id', 'thumb'])->chunk(100, function ($products) {
|
|
|
|
39
|
- foreach ($products as $product) {
|
|
|
|
40
|
- $thumb = $product->thumb;
|
|
|
|
41
|
- if (isset($thumb['url']) && $thumb['url']) {
|
|
|
|
42
|
- $thumb['url'] = thumbImageByUrl($thumb['url']);
|
|
|
|
43
|
- $product->timestamps = false;
|
|
|
|
44
|
- $product->thumb = Arr::a2s($thumb);
|
|
|
|
45
|
- $product->save();
|
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
|
+ $thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
|
|
|
|
45
|
+ $product->timestamps = false;
|
|
|
|
46
|
+ $product->thumb = Arr::a2s($thumb);
|
|
|
|
47
|
+ $product->save();
|
|
|
|
48
|
+ }
|
|
46
|
}
|
49
|
}
|
|
47
|
- }
|
|
|
|
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,21 +62,24 @@ class ThumbProjectImage extends Command |
|
@@ -59,21 +62,24 @@ 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);
|
|
|
|
63
|
-
|
|
|
|
64
|
- Product::select(['id', 'thumb'])->chunk(100, function ($products) {
|
|
|
|
65
|
- foreach ($products as $product) {
|
|
|
|
66
|
- $thumb = $product->thumb;
|
|
|
|
67
|
- if (isset($thumb['url']) && $thumb['url']) {
|
|
|
|
68
|
- $thumb['url'] = thumbImageByUrl($thumb['url']);
|
|
|
|
69
|
- $product->timestamps = false;
|
|
|
|
70
|
- $product->thumb = Arr::a2s($thumb);
|
|
|
|
71
|
- $product->save();
|
65
|
+ $project_info = ProjectServer::useProject($project_id);
|
|
|
|
66
|
+
|
|
|
|
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) {
|
|
|
|
70
|
+ foreach ($products as $product) {
|
|
|
|
71
|
+ $thumb = $product->thumb;
|
|
|
|
72
|
+ if (isset($thumb['url']) && $thumb['url']) {
|
|
|
|
73
|
+ $thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
|
|
|
|
74
|
+ $product->timestamps = false;
|
|
|
|
75
|
+ $product->thumb = Arr::a2s($thumb);
|
|
|
|
76
|
+ $product->save();
|
|
|
|
77
|
+ }
|
|
72
|
}
|
78
|
}
|
|
73
|
- }
|
|
|
|
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
|
}
|