作者 lyh

gx

@@ -241,25 +241,22 @@ class CategoryLogic extends BaseLogic @@ -241,25 +241,22 @@ class CategoryLogic extends BaseLogic
241 */ 241 */
242 public function categoryDelete(){ 242 public function categoryDelete(){
243 $ids = $this->param['ids']; 243 $ids = $this->param['ids'];
244 - DB::beginTransaction();  
245 - try { 244 + foreach ($ids as $id){
  245 + $info = $this->model->read(['pid'=>$id],['id']);
  246 + if($info !== false){
  247 + $this->fail('分类id:'.$id.'拥有子集不允许删除');
  248 + }
246 $productModel = new Product(); 249 $productModel = new Product();
247 - foreach ($ids as $id){  
248 - $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);  
249 - if($product_info !== false){  
250 - $this->fail('当前分类拥有产品不允许删除');  
251 - }  
252 - //删除路由  
253 - $this->delRoute($id);  
254 - $this->model->del(['id'=>$id]); 250 + $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);
  251 + if($product_info !== false){
  252 + $this->fail('当前分类拥有产品不允许删除');
255 } 253 }
256 - //清除缓存  
257 - Common::del_user_cache('product_category',$this->user['project_id']);  
258 - DB::commit();  
259 - }catch (\Exception $e){  
260 - DB::rollBack();  
261 - $this->fail('删除失败'); 254 + //删除路由
  255 + $this->delRoute($id);
  256 + $this->model->del(['id'=>$id]);
262 } 257 }
  258 + //清除缓存
  259 + Common::del_user_cache('product_category',$this->user['project_id']);
263 return $this->success(); 260 return $this->success();
264 } 261 }
265 262