Procházet zdrojové kódy

[智价云] 补充商品分类&公司分类删除规则

tangyuanwang před 2 měsíci
rodič
revize
c09f32ec63

+ 5 - 1
app/Http/Controllers/Manager/WashConfig/CompanyCategory.php

@@ -211,12 +211,16 @@ class CompanyCategory extends Controller
      * @date      2025-12-19
      * 
      */
-    public function delete(Request $request, CompanyCategoryModel $CompanyCategoryModel)
+    public function delete(Request $request, CompanyCategoryModel $CompanyCategoryModel,ViolationStoreModel $ViolationStoreModel)
     {
         // 验证参数
         $request->scene('delete')->validate();
         // 接收数据
         $id = request('id', 0);
+        $violation_store_count = $ViolationStoreModel->where(['category_id' => $id])->count();
+        if ($violation_store_count > 0) {
+            return json_send(['code' => 'error', 'msg' => '该分类下存在公司配置,删除失败']);
+        }
         // 查询用户
         $where = ['id' => $id];
         // 执行删除

+ 9 - 1
app/Http/Controllers/Manager/WashConfig/ProductCategory.php

@@ -215,12 +215,20 @@ class ProductCategory extends Controller
      * @date      2025-12-18
      * 
      */
-    public function delete(Request $request, ProductCategoryModel $ProductCategoryModel)
+    public function delete(Request $request, ProductCategoryModel $ProductCategoryModel,LowPriceGoodsModel $LowPriceGoodsModel,ViolationProductModel $ViolationProductModel)
     {
         // 验证参数
         $request->scene('delete')->validate();
         // 接收数据
         $id = request('id', 0);
+        $low_price_goods_count = $LowPriceGoodsModel->where(['category_id' => $id])->count();
+        if ($low_price_goods_count > 0) {
+            return json_send(['code' => 'error', 'msg' => '该分类下存在低价商品配置,删除失败']);
+        }
+        $violation_product_count = $ViolationProductModel->where(['category_id' => $id])->count();
+        if ($violation_product_count > 0) {
+            return json_send(['code' => 'error', 'msg' => '该分类下存在禁止商品配置,删除失败']);
+        }
         // 查询用户
         $where = ['id' => $id];
         // 执行删除