|
...
|
...
|
@@ -79,8 +79,8 @@ class KeywordLogic extends BaseLogic |
|
|
|
if($info !== false){
|
|
|
|
return $this->success(['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
$this->param = $this->addHandleParam($this->param);
|
|
|
|
$id = $this->model->insertGetId($this->param);
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
//路由映射
|
|
|
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
...
|
...
|
@@ -93,20 +93,6 @@ class KeywordLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :添加组装数据
|
|
|
|
* @name :addHandleParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/30 15:00
|
|
|
|
*/
|
|
|
|
public function addHandleParam($param){
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
$param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$param['updated_at'] = $param['created_at'];
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据时参数处理
|
|
|
|
* @name :handleSaveParam
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -135,27 +121,11 @@ class KeywordLogic extends BaseLogic |
|
|
|
if(!empty($param['seo_title'])){
|
|
|
|
$param['seo_title'] = ucfirst($param['seo_title']);
|
|
|
|
}
|
|
|
|
$param['first_word'] = $this->first_word($param['title']);
|
|
|
|
$param['first_word'] = $this->model->first_word($param['title']);
|
|
|
|
return $param;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取字符串首字符
|
|
|
|
* @name :first_word
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/10/28 10:47
|
|
|
|
*/
|
|
|
|
public function first_word($title){
|
|
|
|
$first_title = mb_substr(strtolower($title), 0, 1);
|
|
|
|
if (is_numeric($first_title)){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
$string_key = array_search($first_title, $this->model->firstNumWord);
|
|
|
|
return $string_key ?: 27;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :批量添加关键词任务, 异步处理
|
|
|
|
* @name :batchAdd
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -164,20 +134,7 @@ class KeywordLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function batchAdd(){
|
|
|
|
try {
|
|
|
|
foreach ($this->param['title'] as $k=>$v){
|
|
|
|
if(empty($v)){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$info = $this->model->read(['title'=>$v],['id']);
|
|
|
|
if($info === false){
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
$param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$param['updated_at'] = $param['created_at'];
|
|
|
|
$param['title'] = $v;
|
|
|
|
$param['first_word'] = $this->first_word($param['title']);
|
|
|
|
$this->model->insertGetId($param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->model->saveBKeyword($this->user['project_id'],$this->param['title']);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
...
|
...
|
@@ -249,7 +206,7 @@ class KeywordLogic extends BaseLogic |
|
|
|
if($v){
|
|
|
|
$keyword_info = $this->model->read(['title'=>$v]);
|
|
|
|
if(!$keyword_info){
|
|
|
|
$k_id = $this->model->addReturnId(['title'=>$v,'first_word' => $this->first_word($v),'project_id'=>$project_id]);
|
|
|
|
$k_id = $this->model->addReturnId(['title'=>$v,'first_word' => $this->model->first_word($v),'project_id'=>$project_id]);
|
|
|
|
$route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $k_id, $project_id);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$k_id]);
|
|
|
|
}else{
|
...
|
...
|
|