wugg 2 years ago
parent
commit
a4f2602636

+ 8 - 0
app/admin/controller/Brand.php

@@ -20,6 +20,10 @@ class Brand extends Base
         if($brand_name==""){
             return error_show(1002,"参数brand_name不能为空");
         }
+
+        $brandisT=Db::name("brand")->where(["brand_name"=>$brand_name,"is_del"=>0])->findOrEmpty();
+        if(!empty($brandisT))return error_show(1002,"品牌名称已存在");
+
         $logo_url= isset($this->post['logo_url'])  && $this->post['logo_url'] !=="" ? trim($this->post['logo_url']):"";
 //        if($logo_url==""){
 //            return error_show(1002,"参数logo_url不能为空");
@@ -32,6 +36,7 @@ class Brand extends Base
         if(empty($user)||$user['code']!=0){
             return error_show(102,"创建人数据不存在");
         }
+
         $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
         $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
         $status = isset($this->post['status']) &&$this->post['status'] !==""? intval($this->post['status']):"1";
@@ -130,6 +135,9 @@ class Brand extends Base
         if($brand_name==""){
             return error_show(1002,"参数brand_name不能为空");
         }
+        $brandisT=Db::name("brand")->where(["brand_name"=>$brand_name,"is_del"=>0])->where("id","<>",$id)
+        ->findOrEmpty();
+        if(!empty($brandisT))return error_show(1002,"品牌名称已存在");
         $logo_url= isset($this->post['logo_url'])  && $this->post['logo_url'] !=="" ? trim($this->post['logo_url']):"";
 //        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
 //        if($token==''){

+ 2 - 1
app/admin/controller/Cat.php

@@ -23,7 +23,7 @@ class Cat extends Base
 
         if ($param['cat_name'] !== '') $where[] = ['cat_name', 'like', '%' . $param['cat_name'] . '%'];
 
-        $data = Db::name('cat')->where($where)->cursor();
+        $data = Db::name('cat')->where($where)->order("id desc")->cursor();
         $vmp = [];
         foreach ($data as $sts) {
             $vmp[] = stro($sts);
@@ -149,6 +149,7 @@ class Cat extends Base
             ->alias('c')
             ->where($where)
             ->page($param['page'], $param['size'])
+            ->order("id desc")
             ->select()
             ->toArray();
         $var = [];

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

@@ -97,7 +97,7 @@ class Customer extends Base
             ->alias('co')
             ->where($condition)
             ->order("co.addtime",'desc')
-            ->column("co.id,co.pid,co.name,co.level,co.depart_link,co.creater,co.addtime,co.status");
+            ->column("co.id,co.pid,co.name,co.level,co.depart_link,co.creater,co.createrid,co.addtime,co.status");
 
         $all_createrid = array_column($list,'createrid');
         $all_item = get_company_name_by_uid($all_createrid);

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

@@ -66,7 +66,7 @@ class Exclusive extends Base
             return error_show(1002, "专属类型名称已存在");
         }
         $pid =isset($this->post['pid'])&&$this->post['pid']!=="" ? intval($this->post['pid']):0;
