作者 刘锟

update

@@ -122,7 +122,7 @@ class ProjectUpdate extends Command @@ -122,7 +122,7 @@ class ProjectUpdate extends Command
122 $data = curl_c($url); 122 $data = curl_c($url);
123 if (isset($data['code']) && $data['code'] == 200) { 123 if (isset($data['code']) && $data['code'] == 200) {
124 $items = $data['data'] ?? []; 124 $items = $data['data'] ?? [];
125 - $this->category_insert($project_id, $items, 0); 125 + $this->category_insert($project_id, $items, 0, $domain_arr['host'], $web_url_domain, $home_url);
126 } else { 126 } else {
127 return true; 127 return true;
128 } 128 }
@@ -737,7 +737,7 @@ class ProjectUpdate extends Command @@ -737,7 +737,7 @@ class ProjectUpdate extends Command
737 } 737 }
738 738
739 //产品多级分类入库 739 //产品多级分类入库
740 - protected function category_insert($project_id, $items, $pid = 0) 740 + protected function category_insert($project_id, $items, $pid, $domain, $web_url_domain, $home_url)
741 { 741 {
742 $model = new Category(); 742 $model = new Category();
743 foreach ($items as $item) { 743 foreach ($items as $item) {
@@ -747,9 +747,17 @@ class ProjectUpdate extends Command @@ -747,9 +747,17 @@ class ProjectUpdate extends Command
747 if (!$parent) { 747 if (!$parent) {
748 try { 748 try {
749 $item['name'] = $this->special2str($item['name'] ?? ''); 749 $item['name'] = $this->special2str($item['name'] ?? '');
  750 + //图片
  751 + if (is_array($item['images'] ?? '')) {
  752 + $image = $item['images'][0] ?? '';
  753 + } else {
  754 + $image = $item['images'] ?? '';
  755 + }
  756 + $new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
750 $parent_id = $model->addReturnId([ 757 $parent_id = $model->addReturnId([
751 'project_id' => $project_id, 758 'project_id' => $project_id,
752 'title' => $item['name'], 759 'title' => $item['name'],
  760 + 'image' => $new_img,
753 'pid' => $pid, 761 'pid' => $pid,
754 'keywords' => $item['keywords'] ?? '', 762 'keywords' => $item['keywords'] ?? '',
755 'describe' => $item['description'] ?? '', 763 'describe' => $item['description'] ?? '',
@@ -766,7 +774,7 @@ class ProjectUpdate extends Command @@ -766,7 +774,7 @@ class ProjectUpdate extends Command
766 } 774 }
767 775
768 if (!empty($item['children'] ?? [])) { 776 if (!empty($item['children'] ?? [])) {
769 - $this->category_insert($project_id, $item['children'], $parent_id); 777 + $this->category_insert($project_id, $item['children'], $parent_id, $domain, $web_url_domain, $home_url);
770 } 778 }
771 } 779 }
772 } 780 }