/**
     * @brief 医生认证申请
     * @author cs
     * @exampleUrl 
     *
     * @Param $userId
     * @Param $name
     * @Param $hospitalName
     * @Param $facultyName
     * @Param $hospitalProvince
     * @Param $hospitalCity
     * @Param $isPublic
     * @Param $workCard
     * @Param $certificate
     *
     * @Returns   
  */
 public function doctorAuthApplication($userId, $name, $hospitalName, $facultyName, $hospitalProvince='', $hospitalCity='', $isPublic='', $workCardAttachmentIds='', $certificateAttachmentIds='', $mobile='', $captcha = '', $grade = '')
 {/*{{{*/
     $user = DAL::get()->find('user', $userId);
     if ($user->isNull())
     {
         $this->setErrorCode(1221);
         return 0;
     }
     if ($mobile || $captcha)
     {
         if ($mobile == '13800138000')
         {
             $this->setErrorCode(828);
             return 0;
         }
         if(false == XString::isMobileNew($mobile))
         {
             $this->setErrorCode(827);
             return 0;
         }
         if(!User::validKeyForRegister($mobile, strtolower($captcha)))
         {
             $this->setErrorCode(1181);
             return 0;
         }
         UserClient::getInstance()->setMobile($user->id, $mobile);
     }
     if ($name == '')
     {
         $this->setErrorCode(830);
         return 0;
     }
     if ($hospitalName == '')
     {
         $this->setErrorCode(804);
         return 0;
     }
     if ($facultyName == '')
     {
         $this->setErrorCode(8041);
         return 0;
     }
     $workCardIds = $certificateIds = array();
     if (!empty($workCardAttachmentIds))
     {
         $token = strtok($workCardAttachmentIds, ',');
         while($token !== false)
         {
             $workCardIds[] = $token;
             $token = strtok(',');
         }
     }
     if(!empty($certificateAttachmentIds))
     {
         $token = strtok($certificateAttachmentIds, ',');
         while($token !== false)
         {
             $certificateIds[] = $token;
             $token = strtok(',');
         }
     }
     $preDoctor = DAL::get()->find_by_userid('predoctor', $user->id);
     if (false == $preDoctor->isNull())
     {
         if ($preDoctor->isInit())
         {
             $this->setErrorCode(803);
             return 0;
         }
         if ($preDoctor->isConfirmed())
         {
             $this->setErrorCode(802);
             return 0;
         }
     }
     $params = array();
     $params['name'] = $name;
     $params['hospitalName'] = $hospitalName;
     $params['facultyName'] = $facultyName;
     $params['hospitalProvince'] = $hospitalProvince;
     $params['hospitalCity'] = $hospitalCity;
     $params['isPublic'] = $isPublic;
     $params['workCard'] = $workCardIds;
     $params['certificate'] =$certificateIds;
     $params['grade'] = $grade == '无职称' ? '' : $grade;
     $preDoctor = PreDoctorClient::getInstance()->addPreDoctor($user->id, $params);
     if ($preDoctor->isNull())
     {
         $this->setErrorCode(801);
         return 0;
     }
     if ($_REQUEST['os'] == 'ios' && $_REQUEST['v'] >= '3.0.1' || $_REQUEST['os'] == 'android' && $_REQUEST['v'] >= '3.0.5')
     {
         $title = '医生客户端注册完成';
         $content = "尊敬的医生您好,您已完成注册,可以开始使用客户端的部分功能。\n目前对您的信息正在核对与认证,认证后您可使用客户端全部功能。\n有任何疑问可通过客户端直接联系我们,谢谢。";
         StationLetterClient::getInstance()->sendMsg(Message::AdminUserId, $preDoctor->user->id, $title, $content);
     }
     $this->content = array('successfuly' => 1); 
 }/*}}}*/
    public function doRegister($request, $response)
    {/*{{{*/
        $mobile = $request->mobile;
        $password1 = $request->password1;
        $password2 = $request->password2;
        $key = $request->key;

        if(User::validKeyForRegister($mobile, $key))
        {
            $user = UserClient::getInstance()->register($mobile, $password1, array('mobile' => $mobile));
            User::sendRegisterMsg($user->id);
            $user = UserClient::getInstance()->login($mobile, $password1);
            $forward = ($request->forward) ? $request->forward : $response->router->urlfor('user/index');
            $results = array('res' => 'success', 'msg' => '', 'next' => $forward);
        }
        else
        {
            $results = array('res' => 'failure', 'msg' => mb_convert_encoding('短信验证码不正确', 'UTF-8', 'GBK'), 'next' => '');
        }
        echo json_encode($results);
        return self::DIRECT_OUTPUT;
    }/*}}}*/
    public function registerVerifyKey($request,$response)
    {/*{{{*/
        $flag = array();
        $userPhone = $request->userPhone;
        $telCode = $request->telcode;
        if(User::validKeyForRegister($userPhone,$telCode))
        {
            $flag = array('res' => 'success');
        }
        else
        {
            $flag = array('res' => 'wrongcode');  //验证码错误
        }

        echo json_encode($flag);
        return parent::DIRECT_OUTPUT;
    }/*}}}*/
Example #4
0
 public function validKeyForRegister($mobile, $key)
 {/*{{{*/
     if(false == XString::isMobile($mobile))
     {
         $this->setErrorCode(110);
         return 0;
     }
     $isValid = 1;
     $validMsg = '';
     if(User::validKeyForRegister($mobile, $key) == false)
     {
         $isValid = 0;
         $validMsg = '验证码输入有误,请重试';
     }
     $this->content = array('isValid' => $isValid, 'validMsg' => $validMsg);
 }/*}}}*/