panlumeng 3 tahun lalu
induk
melakukan
08b9ad433a

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

@@ -47,6 +47,9 @@ class Exclusive extends Base
             return error_show(1002, "专属类型名称已存在");
         }
         $pid =isset($this->post['pid'])&&$this->post['pid']!=="" ? intval($this->post['pid']):0;
+        if($pid==""){
+            return error_show(1002,"父级id不能为空");
+        }
         $level=1;
         $search = $name;
         if($pid!==0){
@@ -86,23 +89,68 @@ class Exclusive extends Base
     }
 
     public function  status(){
-            $id=isset($this->post['id'])&&$this->post['id']!=="" ? intval($this->post['id']):"";
-            if($id===""){
-                return error_show(1004,"参数id不能为空");
-            }
-            $exclusive=Db::name("exclusive")->where(["id"=>$id,"is_del"=>0])->find();
-            if($exclusive==false){
-                return error_show(1004,"未找到数据");
+//            $id=isset($this->post['id'])&&$this->post['id']!=="" ? intval($this->post['id']):"";
+//            if($id===""){
+//                return error_show(1004,"参数id不能为空");
+//            }
+//            $exclusive=Db::name("exclusive")->where(["id"=>$id,"is_del"=>0])->find();
+//            if($exclusive==false){
+//                return error_show(1004,"未找到数据");
+//            }
+//            $msg = $exclusive['status']==0? "启用":"禁用";
+//            $exclusive['status'] = $exclusive['status']==0?1:0;
+//            $exclusive['updatetime'] =date("Y-m-d H:i:s");
+//            $in =Db::name("exclusive")->save($exclusive);
+//            if($in){
+//                return app_show(0,"{$msg}成功");
+//            }else{
+//                return error_show(1004,"{$msg}失败");
+//            }
+        $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
+        if($id===""){
+            return error_show(1002,"参数id不能为空");
+        }
+        $stn = Db::name('exclusive')->where(['id'=>$id])->find();
+        if(empty($stn)){
+            return error_show(1002,"未找到商品数据");
+        }
+        $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
+        if($status===""){
+            return error_show(1002,"参数status不能为空");
+        }
+        if ($stn['level']==2) {
+            if($status==1){
+                $can = mai($stn['id']);
+                $cat=array_column($can,'id');
+            }else{
+                $cat =$stn['id'];
             }
-            $msg = $exclusive['status']==0? "启用":"禁用";
-            $exclusive['status'] = $exclusive['status']==0?1:0;
-            $exclusive['updatetime'] =date("Y-m-d H:i:s");
-            $in =Db::name("exclusive")->save($exclusive);
-            if($in){
-                return app_show(0,"{$msg}成功");
+            // return error_show(1002, "所在级别不能启用");
+        }
+        if($stn['level']==1){
+            if($status==1){
+                return error_show(1002,"所在等级不能启用");
             }else{
-                return error_show(1004,"{$msg}失败");
+                $db= Db::name('exclusive')->where(['pid'=>$stn['id'],'status'=>1,'is_del'=>0])->count();
+                if($db==0){
+                    $cat = $stn['id'];
+                }else{
+                    return error_show(1002,"子级分类未禁用");
+                }
             }
+        }
+        // $pd= $stn['status'];
+        $it=[];
+        $it['status']=$status;
+        $it['updatetime']=date("Y-m-d H:i:s");
+        $str = Db::name('exclusive')->where(['id'=>$cat,'is_del'=>0])->save($it);
+        if($str){
+//        $order = ["order_code"=>$id,"status"=>$pd,"action_remark"=>'',"action_type"=>"edit"];
+//        ActionLog::logAdd($this->post['token'],$order,"sxd",$stn['status'],$order);
+            return error_show(0,"状态更新成功");
+        }else{
+            return error_show(1002,"状态更新失败");
+        }
     }
 
     public function query(){
@@ -150,11 +198,17 @@ class Exclusive extends Base
         if($info==""){
             return error_show(1002,"未找到数据");
         }
+        if($info['status']===1){
+            return error_show(1004,"启用状态不可编辑");
+        }
         $name = isset($this->post['name'])&&$this->post['name']!=""? trim($this->post['name']):"";
         if($name==""){
             return error_show(1004,"参数name不能为空");
         }
         $pid =isset($this->post['pid'])&&$this->post['pid']!=="" ? intval($this->post['pid']):0;
+        if($pid==""){
+            return error_show(1004,"参数pid不能为空");
+        }
         $level=1;
         $search = $name;
         if($pid!==0){

+ 4 - 0
app/admin/controller/Title.php

@@ -19,6 +19,10 @@ class Title extends BaseController
         if($companyNo==""){
             return error_show(1002,"参数companyNo不能为空");
         }
+        $companyinfo =Db::name('customer_title')->where(['is_del' => 0, 'companyNo'=>$companyNo])->find();
+        if (!empty($companyinfo)) {
+            return error_show(1002, "统一社会信用代码名称已存在");
+        }
         $invoice_title = isset($this->post['invoice_title']) && $this->post['invoice_title'] !=="" ? trim($this->post['invoice_title']):"";
         if($invoice_title==""){
             return error_show(1002,"参数invoice_title不能为空");

+ 1 - 0
app/admin/route/app.php

@@ -445,4 +445,5 @@ Route::rule("excluadd","admin/Exclusive/add");
 Route::rule("exclustatus","admin/Exclusive/status");
 Route::rule("excluquery","admin/Exclusive/query");
 Route::rule("excludel","admin/Exclusive/delete");
+Route::rule("excluedit","admin/Exclusive/edit");
 

+ 18 - 0
app/common.php

@@ -391,6 +391,24 @@ function coco($data){
     return $data;
 }
 
+function mai($var,$data=[]){
+    $str = Db::name('exclusive')->where(['id'=>$var])->find();
+    if($str==false){
+        return [];
+    }
+    $vmn =[];
+    $vmn['id'] =$str['id'];
+    $vmn['rname'] =$str['name'];
+    array_unshift($data,$vmn);
+    // $var['id']=made();
+    if($str['pid']==0){
+        // krsort($data);
+        return $data;
+    }else{
+        return mai($str['pid'],$data);
+    }
+}
+
 function made($var,$data=[]){
     $str = Db::name('cat')->where(['id'=>$var])->find();
     if($str==false){