作者 lyh

gx

@@ -241,10 +241,12 @@ class CategoryLogic extends BaseLogic @@ -241,10 +241,12 @@ 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 {  
246 - $productModel = new Product();  
247 foreach ($ids as $id){ 244 foreach ($ids as $id){
  245 + $info = $this->model->read(['pid'=>$id],['id']);
  246 + if($info !== false){
  247 + $this->fail('分类id:'.$id.'拥有子集不允许删除');
  248 + }
  249 + $productModel = new Product();
248 $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]); 250 $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);
249 if($product_info !== false){ 251 if($product_info !== false){
250 $this->fail('当前分类拥有产品不允许删除'); 252 $this->fail('当前分类拥有产品不允许删除');
@@ -255,11 +257,6 @@ class CategoryLogic extends BaseLogic @@ -255,11 +257,6 @@ class CategoryLogic extends BaseLogic
255 } 257 }
256 //清除缓存 258 //清除缓存
257 Common::del_user_cache('product_category',$this->user['project_id']); 259 Common::del_user_cache('product_category',$this->user['project_id']);
258 - DB::commit();  
259 - }catch (\Exception $e){  
260 - DB::rollBack();  
261 - $this->fail('删除失败');  
262 - }  
263 return $this->success(); 260 return $this->success();
264 } 261 }
265 262