|
...
|
...
|
@@ -66,8 +66,8 @@ class CategoryLogic extends BaseLogic |
|
|
|
* @time :2023/8/21 17:14
|
|
|
|
*/
|
|
|
|
public function categorySave(){
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
// DB::beginTransaction();
|
|
|
|
// try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$this->handleEditParam($this->param);
|
|
|
|
$id = $this->param['id'];
|
|
...
|
...
|
@@ -78,11 +78,11 @@ class CategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
//路由映射
|
|
|
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
|
|
|
|
DB::commit();
|
|
|
|
} catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('保存失败');
|
|
|
|
}
|
|
|
|
// DB::commit();
|
|
|
|
// } catch (\Exception $e){
|
|
|
|
// DB::rollBack();
|
|
|
|
// $this->fail('保存失败');
|
|
|
|
// }
|
|
|
|
//通知更新
|
|
|
|
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]);
|
|
|
|
return $this->success();
|
|
...
|
...
|
@@ -102,12 +102,28 @@ class CategoryLogic extends BaseLogic |
|
|
|
$info = $this->model->read(['id'=>$param['id']]);
|
|
|
|
$sub_info = $this->model->read(['pid'=>$param['id']]);
|
|
|
|
if(($info['pid'] != $param['pid']) && ($sub_info != false)){
|
|
|
|
$this->fail('当前分类拥有字分类,不允许修改上级分类');
|
|
|
|
$this->fail('当前分类拥有子分类,不允许修改上级分类');
|
|
|
|
}
|
|
|
|
$productModel = new Product();
|
|
|
|
$product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);
|
|
|
|
if($product_info !== false){
|
|
|
|
$this->fail('当前产品分类拥有产品不允许编辑上级分类');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :添加时处理分类
|
|
|
|
* @name :handleAddParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/21 18:34
|
|
|
|
*/
|
|
|
|
public function handleAddParam(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除
|
|
|
|
* @name :delete
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -124,7 +140,6 @@ class CategoryLogic extends BaseLogic |
|
|
|
if(!$info){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//是否有子分类
|
|
|
|
if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
|
|
|
|
$this->fail("分类{$info['title']}存在子分类,不能删除");
|
...
|
...
|
|