|
@@ -66,8 +66,8 @@ class CategoryLogic extends BaseLogic |
|
@@ -66,8 +66,8 @@ class CategoryLogic extends BaseLogic |
|
66
|
* @time :2023/8/21 17:14
|
66
|
* @time :2023/8/21 17:14
|
|
67
|
*/
|
67
|
*/
|
|
68
|
public function categorySave(){
|
68
|
public function categorySave(){
|
|
69
|
- DB::beginTransaction();
|
|
|
|
70
|
- try {
|
69
|
+// DB::beginTransaction();
|
|
|
|
70
|
+// try {
|
|
71
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
71
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
72
|
$this->handleEditParam($this->param);
|
72
|
$this->handleEditParam($this->param);
|
|
73
|
$id = $this->param['id'];
|
73
|
$id = $this->param['id'];
|
|
@@ -78,11 +78,11 @@ class CategoryLogic extends BaseLogic |
|
@@ -78,11 +78,11 @@ class CategoryLogic extends BaseLogic |
|
78
|
}
|
78
|
}
|
|
79
|
//路由映射
|
79
|
//路由映射
|
|
80
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
|
80
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
|
|
81
|
- DB::commit();
|
|
|
|
82
|
- } catch (\Exception $e){
|
|
|
|
83
|
- DB::rollBack();
|
|
|
|
84
|
- $this->fail('保存失败');
|
|
|
|
85
|
- }
|
81
|
+// DB::commit();
|
|
|
|
82
|
+// } catch (\Exception $e){
|
|
|
|
83
|
+// DB::rollBack();
|
|
|
|
84
|
+// $this->fail('保存失败');
|
|
|
|
85
|
+// }
|
|
86
|
//通知更新
|
86
|
//通知更新
|
|
87
|
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]);
|
87
|
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]);
|
|
88
|
return $this->success();
|
88
|
return $this->success();
|
|
@@ -102,12 +102,28 @@ class CategoryLogic extends BaseLogic |
|
@@ -102,12 +102,28 @@ class CategoryLogic extends BaseLogic |
|
102
|
$info = $this->model->read(['id'=>$param['id']]);
|
102
|
$info = $this->model->read(['id'=>$param['id']]);
|
|
103
|
$sub_info = $this->model->read(['pid'=>$param['id']]);
|
103
|
$sub_info = $this->model->read(['pid'=>$param['id']]);
|
|
104
|
if(($info['pid'] != $param['pid']) && ($sub_info != false)){
|
104
|
if(($info['pid'] != $param['pid']) && ($sub_info != false)){
|
|
105
|
- $this->fail('当前分类拥有字分类,不允许修改上级分类');
|
105
|
+ $this->fail('当前分类拥有子分类,不允许修改上级分类');
|
|
|
|
106
|
+ }
|
|
|
|
107
|
+ $productModel = new Product();
|
|
|
|
108
|
+ $product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);
|
|
|
|
109
|
+ if($product_info !== false){
|
|
|
|
110
|
+ $this->fail('当前产品分类拥有产品不允许编辑上级分类');
|
|
106
|
}
|
111
|
}
|
|
107
|
return true;
|
112
|
return true;
|
|
108
|
}
|
113
|
}
|
|
109
|
|
114
|
|
|
110
|
/**
|
115
|
/**
|
|
|
|
116
|
+ * @remark :添加时处理分类
|
|
|
|
117
|
+ * @name :handleAddParam
|
|
|
|
118
|
+ * @author :lyh
|
|
|
|
119
|
+ * @method :post
|
|
|
|
120
|
+ * @time :2023/8/21 18:34
|
|
|
|
121
|
+ */
|
|
|
|
122
|
+ public function handleAddParam(){
|
|
|
|
123
|
+
|
|
|
|
124
|
+ }
|
|
|
|
125
|
+
|
|
|
|
126
|
+ /**
|
|
111
|
* @remark :删除
|
127
|
* @remark :删除
|
|
112
|
* @name :delete
|
128
|
* @name :delete
|
|
113
|
* @author :lyh
|
129
|
* @author :lyh
|
|
@@ -124,7 +140,6 @@ class CategoryLogic extends BaseLogic |
|
@@ -124,7 +140,6 @@ class CategoryLogic extends BaseLogic |
|
124
|
if(!$info){
|
140
|
if(!$info){
|
|
125
|
continue;
|
141
|
continue;
|
|
126
|
}
|
142
|
}
|
|
127
|
-
|
|
|
|
128
|
//是否有子分类
|
143
|
//是否有子分类
|
|
129
|
if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
|
144
|
if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
|
|
130
|
$this->fail("分类{$info['title']}存在子分类,不能删除");
|
145
|
$this->fail("分类{$info['title']}存在子分类,不能删除");
|