Browse Source

业务参数的启用、禁用优化

wufeng 2 years ago
parent
commit
5b5e531ed5
1 changed files with 14 additions and 0 deletions
  1. 14 0
      app/admin/controller/Exclusive.php

+ 14 - 0
app/admin/controller/Exclusive.php

@@ -180,6 +180,20 @@ class Exclusive extends Base
                         if (!empty($child_id)) throw new Exception('请先禁用全部子级');
 
                     }
+                }else{
+                    //如果它的兄弟全部禁用的话,连同它的父级也禁用
+                    $normal_c = Db::name('exclusive')
+                        ->field('id')
+                        ->where(['pid' => $res['pid'], 'is_del' => 0, 'status' => 1])
+                        ->where('id', '<>', $param['id'])
+                        ->find();
+
+                    if (empty($normal_c)) {
+                        Db::name('exclusive')
+                            ->where(['id' => $res['pid'], 'status' => 1])
+                            ->update(['status' => 0, 'updatetime' => date('Y-m-d H:i:s')]);
+                    }
+
                 }
 
             }