Exemplo n.º 1
0
 public function indexAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $tTime = time();
     if (empty($pPhone)) {
         Tool_Fnc::ajaxMsg('请输入手机号码');
     }
     if (empty($pPassword)) {
         Tool_Fnc::ajaxMsg('请输入密码');
     }
     if (!Tool_Validate::mo($pPhone)) {
         Tool_Fnc::ajaxMsg('手机号不正确');
     }
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did 错误');
     }
     $tUserMO = new UserModel();
     $tUserRow = $tUserMO->field('private_key')->where('phone = \'' . $pPhone . '\'')->fRow();
     $tUkey = empty($tUserRow['private_key']) ? '' : $tUserRow['private_key'];
     $tMd5str = Tool_Fnc::markmd5($pPassword, $tUkey);
     $tUserRow = $tUserMO->field('id,user_type')->where('phone = \'' . $pPhone . '\' and passwd = \'' . $tMd5str . '\'')->fRow();
     if (empty($tUserRow['id'])) {
         Tool_Fnc::ajaxMsg("用户名或者密码错误");
     }
     //添加登陆 记录
     $tData = array('uid' => $tUserRow['id'], 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
     $tUllMO = new UserloginlogModel();
     if (!$tUllMO->insert($tData)) {
         Tool_Fnc::ajaxMsg("登录失败");
     }
     //did入库
     $tUDMO = new UserdidModel();
     $tUDRow = $tUDMO->field('count(0) c')->where('uid = ' . $tUserRow['id'] . ' and did = \'' . $pDid . '\'')->fRow();
     if (empty($tUDRow['c'])) {
         $tData = array('uid' => $tUserRow['id'], 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
         $tUDMO->insert($tData);
     }
     $tTokenarr = $this->creattoken($tUserRow['id']);
     //匿名转实名
     $tUserMO->incognito_real($pDid, $tUserRow['id']);
     Tool_Fnc::ajaxMsg("登录成功", 1, array_merge($tTokenarr, array('user_type' => $tUserRow['user_type'])));
     //登录成功返回token
 }
Exemplo n.º 2
0
 public function regAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']);
     #客户端发送的必须是md5的 密码
     $pCode = empty($p['code']) ? '0' : trim($p['code']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $tTime = time();
     if (empty($pPassword)) {
         Tool_Fnc::ajaxMsg('密码不能为空');
     }
     if (empty($pCode)) {
         Tool_Fnc::ajaxMsg('验证码不能为空');
     }
     if (!Tool_Validate::integer($pCode)) {
         Tool_Fnc::ajaxMsg('验证码格式错误');
     }
     if (strlen($pPassword) != 32) {
         Tool_Fnc::ajaxMsg('接口发送的必须是密文密码');
     }
     if (empty($pDid) || !Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did error');
     }
     $tUMO = new UserModel();
     $tRow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow();
     if (!empty($tRow['c'])) {
         Tool_Fnc::ajaxMsg('该手机已被他人使用,请重新输入');
     }
     $tUMO = new UserModel();
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pPassword, $tKey);
     $tCodeMO = new PhonecodeModel();
     $tCodeCRow = $tCodeMO->check($pPhone, 1, $pCode);
     if ($tCodeCRow['status'] == 0) {
         Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
     }
     $pSex = !isset($p['sex']) ? Tool_Fnc::ajaxMsg('请填写性别') : intval($p['sex']);
     $pDryWeight = !isset($p['dry_weight']) ? Tool_Fnc::ajaxMsg('请填写干体重') : floatval($p['dry_weight']);
     $pDateOfBirth = empty($p['date_of_birth']) ? Tool_Fnc::ajaxMsg('请填写出生日期') : trim($p['date_of_birth']);
     if (!empty($pDateOfBirth) && !Tool_Validate::is_date($pDateOfBirth)) {
         Tool_Fnc::ajaxMsg('日期格式不正确');
     }
     $tData = array('phone' => $pPhone, 'reg_ip' => Tool_Fnc::realip(), "passwd" => $tMd5str, "reg_time" => $tTime, 'private_key' => $tKey, 'reg_did' => $pDid, 'user_type' => 0, 'sex' => $pSex, 'dry_weight' => $pDryWeight, 'date_of_birth' => $pDateOfBirth, 'reg_did' => $pDid);
     if (!($tID = $tUMO->insert($tData))) {
         Tool_Fnc::ajaxMsg('注册失败');
     }
     //did入库
     $tUDMO = new UserdidModel();
     $tUDRow = $tUDMO->field('count(0) c')->where('uid = ' . $tID . ' and did = \'' . $pDid . '\'')->fRow();
     if (empty($tUDRow['c'])) {
         $tData = array('uid' => $tID, 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
         $tUDMO->insert($tData);
     }
     $tTokenarr = $this->creattoken($tID);
     //干重记录表数据更新
     $tDWMO = new DryweightlogModel();
     $tDryWeightLog = array('uid' => $tID, 'weight' => $pDryWeight, 'date' => date('Y-m-d'), 'month' => date('Y-m'), 'year' => date('Y'), 'created' => $tTime);
     $tDWMO->insert($tDryWeightLog);
     //匿名转实名
     $tUMO->incognito_real($pDid, $tID);
     $tTokenarr = array_merge($tTokenarr, array('user_type' => 0));
     Tool_Fnc::ajaxMsg('注册成功', 1, $tTokenarr);
 }
Exemplo n.º 3
0
 public function indexAction()
 {
     $tTime = time();
     $tH = date('H', $tTime);
     $tRedis = Cache_Redis::instance();
     $tMO = new OrdinarydialysistimeModel();
     $tODDMO = new OrdinarydialysisdateModel();
     $tUMO = new UserModel();
     $tUDMO = new UserdidModel();
     $tUAMO = new UserassessmentModel();
     $tCMO = new CenterModel();
     if ($tH >= 7 && $tH <= 11) {
         #今日提醒
         $tWeek = date('w', $tTime);
         $tDate = date('Y-m-d', $tTime);
         $tWhere = ' time_code in (2,3)';
         $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('today_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = $tRow['time_code'] == 2 ? '下午' : '晚上';
             $tTimecodestr .= $tRow['time'];
             $tTpl_val = '#timecodestr#=今日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['today_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime) . $tTimecodestr;
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['today_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
             $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow();
             if (!empty($tODDRow['c'])) {
                 continue;
             }
             #添加透析日期
             $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime);
             $tODDMO->insert($tData);
         }
     } elseif ($tH >= 13 && $tH <= 21) {
         #第二天上午
         $tWeek = date('w', $tTime + 86400);
         $tDate = date('Y-m-d', $tTime + 86400);
         $tWhere = ' time_code = 1';
         $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('tomorrow_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = '上午' . $tRow['time'];
             $tTpl_val = '#timecodestr#=明日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['tomorrow_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime + 86400) . '上午' . $tRow['time'];
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['tomorrow_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
             #添加透析日期
             $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow();
             if (!empty($tODDRow['c'])) {
                 continue;
             }
             $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime);
             $tODDMO->insert($tData);
         }
     }
     exit;
 }
