Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
1 个修改的文件
包含
123 行增加
和
65 行删除
| @@ -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,17 +147,18 @@ class ProjectUpdate extends Command | @@ -144,17 +147,18 @@ 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'); | 150 | + if ($item['name'] ?? '') { |
| 151 | + $keyword = $model->read(['title' => $item['name']], 'id'); | ||
| 148 | if (!$keyword) { | 152 | if (!$keyword) { |
| 149 | try { | 153 | try { |
| 150 | $id = $model->addReturnId([ | 154 | $id = $model->addReturnId([ |
| 151 | 'project_id' => $project_id, | 155 | '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 | + 'title' => $item['name'], |
| 157 | + 'seo_title' => $item['seo_title'] ?? '', | ||
| 158 | + 'seo_keywords' => $item['seo_keywords'] ?? '', | ||
| 159 | + 'seo_description' => $item['seo_description'] ?? '', | ||
| 156 | ]); | 160 | ]); |
| 157 | - $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['text_title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id); | 161 | + $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id); |
| 158 | $model->edit(['route' => $route], ['id' => $id]); | 162 | $model->edit(['route' => $route], ['id' => $id]); |
| 159 | } catch (\Exception $e) { | 163 | } catch (\Exception $e) { |
| 160 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; | 164 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; |
| @@ -165,6 +169,9 @@ class ProjectUpdate extends Command | @@ -165,6 +169,9 @@ class ProjectUpdate extends Command | ||
| 165 | } | 169 | } |
| 166 | } | 170 | } |
| 167 | } | 171 | } |
| 172 | + } else { | ||
| 173 | + return true; | ||
| 174 | + } | ||
| 168 | } elseif ($api_type == 'website_info') { | 175 | } elseif ($api_type == 'website_info') { |
| 169 | //网站信息 | 176 | //网站信息 |
| 170 | $url = $api_url . '?' . http_build_query(['w' => 'website_info']); | 177 | $url = $api_url . '?' . http_build_query(['w' => 'website_info']); |
| @@ -175,26 +182,38 @@ class ProjectUpdate extends Command | @@ -175,26 +182,38 @@ 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]); | 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]); | ||
| 179 | if (!$receiving_phones) { | 189 | if (!$receiving_phones) { |
| 180 | $model->add([ | 190 | $model->add([ |
| 181 | 'type' => 1, | 191 | 'type' => 1, |
| 182 | - 'values' => $phones, | 192 | + 'values' => $v_phone, |
| 183 | 'project_id' => $project_id | 193 | 'project_id' => $project_id |
| 184 | ]); | 194 | ]); |
| 185 | } | 195 | } |
| 186 | } | 196 | } |
| 197 | + } | ||
| 198 | + } | ||
| 187 | if ($emails) { | 199 | if ($emails) { |
| 188 | - $receiving_emails = $model->read(['type' => 2, 'values' => $emails]); | 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]); | ||
| 189 | if (!$receiving_emails) { | 204 | if (!$receiving_emails) { |
| 190 | $model->add([ | 205 | $model->add([ |
| 191 | 'type' => 2, | 206 | 'type' => 2, |
| 192 | - 'values' => $emails, | 207 | + 'values' => $v_email, |
| 193 | 'project_id' => $project_id | 208 | 'project_id' => $project_id |
| 194 | ]); | 209 | ]); |
| 195 | } | 210 | } |
| 196 | } | 211 | } |
| 197 | } | 212 | } |
| 213 | + } | ||
| 214 | + } else { | ||
| 215 | + return true; | ||
| 216 | + } | ||
| 198 | } elseif ($api_type == 'post') { | 217 | } elseif ($api_type == 'post') { |
| 199 | //产品 | 218 | //产品 |
| 200 | $url = $api_url . '?' . http_build_query(['w' => 'post', 'page' => 1, 'pagesize' => 0]); | 219 | $url = $api_url . '?' . http_build_query(['w' => 'post', 'page' => 1, 'pagesize' => 0]); |
| @@ -212,17 +231,19 @@ class ProjectUpdate extends Command | @@ -212,17 +231,19 @@ 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 | - | 234 | + if ($item['ttile'] ?? '') { |
| 216 | $product = $model->read(['title' => $item['ttile']], 'id'); | 235 | $product = $model->read(['title' => $item['ttile']], 'id'); |
| 217 | if (!$product) { | 236 | if (!$product) { |
| 218 | //图片 | 237 | //图片 |
| 219 | $gallery = []; | 238 | $gallery = []; |
| 239 | + if ($item['images'] ?? []) { | ||
| 220 | foreach ($item['images'] as $k_img => $img) { | 240 | foreach ($item['images'] as $k_img => $img) { |
| 221 | $gallery[] = ['alt' => '这是一张产品图', 'url' => $img]; | 241 | $gallery[] = ['alt' => '这是一张产品图', 'url' => $img]; |
| 222 | } | 242 | } |
| 243 | + } | ||
| 223 | //分类 | 244 | //分类 |
| 224 | $category_id = ''; | 245 | $category_id = ''; |
| 225 | - if ($item['category']) { | 246 | + if ($item['category'] ?? []) { |
| 226 | $category_arr = []; | 247 | $category_arr = []; |
| 227 | foreach ($item['category'] as $cate) { | 248 | foreach ($item['category'] as $cate) { |
| 228 | if ($cate['parent'] == 0) { | 249 | if ($cate['parent'] == 0) { |
| @@ -240,15 +261,15 @@ class ProjectUpdate extends Command | @@ -240,15 +261,15 @@ class ProjectUpdate extends Command | ||
| 240 | $id = $model->addReturnId([ | 261 | $id = $model->addReturnId([ |
| 241 | 'project_id' => $project_id, | 262 | 'project_id' => $project_id, |
| 242 | 'title' => $item['ttile'], | 263 | 'title' => $item['ttile'], |
| 243 | - 'intro' => $item['description'], | ||
| 244 | - 'content' => $item['content'], | 264 | + 'intro' => $item['description'] ?? '', |
| 265 | + 'content' => $item['content'] ?? '', | ||
| 245 | 'category_id' => $category_id, | 266 | 'category_id' => $category_id, |
| 246 | 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', | 267 | 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', |
| 247 | 'gallery' => Arr::a2s($gallery), | 268 | 'gallery' => Arr::a2s($gallery), |
| 248 | 'seo_mate' => Arr::a2s([ | 269 | 'seo_mate' => Arr::a2s([ |
| 249 | 'title' => $item['ttile'], | 270 | 'title' => $item['ttile'], |
| 250 | - 'keyword' => $item['keywords'], | ||
| 251 | - 'description' => $item['description'] | 271 | + 'keyword' => $item['keywords'] ?? '', |
| 272 | + 'description' => $item['description'] ?? '' | ||
| 252 | ]), | 273 | ]), |
| 253 | 'status' => Product::STATUS_ON | 274 | 'status' => Product::STATUS_ON |
| 254 | ]); | 275 | ]); |
| @@ -263,6 +284,9 @@ class ProjectUpdate extends Command | @@ -263,6 +284,9 @@ class ProjectUpdate extends Command | ||
| 263 | } | 284 | } |
| 264 | } | 285 | } |
| 265 | } | 286 | } |
| 287 | + } else { | ||
| 288 | + return true; | ||
| 289 | + } | ||
| 266 | } elseif ($api_type == 'news' || $api_type == 'blog') { | 290 | } elseif ($api_type == 'news' || $api_type == 'blog') { |
| 267 | //新闻或博客 | 291 | //新闻或博客 |
| 268 | $url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]); | 292 | $url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]); |
| @@ -285,6 +309,7 @@ class ProjectUpdate extends Command | @@ -285,6 +309,7 @@ class ProjectUpdate extends Command | ||
| 285 | 309 | ||
| 286 | foreach ($items as $item) { | 310 | foreach ($items as $item) { |
| 287 | 311 | ||
| 312 | + if ($item['ttile'] ?? '') { | ||
| 288 | $news = $model->read(['name' => $item['ttile']], 'id'); | 313 | $news = $model->read(['name' => $item['ttile']], 'id'); |
| 289 | if (!$news) { | 314 | if (!$news) { |
| 290 | try { | 315 | try { |
| @@ -292,9 +317,9 @@ class ProjectUpdate extends Command | @@ -292,9 +317,9 @@ class ProjectUpdate extends Command | ||
| 292 | 'project_id' => $project_id, | 317 | 'project_id' => $project_id, |
| 293 | 'name' => $item['ttile'], | 318 | 'name' => $item['ttile'], |
| 294 | 'seo_title' => $item['ttile'], | 319 | 'seo_title' => $item['ttile'], |
| 295 | - 'seo_keywords' => $item['keywords'], | ||
| 296 | - 'seo_description' => $item['description'], | ||
| 297 | - 'text' => $item['content'], | 320 | + 'seo_keywords' => $item['keywords'] ?? '', |
| 321 | + 'seo_description' => $item['description'] ?? '', | ||
| 322 | + 'text' => $item['content'] ?? '', | ||
| 298 | 'image' => $item['images'][0] ?? '', | 323 | 'image' => $item['images'][0] ?? '', |
| 299 | 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE | 324 | 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE |
| 300 | ]); | 325 | ]); |
| @@ -310,6 +335,9 @@ class ProjectUpdate extends Command | @@ -310,6 +335,9 @@ class ProjectUpdate extends Command | ||
| 310 | } | 335 | } |
| 311 | } | 336 | } |
| 312 | } else { | 337 | } else { |
| 338 | + return true; | ||
| 339 | + } | ||
| 340 | + } else { | ||
| 313 | //单页 | 341 | //单页 |
| 314 | $url = $api_url . '?' . http_build_query(['w' => 'page', 'page' => 1, 'pagesize' => 0]); | 342 | $url = $api_url . '?' . http_build_query(['w' => 'page', 'page' => 1, 'pagesize' => 0]); |
| 315 | $data = http_get($url, ['charset' => 'UTF-8']); | 343 | $data = http_get($url, ['charset' => 'UTF-8']); |
| @@ -326,7 +354,7 @@ class ProjectUpdate extends Command | @@ -326,7 +354,7 @@ 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 | - | 357 | + if ($item['ttile'] ?? '') { |
| 330 | $custom = $model->read(['name' => $item['ttile']], 'id'); | 358 | $custom = $model->read(['name' => $item['ttile']], 'id'); |
| 331 | if (!$custom) { | 359 | if (!$custom) { |
| 332 | try { | 360 | try { |
| @@ -334,9 +362,9 @@ class ProjectUpdate extends Command | @@ -334,9 +362,9 @@ class ProjectUpdate extends Command | ||
| 334 | 'project_id' => $project_id, | 362 | 'project_id' => $project_id, |
| 335 | 'name' => $item['ttile'], | 363 | 'name' => $item['ttile'], |
| 336 | 'title' => $item['ttile'], | 364 | 'title' => $item['ttile'], |
| 337 | - 'keywords' => $item['keywords'], | ||
| 338 | - 'description' => $item['description'], | ||
| 339 | - 'html' => $item['content'], | 365 | + 'keywords' => $item['keywords'] ?? '', |
| 366 | + 'description' => $item['description'] ?? '', | ||
| 367 | + 'html' => $item['content'] ?? '', | ||
| 340 | 'status' => 1 | 368 | 'status' => 1 |
| 341 | ]); | 369 | ]); |
| 342 | $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); | 370 | $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); |
| @@ -350,6 +378,9 @@ class ProjectUpdate extends Command | @@ -350,6 +378,9 @@ class ProjectUpdate extends Command | ||
| 350 | } | 378 | } |
| 351 | } | 379 | } |
| 352 | } | 380 | } |
| 381 | + } else { | ||
| 382 | + return true; | ||
| 383 | + } | ||
| 353 | } | 384 | } |
| 354 | } | 385 | } |
| 355 | //关闭数据库 | 386 | //关闭数据库 |
| @@ -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 | } |
-
请 注册 或 登录 后发表评论