123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-09-03 15:18:25
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-11-10 17:41:01
- */
- namespace app\index\logic;
- use app\index\model\companymodel;
- use app\index\model\smscoderecordmodel;
- use app\index\model\userinfomodel;
- use app\index\model\workermodel;
- class loginlogic
- {
- private function checkwechatlogin($loginfo)
- {
- if (!isset($loginfo['unionid']) || empty($loginfo['unionid'])) {
- return false;
- }
- return true;
- }
- //短信登录
- /*
- * 20210908
- * edit by steelxu
- * 如果短信验证成功应当返回用户数据
- */
- public function smslogin($loginfo)
- {
- $m_sc = new smscoderecordmodel();
- $m_u = new userinfomodel();
- $m_w = new workermodel();
- $checkResult = $this->checksmslogin($loginfo);
- if (!$checkResult) {
- return backarr(-1, '请求数据错误');
- }
- $tel = $loginfo['tel'];
- $smscode = $loginfo['smscode'];
- $searchData = [
- 'tel' => $tel,
- 'smscode' => $smscode,
- ];
- $sccInfo = $m_sc->getinfo($searchData);
- if ($sccInfo) {
- $m_sc->deletebyid($sccInfo['id']);
- $uInfo = $m_u->getInfo(['telno' => $tel]);
- if (empty($uInfo['isactive'])) {
- return backarr(0, '用户状态不可用');
- }
- if (!$uInfo) {
- $insertinfo['telno'] = $tel;
- $id = $m_u->insertData($insertinfo);
- $info = [
- 'id' => $id,
- 'gender' => '',
- 'telno' => $tel,
- 'wname' => '',
- 'isactive' => '1',
- 'labid' => 0,
- 'sfzid' => false,
- 'company' => [], //非企业用户
- ];
- //worderinsert
- $winsertInfo = [
- 'userid' => $id,
- 'telno' => $tel,
- ];
- $wid = $m_w->insertData($winsertInfo);
- //return backarr(2, '未注册');
- return backarr(1, '登录成功', $info);
- } else {
- //$m_sc->deletebyid($sccInfo['id']);
- $m_c = new companymodel();
- $cinfo = $m_c->getInfo(['userid' => $uInfo['id'], 'isactive' => 1], ['id', 'company']);
- $info = array();
- $info['id'] = $uInfo['id'];
- $info['gender'] = $uInfo['gender'];
- $info['telno'] = $uInfo['telno'];
- $info['wname'] = $uInfo['wname'];
- $info['isactive'] = strval($uInfo['isactive']);
- $info['labid'] = $uInfo['labid'];
- $info['sfzid'] = empty($uInfo['sfzid']) ? false : true;
- $info['company'] = empty($cinfo) ? [] : $cinfo;
- return backarr(1, '登录成功', $info);
- }
- } else {
- return backarr(0, '登录失败');
- }
- }
- private function checksmslogin($loginfo)
- {
- $fillFiled = ['tel', 'smscode'];
- foreach ($fillFiled as $value) {
- if (!isset($loginfo[$value]) || empty($loginfo[$value]) || !is_numeric($loginfo[$value])) {
- return false;
- }
- }
- return true;
- }
- }
|