public function Create()
 {
     $this->LogInfo("company create ...");
     $obj = $this->GetCommonData();
     //创建公司
     $companyDao = $this->GetModel();
     $condition['company_name'] = $obj->company_name;
     $companyID = $companyDao->where($condition)->getField('company_id');
     if ($companyID != '') {
         $this->LogWarn("Create company failed, company has exist. Company_name is " . $obj->company_name);
         $this->errorCode = MispErrorCode::COMPANY_EXISTED;
         $this->ReturnJson();
         return;
     }
     $object = $this->objectToArray($obj);
     $object['company_status'] = CompanyEnum::STATUS_NORMAL;
     try {
         $companyID = MispCommonService::Create($companyDao, $object);
     } catch (FuegoException $e) {
         $this->errorCode = $e->getCode();
         $this->ReturnJson();
         return;
     }
     //创建公司基本角色
     try {
         $roleID = $this->CreateBasicRole($companyID);
     } catch (FuegoException $e) {
         $this->errorCode = $e->getCode();
         $this->ReturnJson();
         return;
     }
     //创建System user
     $systemUserDao = MispDaoContext::SystemUser();
     $user['user_name'] = $obj->user_name;
     $user['password'] = "******";
     $user['role_id'] = $roleID;
     //增加公司时,同时增加了一个企业管理员账户
     $user['reg_date'] = date('Y-m-d H:i:s', time());
     $user['company_id'] = $companyID;
     $this->LogInfo("Create first admin of company, user info is " . json_encode($user));
     try {
         $userID = MispCommonUserService::Create($user);
     } catch (FuegoException $e) {
         $this->errorCode = $e->getCode();
         $this->ReturnJson();
         return;
     }
     //创建admin
     $admin['user_id'] = $userID;
     $admin['user_name'] = $obj->user_name;
     $admin['company_id'] = $companyID;
     $this->LogInfo("Create first admin of company, admin info is " . json_encode($admin));
     $this->errorCode = MispServiceContext::UserManage()->CreateAdmin($admin);
     $this->ReturnJson();
 }
 public function ModifyPassword()
 {
     $req = $this->GetReqObj();
     $reqType = $this->GetReqType();
     $this->LogInfo("Modify password,client type is " . $reqType);
     if ($reqType == ClientTypeEnum::IOS || $reqType == ClientTypeEnum::ANDROID) {
         //修改密码
         $condition['company_id'] = $req->app_id;
         $condition['user_name'] = $req->user_name;
         $this->errorCode = MispServiceContext::UserManage()->ModifyPassword($condition, $req);
     }
     if ($reqType == "WEB") {
         $condition['user_name'] = $_SESSION['user']['user_name'];
         $this->errorCode = MispServiceContext::UserManage()->ModifyPassword($condition, $req);
         if ($this->errorCode == MispErrorCode::SUCCESS) {
             session_destroy();
         }
     }
     $this->ReturnJson();
 }