/**
  * 通过用户ID修改其手机号码
  *
  * @param array $params
  *  -mobile 手机号码
  * @return boolean|void
  */
 public function modifyMobile($params = array())
 {
     if (isset($params['mobile'])) {
         // 注册手机号码的唯一性
         $mobile = $params['mobile'];
         $mUserBase = new UserBaseInfo();
         $mUserOpLog = new UserOperateLog();
         $user = UserBaseInfo::getLoginUser();
         $data = [];
         if (!$user) {
             Yii::$app->util->formatResData(1205, 'error_not_login', ['msg' => '手机号码修改失败']);
         }
         $data = ['id' => $user['id'], 'mobile' => $mobile];
         $origMobile = $user['mobile'];
         $result = $mUserBase->updateUserById($data);
         if ($result) {
             $session = Yii::$app->session;
             $user = $session[UserBaseInfo::SESSION_KEY_USER];
             $user['mobile'] = $mobile;
             // 针对SSO用户同步相关信息
             $data = ['open_id' => $user['open_id'], 'mobile' => $mobile];
             try {
                 $sso = Yii::$app->sso;
                 $res = $sso->sync('mobile', $data);
                 $sso->syncProfileLog($res, json_encode($data), 'mobile');
             } catch (\Exception $e) {
             }
             $session[UserBaseInfo::SESSION_KEY_USER] = $user;
         } else {
             Yii::$app->util->formatResData(1306, 'error_modify_mobild_failed', ['msg' => '手机号码修改失败']);
         }
         $mUserOpLog->store('安全手机修改', $origMobile, $mobile, $result);
         return $result;
     } else {
         Yii::$app->util->formatResData(1401, 'error_modify_mobild_failed', ['msg' => '手机号码修改失败']);
     }
 }
 /**
  * 绑定安全邮箱
  */
 public function actionBindEmail()
 {
     if (!$this->isLogin) {
         return $this->actionLogin();
         die;
     }
     $this->layout = "base";
     $tool = '';
     $key = Yii::$app->controller->id . '/' . Yii::$app->controller->action->id;
     $user = UserBaseInfo::getLoginUser();
     $userID = $user['id'];
     try {
         $session = Yii::$app->getSession();
         $userModel = new UserBaseInfo();
         $user = $userModel->getUserById($userID);
         // 判断是否已经绑定邮箱
         if ($user['email']) {
             return $this->redirect(['user/modify-email']);
             die;
         }
         if (!$user['mobile']) {
             // TODO:: 手机号为空
         }
         $tool = $user['mobile'];
         $session->set($key . '_tool', $tool);
         $config = Yii::$app->util->loadConfig('flow');
         if (empty($config)) {
             // TODO:: 配置不存在
         }
         $stepConfig = isset($config[$key]['step1']) ? $config[$key]['step1'] : [];
         $action = isset($config[$key]['action']) ? $config[$key]['action'] : '';
         $url = isset($stepConfig['api_url']) ? $stepConfig['api_url'] : '';
         $msgEmailUrl = isset($stepConfig['msg_email_api_url']) ? $stepConfig['msg_email_api_url'] : '';
         // SESSION中存储流程步骤配置信息
         $session->set($key, 'step1');
         // 如果存在就清除下一步SESSION中的验证码
         /*
         $captcha_key = 'captcha_' . $key . '_step1';
         if ($session->has($captcha_key)) {
             $session->remove($captcha_key);
         }
         */
     } catch (Exception $ex) {
         // TODO:: SESSION开启失败
     }
     return $this->render('bind_email/step1.php', ['action' => $action, 'tool' => $tool, 'url' => $url, 'msg_email_url' => $msgEmailUrl]);
 }