Exemplo n.º 1
0
 public function savemobilebindAction()
 {
     $re = array();
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $txtmobile = $request->get("txtmobile");
     $txtvaildcode = $request->get("txtvaildcode");
     if (empty($txtmobile)) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["msg"] = "请输入正确的手机号!";
         $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     if ($txtmobile != $request->getSession()->get("txtmobile")) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["msg"] = "两次手机号输入不一致!";
         $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     if (empty($txtvaildcode) || $txtvaildcode != $request->getSession()->get("mobilevaildcode")) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["msg"] = "请输入正确的验证码!";
         $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     try {
         $sqls = array();
         $all_params = array();
         $sql = "update we_staff set mobile_bind=null where mobile_bind=?";
         $params = array();
         $params[] = $txtmobile;
         $sqls[] = $sql;
         $all_params[] = $params;
         $sql = "update we_staff set mobile=?, mobile_bind=? where login_account=?";
         $params = array();
         $params[] = $txtmobile;
         $params[] = $txtmobile;
         $params[] = $user->getUserName();
         $sqls[] = $sql;
         $all_params[] = $params;
         $da = $this->get("we_data_access");
         $da->ExecSQLs($sqls, $all_params);
         //发送手机绑定通知
         try {
             $noticeMsg = array();
             $noticeMsg["login_account"] = $user->fafa_jid;
             $noticeMsg["nick_name"] = $user->nick_name;
             $noticeMsg["mobile_bind"] = "1";
             $noticeMsg["mobile"] = $txtmobile;
             $message = json_encode($noticeMsg);
             $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $user);
             $recv = $staffMgr->getFriendAndColleagueJid();
             array_push($recv, $user->fafa_jid);
             Utils::sendImPresence("", implode(",", $recv), "mobile_bind", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         } catch (\Exception $e) {
             $this->get("logger")->err($e);
         }
         $re["returncode"] = ReturnCode::$SUCCESS;
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["msg"] = "绑定手机号失败!请重试";
         $this->get('logger')->err($e);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }