|
...
|
...
|
@@ -133,12 +133,9 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
|
|
|
|
$id, $this->user['project_id']);
|
|
|
|
$this->handleAddSon($id);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route);
|
|
|
|
$this->curlDelRoute(['new_route'=>$route]);
|
|
|
|
$this->edit(['route' => $route], ['id' => $id]);
|
|
|
|
//处理上级分类商品
|
|
|
|
$this->handleAddSon($id);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
...
|
...
|
@@ -155,7 +152,6 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
public function categoryEdit(){
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
|
|
|
|
$this->param['id'], $this->user['project_id']);
|
|
|
|
$this->editHandleCategory($this->param['id'],$this->param['pid']);
|
|
|
|
$this->editRoute($this->param['id'],$route);
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
if($rs === false){
|
|
...
|
...
|
@@ -165,48 +161,6 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑分类,处理博客数据
|
|
|
|
* @name :editCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/20 9:32
|
|
|
|
*/
|
|
|
|
public function editHandleCategory($id,$pid){
|
|
|
|
$info = $this->model->read(['id'=>$id],['id','pid']);
|
|
|
|
if($info['pid'] != $pid){
|
|
|
|
//修改勒上级,先查看上级是否拥有产品
|
|
|
|
$contentModel = new CustomModuleContent();
|
|
|
|
$contentCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
|
|
|
|
if($contentCount > 0){
|
|
|
|
//随机获取最后一级id
|
|
|
|
$replacement = $this->getLastId($id);
|
|
|
|
//存在博客时,移动所有博客到当前分类最后一级
|
|
|
|
$contentModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
|
|
|
|
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
|
|
|
|
$contentModel->where('category_id', 'like', '%,' . $pid . ',%')
|
|
|
|
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :随机获取当前id下最后一级的id
|
|
|
|
* @name :getLastId
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/20 9:45
|
|
|
|
*/
|
|
|
|
public function getLastId($id){
|
|
|
|
$info = $this->model->read(['pid'=>$id],['id']);
|
|
|
|
if($info !== false){
|
|
|
|
return $this->getLastId($info['id']);
|
|
|
|
}else{
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :查看是否编辑路由
|
|
|
|
* @name :editCategoryRoute
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -225,46 +179,6 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(添加分类时处理子集分类)addProcessingSon
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/13 11:34
|
|
|
|
*/
|
|
|
|
public function handleAddSon($cate_id){
|
|
|
|
if(isset($this->param['pid']) && !empty($this->param['pid'])) {
|
|
|
|
$this->param['pid'] = 0;
|
|
|
|
}
|
|
|
|
//判断为子分类时
|
|
|
|
if($this->param['pid'] != 0) {
|
|
|
|
//查看当前上级分类下是否有其他分类
|
|
|
|
$cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]],['id']);
|
|
|
|
if ($cate_info === false) {
|
|
|
|
//查看当前上一级分类下是否有关联模块内容
|
|
|
|
$contentModel = new CustomModuleContent();
|
|
|
|
$news_count = $contentModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
|
|
|
|
if ($news_count > 0) {
|
|
|
|
$replacement = $this->handleStr($cate_id);
|
|
|
|
$old = $this->handleStr($this->param['pid']);
|
|
|
|
//更新所有商品到当前分类
|
|
|
|
$contentModel->where('category_id', 'like', '%' . $old . '%')->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理字符串
|
|
|
|
* @name :handleStr
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/5 18:03
|
|
|
|
*/
|
|
|
|
public function handleStr($str){
|
|
|
|
return ',' . $str . ',';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除数据
|
|
|
|
* @name :ModuleDel
|
|
|
|
* @author :lyh
|
...
|
...
|
|