[ ['name' => 'idlist', 'title' => 'idlist', 'require' => true, 'type' => 'array'], ['name' => 'ispass', 'title' => 'ispass', 'require' => true, 'type' => 'numeric', 'regex' => '/[1|2]{1}/'], ], 'getlistbywhere' => [ ['name' => 'ispass', 'title' => 'ispass', 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'], ['name' => 'companyname', 'title' => 'companyname', 'type' => 'string'], ['name' => 'createdate', 'title' => 'createdate', 'type' => 'array'], ['name' => 'page', 'title' => 'page', 'type' => 'numeric'], ['name' => 'size', 'title' => 'size', 'type' => 'numeric'], ], ]; return $list; } /** * 审核公司 * 20220208 * wj */ public function auditcompany($arr) { $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $ids = $arr['idlist']; if (is_string($ids)) { $ids = [$ids]; } $ispass = $arr['ispass']; $m_c = new companymodel(); $successIds = []; foreach ($ids as $key => $value) { $where = ['id' => $value]; $info = $m_c->getInfo($where); if (empty($info)) { log::error("company_id " . $value . " 无对应企业"); continue; } if ($ispass != $info['ispass']) { $successIds[] = $value; $update = ['ispass' => $ispass]; $m_c->updateinfo($where, $update); } } $data = [ 'successIds' => $successIds, ]; return backarr(1, "操作成功", $data); } /** * 获取公司列表 * 20220208 * wj */ public function getlistbywhere($arr) { $arr = $this->filterarray($arr); $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $where = []; if (isset($arr['ispass'])) { $where[] = ['ispass', '=', $arr['ispass']]; } if (isset($arr['companyname'])) { $where[] = ['companyname', 'like', '%' . $arr['companyname'] . '%']; } if (isset($arr['createdate'])) { $createdate = $arr['createdate']; 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'); if ($count <= 0) { return backarr(0, "无数据"); } $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); $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; } }