/** * 获取验证码 actionGetVerificationCode() * @mobile $mobile string --手机号码 * @type $type int --类型:1表示注册新用户,2表示找回密码,3表示绑定手机 * @return result 调用返回结果 * @return msg 调用返回结果说明 * @return data 调用返回数据 * 根据手机号获取注册验证码(用于注册新用户,找回密码,绑定手机) */ public function actionGetVerificationCode() { //检查参数 if (!isset($_REQUEST['mobile']) || !isset($_REQUEST['verifyType'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $version = Yii::app()->request->getParam('version', NULL); $deviceId = Yii::app()->request->getParam('deviceId', NULL); $platform = Yii::app()->request->getParam('platform', NULL); $channel = Yii::app()->request->getParam('channel', NULL); $appVersion = Yii::app()->request->getParam('appVersion', NULL); $osVersion = Yii::app()->request->getParam('osVersion', NULL); $appId = Yii::app()->request->getParam('appId', NULL); $mobile = Yii::app()->request->getParam('mobile', NUll); $type = Yii::app()->request->getParam('verifyType', NULL); if (!$this->isMobile($mobile)) { $this->_return('MSG_ERR_FAIL_PARAM'); } $aType = array('1', '2', '3'); if (!in_array($type, $aType)) { $this->_return('MSG_ERR_FAIL_PARAM'); } // 根据手机号码发送验证码 $data = LogMobileCheckcode::model()->verificationCode($mobile, $type); // var_dump($data);exit; if ($data === 10002) { $this->_return("MSG_ERR_FAIL_PARAM"); } elseif ($data === 10003) { $this->_return("MSG_ERR_INVALID_MOBILE"); } elseif ($data === 10006) { $this->_return("MSG_ERR_UN_REGISTER_MOBILE"); } elseif ($data === 30001) { $this->_return("MSG_ERR_INVALID_BIND_MOBILE"); } // 记录log $this->_return("MSG_SUCCESS", $data); // $data为返回的验证码目前测试用,正式上线去除$data }
/** * action_id : 2103 * 获取验证码 actionGetVerificationCode() * @mobile $mobile string --手机号码 * @type $type int --类型:1表示注册新用户,2表示找回密码,3表示绑定手机 * @return result 调用返回结果 * @return msg 调用返回结果说明 * @return data 调用返回数据 * 根据手机号获取注册验证码(用于注册新用户,找回密码,绑定手机) */ public function actionGetVerificationCode() { //检查参数 if (!isset($_REQUEST['mobile']) || !isset($_REQUEST['verifyType'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $mobile = Yii::app()->request->getParam('mobile', NUll); $type = Yii::app()->request->getParam('verifyType', NULL); if (!$this->isMobile($mobile)) { $this->_return('MSG_ERR_FAIL_PARAM'); } $aType = array('1', '2', '3'); if (!in_array($type, $aType)) { $this->_return('MSG_ERR_FAIL_PARAM'); } // 根据手机号码发送验证码 $data = LogMobileCheckcode::model()->verificationCode($mobile, $type); // var_dump($data);exit; if ($data === 10002) { $this->_return("MSG_ERR_FAIL_PARAM"); } elseif ($data === 20001) { $this->_return("MSG_ERR_INVALID_MOBILE"); } elseif ($data === 20004) { $this->_return("MSG_ERR_UN_REGISTER_MOBILE"); } elseif ($data === 20014) { $this->_return("MSG_ERR_INVALID_BIND_MOBILE"); } // TODO : add log $actionId = 2103; $params = ''; foreach ($_REQUEST as $key => $value) { $params .= $key . '=' . $value . '&'; } LogUserAction::model()->userAction($userId = 0, $actionId, $params); $this->_return("MSG_SUCCESS", $data); // $data为返回的验证码目前测试用,正式上线去除$data }
/** * 用户忘记密码后使用手机号获得验证码重置密码 * @param $mobile * @param $password * @param $checkNum * @return array|int */ public function resetPassword($mobile, $password, $checkNum) { // $passwordMd5 = md5($password); $data = array(); try { $userId = self::getUserByMobile($mobile); if (!$userId) { return 10006; // MSG_ERR_UN_REGISTER_MOBILE } $mobile_checkcode = LogMobileCheckcode::model()->checkCode($mobile, $checkNum); if (!$mobile_checkcode) { return 10005; // MSG_ERR_CODE_OVER_TIME } //手机号码已注册且验证码正确 update Yii::app()->cnhutong_user->createCommand()->update('user', array('password' => $password), 'mobile = :mobile', array(':mobile' => $mobile)); //修改成功,验证码使用后改变验证码status状态 Yii::app()->cnhutong_user->createCommand()->update('log_mobile_checkcode', array('status' => 1), 'mobile = :mobile', array(':mobile' => $mobile)); //userId $data['userId'] = $userId; //token $data['token'] = UserToken::model()->getToken($userId); //用户昵称,积分,等级 $userMessage = self::getUserMessageByUserId($userId); $data['mobile'] = $userMessage['mobile']; $data['nickname'] = $userMessage['username']; $data['points'] = $userMessage['score']; $data['level'] = $userMessage['level']; //members $data['members'] = UserMember::model()->getMembers($userId); if (!$data['members']) { $data['members'] = []; } } catch (Exception $e) { error_log($e); } return $data; }