public JsonResult Login(string username, string password, string checkCode) { JsonResult jsonResult; try { CheckInput(username, password); CheckCheckCode(username, checkCode); ManagerInfo managerInfo = ServiceHelper.Create <IManagerService>().Login(username, password, false); if (managerInfo == null) { throw new HimallException("用户名和密码不匹配"); } ShopInfo shop = ServiceHelper.Create <IShopService>().GetShop(managerInfo.ShopId, false); ClearErrorTimes(username); jsonResult = Json(new { success = true, userId = UserCookieEncryptHelper.Encrypt(managerInfo.Id, "SellerAdmin"), stage = shop.Stage }); } catch (HimallException himallException1) { HimallException himallException = himallException1; int num = SetErrorTimes(username); jsonResult = Json(new { success = false, msg = himallException.Message, errorTimes = num, minTimesWithoutCheckCode = 3 }); } catch (Exception exception1) { Exception exception = exception1; int num1 = SetErrorTimes(username); Log.Error(string.Concat("用户", username, "登录时发生异常"), exception); jsonResult = Json(new { success = false, msg = "未知错误", errorTimes = num1, minTimesWithoutCheckCode = 3 }); } return(jsonResult); }
public JsonResult Login(string username, string password, string checkCode, bool keep = false) { JsonResult jsonResult; try { CheckInput(username, password); CheckCheckCode(username, checkCode); if (username.IndexOf(':') <= 0) { UserLoginIn(username, password, keep); SellerLoginIn(username, password, keep); ClearErrorTimes(username); jsonResult = Json(new { success = true, IsChildSeller = false }); } else { if (SellerLoginIn(username, password, keep) == null) { throw new LoginException("用户名和密码不匹配", LoginException.ErrorTypes.PasswordError); } ClearErrorTimes(username); jsonResult = Json(new { success = true, IsChildSeller = true }); } } catch (LoginException loginException1) { LoginException loginException = loginException1; int num = SetErrorTimes(username); jsonResult = Json(new { success = false, msg = loginException.Message, errorTimes = num, minTimesWithoutCheckCode = 3, errorType = loginException.ErrorType }); } catch (HimallException himallException1) { HimallException himallException = himallException1; int num1 = SetErrorTimes(username); jsonResult = Json(new { success = false, msg = himallException.Message, errorTimes = num1, minTimesWithoutCheckCode = 3 }); } catch (Exception exception1) { Exception exception = exception1; int num2 = SetErrorTimes(username); Log.Error(string.Concat("用户", username, "登录时发生异常"), exception); jsonResult = Json(new { success = false, msg = "未知错误", errorTimes = num2, minTimesWithoutCheckCode = 3 }); } return(jsonResult); }
public void AddCashDepositDetails(CashDepositDetailInfo cashDepositDetail) { context.CashDepositDetailInfo.Add(cashDepositDetail); CashDepositInfo currentBalance = context.CashDepositInfo.FindById <CashDepositInfo>(cashDepositDetail.CashDepositId); if (cashDepositDetail.Balance < new decimal(0) && (currentBalance.CurrentBalance + cashDepositDetail.Balance) < new decimal(0)) { HimallException himallException = new HimallException("扣除金额不能多余供应商可用余额"); } currentBalance.CurrentBalance = currentBalance.CurrentBalance + cashDepositDetail.Balance; if (cashDepositDetail.Balance > new decimal(0)) { currentBalance.EnableLabels = true; } if (cashDepositDetail.Balance > new decimal(0)) { currentBalance.TotalBalance = currentBalance.TotalBalance + cashDepositDetail.Balance; currentBalance.Date = DateTime.Now; } context.SaveChanges(); }
public JsonResult Index(string username, string password) { JsonResult jsonResult; try { CheckInput(username, password); UserMemberInfo userMemberInfo = ServiceHelper.Create <IMemberService>().Login(username, password); if (userMemberInfo == null) { throw new LoginException("用户名和密码不匹配", LoginException.ErrorTypes.PasswordError); } string str = UserCookieEncryptHelper.Encrypt(userMemberInfo.Id, "Mobile"); if (base.PlatformType != Himall.Core.PlatformType.WeiXin) { WebHelper.SetCookie("Himall-User", str, DateTime.MaxValue); } else { WebHelper.SetCookie("Himall-User", str); } jsonResult = Json(new { success = true, memberId = userMemberInfo.Id }); } catch (LoginException loginException1) { LoginException loginException = loginException1; jsonResult = Json(new { success = false, msg = loginException.Message }); } catch (HimallException himallException1) { HimallException himallException = himallException1; jsonResult = Json(new { success = false, msg = himallException.Message }); } catch (Exception exception) { Log.Error(string.Concat("用户", username, "登录时发生异常"), exception); jsonResult = Json(new { success = false, msg = "未知错误" }); } return(jsonResult); }
public JsonResult Login(string username, string password, string checkCode) { JsonResult jsonResult; string str = ""; string host = System.Web.HttpContext.Current.Request.Url.Host; try { if (true) // (LicenseChecker.Check(out str, host)) { CheckInput(username, password); CheckCheckCode(username, checkCode); ManagerInfo managerInfo = ServiceHelper.Create <IManagerService>().Login(username, password, true); if (managerInfo == null) { throw new HimallException("用户名和密码不匹配"); } ClearErrorTimes(username); jsonResult = Json(new { success = true, userId = UserCookieEncryptHelper.Encrypt(managerInfo.Id, "Admin") }); } else { jsonResult = Json(new { success = false, msg = str }); } } catch (HimallException himallException1) { HimallException himallException = himallException1; int num = SetErrorTimes(username); jsonResult = Json(new { success = false, msg = himallException.Message, errorTimes = num, minTimesWithoutCheckCode = 3 }); } catch (Exception exception1) { Exception exception = exception1; int num1 = SetErrorTimes(username); Log.Error(string.Concat("用户", username, "登录时发生异常"), exception); jsonResult = Json(new { success = false, msg = "未知错误", errorTimes = num1, minTimesWithoutCheckCode = 3 }); } return(jsonResult); }
public JsonResult CheckCode(string checkCode) { JsonResult jsonResult; try { string item = base.Session["checkCode"] as string; bool lower = item.ToLower() == checkCode.ToLower(); jsonResult = Json(new { success = lower }); } catch (HimallException himallException1) { HimallException himallException = himallException1; jsonResult = Json(new { success = false, msg = himallException.Message }); } catch (Exception exception) { Log.Error("检验验证码时发生异常", exception); jsonResult = Json(new { success = false, msg = "未知错误" }); } return(jsonResult); }