[ ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'], ['name' => 'organization_code', 'title' => 'organization_code', 'type' => 'string'], ['name' => 'companyname', 'title' => 'companyname', 'type' => 'string'], ], 'getinfobyid' => [ ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'], ], 'updatebyid' => [ ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'], ], 'getinfowitchinventbyid' => [ ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'], ['name' => 'activestate', 'title' => 'activestate', 'regex' => '/[0|1|2]{1}/'], ], ]; return $list; } /** * 新建信息 * wj * 20220118 */ public function newinfo($arr) { $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $m_u = new usermodel(); $m_c = new companymodel(); $openid = $arr['openid']; $info = $m_u->getinfobyopenid($openid); if (empty($info)) { return backarr(0, "用户不存在"); } /*if (empty($info['is_company'])) { return backarr(0, "非企业用户"); }*/ unset($arr['openid']); $where = []; $cinfo = []; if (isset($arr['organization_code'])) { $where['organization_code'] = $arr['organization_code']; } if (isset($arr['companyname'])) { $where['companyname'] = $arr['companyname']; } if (empty(!$where)) { $cinfo = $m_c->getinfo($where, ['id']); } if (empty($cinfo)) { $id = $m_c->insertData($arr); } else { $id = $cinfo['id']; } $updateDate = ['company_id' => $id]; $row = $m_u->updatebyid($info['id'], $updateDate); return backarr(1, "新增成功", ['id' => $id]); } /** * 根据id获取企业信息 * wj * 20220118 */ public function getinfobyid($arr) { $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $id = $arr['id']; $m_c = new companymodel(); $info = $m_c->getinfobyid($id); if (empty($info)) { return backarr(0, "无数据"); } return backarr(1, "获取成功", $info); } /** * 根据id获取企业信息包括岗位 * wj * 20220119 */ public function getinfowitchinventbyid($arr) { $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $id = $arr['id']; $m_c = new companymodel(); $info = $m_c->getinfobyid($id); if (empty($info)) { return backarr(0, "无数据"); } $info = $this->formatinfo($info); $m_i = new inventmodel(); $where = ['company_id' => $info['id']]; if (isset($arr['activestate'])) { $where['active_state'] = $arr['activestate']; } $ilist = $m_i->getlist($where, "*", 1, 0); $info['invent_list'] = $ilist; return backarr(1, "获取成功", $info); } /** * 根据id修改企业信息 * wj * 20220118 */ public function updatebyid($arr) { $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $id = $arr['id']; unset($arr['id']); $m_c = new companymodel(); $row = $m_c->updatebyid($id, $arr); if (empty($row)) { return backarr(0, "修改失败"); } return backarr(1, "获取成功", ['id' => $id]); } /** * 获取本次活动全部公司总数 * 20220122 * wj */ public function getcountbyparty($arr) { $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $partyid = $arr['partyid']; $m_c = new companymodel(); $count = $m_c->getcountbyparty($partyid); return backarr(1, "获取成功", $count); } /** * 格式化 公司信息 仅小程序使用 */ 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; } }