public function Register() { $this->LogInfo("Customer register ..."); $Req = $this->GetReqObj(); //获取用户角色 $roleDao = MispDaoContext::SystemRole(); $roleCondition['user_type_id'] = UserTypeEnum::CUSTOMER; $roleCondition['company_id'] = $Req->app_id; $customerRole = $roleDao->where($roleCondition)->getField('role_id'); $this->LogInfo("Get customer role success,customer role is " . $customerRole); //创建用户信息 $user['user_name'] = $Req->user_name; $user['password'] = $Req->password; $user['role_id'] = $customerRole; $user['reg_date'] = date('Y-m-d H:i:s', time()); $user['company_id'] = $Req->app_id; try { $result = MispCommonUserService::Create($user); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } //创建会员信息 $user['user_id'] = $result; $customerInfo['addr'] = $Req->addr; $this->errorCode = MispServiceContext::UserManage()->Register($user, $customerInfo); $this->ReturnJson(); }
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 Create() { $this->LogInfo("customer create ..."); $obj = $this->GetCommonData(); if ("" == $obj->role_id) { $this->errorCode = MispErrorCode::ERROR_ROLE_IS_EMPTY; $this->ReturnJson(); return; } //创建用户 $user['user_name'] = $obj->user_name; $user['password'] = '******'; $user['role_id'] = $obj->role_id; $user['reg_date'] = date('Y-m-d H:i:s', time()); $user['company_id'] = $_SESSION['user']['company_id']; try { $result = MispCommonUserService::Create($user); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } //创建会员 $customerDao = $this->GetModel(); $customer['user_id'] = $result; $customer['user_name'] = $obj->user_name; $customer['customer_name'] = $obj->customer_name; $customer['nickname'] = $obj->nickname; $customer['phone'] = $obj->phone; $customer['birthday'] = $obj->birthday; $customer['addr'] = $obj->addr; $customer['score'] = $obj->score; $customer['card_number'] = $obj->card_number; $customer['customer_sex'] = $obj->customer_sex; $customer['customer_email'] = $obj->customer_email; $customer['company_id'] = $_SESSION['user']['company_id']; $this->LogInfo("Create customer " . json_encode($customer)); try { $result = MispCommonService::Create($customerDao, $customer); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); } $this->ReturnJson(); }
public function Create() { $this->LogInfo("create user..."); $systemUserDao = MispDaoContext::SystemUser(); $req = $this->GetCommonData(); $user['user_name'] = $req->user_name; $user['password'] = $req->password; $user['role_id'] = $req->role_id; $user['reg_date'] = date('Y-m-d H:i:s', time()); $user['company_id'] = CompanyEnum::GROUP_COMPANY; try { $result = MispCommonUserService::Create($user); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } $this->ReturnJson(); }
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(); }