public object GetUser(string userName, string password) { var _iSiteSettingService = ObjectContainer.Current.Resolve <ISiteSettingService>(); var siteSettings = _iSiteSettingService.GetSiteSettings(); //普通登录 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { //诊所登录也放在这里,因为诊所app和门店app为同一个并且没做登录区分,只能通过登录后才能知道是登录的诊所还是门店管理员 var seller = ManagerApplication.Login(userName, password); if (seller != null) { if (!siteSettings.IsOpenShopApp) { return(ErrorResult("未授权诊所APP")); } var shop = ShopApplication.GetShop(seller.ShopId); if (shop != null && shop.ShopStatus != ShopInfo.ShopAuditStatus.Open) { return(ErrorResult("无效的账号")); } dynamic result = SuccessResult(); string memberId = UserCookieEncryptHelper.Encrypt(seller.Id, CookieKeysCollection.USERROLE_SELLERADMIN); result.UserKey = memberId; result.type = ManagerType.ShopManager; return(result); } if (!siteSettings.IsOpenStore) { return(ErrorResult("未授权门店模块")); } var member = Himall.Application.ShopBranchApplication.ShopBranchLogin(userName, password); if (member != null) { dynamic result = SuccessResult(); string memberId = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER); result.UserKey = memberId; result.type = ManagerType.ShopBranchManager; return(result); } return(ErrorResult("用户名或密码错误")); } return(ErrorResult("用户名或密码不能为空")); }
public object GetUser(string userName, string password) { var siteSettings = SiteSettingApplication.SiteSettings; //普通登录 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { //商家登录也放在这里,因为商家app和门店app为同一个并且没做登录区分,只能通过登录后才能知道是登录的商家还是门店管理员 var seller = ManagerApplication.Login(userName, password); dynamic result = SuccessResult(); if (seller != null) { if (!siteSettings.IsOpenShopApp) { return(ErrorResult("未授权商家APP")); } var shop = ShopApplication.GetShop(seller.ShopId); if (shop != null && shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired) { return(ErrorResult("店铺已过期")); } if (null != shop && shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze) { return(ErrorResult("店铺已冻结")); } if (shop != null && shop.ShopStatus != Entities.ShopInfo.ShopAuditStatus.Open) { return(ErrorResult("无效的账号")); } if (seller.RoleId != 0) { var model = RoleApplication.GetRoleInfo(seller.RoleId); //TODO:FG 权限验证 实现逻辑待优化 var SellerPrivileges = RoleApplication.GetSellerPrivileges(seller.RoleId); if (!SellerPermission.CheckPermissions(SellerPrivileges, "App", "App")) { return(ErrorResult("您没有登录商家APP的权限")); } } result = SuccessResult(); result.UserKey = UserCookieEncryptHelper.Encrypt(seller.Id, CookieKeysCollection.USERROLE_SELLERADMIN); result.type = ManagerType.ShopManager; return(result); } var member = ShopBranchApplication.ShopBranchLogin(userName, password); if (member == null) { return(ErrorResult("用户名或密码错误")); } var shopbranch = ShopBranchApplication.GetShopBranchById(member.ShopBranchId); if (shopbranch != null) { if (shopbranch.Status == ShopBranchStatus.Freeze) { return(ErrorResult("门店已被冻结")); } if (!siteSettings.IsOpenStore) { return(ErrorResult("未授权门店模块")); } } var membershop = ShopApplication.GetShop(shopbranch.ShopId); if (membershop != null && membershop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired) { return(ErrorResult("门店所属店铺已过期")); } if (null != membershop && membershop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze) { return(ErrorResult("门店所属店铺已冻结")); } if (member != null) { result = SuccessResult(); result.UserKey = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER); result.type = ManagerType.ShopBranchManager; return(result); } } return(ErrorResult("用户名或密码不能为空")); }