|
...
|
...
|
@@ -241,10 +241,12 @@ class CategoryLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function categoryDelete(){
|
|
|
|
$ids = $this->param['ids'];
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
$productModel = new Product();
|
|
|
|
foreach ($ids as $id){
|
|
|
|
$info = $this->model->read(['pid'=>$id],['id']);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('分类id:'.$id.'拥有子集不允许删除');
|
|
|
|
}
|
|
|
|
$productModel = new Product();
|
|
|
|
$product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);
|
|
|
|
if($product_info !== false){
|
|
|
|
$this->fail('当前分类拥有产品不允许删除');
|
|
...
|
...
|
@@ -255,11 +257,6 @@ class CategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
//清除缓存
|
|
|
|
Common::del_user_cache('product_category',$this->user['project_id']);
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('删除失败');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|