/**
  * 发送注册验证码
  */
 public function SendVerifyCode()
 {
     $this->LogInfo("Send verify code...");
     $obj = $this->GetReqObj();
     //判断公司是否冻结
     $companyCondition['company_id'] = $obj->app_id;
     $companyDao = MispDaoContext::Company();
     $companyStatus = $companyDao->where($companyCondition)->getField('company_status');
     if (CompanyEnum::STATUS_FREEZE == $companyStatus) {
         $this->LogWarn("Send verify code failed. The company is freezed, company id is " . $obj->app_id);
         $this->errorCode = MispErrorCode::COMPANY_SERVICE_STOP;
         $this->ReturnJson();
         return;
     }
     //发送验证码
     $phoneNum = $obj->phone_num;
     $content = ShortMessage::getRandNum(4);
     $text1 = "验证码:";
     $text2 = ",您正在使用快客洗涤手机客户端,请在10分钟内验证。(洁净生活·快客开始,服务电话:0859-3383000)";
     $message = $text1 . $content . $text2 . "【快客洗涤】";
     $result = ShortMessage::SendMessage($phoneNum, $message);
     $xmlObj = simplexml_load_string($result);
     if ($xmlObj->RetCode == "Sucess") {
         $this->LogInfo("Send verify code success, verify code is " . $content);
         $data['obj'] = $content;
         $this->ReturnJson($data);
         return;
     } else {
         $this->LogInfo("Send verify code failed.");
         $this->errorCode = SEND_MESSAGE_FAILED;
         $this->ReturnJson();
         return;
     }
 }
 static function GetRoleID($condition)
 {
     FuegoLog::getLog()->LogInfo("Get role id. condition is " . $condition);
     $roleDao = MispDaoContext::SystemRole();
     $roleList = $roleDao->where($condition)->getField('role_id', true);
     FuegoLog::getLog()->LogInfo("Role id list is " . json_encode($roleList));
     return $roleList;
 }
 static function Delete($userID)
 {
     $errorCode = MispErrorCode::SUCCESS;
     FuegoLog::getLog()->LogInfo("delete user...");
     $systemUserDao = MispDaoContext::SystemUser();
     $condition['user_id'] = $userID;
     try {
         $result = MispCommonService::Delete($systemUserDao, $condition);
     } catch (FuegoException $e) {
         $errorCode = $e->getCode();
     }
     return $errorCode;
 }
 public function DoAuth()
 {
     $this->LogInfo("User login validator.DoAuth...");
     $req = $this->GetReqObj();
     $condition['token_name'] = $req->token;
     $tokenDao = MispDaoContext::Token();
     $tokenCount = $tokenDao->where($condition)->count();
     if (0 == $tokenCount) {
         $this->LogWarn("DoAuth failed, user login invalid.");
         $this->errorCode = MispErrorCode::ERROR_LOGIN_INVALID;
         $this->ReturnJson();
     }
     $this->LogInfo("DoAuth success.");
 }
 public function GetRoleList($RoleGroupID)
 {
     $this->LogInfo("Load role list.");
     $roleDao = MispDaoContext::SystemRole();
     $roleCondition['company_id'] = $_SESSION['user']['company_id'];
     $roleCondition['user_type_id'] = $RoleGroupID;
     $this->LogInfo("get role conditon is " . json_encode($roleCondition));
     $roleList = $roleDao->where($roleCondition)->select();
     $comboxRoleList = array();
     foreach ($roleList as $role) {
         $combox['role_id'] = $role['role_id'];
         $combox['role_name'] = $role['role_name'];
         array_push($comboxRoleList, $combox);
     }
     $this->LogInfo("The role list is " . json_encode($comboxRoleList));
     echo json_encode($comboxRoleList);
     exit;
 }
 public function ModifyPassword($condition, $req)
 {
     FuegoLog::getLog()->LogInfo("Modify password...");
     $errorCode = MispErrorCode::SUCCESS;
     $userDao = MispDaoContext::SystemUser();
     $orginalUser = $userDao->where($condition)->find();
     $orginalPwd = $orginalUser['password'];
     if ($orginalPwd != $req->pwdOld) {
         FuegoLog::getLog()->LogWarn("Modify password failed,pwdOld is wrong.");
         $errorCode = MispErrorCode::ERROR_OLD_PASSWORD_WORD;
         return $errorCode;
     }
     $orginalUser['password'] = $req->pwdNew;
     try {
         $result = MispCommonService::Modify($userDao, $orginalUser);
         FuegoLog::getLog()->LogInfo("Modify password success.");
     } catch (FuegoException $e) {
         $errorCode = $e->getCode();
     }
     return $errorCode;
 }
 public function Create()
 {
     $this->LogInfo("create admin...");
     $systemUserDao = MispDaoContext::SystemUser();
     $req = $this->GetCommonData();
     if ("" == $req->role_id) {
         $this->errorCode = MispErrorCode::ERROR_ROLE_IS_EMPTY;
         $this->ReturnJson();
         return;
     }
     //创建User信息
     $user['user_name'] = $req->user_name;
     $user['password'] = "******";
     $user['role_id'] = $req->role_id;
     $user['reg_date'] = date('Y-m-d H:i:s', time());
     $user['company_id'] = $_SESSION['user']['company_id'];
     $this->LogInfo("Create user info " . json_encode($user));
     try {
         $result = MispCommonUserService::Create($user);
     } catch (FuegoException $e) {
         $this->errorCode = $e->getCode();
         $this->ReturnJson();
         return;
     }
     //创建管理员信息
     $adminDao = $this->GetModel();
     $admin['user_id'] = $result;
     $admin['user_name'] = $req->user_name;
     $admin['email'] = $req->email;
     $admin['company_id'] = $_SESSION['user']['company_id'];
     $this->LogInfo("Create admin info " . json_encode($admin));
     try {
         $result = MispCommonService::Create($adminDao, $admin);
     } catch (FuegoException $e) {
         $this->errorCode = $e->getCode();
     }
     $this->ReturnJson();
 }
 public function CreateBasicRole($companyID)
 {
     //创建公司基本角色
     $roleDao = MispDaoContext::SystemRole();
     //创建管理员角色
     $role['role_name'] = "管理员";
     $role['user_type_id'] = UserTypeEnum::ADMIN;
     $role['user_type_name'] = "ADMIN";
     $role['company_id'] = $companyID;
     $adminRoleID = MispCommonService::Create($roleDao, $role);
     //创建管理员权限
     $privilegeDao = MispDaoContext::Privilege();
     $privilegeList = array();
     for ($i = 1; $i < 5; $i++) {
         $privilege['master_type'] = PrivilegeEnum::MASTER_TYPE_ROLE;
         $privilege['master_value'] = $adminRoleID;
         $privilege['access_obj_type'] = PrivilegeEnum::ACCESS_TYPE_MENU;
         $privilege['access_obj_value'] = $i;
         array_push($privilegeList, $privilege);
     }
     $loginPrivilege['master_type'] = PrivilegeEnum::MASTER_TYPE_ROLE;
     $loginPrivilege['master_value'] = $adminRoleID;
     $loginPrivilege['access_obj_type'] = PrivilegeEnum::ACCESS_TYPE_LOGIN;
     $loginPrivilege['access_obj_value'] = PrivilegeEnum::ACCESS_VALUE_WEB_LOGIN;
     array_push($privilegeList, $loginPrivilege);
     $result = MispCommonService::CreateList($privilegeDao, $privilegeList);
     //创建消费者角色
     $role['role_name'] = "消费者";
     $role['user_type_id'] = UserTypeEnum::CUSTOMER;
     $role['user_type_name'] = "CUSTOMER";
     $role['company_id'] = $companyID;
     $sellerRoleID = MispCommonService::Create($roleDao, $role);
     //创建消费者权限
     $loginPrivilege['master_type'] = PrivilegeEnum::MASTER_TYPE_ROLE;
     $loginPrivilege['master_value'] = $sellerRoleID;
     $loginPrivilege['access_obj_type'] = PrivilegeEnum::ACCESS_TYPE_LOGIN;
     $loginPrivilege['access_obj_value'] = PrivilegeEnum::ACCESS_VALUE_APP_LOGIN;
     $result = MispCommonService::Create($privilegeDao, $loginPrivilege);
     return $adminRoleID;
 }
 public function GetMenuTree()
 {
     $this->LogInfo("get menu tree");
     //获取用户菜单权限
     $privilegeDao = MispDaoContext::Privilege();
     $condition['master_value'] = $_SESSION['user']['role_id'];
     $condition['master_type'] = PrivilegeEnum::MASTER_TYPE_ROLE;
     $condition['access_obj_type'] = PrivilegeEnum::ACCESS_TYPE_MENU;
     $menuIDList = $privilegeDao->where($condition)->getField('access_obj_value', true);
     //获取菜单列表
     $menuDao = MispDaoContext::Menu();
     $map['menu_id'] = array('in', $menuIDList);
     $menuList = $menuDao->where($map)->select();
     //转换为tree
     $treeList = array();
     foreach ($menuList as $menu) {
         $tree['id'] = $menu['menu_id'];
         $tree['text'] = $menu['value'];
         $tree['iconCls'] = $menu['icon'];
         $tree['attributes']['url'] = $menu['url'];
         array_push($treeList, $tree);
     }
     $this->LogInfo("menu tree is " . json_encode($treeList));
     echo json_encode($treeList);
     exit;
 }
 protected function GetModel()
 {
     return MispDaoContext::ClientVersion();
 }