Exemplo n.º 4
0
 public function indexAction()
 {
     $tTime = time();
     $tH = date('H', $tTime);
     $tMO = new BqeschedulingdetailModel();
     $tUMO = new UserModel();
     $tUDMO = new UserdidModel();
     $tUAMO = new UserassessmentModel();
     $tCMO = new CenterModel();
     $tRedis = Cache_Redis::instance();
     echo '<pre>';
     if ($tH >= 7 && $tH <= 11) {
         #今日提醒
         $tDatas = $tMO->field('uid,time_code')->where('scheduling_date = \'' . date('Y-m-d', $tTime) . '\' and time_code in(2,3) and uid <> 0')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('today_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTitle = '透析提醒';
             $tTimecodestr = $tRow['time_code'] == 2 ? '下午' : '晚上';
             $tTpl_val = '#timecodestr#=今日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['today_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime) . $tTimecodestr;
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['today_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
         }
     } elseif ($tH >= 19 && $tH <= 21) {
         $tTimeCode = 1;
         #第二天上午
         $tDatas = $tMO->field('uid')->where('scheduling_date = \'' . date('Y-m-d', $tTime + 86400) . '\' and time_code = ' . $tTimeCode)->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('tomorrow_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = '上午';
             $tTpl_val = '#timecodestr#=明日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=明日天气' . $tCRow['tomorrow_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'])));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime + 86400) . '上午' . $tRow['time'];
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['tomorrow_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
         }
     }
 }