示例#1
0
 public function importActiveSaveAction()
 {
     $request = $this->get("request");
     $account = trim($request->get("account"));
     $passWord = trim($request->get("passWord"));
     if (empty($account) || empty($passWord)) {
         return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => "帐号或者密码不能为空"));
     }
     $staffmgr = new Staff($this->get("we_data_access"), $this->get("we_data_access_im"), $account);
     $isexist = $staffmgr->isExist();
     if ($isexist != null) {
         return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => "帐号已可以正常使用"));
     }
     try {
         $importData = $staffmgr->getImportInfo();
         ////判断帐号、姓名、手机是否重复或已使用
         $arrayName = array((string) $importData["login_account"], (string) $importData["eno"], (string) $importData["nick_name"]);
         $sql = "select  (select nick_name from we_staff where login_account=?) accountcheck ,";
         $sql = $sql . "  (select nick_name from we_staff where eno=? and nick_name=?) namecheck ";
         $mobileNO = trim($importData["mobile"]);
         if (!empty($mobileNO)) {
             $sql = $sql . " ,(select nick_name from we_staff where mobile=?) mobilecheck ";
             $arrayName[] = (string) $mobileNO;
         }
         $da = $this->get("we_data_access");
         $ds = $da->getdata("t", $sql, $arrayName);
         if ($ds) {
             $dr = $ds["t"]["rows"][0];
             if (!empty($dr["accountcheck"])) {
                 if ($dr["accountcheck"] == $importData["nick_name"]) {
                     throw new \Exception("您的帐号的已激活,可以正常使用。");
                 } else {
                     throw new \Exception("该帐号已被" . $dr["accountcheck"] . "使用!");
                 }
             } else {
                 if (!empty($dr["namecheck"])) {
                     throw new \Exception("姓名已存在,不能重复激活!");
                 } else {
                     if (!empty($dr["mobilecheck"])) {
                         throw new \Exception("手机号已被" . $dr["mobilecheck"] . "使用,请使用其他有效手机号码注册!");
                     }
                 }
             }
         }
         //激活人员帐号
         $sdo = new \Justsy\BaseBundle\Controller\ActiveController();
         $sdo->setContainer($this->container);
         $sdo->doSaveAction();
         //根据导入信息更新注册信息
         $staffmgr->updateByImport($importData);
         $staffmgr->deleteImportPhy();
     } catch (\Exception $e) {
         $this->get("logger")->err($e);
         return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => $e->getMessage()));
     }
     $data = $staffmgr->getInfo();
     $data["t_code"] = substr($passWord, 0, 1) . "******" . substr($passWord, -1);
     $data["password"] = $passWord;
     return $this->render('JustsyBaseBundle:Active:import_succeed.html.twig', array('edomain' => $data["eno"], 'data' => $data));
 }