作者 lyh

gx脚本更新路由

@@ -20,6 +20,8 @@ use App\Models\News\News; @@ -20,6 +20,8 @@ use App\Models\News\News;
20 use App\Models\News\NewsCategory; 20 use App\Models\News\NewsCategory;
21 use App\Models\Product\Category; 21 use App\Models\Product\Category;
22 use App\Models\Product\CategoryRelated; 22 use App\Models\Product\CategoryRelated;
  23 +use App\Models\Product\Column;
  24 +use App\Models\Product\Detail;
23 use App\Models\Product\Extend; 25 use App\Models\Product\Extend;
24 use App\Models\Product\ExtendInfo; 26 use App\Models\Product\ExtendInfo;
25 use App\Models\Product\Keyword; 27 use App\Models\Product\Keyword;
@@ -335,7 +337,7 @@ class ProjectUpdate extends Command @@ -335,7 +337,7 @@ class ProjectUpdate extends Command
335 } 337 }
336 //名称去掉特殊符号 338 //名称去掉特殊符号
337 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 339 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
338 - 340 + $content = $item['content'] ?? '';
339 try { 341 try {
340 $product = $model->read(['route' => $route], ['id', 'six_read']); 342 $product = $model->read(['route' => $route], ['id', 'six_read']);
341 if (!$product) { 343 if (!$product) {
@@ -343,7 +345,7 @@ class ProjectUpdate extends Command @@ -343,7 +345,7 @@ class ProjectUpdate extends Command
343 'project_id' => $project_id, 345 'project_id' => $project_id,
344 'title' => $item['ttile'], 346 'title' => $item['ttile'],
345 'intro' => $item['short_description'] ?? '', 347 'intro' => $item['short_description'] ?? '',
346 - 'content' => $item['content'] ?? '', 348 + 'content' => $content,
347 'category_id' => $category_id, 349 'category_id' => $category_id,
348 'keyword_id' => $keyword_id, 350 'keyword_id' => $keyword_id,
349 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 351 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
@@ -364,6 +366,20 @@ class ProjectUpdate extends Command @@ -364,6 +366,20 @@ class ProjectUpdate extends Command
364 'six_read' => 1, 366 'six_read' => 1,
365 'route' => $route 367 'route' => $route
366 ]); 368 ]);
  369 + if(!empty($content)){
  370 + $data_s = [
  371 + 'product_id'=>$id,
  372 + 'column_id'=>1,
  373 + 'text_type'=>1,
  374 + 'title'=>'product detail',
  375 + 'sort'=>1,
  376 + 'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
  377 + 'created_at'=>date('Y-m-d H:i:s'),
  378 + 'updated_at'=>date('Y-m-d H:i:s')
  379 + ];
  380 + $detailModel = new Detail();
  381 + $detailModel->insert($data_s);
  382 + }
367 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id); 383 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
368 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $domain_arr['host'], $link_type, $language_list, $page_list); 384 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
369 $six_read = 1; 385 $six_read = 1;
@@ -375,7 +391,7 @@ class ProjectUpdate extends Command @@ -375,7 +391,7 @@ class ProjectUpdate extends Command
375 $model->edit([ 391 $model->edit([
376 'title' => $item['ttile'], 392 'title' => $item['ttile'],
377 'intro' => $item['short_description'] ?? '', 393 'intro' => $item['short_description'] ?? '',
378 - 'content' => $item['content'] ?? '', 394 + 'content' => $content,
379 'category_id' => $category_id, 395 'category_id' => $category_id,
380 'keyword_id' => $keyword_id, 396 'keyword_id' => $keyword_id,
381 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 397 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
@@ -391,8 +407,22 @@ class ProjectUpdate extends Command @@ -391,8 +407,22 @@ class ProjectUpdate extends Command
391 'files' => $files, 407 'files' => $files,
392 ], ['id' => $id]); 408 ], ['id' => $id]);
393 } 409 }
  410 + if(!empty($content)){
  411 + $detailModel = new Detail();
  412 + $detailModel->del(['product_id'=>$id,'column_id'=>1]);
  413 + $data_s = [
  414 + 'product_id'=>$id,
  415 + 'column_id'=>1,
  416 + 'text_type'=>1,
  417 + 'title'=>'product detail',
  418 + 'sort'=>1,
  419 + 'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
  420 + 'created_at'=>date('Y-m-d H:i:s'),
  421 + 'updated_at'=>date('Y-m-d H:i:s')
  422 + ];
  423 + $detailModel->insert($data_s);
  424 + }
394 } 425 }
395 -  
396 if ($six_read) { 426 if ($six_read) {
397 //关联分类 427 //关联分类
398 CategoryRelated::saveRelated($id, array_column($category_arr, 'id')); 428 CategoryRelated::saveRelated($id, array_column($category_arr, 'id'));
@@ -945,6 +945,41 @@ class ProductLogic extends BaseLogic @@ -945,6 +945,41 @@ class ProductLogic extends BaseLogic
945 'status' => Product::STATUS_ON 945 'status' => Product::STATUS_ON
946 ] 946 ]
947 ); 947 );
  948 + if(!empty($content)){
  949 + $data = [
  950 + 'product_id'=>$id,
  951 + 'column_id'=>1,
  952 + 'text_type'=>1,
  953 + 'title'=>'product detail',
  954 + 'sort'=>1,
  955 + 'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
  956 + 'created_at'=>date('Y-m-d H:i:s'),
  957 + 'updated_at'=>date('Y-m-d H:i:s')
  958 + ];
  959 + $detailModel = new Detail();
  960 + $detailModel->insert($data);
  961 + }
  962 + if(!empty($describe)){
  963 + foreach ($describe as $describe_key => $describe_value){
  964 + if(empty($describe_value['title'])){
  965 + continue;
  966 + }
  967 + //添加切换栏
  968 + $cModel = new Column();
  969 + $c_id = $cModel->addReturnId(['column_name'=>$describe_value['title'],'product_id'=>$id]);
  970 + $dataS = [
  971 + 'product_id'=>$c_id,
  972 + 'column_id'=>$id,
  973 + 'text_type'=>1,
  974 + 'title'=>$describe_value['title'] ?? '',
  975 + 'sort'=>$describe_key + 1,
  976 + 'content'=>json_encode(['content'=>$describe_value['text'] ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
  977 + 'created_at'=>date('Y-m-d H:i:s'),
  978 + 'updated_at'=>date('Y-m-d H:i:s')
  979 + ];
  980 + $detailModel->insert($dataS);
  981 + }
  982 + }
948 //更新路由 983 //更新路由
949 if($route){ 984 if($route){
950 $route_map = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->where('source_id', $id)->first(); 985 $route_map = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->where('source_id', $id)->first();