Ejemplo n.º 1
0
 public function Register($parameter)
 {
     $eno = trim($parameter["eno"]);
     $conn = $this->get("we_data_access");
     if (empty($eno)) {
         $this->get("logger")->err("企业编号不能为空。");
         return array("returncode" => ReturnCode::$SYSERROR, "msg" => "企业编号不能为空。");
     }
     $login_account = $parameter["login_account"];
     $nick_name = $parameter["nick_name"];
     $returncode = ReturnCode::$SUCCESS;
     $msg = "";
     $user_openid = "";
     $employeeRegister = new \Justsy\BaseBundle\Controller\ActiveController();
     $employeeRegister->setContainer($this->container);
     $registerResult = $employeeRegister->ThirdRegister($eno, $login_account, $nick_name, $parameter["ldap_uid"]);
     if ($registerResult["success"]) {
         $appid = $parameter["appid"];
         $user_openid = $registerResult["openid"];
         $sqls = array();
         $paras = array();
         $login_account = $login_account . "@fafatime.com";
         $sql = " insert into we_staff_account_bind(bind_account,bind_type,bind_uid,login_account,bind_created,nick_name,province,city,profile_image_url,appid)values(?,?,?,?,now(),?,?,?,?,?);";
         $para = array((string) $user_openid, (string) $parameter["type"], (string) $parameter["openid"], (string) $login_account, (string) $nick_name, (string) $parameter["province"], (string) $parameter["city"], (string) $parameter["headimgurl"], (string) $appid);
         array_push($sqls, $sql);
         array_push($paras, $para);
         //更改用户性别字段
         $sex = $parameter["sex"];
         if (!empty($sex)) {
             if ($sex == "1" || $sex == "2") {
                 $sex = $sex == "1" ? "男" : "女";
                 $sql = "update we_staff set sex_id=? where login_account=?";
                 $para = array((string) $sex, (string) $login_account);
                 array_push($sqls, $sql);
                 array_push($paras, $para);
             }
         }
         try {
             $conn->ExecSQLs($sqls, $paras);
             //用户头像处理
             // $this->SaveUserHead($login_account,$parameter["headimgurl"]);
             $msg = "操作成功!";
         } catch (Exception $e) {
             $returncode = ReturnCode::$SYSERROR;
             $msg = $e->getMessage();
             $this->get("logger")->err($e->getMessage());
         }
     } else {
         $returncode = ReturnCode::$SYSERROR;
         $msg = "帐号注册失败。";
     }
     return array("returncode" => $returncode, "msg" => $msg);
 }