wang jun vor 3 Jahren
Ursprung
Commit
335d4b5451

+ 15 - 0
application/admin/controller/Company.php

@@ -50,4 +50,19 @@ class Company extends AdminBase
         }
         return backjson2(200, $result['msg'], $result['data']);
     }
+    /**
+     * 根据id获取企业信息
+     * 20220209
+     * wj
+     */
+    public function getinfobyid()
+    {
+        $param = request()->param();
+        $l_c = new companylogic();
+        $result = $l_c->getinfobyid($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200, $result['msg'], $result['data']);
+    }
 }

+ 18 - 2
application/admin/logic/baselogic.php

@@ -47,7 +47,7 @@ class baselogic
                     }
                     $paramvalue = $param[$name];
                     //类型
-                    if (isset($value['type'])) {
+                    if (isset($value['type']) && $paramvalue != "") {
                         $tpe = $value['type'];
                         switch ($tpe) {
                             case 'string':
@@ -78,7 +78,7 @@ class baselogic
                         }
                     }
                     //正则
-                    if (isset($value['regex'])) {
+                    if (isset($value['regex']) && $paramvalue != "") {
                         $regex = $value['regex'];
                         if (!preg_match($regex, $paramvalue)) {
                             throw new \Exception($title . '正则格式错误');
@@ -103,4 +103,20 @@ class baselogic
     {
         return [];
     }
+    /**
+     * 过滤空数组
+     *
+     * @return void
+     */
+    protected function filterarray($arr)
+    {
+        $newArr = [];
+        foreach ($arr as $key => $value) {
+            if (is_string($value) && $value == "") {
+                continue;
+            }
+            $newArr[$key] = $value;
+        }
+        return $newArr;
+    }
 }

+ 59 - 5
application/admin/logic/companylogic.php

@@ -21,7 +21,7 @@ class companylogic extends baselogic
     {
         $list = [
             'auditcompany' => [
-                ['name' => 'ids', 'title' => 'id', 'require' => true, 'type' => 'array'],
+                ['name' => 'idlist', 'title' => 'idlist', 'require' => true, 'type' => 'array'],
                 ['name' => 'ispass', 'title' => 'ispass', 'require' => true, 'type' => 'numeric', 'regex' => '/[1|2]{1}/'],
             ],
             'getlistbywhere' => [
@@ -45,7 +45,7 @@ class companylogic extends baselogic
         if (1 != $result['status']) {
             return $result;
         }
-        $ids = $arr['ids'];
+        $ids = $arr['idlist'];
         if (is_string($ids)) {
             $ids = [$ids];
         }
@@ -77,6 +77,7 @@ class companylogic extends baselogic
      */
     public function getlistbywhere($arr)
     {
+        $arr = $this->filterarray($arr);
         $result = $this->checkparam(__FUNCTION__, $arr);
         if (1 != $result['status']) {
             return $result;
@@ -90,8 +91,10 @@ class companylogic extends baselogic
         }
         if (isset($arr['createdate'])) {
             $createdate = $arr['createdate'];
-            $where[] = ['create_time', '>=', $createdate[0]];
-            $where[] = ['create_time', '<=', $createdate[1]];
+            if (count($createdate) == count(array_filter($createdate))) {
+                $where[] = ['create_time', '>=', $createdate[0]];
+                $where[] = ['create_time', '<=', $createdate[1]];
+            }
         }
         $m_c = new companymodel();
         $count = $m_c->getList($where, 'count');
@@ -101,6 +104,57 @@ class companylogic extends baselogic
         $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
         $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
         $list = $m_c->getList($where, '*', $page, $size);
-        return backarr(1, "查询成功", $list);
+        $data = [
+            'list' => $list,
+            'total' => $count,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+    /**
+     * 根据id获取企业信息
+     * 20220209
+     * wj
+     */
+    public function getinfobyid($arr)
+    {
+        $arr = $this->filterarray($arr);
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $where = [];
+        $id = $arr['id'];
+        $where['id'] = $id;
+        $m_c = new companymodel();
+        $info = $m_c->getInfo($where);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $info = $this->formatinfo($info);
+        return backarr(1, "success", $info);
+    }
+    /**
+     * 格式化企业信息
+     * 20220209
+     * wj
+     */
+    private function formatinfo($info)
+    {
+        if (isset($info['enterprisephoto']) && is_string($info['enterprisephoto'])) {
+            if (!empty($info['enterprisephoto'])) {
+                $jsonArr = json_decode($info['enterprisephoto'], true);
+                /*$pregstr = '/^(http:\/\/*)|(https:\/\/*)/';
+                foreach ($jsonArr as $key => $value) {
+                $matchResult = preg_match($pregstr, $value, $matchArr);
+                if ($matchResult) {
+                foreach ($matchArr as $mkey => $mvalue) {
+                $jsonArr[$key] = str_replace($mvalue, "", $value);
+                }
+                }
+                }*/
+                $info['enterprisephoto'] = $jsonArr;
+            }
+        }
+        return $info;
     }
 }

+ 2 - 2
application/admin/logic/webuserloglogic.php

@@ -70,10 +70,10 @@ class webuserloglogic
         $where = [];
         if (isset($arr['type']) && !empty($arr['type'])) {
             $type = explode(',', $arr['type']);
-            $where['type'] = ['in', $type];
+            $where[] = ['type', 'in', $type];
         }
         if (isset($arr['refid']) && !empty($arr['refid']) && is_numeric($arr['refid'])) {
-            $where['refid'] = $arr['refid'];
+            $where[] = ['refid', '=', $arr['refid']];
         }
         $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
         $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;

+ 1 - 1
application/admin/model/companymodel.php

@@ -75,7 +75,7 @@ class companymodel extends Model
                 $data = $sqlObj->select();
             }
         } else {
-            $data = $sqlObj = $sqlObj->count();
+            $data = $sqlObj->count();
         }
         return $data;
     }

+ 1 - 1
application/admin/model/webuserlogmodel.php

@@ -54,7 +54,7 @@ class webuserlogmodel extends Model
                 $data = $sqlObj->select();
             }
         } else {
-            $data = $sqlObj = $sqlObj->count();
+            $data = $sqlObj->count();
         }
         return $data;
     }