正在显示
1 个修改的文件
包含
34 行增加
和
5 行删除
| @@ -3,9 +3,12 @@ | @@ -3,9 +3,12 @@ | ||
| 3 | namespace App\Console\Commands\Update; | 3 | namespace App\Console\Commands\Update; |
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | +use App\Http\Logic\Bside\Product\CategoryLogic; | ||
| 7 | +use App\Http\Logic\Bside\Product\KeywordLogic; | ||
| 6 | use App\Models\Blog\Blog; | 8 | use App\Models\Blog\Blog; |
| 7 | use App\Models\Com\UpdateLog; | 9 | use App\Models\Com\UpdateLog; |
| 8 | use App\Models\News\News; | 10 | use App\Models\News\News; |
| 11 | +use App\Models\Product\Category; | ||
| 9 | use App\Models\Product\Keyword; | 12 | use App\Models\Product\Keyword; |
| 10 | use App\Models\Product\Product; | 13 | use App\Models\Product\Product; |
| 11 | use App\Models\RouteMap\RouteMap; | 14 | use App\Models\RouteMap\RouteMap; |
| @@ -118,21 +121,46 @@ class ProjectUpdate extends Command | @@ -118,21 +121,46 @@ class ProjectUpdate extends Command | ||
| 118 | 121 | ||
| 119 | $product = $model->read(['title' => $item['ttile']], 'id'); | 122 | $product = $model->read(['title' => $item['ttile']], 'id'); |
| 120 | if (!$product) { | 123 | if (!$product) { |
| 124 | + //图片 | ||
| 121 | $gallery = []; | 125 | $gallery = []; |
| 122 | foreach ($item['images'] as $k_img => $img) { | 126 | foreach ($item['images'] as $k_img => $img) { |
| 123 | $gallery[] = ['alt' => '这是一张产品图', 'url' => $img]; | 127 | $gallery[] = ['alt' => '这是一张产品图', 'url' => $img]; |
| 124 | } | 128 | } |
| 129 | + //关键词 | ||
| 130 | + $keyword_id = ''; | ||
| 131 | + if ($item['keywords']) { | ||
| 132 | + $keywordLogic = new KeywordLogic(); | ||
| 133 | + $keyword_id = $keywordLogic->importProductKeyword($project_id, $item['keywords']); | ||
| 134 | + } | ||
| 135 | + //分类 | ||
| 136 | + $category_id = ''; | ||
| 137 | + if ($item['category']) { | ||
| 138 | + $category_arr = []; | ||
| 139 | + foreach ($item['category'] as $cate) { | ||
| 140 | + if ($cate['parent'] == 0) { | ||
| 141 | + array_unshift($category_arr, $cate['name']); | ||
| 142 | + } else { | ||
| 143 | + array_push($category_arr, $cate['name']); | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + if ($category_arr) { | ||
| 147 | + $categoryLogic = new CategoryLogic(); | ||
| 148 | + $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr)); | ||
| 149 | + } | ||
| 150 | + } | ||
| 125 | $id = $model->addReturnId([ | 151 | $id = $model->addReturnId([ |
| 126 | 'project_id' => $project_id, | 152 | 'project_id' => $project_id, |
| 127 | 'title' => $item['ttile'], | 153 | 'title' => $item['ttile'], |
| 128 | - 'intro' => '', | 154 | + 'intro' => $item['description'], |
| 129 | 'content' => $item['content'], | 155 | 'content' => $item['content'], |
| 156 | + 'keyword_id' => $keyword_id, | ||
| 157 | + 'category_id' => $category_id, | ||
| 130 | 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', | 158 | 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', |
| 131 | 'gallery' => Arr::a2s($gallery), | 159 | 'gallery' => Arr::a2s($gallery), |
| 132 | 'seo_mate' => Arr::a2s([ | 160 | 'seo_mate' => Arr::a2s([ |
| 133 | 'title' => $item['ttile'], | 161 | 'title' => $item['ttile'], |
| 134 | - 'keyword' => '', | ||
| 135 | - 'description' => '' | 162 | + 'keyword' => $item['keywords'], |
| 163 | + 'description' => $item['description'] | ||
| 136 | ]), | 164 | ]), |
| 137 | 'status' => Product::STATUS_ON | 165 | 'status' => Product::STATUS_ON |
| 138 | ]); | 166 | ]); |
| @@ -182,7 +210,7 @@ class ProjectUpdate extends Command | @@ -182,7 +210,7 @@ class ProjectUpdate extends Command | ||
| 182 | } | 210 | } |
| 183 | } | 211 | } |
| 184 | } | 212 | } |
| 185 | - }else{ | 213 | + } else { |
| 186 | //单页 | 214 | //单页 |
| 187 | $url = $api_url . '?' . http_build_query(['w' => 'page', 'page' => 1, 'pagesize' => 0]); | 215 | $url = $api_url . '?' . http_build_query(['w' => 'page', 'page' => 1, 'pagesize' => 0]); |
| 188 | $data = http_get($url, ['charset' => 'UTF-8']); | 216 | $data = http_get($url, ['charset' => 'UTF-8']); |
| @@ -204,7 +232,8 @@ class ProjectUpdate extends Command | @@ -204,7 +232,8 @@ class ProjectUpdate extends Command | ||
| 204 | if (!$custom) { | 232 | if (!$custom) { |
| 205 | $id = $model->addReturnId([ | 233 | $id = $model->addReturnId([ |
| 206 | 'project_id' => $project_id, | 234 | 'project_id' => $project_id, |
| 207 | - 'name' => $item['ttile'] | 235 | + 'name' => $item['ttile'], |
| 236 | + 'html' => $item['content'] | ||
| 208 | ]); | 237 | ]); |
| 209 | $route = RouteMap::setRoute($item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); | 238 | $route = RouteMap::setRoute($item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); |
| 210 | $model->edit(['url' => $route], ['id' => $id]); | 239 | $model->edit(['url' => $route], ['id' => $id]); |
-
请 注册 或 登录 后发表评论