正在显示
1 个修改的文件
包含
114 行增加
和
39 行删除
| @@ -17,6 +17,7 @@ use App\Models\Product\Category; | @@ -17,6 +17,7 @@ use App\Models\Product\Category; | ||
| 17 | use App\Models\Product\CategoryRelated; | 17 | use App\Models\Product\CategoryRelated; |
| 18 | use App\Models\Product\Column; | 18 | use App\Models\Product\Column; |
| 19 | use App\Models\Product\Detail; | 19 | use App\Models\Product\Detail; |
| 20 | +use App\Models\Product\ExtendInfo; | ||
| 20 | use App\Models\Product\Product; | 21 | use App\Models\Product\Product; |
| 21 | use App\Models\RouteMap\RouteMap; | 22 | use App\Models\RouteMap\RouteMap; |
| 22 | use App\Models\Template\BTemplate; | 23 | use App\Models\Template\BTemplate; |
| @@ -140,6 +141,7 @@ class LyhImportTest extends Command | @@ -140,6 +141,7 @@ class LyhImportTest extends Command | ||
| 140 | $productModel = new Product(); | 141 | $productModel = new Product(); |
| 141 | $detailModel = new Detail(); | 142 | $detailModel = new Detail(); |
| 142 | $columnModel = new Column(); | 143 | $columnModel = new Column(); |
| 144 | + $extentInfoModel = new ExtendInfo(); | ||
| 143 | foreach ($line_of_text as $k => $val){ | 145 | foreach ($line_of_text as $k => $val){ |
| 144 | if($k < 1){ | 146 | if($k < 1){ |
| 145 | continue; | 147 | continue; |
| @@ -156,58 +158,131 @@ class LyhImportTest extends Command | @@ -156,58 +158,131 @@ class LyhImportTest extends Command | ||
| 156 | $saveData['category_id'] = ','.$cateInfo['id'].','; | 158 | $saveData['category_id'] = ','.$cateInfo['id'].','; |
| 157 | } | 159 | } |
| 158 | } | 160 | } |
| 159 | - if(!empty($val[2])){ | ||
| 160 | - | ||
| 161 | - } | ||
| 162 | - $saveData['intro'] = $val[2]; | ||
| 163 | - $saveData['content'] = $val[3]; | ||
| 164 | - $seo = ['seo_title'=>$val[5]]; | 161 | + $saveData['intro'] = $val[6] ?? ''; |
| 162 | + $seo = ['seo_title'=>$val[0]]; | ||
| 165 | $saveData['seo_mate'] = json_encode($seo,true); | 163 | $saveData['seo_mate'] = json_encode($seo,true); |
| 166 | - $thumb = ['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[6])]; | ||
| 167 | - $gallery = [['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[6])]]; | 164 | + $thumb = ['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[11])]; |
| 165 | + $gallery = [['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[11])]]; | ||
| 168 | $saveData['thumb'] = json_encode($thumb,true); | 166 | $saveData['thumb'] = json_encode($thumb,true); |
| 169 | $saveData['gallery'] = json_encode($gallery,true); | 167 | $saveData['gallery'] = json_encode($gallery,true); |
| 170 | $id = $productModel->addReturnId($saveData); | 168 | $id = $productModel->addReturnId($saveData); |
| 171 | - echo date('Y-m-d H:i:s') . '新增产品id:'.$id . PHP_EOL; | ||
| 172 | //设置关联关系 | 169 | //设置关联关系 |
| 173 | if($cateInfo !== false){ | 170 | if($cateInfo !== false){ |
| 174 | CategoryRelated::saveRelated($id,[$cateInfo['id']]); | 171 | CategoryRelated::saveRelated($id,[$cateInfo['id']]); |
| 175 | } | 172 | } |
| 176 | //设置路由 | 173 | //设置路由 |
| 177 | - $route = RouteMap::setRoute($val[1],RouteMap::SOURCE_PRODUCT,$id,$project_id); | 174 | + $route = RouteMap::setRoute($val[0],RouteMap::SOURCE_PRODUCT,$id,$project_id); |
| 178 | $productModel->edit(['route'=>$route],['id'=>$id]); | 175 | $productModel->edit(['route'=>$route],['id'=>$id]); |
| 179 | - //设置产品描述 | ||
| 180 | - $detail = [ | ||
| 181 | - 'product_id'=>$id, | ||
| 182 | - 'column_id'=>1, | ||
| 183 | - 'text_type'=>1, | ||
| 184 | - 'content'=>json_encode(['content'=>$val[3]]) | ||
| 185 | - ]; | ||
| 186 | - $detailModel->addReturnId($detail); | ||
| 187 | - //扩展描述设置 | ||
| 188 | - $detailFaq = [ | ||
| 189 | - 'column_name'=>'FAQs', | ||
| 190 | - 'product_id'=>$id | ||
| 191 | - ]; | ||
| 192 | - $faqId = $columnModel->addReturnId($detailFaq); | ||
| 193 | - | ||
| 194 | - $faqsDetail = json_decode($val[4],true); | ||
| 195 | - if(!empty($faqsDetail) && is_array($faqsDetail)){ | ||
| 196 | - $faqContent = '<div>'; | ||
| 197 | - foreach ($faqsDetail as $faq_Val){ | ||
| 198 | - $faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />"; | ||
| 199 | - } | ||
| 200 | - $faqContent .= '</div>'; | ||
| 201 | - $detailFaqInfo = [ | 176 | + echo date('Y-m-d H:i:s') . '新增产品id:'.$id . PHP_EOL; |
| 177 | + if(!empty($val[2])){ | ||
| 178 | + $extent = [ | ||
| 179 | + 'key'=>'pd_extended_field_4', | ||
| 180 | + 'product_id'=>$id, | ||
| 181 | + 'project_id'=>$project_id, | ||
| 182 | + 'values'=>$val[2], | ||
| 183 | + ]; | ||
| 184 | + $extentInfoModel->addReturnId($extent); | ||
| 185 | + } | ||
| 186 | + if(!empty($val[3])){ | ||
| 187 | + $extent = [ | ||
| 188 | + 'key'=>'pd_extended_field_1', | ||
| 202 | 'product_id'=>$id, | 189 | 'product_id'=>$id, |
| 203 | - 'column_id'=>$faqId, | 190 | + 'project_id'=>$project_id, |
| 191 | + 'values'=>$val[3], | ||
| 192 | + ]; | ||
| 193 | + $extentInfoModel->addReturnId($extent); | ||
| 194 | + } | ||
| 195 | + if(!empty($val[4])){ | ||
| 196 | + $extent = [ | ||
| 197 | + 'key'=>'pd_extended_field_2', | ||
| 198 | + 'product_id'=>$id, | ||
| 199 | + 'project_id'=>$project_id, | ||
| 200 | + 'values'=>$val[4], | ||
| 201 | + ]; | ||
| 202 | + $extentInfoModel->addReturnId($extent); | ||
| 203 | + } | ||
| 204 | + if(!empty($val[5])){ | ||
| 205 | + $extent = [ | ||
| 206 | + 'key'=>'pd_extended_field_3', | ||
| 207 | + 'product_id'=>$id, | ||
| 208 | + 'project_id'=>$project_id, | ||
| 209 | + 'values'=>$val[5], | ||
| 210 | + ]; | ||
| 211 | + $extentInfoModel->addReturnId($extent); | ||
| 212 | + } | ||
| 213 | + //产品描述 | ||
| 214 | + if(!empty($val[7])){ | ||
| 215 | + //设置产品描述 | ||
| 216 | + $detail = [ | ||
| 217 | + 'title'=>'SEODescription', | ||
| 218 | + 'product_id'=>$id, | ||
| 219 | + 'column_id'=>1, | ||
| 204 | 'text_type'=>1, | 220 | 'text_type'=>1, |
| 205 | - 'content'=>json_encode(['content'=>$faqContent]) | 221 | + 'content'=>json_encode(['content'=>$val[7]]) |
| 206 | ]; | 222 | ]; |
| 207 | - $detailModel->addReturnId($detailFaqInfo); | ||
| 208 | - }else{ | ||
| 209 | - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[1] . PHP_EOL .'faqs数据有问题:' . $val[4], true) . PHP_EOL, FILE_APPEND); | ||
| 210 | - echo date('Y-m-d H:i:s') . '产品标题:'. $val[1] . PHP_EOL .'faqs数据有问题:' . $val[4]; | 223 | + $detailModel->addReturnId($detail); |
| 224 | + } | ||
| 225 | + //产品描述 | ||
| 226 | + if(!empty($val[8])){ | ||
| 227 | + //设置产品描述 | ||
| 228 | + $detail = [ | ||
| 229 | + 'title'=>'SEOSpecification', | ||
| 230 | + 'product_id'=>$id, | ||
| 231 | + 'column_id'=>1, | ||
| 232 | + 'text_type'=>1, | ||
| 233 | + 'content'=>json_encode(['content'=>$val[8]]) | ||
| 234 | + ]; | ||
| 235 | + $detailModel->addReturnId($detail); | ||
| 236 | + } | ||
| 237 | + if(!empty($val[9])){ | ||
| 238 | + try { | ||
| 239 | + $faqsDetail = json_decode($val[9],true); | ||
| 240 | + if(!empty($faqsDetail) && is_array($faqsDetail)){ | ||
| 241 | + $faqContent = '<div>'; | ||
| 242 | + foreach ($faqsDetail as $faq_Val){ | ||
| 243 | + $faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />"; | ||
| 244 | + } | ||
| 245 | + $faqContent .= '</div>'; | ||
| 246 | + $detailFaqInfo = [ | ||
| 247 | + 'title'=>'SEOQandA', | ||
| 248 | + 'product_id'=>$id, | ||
| 249 | + 'column_id'=>1, | ||
| 250 | + 'text_type'=>1, | ||
| 251 | + 'content'=>json_encode(['content'=>$faqContent]) | ||
| 252 | + ]; | ||
| 253 | + $detailModel->addReturnId($detailFaqInfo); | ||
| 254 | + }else{ | ||
| 255 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[9], true) . PHP_EOL, FILE_APPEND); | ||
| 256 | + echo date('Y-m-d H:i:s') . '产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[9]; | ||
| 257 | + } | ||
| 258 | + }catch(\Exception $e){ | ||
| 259 | + echo 'fqs'; | ||
| 260 | + } | ||
| 261 | + } | ||
| 262 | + if(!empty($val[10])){ | ||
| 263 | + try { | ||
| 264 | + $faqsDetail = json_decode($val[10],true); | ||
| 265 | + if(!empty($faqsDetail) && is_array($faqsDetail)){ | ||
| 266 | + $faqContent = '<div>'; | ||
| 267 | + foreach ($faqsDetail as $faq_Val){ | ||
| 268 | + $faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />"; | ||
| 269 | + } | ||
| 270 | + $faqContent .= '</div>'; | ||
| 271 | + $detailFaqInfo = [ | ||
| 272 | + 'title'=>'SEOQandA_Product', | ||
| 273 | + 'product_id'=>$id, | ||
| 274 | + 'column_id'=>1, | ||
| 275 | + 'text_type'=>1, | ||
| 276 | + 'content'=>json_encode(['content'=>$faqContent]) | ||
| 277 | + ]; | ||
| 278 | + $detailModel->addReturnId($detailFaqInfo); | ||
| 279 | + }else{ | ||
| 280 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[10], true) . PHP_EOL, FILE_APPEND); | ||
| 281 | + echo date('Y-m-d H:i:s') . '产品标题:'. $val[0] . PHP_EOL .'SEOQandA_Product数据有问题:' . $val[10]; | ||
| 282 | + } | ||
| 283 | + }catch(\Exception $e){ | ||
| 284 | + continue; | ||
| 285 | + } | ||
| 211 | } | 286 | } |
| 212 | } | 287 | } |
| 213 | return true; | 288 | return true; |
-
请 注册 或 登录 后发表评论