-        if($pid==""){
+        if($pid===""){
             return error_show(1002,"父级id不能为空");
         }
         $level=1;

+ 4 - 4
app/admin/controller/Keepbrand.php

@@ -15,9 +15,9 @@ class Keepbrand extends Base
     }
     public function create(){
         $brand_book = isset($this->post['brand_book']) && $this->post['brand_book'] !=="" ? trim($this->post['brand_book']):"";
-        if($brand_book==""){
-            return error_show(1003,"参数brand_book不能为空");
-        }
+//        if($brand_book==""){
+//            return error_show(1003,"参数brand_book不能为空");
+//        }
         $gyscode = isset($this->post['gyscode']) && $this->post['gyscode'] !=="" ? trim($this->post['gyscode']):"";
         if($gyscode==""){
             return error_show(1003,"参数gyscode不能为空");
@@ -26,7 +26,7 @@ class Keepbrand extends Base
         if($brand_id==""){
             return error_show(1003,"参数brand_id不能为空");
         }
-        $rename = Db::name('brand_book')->where(['brand_id' => $brand_id,'is_del' => 0])->find();
+        $rename = Db::name('brand_book')->where(['brand_id' => $brand_id,"gyscode"=>$gyscode,'is_del' => 0])->find();
         if (!empty($rename)) {
             return error_show(1002, "品牌名称已存在");
         }

+ 10 - 5
app/admin/controller/Role.php

@@ -33,12 +33,12 @@ class Role extends Base
         isset($post['role_name']) && $post['role_name'] !== "" ? $condition[] = ['a.role_name', "like", "%" . $post['role_name'] . "%"] : "";
         isset($post['relaComNo']) && $post['relaComNo'] !== "" ? $condition[] = ["a.companyNo", "=", $post['relaComNo']] : "";
         isset($post['companyNo']) && $post['companyNo'] !== "" ? $condition[] = ["a.companyNo", "=", $post['companyNo']] : "";
-        isset($post['companyName']) && $post['companyName'] !== "" ? $condition[] = ["b.name", "like", "%{$post['companyName']}%"] : "";
+//        isset($post['companyName']) && $post['companyName'] !== "" ? $condition[] = ["b.name", "like", "%{$post['companyName']}%"] : "";
         isset($post['level']) && $post['level'] !== "" ? $condition[] = ["a.role_level", "=", $post['level']] : "";
 
         $count = Db::name("role")
             ->alias("a")
-            ->leftJoin("supplier_info b", "a.companyNo=b.code")
+//            ->leftJoin("supplier_info b", "a.companyNo=b.code")
             ->where($condition)
             ->count('a.id');
         $page = isset($post['page']) ? intval($post['page']) : 1;
@@ -46,15 +46,20 @@ class Role extends Base
         $page >= ceil($count / $size) ? $page = (int)ceil($count / $size) : "";
         $list = Db::name("role")
             ->alias("a")
-            ->leftJoin("supplier_info b", "a.companyNo=b.code")
+//            ->leftJoin("supplier_info b", "a.companyNo=b.code")
             ->leftJoin("role_action t", "a.id=t.role_id")
-            ->field("a.*,b.name as companyName,t.action_conllect as action,t.action_data")
+            ->field("a.*,t.action_conllect as action,t.action_data")
             ->order("a.addtime desc")
             ->where($condition)
             ->page($page, $size)
             ->select()
             ->toArray();
-
+        $userComon=new \app\admin\common\User();
+        $supplier =$userComon->handle("getCodeAndName",["code"=>array_column($list,"companyNo")]);
+        $supplierArr=$supplier['data']??[];
+        foreach ($list as &$value){
+        	$value['companyName'] = $supplierArr[$value['companyNo']]??"";
+        }
         return app_show(0, "获取成功", ["list" => $list, "count" => $count]);
     }
 

+ 13 - 33
app/common.php

@@ -1,7 +1,7 @@
 <?php
 // 应用公共文件
 
-use think\facade\Config;
+use app\admin\common\User as CommonUser;use think\facade\Config;
 use think\facade\Db;
 use think\facade\Filesystem;
 use think\helper\Str;
@@ -115,7 +115,7 @@ function VerifyTokens($token){
 //    ];
 //    $response=curl_request($url,$data);
 
-    $userCommon = new \app\admin\common\User();
+    $userCommon = new CommonUser();
     $rs = $userCommon->VerifyTokens(['token'=>$token]);
 
     return json_decode($rs,true);
@@ -128,13 +128,8 @@ function VerifyTokens($token){
  * @return mixed
  */
 function GetUserlist($token,$condition){
-    $host = Config::get("app");
-
-    $url = $host["api_host"]."/Api/getuserlist";
-    $condition['token']=$token;
-    $response=curl_request($url,$condition);
-
-    return json_decode($response,true);
+    $userCommon = new CommonUser();
+    return json_decode($userCommon->GetUserlist($condition), true);
 }
 
 /**
@@ -143,23 +138,13 @@ function GetUserlist($token,$condition){
  * @return mixed
  */
 function GetAccountall($token, $condition){
-    $host = Config::get("app");
-
-    $url = $host["api_host"]."/Api/userall";
-    $condition['token']=$token;
-    $response=curl_request($url,$condition);
-
-    return json_decode($response,true);
+    $userCommon = new CommonUser();
+    return json_decode($userCommon->GetAccountall($condition), true);
 }
 
-function GetList($token,$condition){
-    $host = Config::get("app");
-
-    $url = $host["api_host"]."/Api/userlist";
-    $condition['token']=$token;
-    $response=curl_request($url,$condition);
-
-    return json_decode($response,true);
+function GetList($condition){
+    $userCommon = new CommonUser();
+    return json_decode($userCommon->GetUserlist($condition), true);
 }
 
 /**
@@ -168,18 +153,13 @@ function GetList($token,$condition){
  * @return mixed
  */
 function GetInfoById($token,$condition){
-    $host = Config::get("app");
-    $url = $host["api_host"]."/Api/userinfobyid";
-    $condition['token']=$token;
-    $response=curl_request($url,$condition);
-    return json_decode($response,true);
+    $userCommon = new CommonUser();
+    return json_decode($userCommon->GetUserInfo($condition), true);
 }
 
 function GetInfoNoToken($condition){
-    $host = Config::get("app");
-    $url = $host["api_host"]."/Api/uinfo";
-    $response=curl_request($url,$condition);
-    return json_decode($response,true);
+    $userCommon = new CommonUser();
+    return json_decode($userCommon->GetUserInfo($condition), true);
 }
 
 function makeNo($str){