|
@@ -85,48 +85,51 @@ class ProjectUpdate extends Command |
|
@@ -85,48 +85,51 @@ class ProjectUpdate extends Command |
|
85
|
$data = http_get($url, ['charset' => 'UTF-8']);
|
85
|
$data = http_get($url, ['charset' => 'UTF-8']);
|
|
86
|
if (isset($data['code']) && $data['code'] == 200) {
|
86
|
if (isset($data['code']) && $data['code'] == 200) {
|
|
87
|
$items = $data['data'] ?? [];
|
87
|
$items = $data['data'] ?? [];
|
|
88
|
- $model = new Category();
|
|
|
|
89
|
- foreach ($items as $item) {
|
|
|
|
90
|
- $parent = $model->read(['pid' => 0, 'title' => $item['name']], 'id');
|
|
|
|
91
|
- if (!$parent) {
|
|
|
|
92
|
- try {
|
|
|
|
93
|
- $parent_id = $model->addReturnId([
|
|
|
|
94
|
- 'project_id' => $project_id,
|
|
|
|
95
|
- 'title' => $item['name'],
|
|
|
|
96
|
- 'pid' => 0,
|
|
|
|
97
|
- 'keywords' => $item['keywords'],
|
|
|
|
98
|
- 'describe' => $item['description']
|
|
|
|
99
|
- ]);
|
|
|
|
100
|
- $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
|
|
101
|
- $model->edit(['route' => $route], ['id' => $parent_id]);
|
|
|
|
102
|
- } catch (\Exception $e) {
|
|
|
|
103
|
- echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
104
|
- continue;
|
|
|
|
105
|
- }
|
|
|
|
106
|
- }else{
|
|
|
|
107
|
- $parent_id = $parent['id'];
|
|
|
|
108
|
- }
|
|
|
|
109
|
-
|
|
|
|
110
|
- foreach ($item['children'] as $child) {
|
|
|
|
111
|
- $child_info = $model->read(['pid' => $parent_id, 'title' => $child['name']]);
|
|
|
|
112
|
- if (!$child_info) {
|
|
|
|
113
|
- try {
|
|
|
|
114
|
- $child_id = $model->addReturnId([
|
|
|
|
115
|
- 'project_id' => $project_id,
|
|
|
|
116
|
- 'title' => $child['name'],
|
|
|
|
117
|
- 'pid' => $parent_id,
|
|
|
|
118
|
- 'keywords' => $child['keywords'],
|
|
|
|
119
|
- 'describe' => $child['description']
|
|
|
|
120
|
- ]);
|
|
|
|
121
|
- $route = RouteMap::setRoute($child['url'] ? $this->get_url_route($child['url']) : $child['name'], RouteMap::SOURCE_PRODUCT_CATE, $child_id, $project_id);
|
|
|
|
122
|
- $model->edit(['route' => $route], ['id' => $child_id]);
|
|
|
|
123
|
- } catch (\Exception $e) {
|
|
|
|
124
|
- echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
125
|
- continue;
|
|
|
|
126
|
- }
|
|
|
|
127
|
- }
|
|
|
|
128
|
- }
|
|
|
|
129
|
- }
|
88
|
+ $this->category_insert($project_id, $items, 0);
|
|
|
|
89
|
+// $model = new Category();
|
|
|
|
90
|
+// foreach ($items as $item) {
|
|
|
|
91
|
+// $parent = $model->read(['pid' => 0, 'title' => $item['name']], 'id');
|
|
|
|
92
|
+// if (!$parent) {
|
|
|
|
93
|
+// try {
|
|
|
|
94
|
+// $parent_id = $model->addReturnId([
|
|
|
|
95
|
+// 'project_id' => $project_id,
|
|
|
|
96
|
+// 'title' => $item['name'],
|
|
|
|
97
|
+// 'pid' => 0,
|
|
|
|
98
|
+// 'keywords' => $item['keywords'],
|
|
|
|
99
|
+// 'describe' => $item['description']
|
|
|
|
100
|
+// ]);
|
|
|
|
101
|
+// $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
|
|
102
|
+// $model->edit(['route' => $route], ['id' => $parent_id]);
|
|
|
|
103
|
+// } catch (\Exception $e) {
|
|
|
|
104
|
+// echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
105
|
+// continue;
|
|
|
|
106
|
+// }
|
|
|
|
107
|
+// } else {
|
|
|
|
108
|
+// $parent_id = $parent['id'];
|
|
|
|
109
|
+// }
|
|
|
|
110
|
+//
|
|
|
|
111
|
+// foreach ($item['children'] as $child) {
|
|
|
|
112
|
+// $child_info = $model->read(['pid' => $parent_id, 'title' => $child['name']]);
|
|
|
|
113
|
+// if (!$child_info) {
|
|
|
|
114
|
+// try {
|
|
|
|
115
|
+// $child_id = $model->addReturnId([
|
|
|
|
116
|
+// 'project_id' => $project_id,
|
|
|
|
117
|
+// 'title' => $child['name'],
|
|
|
|
118
|
+// 'pid' => $parent_id,
|
|
|
|
119
|
+// 'keywords' => $child['keywords'],
|
|
|
|
120
|
+// 'describe' => $child['description']
|
|
|
|
121
|
+// ]);
|
|
|
|
122
|
+// $route = RouteMap::setRoute($child['url'] ? $this->get_url_route($child['url']) : $child['name'], RouteMap::SOURCE_PRODUCT_CATE, $child_id, $project_id);
|
|
|
|
123
|
+// $model->edit(['route' => $route], ['id' => $child_id]);
|
|
|
|
124
|
+// } catch (\Exception $e) {
|
|
|
|
125
|
+// echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
126
|
+// continue;
|
|
|
|
127
|
+// }
|
|
|
|
128
|
+// }
|
|
|
|
129
|
+// }
|
|
|
|
130
|
+// }
|
|
|
|
131
|
+ } else {
|
|
|
|
132
|
+ return true;
|
|
130
|
}
|
133
|
}
|
|
131
|
} elseif ($api_type == 'tag') {
|
134
|
} elseif ($api_type == 'tag') {
|
|
132
|
//关键词
|
135
|
//关键词
|
|
@@ -144,26 +147,30 @@ class ProjectUpdate extends Command |
|
@@ -144,26 +147,30 @@ class ProjectUpdate extends Command |
|
144
|
|
147
|
|
|
145
|
$model = new Keyword();
|
148
|
$model = new Keyword();
|
|
146
|
foreach ($items as $item) {
|
149
|
foreach ($items as $item) {
|
|
147
|
- $keyword = $model->read(['title' => $item['text_title']], 'id');
|
|
|
|
148
|
- if (!$keyword) {
|
|
|
|
149
|
- try {
|
|
|
|
150
|
- $id = $model->addReturnId([
|
|
|
|
151
|
- 'project_id' => $project_id,
|
|
|
|
152
|
- 'title' => $item['text_title'],
|
|
|
|
153
|
- 'seo_title' => $item['seo_title'],
|
|
|
|
154
|
- 'seo_keywords' => $item['seo_keywords'],
|
|
|
|
155
|
- 'seo_description' => $item['seo_description'],
|
|
|
|
156
|
- ]);
|
|
|
|
157
|
- $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['text_title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id);
|
|
|
|
158
|
- $model->edit(['route' => $route], ['id' => $id]);
|
|
|
|
159
|
- } catch (\Exception $e) {
|
|
|
|
160
|
- echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
161
|
- continue;
|
150
|
+ if ($item['name'] ?? '') {
|
|
|
|
151
|
+ $keyword = $model->read(['title' => $item['name']], 'id');
|
|
|
|
152
|
+ if (!$keyword) {
|
|
|
|
153
|
+ try {
|
|
|
|
154
|
+ $id = $model->addReturnId([
|
|
|
|
155
|
+ 'project_id' => $project_id,
|
|
|
|
156
|
+ 'title' => $item['name'],
|
|
|
|
157
|
+ 'seo_title' => $item['seo_title'] ?? '',
|
|
|
|
158
|
+ 'seo_keywords' => $item['seo_keywords'] ?? '',
|
|
|
|
159
|
+ 'seo_description' => $item['seo_description'] ?? '',
|
|
|
|
160
|
+ ]);
|
|
|
|
161
|
+ $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id);
|
|
|
|
162
|
+ $model->edit(['route' => $route], ['id' => $id]);
|
|
|
|
163
|
+ } catch (\Exception $e) {
|
|
|
|
164
|
+ echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
165
|
+ continue;
|
|
|
|
166
|
+ }
|
|
162
|
}
|
167
|
}
|
|
163
|
}
|
168
|
}
|
|
164
|
}
|
169
|
}
|
|
165
|
}
|
170
|
}
|
|
166
|
}
|
171
|
}
|
|
|
|
172
|
+ } else {
|
|
|
|
173
|
+ return true;
|
|
167
|
}
|
174
|
}
|
|
168
|
} elseif ($api_type == 'website_info') {
|
175
|
} elseif ($api_type == 'website_info') {
|
|
169
|
//网站信息
|
176
|
//网站信息
|
|
@@ -175,25 +182,37 @@ class ProjectUpdate extends Command |
|
@@ -175,25 +182,37 @@ class ProjectUpdate extends Command |
|
175
|
|
182
|
|
|
176
|
$model = new WebSettingReceiving();
|
183
|
$model = new WebSettingReceiving();
|
|
177
|
if ($phones) {
|
184
|
if ($phones) {
|
|
178
|
- $receiving_phones = $model->read(['type' => 1, 'values' => $phones]);
|
|
|
|
179
|
- if (!$receiving_phones) {
|
|
|
|
180
|
- $model->add([
|
|
|
|
181
|
- 'type' => 1,
|
|
|
|
182
|
- 'values' => $phones,
|
|
|
|
183
|
- 'project_id' => $project_id
|
|
|
|
184
|
- ]);
|
185
|
+ $phone_arr = explode(',', $phones);
|
|
|
|
186
|
+ foreach ($phone_arr as $v_phone) {
|
|
|
|
187
|
+ if ($v_phone) {
|
|
|
|
188
|
+ $receiving_phones = $model->read(['type' => 2, 'values' => $v_phone]);
|
|
|
|
189
|
+ if (!$receiving_phones) {
|
|
|
|
190
|
+ $model->add([
|
|
|
|
191
|
+ 'type' => 1,
|
|
|
|
192
|
+ 'values' => $v_phone,
|
|
|
|
193
|
+ 'project_id' => $project_id
|
|
|
|
194
|
+ ]);
|
|
|
|
195
|
+ }
|
|
|
|
196
|
+ }
|
|
185
|
}
|
197
|
}
|
|
186
|
}
|
198
|
}
|
|
187
|
if ($emails) {
|
199
|
if ($emails) {
|
|
188
|
- $receiving_emails = $model->read(['type' => 2, 'values' => $emails]);
|
|
|
|
189
|
- if (!$receiving_emails) {
|
|
|
|
190
|
- $model->add([
|
|
|
|
191
|
- 'type' => 2,
|
|
|
|
192
|
- 'values' => $emails,
|
|
|
|
193
|
- 'project_id' => $project_id
|
|
|
|
194
|
- ]);
|
200
|
+ $email_arr = explode(',', $emails);
|
|
|
|
201
|
+ foreach ($email_arr as $v_email) {
|
|
|
|
202
|
+ if ($v_email) {
|
|
|
|
203
|
+ $receiving_emails = $model->read(['type' => 1, 'values' => $v_email]);
|
|
|
|
204
|
+ if (!$receiving_emails) {
|
|
|
|
205
|
+ $model->add([
|
|
|
|
206
|
+ 'type' => 2,
|
|
|
|
207
|
+ 'values' => $v_email,
|
|
|
|
208
|
+ 'project_id' => $project_id
|
|
|
|
209
|
+ ]);
|
|
|
|
210
|
+ }
|
|
|
|
211
|
+ }
|
|
195
|
}
|
212
|
}
|
|
196
|
}
|
213
|
}
|
|
|
|
214
|
+ } else {
|
|
|
|
215
|
+ return true;
|
|
197
|
}
|
216
|
}
|
|
198
|
} elseif ($api_type == 'post') {
|
217
|
} elseif ($api_type == 'post') {
|
|
199
|
//产品
|
218
|
//产品
|
|
@@ -212,56 +231,61 @@ class ProjectUpdate extends Command |
|
@@ -212,56 +231,61 @@ class ProjectUpdate extends Command |
|
212
|
$model = new Product();
|
231
|
$model = new Product();
|
|
213
|
|
232
|
|
|
214
|
foreach ($items as $item) {
|
233
|
foreach ($items as $item) {
|
|
215
|
-
|
|
|
|
216
|
- $product = $model->read(['title' => $item['ttile']], 'id');
|
|
|
|
217
|
- if (!$product) {
|
|
|
|
218
|
- //图片
|
|
|
|
219
|
- $gallery = [];
|
|
|
|
220
|
- foreach ($item['images'] as $k_img => $img) {
|
|
|
|
221
|
- $gallery[] = ['alt' => '这是一张产品图', 'url' => $img];
|
|
|
|
222
|
- }
|
|
|
|
223
|
- //分类
|
|
|
|
224
|
- $category_id = '';
|
|
|
|
225
|
- if ($item['category']) {
|
|
|
|
226
|
- $category_arr = [];
|
|
|
|
227
|
- foreach ($item['category'] as $cate) {
|
|
|
|
228
|
- if ($cate['parent'] == 0) {
|
|
|
|
229
|
- array_unshift($category_arr, $cate['name']);
|
|
|
|
230
|
- } else {
|
|
|
|
231
|
- array_push($category_arr, $cate['name']);
|
234
|
+ if ($item['ttile'] ?? '') {
|
|
|
|
235
|
+ $product = $model->read(['title' => $item['ttile']], 'id');
|
|
|
|
236
|
+ if (!$product) {
|
|
|
|
237
|
+ //图片
|
|
|
|
238
|
+ $gallery = [];
|
|
|
|
239
|
+ if ($item['images'] ?? []) {
|
|
|
|
240
|
+ foreach ($item['images'] as $k_img => $img) {
|
|
|
|
241
|
+ $gallery[] = ['alt' => '这是一张产品图', 'url' => $img];
|
|
232
|
}
|
242
|
}
|
|
233
|
}
|
243
|
}
|
|
234
|
- if ($category_arr) {
|
|
|
|
235
|
- $categoryLogic = new CategoryLogic();
|
|
|
|
236
|
- $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
|
244
|
+ //分类
|
|
|
|
245
|
+ $category_id = '';
|
|
|
|
246
|
+ if ($item['category'] ?? []) {
|
|
|
|
247
|
+ $category_arr = [];
|
|
|
|
248
|
+ foreach ($item['category'] as $cate) {
|
|
|
|
249
|
+ if ($cate['parent'] == 0) {
|
|
|
|
250
|
+ array_unshift($category_arr, $cate['name']);
|
|
|
|
251
|
+ } else {
|
|
|
|
252
|
+ array_push($category_arr, $cate['name']);
|
|
|
|
253
|
+ }
|
|
|
|
254
|
+ }
|
|
|
|
255
|
+ if ($category_arr) {
|
|
|
|
256
|
+ $categoryLogic = new CategoryLogic();
|
|
|
|
257
|
+ $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
|
|
|
|
258
|
+ }
|
|
237
|
}
|
259
|
}
|
|
238
|
- }
|
|
|
|
239
|
- try {
|
|
|
|
240
|
- $id = $model->addReturnId([
|
|
|
|
241
|
- 'project_id' => $project_id,
|
|
|
|
242
|
- 'title' => $item['ttile'],
|
|
|
|
243
|
- 'intro' => $item['description'],
|
|
|
|
244
|
- 'content' => $item['content'],
|
|
|
|
245
|
- 'category_id' => $category_id,
|
|
|
|
246
|
- 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
|
|
|
|
247
|
- 'gallery' => Arr::a2s($gallery),
|
|
|
|
248
|
- 'seo_mate' => Arr::a2s([
|
260
|
+ try {
|
|
|
|
261
|
+ $id = $model->addReturnId([
|
|
|
|
262
|
+ 'project_id' => $project_id,
|
|
249
|
'title' => $item['ttile'],
|
263
|
'title' => $item['ttile'],
|
|
250
|
- 'keyword' => $item['keywords'],
|
|
|
|
251
|
- 'description' => $item['description']
|
|
|
|
252
|
- ]),
|
|
|
|
253
|
- 'status' => Product::STATUS_ON
|
|
|
|
254
|
- ]);
|
|
|
|
255
|
- $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PRODUCT, $id, $project_id);
|
|
|
|
256
|
- $model->edit(['route' => $route], ['id' => $id]);
|
|
|
|
257
|
- } catch (\Exception $e) {
|
|
|
|
258
|
- echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
259
|
- continue;
|
264
|
+ 'intro' => $item['description'] ?? '',
|
|
|
|
265
|
+ 'content' => $item['content'] ?? '',
|
|
|
|
266
|
+ 'category_id' => $category_id,
|
|
|
|
267
|
+ 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
|
|
|
|
268
|
+ 'gallery' => Arr::a2s($gallery),
|
|
|
|
269
|
+ 'seo_mate' => Arr::a2s([
|
|
|
|
270
|
+ 'title' => $item['ttile'],
|
|
|
|
271
|
+ 'keyword' => $item['keywords'] ?? '',
|
|
|
|
272
|
+ 'description' => $item['description'] ?? ''
|
|
|
|
273
|
+ ]),
|
|
|
|
274
|
+ 'status' => Product::STATUS_ON
|
|
|
|
275
|
+ ]);
|
|
|
|
276
|
+ $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PRODUCT, $id, $project_id);
|
|
|
|
277
|
+ $model->edit(['route' => $route], ['id' => $id]);
|
|
|
|
278
|
+ } catch (\Exception $e) {
|
|
|
|
279
|
+ echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
280
|
+ continue;
|
|
|
|
281
|
+ }
|
|
260
|
}
|
282
|
}
|
|
261
|
}
|
283
|
}
|
|
262
|
}
|
284
|
}
|
|
263
|
}
|
285
|
}
|
|
264
|
}
|
286
|
}
|
|
|
|
287
|
+ } else {
|
|
|
|
288
|
+ return true;
|
|
265
|
}
|
289
|
}
|
|
266
|
} elseif ($api_type == 'news' || $api_type == 'blog') {
|
290
|
} elseif ($api_type == 'news' || $api_type == 'blog') {
|
|
267
|
//新闻或博客
|
291
|
//新闻或博客
|
|
@@ -285,29 +309,33 @@ class ProjectUpdate extends Command |
|
@@ -285,29 +309,33 @@ class ProjectUpdate extends Command |
|
285
|
|
309
|
|
|
286
|
foreach ($items as $item) {
|
310
|
foreach ($items as $item) {
|
|
287
|
|
311
|
|
|
288
|
- $news = $model->read(['name' => $item['ttile']], 'id');
|
|
|
|
289
|
- if (!$news) {
|
|
|
|
290
|
- try {
|
|
|
|
291
|
- $id = $model->addReturnId([
|
|
|
|
292
|
- 'project_id' => $project_id,
|
|
|
|
293
|
- 'name' => $item['ttile'],
|
|
|
|
294
|
- 'seo_title' => $item['ttile'],
|
|
|
|
295
|
- 'seo_keywords' => $item['keywords'],
|
|
|
|
296
|
- 'seo_description' => $item['description'],
|
|
|
|
297
|
- 'text' => $item['content'],
|
|
|
|
298
|
- 'image' => $item['images'][0] ?? '',
|
|
|
|
299
|
- 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE
|
|
|
|
300
|
- ]);
|
|
|
|
301
|
- $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
|
|
|
|
302
|
- $model->edit(['url' => $route], ['id' => $id]);
|
|
|
|
303
|
- } catch (\Exception $e) {
|
|
|
|
304
|
- echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
305
|
- continue;
|
312
|
+ if ($item['ttile'] ?? '') {
|
|
|
|
313
|
+ $news = $model->read(['name' => $item['ttile']], 'id');
|
|
|
|
314
|
+ if (!$news) {
|
|
|
|
315
|
+ try {
|
|
|
|
316
|
+ $id = $model->addReturnId([
|
|
|
|
317
|
+ 'project_id' => $project_id,
|
|
|
|
318
|
+ 'name' => $item['ttile'],
|
|
|
|
319
|
+ 'seo_title' => $item['ttile'],
|
|
|
|
320
|
+ 'seo_keywords' => $item['keywords'] ?? '',
|
|
|
|
321
|
+ 'seo_description' => $item['description'] ?? '',
|
|
|
|
322
|
+ 'text' => $item['content'] ?? '',
|
|
|
|
323
|
+ 'image' => $item['images'][0] ?? '',
|
|
|
|
324
|
+ 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE
|
|
|
|
325
|
+ ]);
|
|
|
|
326
|
+ $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
|
|
|
|
327
|
+ $model->edit(['url' => $route], ['id' => $id]);
|
|
|
|
328
|
+ } catch (\Exception $e) {
|
|
|
|
329
|
+ echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
330
|
+ continue;
|
|
|
|
331
|
+ }
|
|
306
|
}
|
332
|
}
|
|
307
|
}
|
333
|
}
|
|
308
|
}
|
334
|
}
|
|
309
|
}
|
335
|
}
|
|
310
|
}
|
336
|
}
|
|
|
|
337
|
+ } else {
|
|
|
|
338
|
+ return true;
|
|
311
|
}
|
339
|
}
|
|
312
|
} else {
|
340
|
} else {
|
|
313
|
//单页
|
341
|
//单页
|
|
@@ -326,29 +354,32 @@ class ProjectUpdate extends Command |
|
@@ -326,29 +354,32 @@ class ProjectUpdate extends Command |
|
326
|
$model = new BCustomTemplate();
|
354
|
$model = new BCustomTemplate();
|
|
327
|
|
355
|
|
|
328
|
foreach ($items as $item) {
|
356
|
foreach ($items as $item) {
|
|
329
|
-
|
|
|
|
330
|
- $custom = $model->read(['name' => $item['ttile']], 'id');
|
|
|
|
331
|
- if (!$custom) {
|
|
|
|
332
|
- try {
|
|
|
|
333
|
- $id = $model->addReturnId([
|
|
|
|
334
|
- 'project_id' => $project_id,
|
|
|
|
335
|
- 'name' => $item['ttile'],
|
|
|
|
336
|
- 'title' => $item['ttile'],
|
|
|
|
337
|
- 'keywords' => $item['keywords'],
|
|
|
|
338
|
- 'description' => $item['description'],
|
|
|
|
339
|
- 'html' => $item['content'],
|
|
|
|
340
|
- 'status' => 1
|
|
|
|
341
|
- ]);
|
|
|
|
342
|
- $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id);
|
|
|
|
343
|
- $model->edit(['url' => $route], ['id' => $id]);
|
|
|
|
344
|
- } catch (\Exception $e) {
|
|
|
|
345
|
- echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
346
|
- continue;
|
357
|
+ if ($item['ttile'] ?? '') {
|
|
|
|
358
|
+ $custom = $model->read(['name' => $item['ttile']], 'id');
|
|
|
|
359
|
+ if (!$custom) {
|
|
|
|
360
|
+ try {
|
|
|
|
361
|
+ $id = $model->addReturnId([
|
|
|
|
362
|
+ 'project_id' => $project_id,
|
|
|
|
363
|
+ 'name' => $item['ttile'],
|
|
|
|
364
|
+ 'title' => $item['ttile'],
|
|
|
|
365
|
+ 'keywords' => $item['keywords'] ?? '',
|
|
|
|
366
|
+ 'description' => $item['description'] ?? '',
|
|
|
|
367
|
+ 'html' => $item['content'] ?? '',
|
|
|
|
368
|
+ 'status' => 1
|
|
|
|
369
|
+ ]);
|
|
|
|
370
|
+ $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id);
|
|
|
|
371
|
+ $model->edit(['url' => $route], ['id' => $id]);
|
|
|
|
372
|
+ } catch (\Exception $e) {
|
|
|
|
373
|
+ echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
374
|
+ continue;
|
|
|
|
375
|
+ }
|
|
347
|
}
|
376
|
}
|
|
348
|
}
|
377
|
}
|
|
349
|
}
|
378
|
}
|
|
350
|
}
|
379
|
}
|
|
351
|
}
|
380
|
}
|
|
|
|
381
|
+ } else {
|
|
|
|
382
|
+ return true;
|
|
352
|
}
|
383
|
}
|
|
353
|
}
|
384
|
}
|
|
354
|
}
|
385
|
}
|
|
@@ -391,4 +422,31 @@ class ProjectUpdate extends Command |
|
@@ -391,4 +422,31 @@ class ProjectUpdate extends Command |
|
391
|
$arr = explode('/', $url);
|
422
|
$arr = explode('/', $url);
|
|
392
|
return $arr[count($arr) - 2];
|
423
|
return $arr[count($arr) - 2];
|
|
393
|
}
|
424
|
}
|
|
|
|
425
|
+
|
|
|
|
426
|
+ protected function category_insert($project_id, $items, $pid = 0)
|
|
|
|
427
|
+ {
|
|
|
|
428
|
+ $model = new Category();
|
|
|
|
429
|
+ foreach ($items as $item) {
|
|
|
|
430
|
+ if ($item['name'] ?? '') {
|
|
|
|
431
|
+ $parent = $model->read(['pid' => $pid, 'title' => $item['name']], 'id');
|
|
|
|
432
|
+ if (!$parent) {
|
|
|
|
433
|
+ $parent_id = $model->addReturnId([
|
|
|
|
434
|
+ 'project_id' => $project_id,
|
|
|
|
435
|
+ 'title' => $item['name'],
|
|
|
|
436
|
+ 'pid' => $pid,
|
|
|
|
437
|
+ 'keywords' => $item['keywords'] ?? '',
|
|
|
|
438
|
+ 'describe' => $item['description'] ?? ''
|
|
|
|
439
|
+ ]);
|
|
|
|
440
|
+ $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
|
|
441
|
+ $model->edit(['route' => $route], ['id' => $parent_id]);
|
|
|
|
442
|
+ } else {
|
|
|
|
443
|
+ $parent_id = $parent['id'];
|
|
|
|
444
|
+ }
|
|
|
|
445
|
+
|
|
|
|
446
|
+ if (!empty($item['children'])) {
|
|
|
|
447
|
+ $this->category_insert($project_id, $item['children'], $parent_id);
|
|
|
|
448
|
+ }
|
|
|
|
449
|
+ }
|
|
|
|
450
|
+ }
|
|
|
|
451
|
+ }
|
|
394
|
} |
452
|
} |