/// <summary> /// 登录 /// </summary> public CustomerInfoModel DoLogin(CustomerLoginModel loginModel) { if (string.IsNullOrEmpty(loginModel.CorpId)) { throw new Exception("公司代码不能为空"); } //判断是否是商旅客户 CorporationModel corporationModel = _corporationBll.GetCorpInfoByCorpId(loginModel.CorpId); if (corporationModel == null || string.IsNullOrEmpty(corporationModel.IsAmplitudeCorp) || corporationModel.IsAmplitudeCorp.ToUpper() == "F") { throw new Exception("没有开通差旅功能,请联系客服开通"); } //1.根据用户名,密码,公司代码,验证身份 CustomerInfoModel customerInfo = _verifyBll.VerifyCustomer(loginModel); if (customerInfo == null) { return(null); } if (!string.IsNullOrEmpty(customerInfo.IsLock) && customerInfo.IsLock.ToUpper() == "T") { throw new Exception("该客户已经被冻结,请先解冻再登录"); } if (!string.IsNullOrEmpty(customerInfo.IsDel) && customerInfo.IsDel.ToUpper() == "T") { throw new Exception("该客户已经被删除,无法登录"); } //2.验证通过后,将token,UserId(key-value)保存到Redis中(事件方式) TokenEvent?.Invoke(this, new TokenEventArgs(loginModel.Token, customerInfo.UserId, customerInfo.Cid, loginModel.ClientType)); //当前个性化如果设置需要短信验证则IsCheckClientId为true if ((corporationModel?.IsNoteVerify ?? 0) == 0) { loginModel.IsCheckClientId = false; } else { loginModel.IsCheckClientId = true; } if (!(loginModel.IsCheckClientId ?? false) && !string.IsNullOrEmpty(loginModel.ClientId)) { //3.更新设备id _addAppClientIdServiceBll.AddAppClientId(new AddAppClientIdModel() { Cid = customerInfo.Cid, ClientId = loginModel.ClientId, ClientType = loginModel.ClientType }); } //3.获取设备id loginModel.ClientId = _addAppClientIdServiceBll.GetAppClientId(customerInfo.Cid); return(customerInfo); }
/// <summary> /// 登出 /// </summary> /// <param name="token"></param> public void DoLoginOut(string token) { TokenEvent?.Invoke(this, new TokenEventArgs(token, "", 0, "")); }