panlumeng 3 years ago
parent
commit
c04a1ec275
3 changed files with 45 additions and 26 deletions
  1. 31 25
      app/admin/controller/Exclusive.php
  2. 1 1
      app/admin/controller/Suppler.php
  3. 13 0
      app/common.php

+ 31 - 25
app/admin/controller/Exclusive.php

@@ -102,35 +102,41 @@ class Exclusive extends Base
     }
 
     public function query(){
-        $where =[["is_del","=",0]];
-        $cat_name=isset($this->post['name']) && $this->post['name'] !==""? trim($this->post['name']) :"";
+//        $where =[["is_del","=",0]];
+//        $cat_name=isset($this->post['name']) && $this->post['name'] !==""? trim($this->post['name']) :"";
+//        if($cat_name!==""){
+//            $where[]=['name',"like","%$cat_name%"];
+//        }
+//        $pid=isset($this->post['pid']) && $this->post['pid'] !==""? intval($this->post['pid']) :"";
+//        if($pid!==""){
+//            $where[]=['pid',"=",$pid];
+//        }
+//        $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
+//        if($status!==""){
+//            $where[]=['status',"=",$status];
+//        }
+//        $level=isset($this->post['level']) && $this->post['level'] !==""? intval($this->post['level']) :"";
+//        if($level!==""){
+//            $where[]=['level',"=",$level];
+//        }
+//        $list = Db::name("exclusive")->where($where)->select();
+//        return app_show(0,"获取成功",$list);
+
+        $where=[["is_del","=",0]];
+        $pid =  isset($this->post['pid']) &&$this->post['pid']!=="" ?intval($this->post['pid']): "0";
+        $where[]=["pid","=",$pid];
+        $cat_name=isset($this->post['cat_name']) && $this->post['cat_name'] !==""? intval($this->post['cat_name']) :"";
         if($cat_name!==""){
-            $where[]=['name',"like","%$cat_name%"];
+            $where[]=['cat_name',"like","%$cat_name%"];
         }
-        $pid=isset($this->post['pid']) && $this->post['pid'] !==""? intval($this->post['pid']) :"";
-        if($pid!==""){
-            $where[]=['pid',"=",$pid];
+        $data = Db::name("exclusive")->where($where)->select();
+        $vmp = [];
+        foreach ($data as $sts){
+            $vmp[]=coco($sts);
         }
-        $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
-        if($status!==""){
-            $where[]=['status',"=",$status];
-        }
-        $level=isset($this->post['level']) && $this->post['level'] !==""? intval($this->post['level']) :"";
-        if($level!==""){
-            $where[]=['level',"=",$level];
-        }
-        $list = Db::name("exclusive")->where($where)->select();
-        return app_show(0,"获取成功",$list);
-//        $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
-//        if($id==""){
-//            return error_show(1002,"参数id不能为空");
-//        }
-//        $idinfo = Db::name('exclusive')->where(['id'=>$id])->find();
-//        if($idinfo==""){
-//            return error_show(1002,"未找到数据");
-//        }
-//        return app_show(0,"获取成功",$idinfo);
+        return app_show(0,"获取成功",$vmp);
     }
+
 //    public function edit(){
 //        $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
 //        if($id==""){

+ 1 - 1
app/admin/controller/Suppler.php

@@ -388,7 +388,7 @@ class Suppler extends BaseController
                 "type"=>$type,
                 "license_img"=>$supplier_img,
                 "is_del"=>0,
-                "status"=>$info['license_img']==$supplier_img ? $info['status']:0,
+               // "status"=>$info['license_img']==$supplier_img ? $info['status']:0,
                 "ticket_type"=>$ticket_type,
                 "updatetime"=>date("Y-m-d H:i:s"),
                 "is_platform"=>$is_platform,

+ 13 - 0
app/common.php

@@ -378,6 +378,19 @@ function stro($data){
     }
     return $data;
 }
+
+function coco($data){
+    $db=Db::name('exclusive')->where(['pid'=>$data['id']])->select()->toArray();
+    if(empty($db)){
+        $data['child']=[];
+        return $data;
+    }
+    foreach ($db as $item) {
+        $data['child'][]=coco($item);
+    }
+    return $data;
+}
+
 function made($var,$data=[]){
     $str = Db::name('cat')->where(['id'=>$var])->find();
     if($str==false){