作者 lyh

gx脚本更新路由

... ... @@ -20,6 +20,8 @@ use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Column;
use App\Models\Product\Detail;
use App\Models\Product\Extend;
use App\Models\Product\ExtendInfo;
use App\Models\Product\Keyword;
... ... @@ -335,7 +337,7 @@ class ProjectUpdate extends Command
}
//名称去掉特殊符号
$item['ttile'] = $this->special2str($item['ttile'] ?? '');
$content = $item['content'] ?? '';
try {
$product = $model->read(['route' => $route], ['id', 'six_read']);
if (!$product) {
... ... @@ -343,7 +345,7 @@ class ProjectUpdate extends Command
'project_id' => $project_id,
'title' => $item['ttile'],
'intro' => $item['short_description'] ?? '',
'content' => $item['content'] ?? '',
'content' => $content,
'category_id' => $category_id,
'keyword_id' => $keyword_id,
'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
... ... @@ -364,6 +366,20 @@ class ProjectUpdate extends Command
'six_read' => 1,
'route' => $route
]);
if(!empty($content)){
$data_s = [
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'title'=>'product detail',
'sort'=>1,
'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
$detailModel = new Detail();
$detailModel->insert($data_s);
}
$this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
$six_read = 1;
... ... @@ -375,7 +391,7 @@ class ProjectUpdate extends Command
$model->edit([
'title' => $item['ttile'],
'intro' => $item['short_description'] ?? '',
'content' => $item['content'] ?? '',
'content' => $content,
'category_id' => $category_id,
'keyword_id' => $keyword_id,
'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
... ... @@ -391,8 +407,22 @@ class ProjectUpdate extends Command
'files' => $files,
], ['id' => $id]);
}
if(!empty($content)){
$detailModel = new Detail();
$detailModel->del(['product_id'=>$id,'column_id'=>1]);
$data_s = [
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'title'=>'product detail',
'sort'=>1,
'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
$detailModel->insert($data_s);
}
}
if ($six_read) {
//关联分类
CategoryRelated::saveRelated($id, array_column($category_arr, 'id'));
... ...
... ... @@ -945,6 +945,41 @@ class ProductLogic extends BaseLogic
'status' => Product::STATUS_ON
]
);
if(!empty($content)){
$data = [
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'title'=>'product detail',
'sort'=>1,
'content'=>json_encode(['content'=>$content ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
$detailModel = new Detail();
$detailModel->insert($data);
}
if(!empty($describe)){
foreach ($describe as $describe_key => $describe_value){
if(empty($describe_value['title'])){
continue;
}
//添加切换栏
$cModel = new Column();
$c_id = $cModel->addReturnId(['column_name'=>$describe_value['title'],'product_id'=>$id]);
$dataS = [
'product_id'=>$c_id,
'column_id'=>$id,
'text_type'=>1,
'title'=>$describe_value['title'] ?? '',
'sort'=>$describe_key + 1,
'content'=>json_encode(['content'=>$describe_value['text'] ?? ''],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
$detailModel->insert($dataS);
}
}
//更新路由
if($route){
$route_map = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->where('source_id', $id)->first();
... ...