getInfo(['userid' => $userid, 'isactive' => 1], ['id']); if (!empty($cinfo)) { return backarr(0, "用户id已存在"); } $uinfo = $m_u->getInfo(['id' => $userid], 'id'); if (empty($uinfo)) { return backarr(0, "无数据"); } //tel 去重 if (isset($info['telno']) && !empty($info['telno'])) { $telno = $info['telno']; $cinfo = $m_c->getInfo(['telno' => $telno, 'isactive' => 1], ['id']); if ($cinfo) { return backarr(0, "手机号已存在"); } } if (!isset($info['createtime']) || empty($info['createtime'])) { $info['createtime'] = date('Y-m-d H:i:s', time()); } $id = $m_c->insertData($info); if (!$id) { return backarr(0, "操作失败"); } return backarr(1, "操作成功", ['id' => $id]); } /** * 改详细信息 * 20211221 * wj */ public function updateinfo($arr) { if (!isset($arr['id']) || empty($arr['id'])) { return backarr(0, "请求失败"); } $m_c = new companymodel(); $m_u = new userinfomodel(); $id = $arr['id']; $where = ['id' => $id]; $cinfo = $m_c->getInfo($where); if (empty($cinfo)) { return backarr(0, "无数据"); } $updateField = ['company', 'legalperson', 'telno']; $updateData = []; if (isset($arr['company']) && $cinfo['company'] != $arr['company']) { $updateData['company'] = $arr['company']; } if (isset($arr['legalperson']) && $cinfo['legalperson'] != $arr['legalperson']) { $updateData['legalperson'] = $arr['legalperson']; } if (isset($arr['telno']) && $cinfo['telno'] != $arr['telno']) { $telno = $arr['telno']; if (!isMoblid($telno)) { return backarr(0, "手机号格式错误"); } $ccinfo = $m_c->getInfo(['telno' => $telno, 'isactive' => 1]); if (!empty($ccinfo)) { return backarr(0, "手机号已存在"); } //$uupateData = ['telno' => $telno]; //$uwhere = ['id' => $cinfo['userid']]; //$uinfo = $m_u->getInfo($uwhere); //$row = $m_u->updateinfo($uwhere, $uupateData); /*$enterprisename = isset($updateData['company']) ? $updateData['company'] : $uinfo['enterprisename']; if (empty($uinfo)) { $insertData = [ 'telno' => $telno, 'enterprisename' => $enterprisename, ]; $userid = $m_u->insertData($insertData); } else { $userid = $uinfo['id']; }*/ /*if (empty($row)) { return backarr(0, "用户信息修改失败"); }*/ $updateData['telno'] = $telno; } if (empty($updateData)) { return backarr(0, "无修改数据"); } $row = $m_c->updateinfo($where, $updateData); if (!$row) { return backarr(0, "操作失败"); } return backarr(1, "操作成功", ['id' => $id]); } /** * 获取信息根据id * 20211221 * wj */ public function getinfobyid($arr) { if (!isset($arr['id']) || empty($arr['id'])) { return backarr(0, "请求失败"); } $id = $arr['id']; $m_c = new companymodel(); $where = ['id' => $id]; $cinfo = $m_c->getInfo($where); if (empty($cinfo)) { return backarr(0, "无数据"); } return backarr(1, "操作成功", $cinfo); } /** * 获取信息根据userid * 20211221 * wj */ public function getinfobyuserid($arr) { if (!isset($arr['userid']) || empty($arr['userid'])) { return backarr(0, "请求失败"); } $userid = $arr['userid']; $m_c = new companymodel(); $where = ['userid' => $userid]; $cinfo = $m_c->getInfo($where); if (empty($cinfo)) { return backarr(0, "无数据"); } return backarr(1, "操作成功", $cinfo); } /** * 修改ispass根据id * 20211221 * wj */ public function updateispassbyid($arr) { if (!isset($arr['idlist']) || empty($arr['idlist']) || !is_array($arr['idlist']) || !isset($arr['ispass']) || !in_array($arr['ispass'], [1, 2])) { return backarr(0, "请求失败"); } $idlist = $arr['idlist']; $ispass = $arr['ispass']; $m_c = new companymodel(); $where = ['id' => ['in', $idlist], 'isactive' => 1]; switch ($ispass) { case 1: $where['ispass'] = ['in', [0, 2]]; break; case 2: $where['ispass'] = ['in', [0]]; break; } /*$cinfo = $m_c->getInfo($where); if (empty($cinfo)) { return backarr(0, "无数据"); } $updateData = []; if (in_array($cinfo['ispass'], [0, 2]) && 1 == $ispass) { $updateData['ispass'] = $ispass; } elseif (in_array($cinfo['ispass'], [0]) && 2 == $ispass) { $updateData['ispass'] = $ispass; } if (empty($updateData)) { return backarr(0, "无修改数据"); }*/ $updateData = [ 'ispass' => $ispass, 'passtime' => date('Y-m-d H:i:s'), ]; $row = $m_c->updateinfo($where, $updateData); if (!$row) { return backarr(0, "操作失败"); } return backarr(1, "操作成功", ['idlist' => $idlist, 'ispass' => $ispass]); } /** * 修改isactive根据id * 20211221 * wj */ public function updateisactivebyid($arr) { if (!isset($arr['id']) || empty($arr['id']) || !isset($arr['isactive']) || !in_array($arr['isactive'], [0, 1])) { return backarr(0, "请求失败"); } $id = $arr['id']; $isactive = $arr['isactive']; $m_c = new companymodel(); $where = ['id' => $id]; $cinfo = $m_c->getInfo($where); if (empty($cinfo)) { return backarr(0, "无数据"); } $updateData = []; if ($isactive !== $cinfo['isactive']) { $updateData['isactive'] = $isactive; } if (empty($updateData)) { return backarr(1, "无修改", ['id' => $id]); } $row = $m_c->updateinfo($where, $updateData); if (!$row) { return backarr(0, "操作失败"); } return backarr(1, "操作成功", ['id' => $id, 'isactive' => $isactive]); } /*** * 获取列表 * 20211221 * wj */ public function getlistbywhere($arr) { $m_c = new companymodel(); $m_u = new userinfomodel(); $where = []; if (isset($arr['company']) && !empty($arr['company'])) { $where['company'] = $arr['company']; } if (isset($arr['wname']) && !empty($arr['wname'])) { $where['wname'] = $arr['wname']; } if (isset($arr['telno']) && !empty($arr['telno'])) { $where['telno'] = $arr['telno']; } if (isset($arr['isactive']) && is_numeric($arr['isactive']) && in_array($arr['isactive'], [0, 1])) { $where['isactive'] = $arr['isactive']; } if (isset($arr['ispass']) && is_numeric($arr['ispass']) && in_array($arr['ispass'], [0, 1, 2])) { $where['ispass'] = $arr['ispass']; } if (isset($arr['createtime']) && is_array($arr['createtime'])) { $createtime = array_filter($arr['createtime']); if (2 == count($createtime)) { $where['createtime'] = $arr['createtime']; } } $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1; $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10; $count = $m_c->getList($where, 'count'); if ($count <= 0) { return backarr(0, "无数据"); } $list = $m_c->getList($where, '*', $page, $size); foreach ($list as $key => &$value) { $uinfo = $m_u->getInfo(['id' => $value['userid']], 'wname'); if (empty($uinfo)) { $list[$key]['wname'] = ''; } else { $list[$key]['wname'] = $uinfo['wname']; } } $data = [ 'count' => $count, 'list' => $list, ]; return backarr(1, "查询成功", $data); } }