|
@@ -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
|
}
|