正在显示
1 个修改的文件
包含
8 行增加
和
2 行删除
| @@ -91,6 +91,13 @@ class UpdateProductCategory extends Command | @@ -91,6 +91,13 @@ class UpdateProductCategory extends Command | ||
| 91 | * @time :2023/12/6 16:20 | 91 | * @time :2023/12/6 16:20 |
| 92 | */ | 92 | */ |
| 93 | public function handleCategory($id,$cate_arr){ | 93 | public function handleCategory($id,$cate_arr){ |
| 94 | + $productModel = new Product(); | ||
| 95 | + $productInfo = $productModel->read(['id'=>$id,'deleted_at'=>['!=' ,null]]); | ||
| 96 | + if($productInfo == false){ | ||
| 97 | + $cateRelatedModel = new CategoryRelated(); | ||
| 98 | + $cateRelatedModel->del(['product_id'=>$id]); | ||
| 99 | + return true; | ||
| 100 | + } | ||
| 94 | if(!empty($cate_arr) && is_array($cate_arr)){ | 101 | if(!empty($cate_arr) && is_array($cate_arr)){ |
| 95 | foreach ($cate_arr as $v){ | 102 | foreach ($cate_arr as $v){ |
| 96 | $categoryModel = new Category(); | 103 | $categoryModel = new Category(); |
| @@ -99,7 +106,7 @@ class UpdateProductCategory extends Command | @@ -99,7 +106,7 @@ class UpdateProductCategory extends Command | ||
| 99 | $cateRelatedModel = new CategoryRelated(); | 106 | $cateRelatedModel = new CategoryRelated(); |
| 100 | $cateRelatedModel->del(['cate_id'=>$v]); | 107 | $cateRelatedModel->del(['cate_id'=>$v]); |
| 101 | continue; | 108 | continue; |
| 102 | - }else{ | 109 | + } |
| 103 | //更新关联表 | 110 | //更新关联表 |
| 104 | $cateRelatedModel = new CategoryRelated(); | 111 | $cateRelatedModel = new CategoryRelated(); |
| 105 | $relateInfo = $cateRelatedModel->read(['product_id'=>$id,'cate_id'=>$v]); | 112 | $relateInfo = $cateRelatedModel->read(['product_id'=>$id,'cate_id'=>$v]); |
| @@ -109,5 +116,4 @@ class UpdateProductCategory extends Command | @@ -109,5 +116,4 @@ class UpdateProductCategory extends Command | ||
| 109 | } | 116 | } |
| 110 | } | 117 | } |
| 111 | } | 118 | } |
| 112 | - } | ||
| 113 | } | 119 | } |
-
请 注册 或 登录 后发表评论