private static bool CheckCookies() { string str = CookiesHelper.ReadCookieValue(cookiesName); if (str != string.Empty) { try { string[] strArray = str.Split(new char[] { '|' }); string str2 = strArray[0]; string str3 = strArray[1]; string str4 = strArray[2]; string str5 = strArray[3]; string str6 = strArray[4]; if (FormsAuthentication.HashPasswordForStoringInConfigFile(str3 + str4 + str5 + str6 + ShopConfig.ReadConfigInfo().SecureKey + ClientHelper.Agent, "MD5").ToLower() == str2.ToLower()) { return(true); } CookiesHelper.DeleteCookie(cookiesName); } catch { CookiesHelper.DeleteCookie(cookiesName); } } return(false); }
protected override void PageLoad() { base.PageLoad(); AdminLogBLL.Add(ShopLanguage.ReadLanguage("LogoutSystem")); CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().AdminCookies); ResponseHelper.Redirect("/MobileAdmin/Login.html"); }
/// <summary> /// 检查cookies /// </summary> /// <returns></returns> private static bool CheckCookies() { bool flag = false; string cookiesValue = CookiesHelper.ReadCookieValue(cookiesName); if (cookiesValue != string.Empty) { try { string[] strArray = cookiesValue.Split(new char[] { '|' }); string sign = strArray[0]; string adminID = strArray[1]; string adminName = strArray[2]; string groupID = strArray[3]; string randomNumber = strArray[4]; if (FormsAuthentication.HashPasswordForStoringInConfigFile(adminID + adminName + groupID + randomNumber + ShopConfig.ReadConfigInfo().SecureKey + ClientHelper.Agent, "MD5").ToLower() == sign.ToLower()) { flag = true; } else { CookiesHelper.DeleteCookie(cookiesName); } } catch { CookiesHelper.DeleteCookie(cookiesName); } } return(flag); }
protected void SubmitButton_Click(object sender, EventArgs E) { string oldPassword = StringHelper.Password(Password.Text, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); string newPassword = StringHelper.Password(NewPassword.Text, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); AdminInfo admin = AdminBLL.Read(Cookies.Admin.GetAdminID(false)); if (admin.Password == oldPassword) { AdminBLL.ChangePassword(Cookies.Admin.GetAdminID(false), oldPassword, newPassword); AdminLogBLL.Add(ShopLanguage.ReadLanguage("ChangePassword")); Task.Run(() => { //安全码 ShopConfigInfo config = ShopConfig.ReadConfigInfo(); config.SecureKey = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); ShopConfig.UpdateConfigInfo(config); }); //清除现有cookie CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().AdminCookies); ScriptHelper.Alert(ShopLanguage.ReadLanguage("UpdateOK"), RequestHelper.RawUrl); } else { ScriptHelper.Alert(ShopLanguage.ReadLanguage("OldPasswordError"), RequestHelper.RawUrl); } }
/// <summary> /// 注销主站 /// </summary> /// <param name="user"></param> /// <returns></returns> public object[] LogoutMainSite(UserEntity user) { var result = new object[] { false, "退出失败!" }; try { var html = GetHtml("http://www.loamen.com/member/index_do.php?fmdo=login&dopost=exit#", Encoding.GetEncoding(Encode)); if (html.Contains("成功退出")) { _currentUser = new UserEntity { IsLogged = false }; result[0] = true; result[1] = "成功退出!"; CookiesHelper.DeleteCookie("http://www.loamen.com", "loamen"); } else { result[0] = false; } } catch (Exception ex) { result[0] = false; result[1] = ex.Message; } return(result); }
/// <summary> /// 检查cookies /// </summary> /// <returns></returns> private void ReadUserCookies() { string cookiesName = ShopConfig.ReadConfigInfo().UserCookies; string cookiesValue = CookiesHelper.ReadCookieValue(cookiesName); if (cookiesValue != string.Empty) { try { string[] strArray = cookiesValue.Split(new char[] { '|' }); string sign = strArray[0]; string userID = strArray[1]; string userName = strArray[2]; if (FormsAuthentication.HashPasswordForStoringInConfigFile(userID + userName + ShopConfig.ReadConfigInfo().SecureKey + ClientHelper.Agent, "MD5").ToLower() == sign.ToLower()) { UserId = Convert.ToInt32(userID); UserName = HttpContext.Current.Server.UrlDecode(userName); } else { CookiesHelper.DeleteCookie(cookiesName); } } catch { CookiesHelper.DeleteCookie(cookiesName); } } }
protected override void PostBack() { string newPassword = RequestHelper.GetForm <string>("NewPassword"); string newPassword2 = RequestHelper.GetForm <string>("NewPassword2"); //如果账号不存在 if (!string.Equals(newPassword, newPassword2, StringComparison.OrdinalIgnoreCase)) { ScriptHelper.AlertFront("两次密码不一致"); } else { // 验证通过,重置密码 string checkCode = RequestHelper.GetForm <string>("CheckCode"); string decode = StringHelper.Decode(checkCode, ShopConfig.ReadConfigInfo().SecureKey); int adminID = Convert.ToInt32(decode.Split('|')[0]); newPassword = StringHelper.Password(newPassword, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); // 重置密码 AdminBLL.ChangePassword(adminID, newPassword); //清空safecode,finddate恢复 AdminBLL.ChangeAdminSafeCode(adminID, string.Empty, RequestHelper.DateNow); //错误次数清零,解锁 AdminBLL.UpdateStatus(adminID); string msg = "ok"; //清除原有的user Cookies CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().AdminCookies); CookiesHelper.DeleteCookie("AdminSign"); ResponseHelper.Redirect("/mobileadmin/ResetPassword.html?Result=" + Server.UrlEncode(msg)); } }
protected void Page_Load(object sender, EventArgs e) { AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("LogoutSystem")); CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().UserCookies); CookiesHelper.DeleteCookie("SMSIsChecked"); CookiesHelper.DeleteCookie("SMSCheckCode"); ResponseHelper.Redirect("Login.aspx"); }
/// <summary> /// 修改手机号码 /// </summary> protected void UpdateUserMobile() { string msg = string.Empty; try { UserInfo user = UserBLL.Read(base.UserId); user.Mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile")); string safeCode = RequestHelper.GetForm <string>("phoneVer"); //手机短信验证码 if (CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(user.Mobile)) == null) { msg = "error|校验码失效,请重新获取"; } else { string mobileCode = CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(user.Mobile)).Value.ToString(); if (safeCode.ToLower() != mobileCode.ToLower()) { msg = "error|校验码错误"; } else { CookiesHelper.DeleteCookie("MobileCode" + StringHelper.AddSafe(user.Mobile)); } } if (msg == string.Empty) { if (string.IsNullOrEmpty(user.Mobile)) { msg = "error|请填写手机号码"; } if (!ShopCommon.CheckMobile(user.Mobile)) { msg = "error|手机号码错误"; } if (!UserBLL.CheckMobile(user.Mobile, base.UserId)) { msg = "error|手机号码已被其他会员注册"; } else { UserBLL.Update(user); msg = "ok|修改成功"; } } Response.Clear(); Response.Write(msg); } catch (Exception ex) { Response.Clear(); Response.Write("error|系统忙,请稍后重试"); } finally { Response.End(); } }
protected override void PageLoad() { base.PageLoad(); CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().UserCookies); CookiesHelper.DeleteCookie("SMSIsChecked"); CookiesHelper.DeleteCookie("SMSCheckCode"); CookiesHelper.DeleteCookie("UserPhoto"); CookiesHelper.DeleteCookie("PublicCourseView"); ResponseHelper.Redirect("/"); }
protected override void PageLoad() { base.PageLoad(); CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().UserCookies); CookiesHelper.DeleteCookie("UserPhoto"); CookiesHelper.DeleteCookie("UserEmail"); //退出登录时,重置静态用户对象 base.CurrentUser = new UserInfo(); ResponseHelper.Redirect("/mobile/User/login.html"); }
protected override void PageLoad() { base.PageLoad(); CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().UserCookies); CookiesHelper.DeleteCookie("UserPhoto"); CookiesHelper.DeleteCookie("UserEmail"); //退出登录时,重置静态用户对象 base.CurrentUser = new UserInfo(); ResponseHelper.Redirect(string.IsNullOrEmpty(isMobile) ? "/user/login.html" : "/mobile/login.aspx"); }
/// <summary> /// 注销论坛 /// </summary> /// <param name="user"></param> /// <returns></returns> public object[] LogoutBbs(UserEntity user) { var result = new object[] { false, "退出失败!" }; try { if (!_currentBbsUser.IsLogged) { result[0] = true; result[1] = "退出成功!"; return(result); } string html = GetHtml("http://" + Config.ProxyHeroCloudSetting.BbsDomain + "/jobcenter.php"); if (html.Contains("退出")) { var regex = new Regex("<a\\s+href=\"(?<url>[^\"]+)\">退出"); MatchCollection matchs = regex.Matches(html); if (matchs.Count > 0) { var exitUrl = matchs[0].Groups["url"].Value; html = GetHtml("http://" + Config.ProxyHeroCloudSetting.BbsDomain + "/" + exitUrl, Encoding.GetEncoding(Encode)); result[1] = StringHelper.GetMidString(html, @"<span class=""f14"">", @"</span>"); if (html.Contains("顺利退出")) { _currentBbsUser = new UserEntity { IsLogged = false }; result[0] = true; Cookies = null; CookiesHelper.DeleteCookie("http://" + Config.ProxyHeroCloudSetting.BbsDomain + "", "loamen"); } else { result[0] = false; } } } } catch (Exception ex) { result[0] = false; result[1] = ex.Message; } return(result); }
/// <summary> /// 提交数据 /// </summary> protected override void PostBack() { string userPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword1"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); string checkCode = RequestHelper.GetForm <string>("CheckCode"); string decode = StringHelper.Decode(checkCode, ShopConfig.ReadConfigInfo().SecureKey); int userID = Convert.ToInt32(decode.Split('|')[0]); UserBLL.ChangePassword(userID, userPassword); UserBLL.ChangeUserSafeCode(userID, string.Empty, RequestHelper.DateNow); result = "恭喜您,密码修改成功!" + " 点击<a href=\"/Mobile/user/Login.html\" style=\"color: #1d7fd4\">\"使用新密码登录\"</a>"; //清除原有的user Cookies CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().UserCookies); ResponseHelper.Redirect("/Mobile/User/ResetPassword.html?Result=" + Server.UrlEncode(result)); }
/// <summary> /// 换取访问令牌 /// </summary> private string GetAccessToken(string oauth_token, string oauth_vericode) { LoginConfig loginConfig = new LoginConfig(); string appKey = loginConfig.AppKey; string appSecret = loginConfig.AppSecret; string url = "http://openapi.qzone.qq.com/oauth/qzoneoauth_access_token"; string[] parameters = { "oauth_consumer_key=" + appKey, "oauth_token=" + oauth_token, "oauth_nonce=" + this.GenerateNonce(), "oauth_timestamp=" + this.GenerateTimeStamp(), "oauth_version=1.0", "oauth_signature_method=HMAC-SHA1", "oauth_vericode=" + oauth_vericode, "oauth_client_ip=1" }; //生成url string oauth_token_secret = StringHelper.Decode(CookiesHelper.ReadCookieValue(qq_oauth_token_secret_cookiesName), ShopConfig.ReadConfigInfo().SecureKey); CookiesHelper.DeleteCookie(qq_oauth_token_secret_cookiesName); string sign = GenerateSign(url, parameters, "GET", appSecret + "&" + oauth_token_secret); string tempParameters = string.Empty; for (int i = 0; i < parameters.Length; i++) { tempParameters += parameters[i] + "&"; } url = url + "?" + tempParameters + "oauth_signature=" + UrlEncode(sign); //换取访问令牌 string response = HttpHelper.WebRequestGet(url); string openID = string.Empty; if (response.Length > 0) { NameValueCollection qs = HttpUtility.ParseQueryString(response); if (qs["openid"] != null) { openID = qs["openid"]; } } return(openID); }
private void ReadUserCookies() { string userCookies = ShopConfig.ReadConfigInfo().UserCookies; string userCookiesValue = CookiesHelper.ReadCookieValue(userCookies); if (!string.IsNullOrEmpty(userCookiesValue)) { try { string[] strArray = userCookiesValue.Split(new char[] { '|' }); string ciphertext = strArray[0]; string userID = strArray[1]; string userName = strArray[2]; string moneyUsed = strArray[3]; string gradeID = strArray[4]; string mobile = strArray[5]; string groupID = strArray[6]; string companyID = strArray[7]; string realName = strArray[8]; if (FormsAuthentication.HashPasswordForStoringInConfigFile(userID + userName + moneyUsed.ToString() + gradeID.ToString() + mobile + groupID.ToString() + companyID.ToString() + realName + ShopConfig.ReadConfigInfo().SecureKey + ClientHelper.Agent, "MD5").ToLower() == ciphertext.ToLower()) { this.UserID = Convert.ToInt32(userID); this.UserName = HttpContext.Current.Server.UrlDecode(userName); this.MoneyUsed = Convert.ToDecimal(moneyUsed); this.GradeID = Convert.ToInt32(gradeID); this.UserMobile = mobile; this.UserGroupID = Convert.ToInt32(groupID); this.UserCompanyID = Convert.ToInt32(companyID); this.UserRealName = HttpContext.Current.Server.UrlDecode(realName); } else { CookiesHelper.DeleteCookie(userCookies); } } catch { CookiesHelper.DeleteCookie(userCookies); } } if (this.GradeID == 0) { this.GradeID = UserGradeBLL.ReadUserGradeByMoney(0M).ID; } }
/// <summary> /// 检查cookies /// </summary> /// <returns></returns> private void ReadUserCookies() { string cookiesName = ShopConfig.ReadConfigInfo().UserCookies; if (CookiesHelper.ReadCookie(cookiesName) != null) { string cookiesValue = CookiesHelper.ReadCookieValue(cookiesName); if (!string.IsNullOrEmpty(cookiesValue)) { try { string[] strArray = cookiesValue.Split(new char[] { '|' }); string sign = strArray[0]; string userID = strArray[1]; string userName = strArray[2]; string gradeID = strArray[3]; if (FormsAuthentication.HashPasswordForStoringInConfigFile(userID + userName + gradeID.ToString() + ShopConfig.ReadConfigInfo().SecureKey + ClientHelper.Agent, "MD5").ToLower() == sign.ToLower()) { UserId = Convert.ToInt32(userID); UserName = HttpContext.Current.Server.UrlDecode(userName); GradeID = Convert.ToInt32(gradeID); } else { CookiesHelper.DeleteCookie(cookiesName); } } catch { CookiesHelper.DeleteCookie(cookiesName); } } } if (GradeID == 0) { GradeID = UserGradeBLL.ReadByMoney(0).Id; } UserGrade = UserGradeBLL.Read(GradeID).Name; UserGrade = string.IsNullOrEmpty(UserGrade) ? "游客" : UserGrade; }
private void Submit() { string mobile = StringHelper.SearchSafe(RequestHelper.GetForm <string>("mobile")); string code = StringHelper.AddSafe(RequestHelper.GetForm <string>("code")); if (string.IsNullOrEmpty(mobile)) { ResponseHelper.Write("error|请输入手机号码"); ResponseHelper.End(); } if (!UserBLL.UniqueUser(mobile, base.UserId)) { ResponseHelper.Write("error|手机号码已被占用"); ResponseHelper.End(); } if (string.IsNullOrEmpty(code)) { ResponseHelper.Write("error|请输入短信验证码"); ResponseHelper.End(); } //短信验证码验证 string[] verify = StringHelper.Decode(CookiesHelper.ReadCookieValue("verify"), "sms").Split('|'); if (verify.Length != 2 || mobile != verify[0] || code != verify[1]) { ResponseHelper.Write("error|您输入的短信验证码有误,请重新获取"); ResponseHelper.End(); } CurrentUser.Mobile = mobile; UserBLL.Update(CurrentUser); CookiesHelper.DeleteCookie("verify"); ResponseHelper.Write("ok|手机修改成功"); ResponseHelper.End(); }
private void Submit() { /*-----------重新验证选择的商品------------------------------------------*/ checkCart = StringHelper.AddSafe(RequestHelper.GetForm <string>("CheckCart")); int[] cartIds = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k)); string checkCartCookies = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart")); if (checkCart != checkCartCookies) { ResponseHelper.Write("error|购买商品发生了变化,请重新提交|" + isMobile + "/cart.html"); ResponseHelper.End(); } if (string.IsNullOrEmpty(checkCart) || cartIds.Length < 1) { ResponseHelper.Write("error|请选择需要购买的商品|" + isMobile + "/cart.html"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------读取购物车清单---------------------------------------------*/ List <CartInfo> cartList = CartBLL.ReadList(base.UserId); cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList(); if (cartList.Count <= 0) { ResponseHelper.Write("error|请选择需要购买的商品|" + isMobile + "/cart.html"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------必要性检查:收货地址,配送方式,支付方式-------------------*/ var address = new UserAddressInfo { Id = RequestHelper.GetForm <int>("address_id") }; var shipping = new ShippingInfo { Id = RequestHelper.GetForm <int>("ShippingId") }; var pay = new PayPluginsInfo { Key = StringHelper.AddSafe(RequestHelper.GetForm <string>("pay")) }; bool reNecessaryCheck = false; doReNecessaryCheck: if (address.Id < 1) { ResponseHelper.Write("error|请选择收货地址|"); ResponseHelper.End(); } if (shipping.Id < 1) { ResponseHelper.Write("error|请选择配送方式|"); ResponseHelper.End(); } if (string.IsNullOrEmpty(pay.Key)) { ResponseHelper.Write("error|请选择支付方式|"); ResponseHelper.End(); } //读取数据库中的数据,进行重复验证 if (!reNecessaryCheck) { address = UserAddressBLL.Read(address.Id, base.UserId); shipping = ShippingBLL.Read(shipping.Id); pay = PayPlugins.ReadPayPlugins(pay.Key); reNecessaryCheck = true; goto doReNecessaryCheck; } /*----------------------------------------------------------------------*/ /*-----------商品清单、商品总价、邮费价格、库存检查---------------------*/ decimal productMoney = 0; int count = 0; int[] ids = cartList.Select(k => k.ProductId).ToArray(); var products = ProductBLL.SearchList(1, ids.Length, new ProductSearchInfo { InProductId = string.Join(",", ids) }, ref count); foreach (var cart in cartList) { cart.Product = products.FirstOrDefault(k => k.Id == cart.ProductId) ?? new ProductInfo(); if (!string.IsNullOrEmpty(cart.StandardValueList)) { //使用规格的价格和库存 var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList); cart.Price = standardRecord.SalePrice; cart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount; } else { cart.Price = cart.Product.SalePrice; cart.LeftStorageCount = cart.Product.TotalStorageCount - cart.Product.OrderCount; } //不需要检查库存,所有商品均可购买 ////检查库存 //if (cart.BuyCount > cart.LeftStorageCount) //{ // ResponseHelper.Write("error|商品[" + cart.ProductName + "]库存不足,无法购买|"); // ResponseHelper.End(); //} productMoney += cart.BuyCount * cart.Price; } decimal shippingMoney = 0; //首先根据ShopId分组,根据供应商的不同来分别计算运费 //然后将分拆后的供应商商品,按单个商品独立计算运费(相同商品购买多个则叠加计算) ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shipping.Id, address.RegionId); var shopIds = cartList.GroupBy(k => k.Product.ShopId).Select(k => k.Key).ToList(); foreach (var shopId in shopIds) { var shopCartList = cartList.Where(k => k.Product.ShopId == shopId).ToList(); foreach (var shopCartSplit in shopCartList) { shippingMoney += ShippingRegionBLL.ReadShippingMoney(shipping, shippingRegion, shopCartSplit); } } /*----------------------------------------------------------------------*/ int point = 0; decimal pointMoney = 0; /*-----------计算积分金额(不可使用积分)----------------------------------- * decimal totalRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointTotalRate; * decimal pointRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointMoneyRate; * int point = RequestHelper.GetForm<int>("point"); * decimal pointMoney = 0; * if (totalRate > 0 && pointRate > 0 && point > 0) * { * var member = WebService.Member.GetMember(); * decimal leftPoint = member.Point; * if (point > leftPoint) * { * ResponseHelper.Write("error|您的积分不足|"); * ResponseHelper.End(); * } * else * { * pointMoney = Math.Round(point / pointRate, 2); * * if (pointMoney > productMoney * totalRate) * { * ResponseHelper.Write("error|" + "您最多可以使用 " + (productMoney * totalRate * pointRate) + " 积分|"); * ResponseHelper.End(); * } * } * } * ------------------------------------------------------------------------*/ /*-----------应付总价---------------------------------------------------*/ //decimal payMoney = productMoney + shippingMoney - pointMoney; decimal payMoney = productMoney + shippingMoney; /*----------------------------------------------------------------------*/ var user = UserBLL.Read(base.UserId); /*-----------计算图楼卡余额---------------------------------------------*/ decimal balance = RequestHelper.GetForm <decimal>("money"); if (balance > 0) { bool isSuccess; string msg; isSuccess = true; msg = ""; //var account = WebService.Account.GetAccount(user.CardNo, user.CardPwd, out isSuccess, out msg); if (!isSuccess) { ResponseHelper.Write("error|" + msg + "|"); ResponseHelper.End(); } if (balance > 0 /*(account.Zacc + account.Sacc)*/) { ResponseHelper.Write("error|您的图楼卡余额不足|"); ResponseHelper.End(); } else { if (balance > payMoney) { ResponseHelper.Write("error|" + "您只需使用 " + payMoney + " 元即可支付订单|"); ResponseHelper.End(); } } } payMoney -= balance; /*----------------------------------------------------------------------*/ /*-----------检查金额---------------------------------------------------*/ if (payMoney < 0) { ResponseHelper.Write("error|金额有错误,请重新检查|"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------组装基础订单模型,循环生成订单-----------------------------*/ OrderInfo order = new OrderInfo(); order.ProductMoney = productMoney; order.Consignee = address.Consignee; order.RegionId = address.RegionId; order.Address = address.Address; order.ZipCode = address.ZipCode; order.Tel = address.Tel; order.Mobile = address.Mobile; order.Email = CookiesHelper.ReadCookieValue("UserEmail"); order.ShippingId = shipping.Id; order.ShippingDate = RequestHelper.DateNow; order.ShippingMoney = shippingMoney; order.Point = point; order.PointMoney = pointMoney; order.Balance = balance; order.PayKey = pay.Key; order.PayName = pay.Name; order.PayDate = RequestHelper.DateNow; order.IsRefund = (int)BoolType.False; order.UserMessage = StringHelper.AddSafe(RequestHelper.GetForm <string>("msg")); order.AddDate = RequestHelper.DateNow; order.IP = ClientHelper.IP; order.UserId = base.UserId; order.UserName = base.UserName; //循环生成订单 var orderIds = SplitShopProduct(cartList, order); /*----------------------------------------------------------------------*/ var orders = OrderBLL.ReadList(orderIds.ToArray(), base.UserId); /*-----------如果使用了图楼卡支付,需同步到会员管理系统中---------------*/ /*第二步,在订单付款操作(用户端)中,同步图楼卡余额*/ if (balance > 0) { List <string[]> paras = new List <string[]>(); foreach (var oo in orders) { if (oo.Balance > 0 && oo.OrderStatus == (int)OrderStatus.WaitCheck) { string[] para = new string[2]; para[0] = oo.OrderNumber; para[1] = oo.Balance.ToString(); paras.Add(para); } } //如果有全额使用了图楼卡余额支付的订单,需同步到会员管理系统中 if (paras.Count > 0) { bool isSuccess; string msg; isSuccess = true; msg = ""; //WebService.Account.Purchase(user.CardNo, user.CardPwd, paras, out isSuccess, out msg); //同步失败,删除订单及相关信息 if (!isSuccess) { //删除订单、订单详细、订单状态相关数据 OrderBLL.Delete(orderIds.ToArray(), base.UserId); //更改产品库存订单数量 foreach (var orderId in orderIds) { ProductBLL.ChangeOrderCountByOrder(orderId, ChangeAction.Minus); } ResponseHelper.Write("error|" + msg + "|"); ResponseHelper.End(); } else { //记录用户余额消费记录 foreach (var par in paras) { var accountRecord = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Money, Money = -decimal.Parse(par[1]), Point = 0, Date = DateTime.Now, IP = ClientHelper.IP, Note = "支付订单:" + par[0], UserId = base.UserId, UserName = base.UserName }; UserAccountRecordBLL.Add(accountRecord); } } } } /*----------------------------------------------------------------------*/ /*-----------删除购物车中已下单的商品-----------------------------------*/ CartBLL.Delete(cartIds, base.UserId); CookiesHelper.DeleteCookie("CheckCart"); /*----------------------------------------------------------------------*/ /*如果所有订单均由图楼卡支付完成,则跳转到会员中心,否则跳转到支付提示页面*/ if (orders.Count(k => k.OrderStatus == (int)OrderStatus.WaitPay) > 0) { ResponseHelper.Write("ok||/finish.html?id=" + string.Join(",", orders.Select(k => k.Id).ToArray())); } else { ResponseHelper.Write("ok||/user/index.html"); } ResponseHelper.End(); /*----------------------------------------------------------------------*/ }
/// <summary> /// 提交数据 /// </summary> protected void Post() { string userName = StringHelper.SearchSafe(Server.UrlDecode(RequestHelper.GetForm <string>("UserName"))); string email = StringHelper.SearchSafe(HttpUtility.HtmlDecode(RequestHelper.GetForm <string>("Email"))); string safeCode = StringHelper.AddSafe(HttpUtility.HtmlDecode(RequestHelper.GetForm <string>("SafeCode"))); int checkType = RequestHelper.GetForm <int>("checkType"); string mobile = StringHelper.AddSafe(HttpUtility.HtmlDecode(RequestHelper.GetForm <string>("Mobile"))); string mobileCode = StringHelper.AddSafe(HttpUtility.HtmlDecode(RequestHelper.GetForm <string>("phoneVer"))); UserInfo user = new UserInfo(); //检查用户名 if (userName == string.Empty) { errorMessage = "账户名不能为空"; } if (errorMessage == string.Empty) { user = UserBLL.Read(userName); if (user.Id <= 0) { errorMessage = "账户不存在"; } } //检查验证码 if (errorMessage == string.Empty) { if (safeCode.ToLower() != Cookies.Common.CheckCode.ToLower()) { errorMessage = "验证码错误"; } } switch (checkType) { case 1: //邮箱验证 //检查Email if (errorMessage == string.Empty) { if (email == string.Empty) { errorMessage = "Email不能为空"; } } if (errorMessage == string.Empty) { if (UserBLL.CheckEmail(email)) { errorMessage = "不存在该Email"; } } //检查用户和Email是否匹配 if (errorMessage == string.Empty) { if (user.Email != email) { errorMessage = "账户名和Email不匹配"; } } //记录找回密码信息 if (errorMessage == string.Empty) { string tempSafeCode = Guid.NewGuid().ToString(); UserBLL.ChangeUserSafeCode(user.Id, tempSafeCode, RequestHelper.DateNow); string url = "http://" + Request.ServerVariables["HTTP_HOST"] + "/mobile/User/ResetPassword.html?CheckCode=" + StringHelper.Encode(user.Id + "|" + email + "|" + userName + "|" + user.Mobile + "|" + tempSafeCode, ShopConfig.ReadConfigInfo().SecureKey); EmailContentInfo emailContent = EmailContentHelper.ReadSystemEmailContent("FindPassword"); EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo(); emailSendRecord.Title = emailContent.EmailTitle; emailSendRecord.Content = emailContent.EmailContent.Replace("$Url$", url); emailSendRecord.IsSystem = (int)BoolType.True; emailSendRecord.EmailList = email; emailSendRecord.IsStatisticsOpendEmail = (int)BoolType.False; emailSendRecord.SendStatus = (int)SendStatus.No; emailSendRecord.AddDate = RequestHelper.DateNow; emailSendRecord.SendDate = RequestHelper.DateNow; emailSendRecord.ID = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord); EmailSendRecordBLL.SendEmail(emailSendRecord); result = "您的申请已提交,请登录邮箱重设你的密码!<a href=\"http://mail." + email.Substring(email.IndexOf("@") + 1) + "\" target=\"_blank\">马上登录</a>"; Response.Clear(); Response.Write("ok|/mobile/User/FindPassword.html?Result=" + Server.UrlEncode(result)); Response.End(); //ResponseHelper.Redirect("/User/FindPassword.aspx?Result=" + Server.UrlEncode(result)); } else { Response.Clear(); Response.Write("error|" + errorMessage); Response.End(); //ResponseHelper.Redirect("/User/FindPassword.aspx?ErrorMessage=" + Server.UrlEncode(errorMessage)); } break; case 0: //手机验证 //检查Mobile if (string.IsNullOrEmpty(errorMessage) && string.IsNullOrEmpty(mobile)) { errorMessage = "请填写手机号"; } //检查手机号是否匹配 if (string.IsNullOrEmpty(errorMessage) && !string.Equals(user.Mobile, mobile)) { errorMessage = "请填写正确有效的手机号"; } //检查校验码 if (string.IsNullOrEmpty(errorMessage) && string.IsNullOrEmpty(mobileCode)) { errorMessage = "请填写短信校验码"; } //手机短信校验码 if (CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(mobile)) == null) { errorMessage = "校验码失效,请重新获取"; } else { string cookieMobileCode = CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(mobile)).Value.ToString(); if (cookieMobileCode.ToLower() != mobileCode.ToLower()) { errorMessage = "校验码错误"; } else { CookiesHelper.DeleteCookie("MobileCode" + StringHelper.AddSafe(mobile)); } } //找回密码 if (errorMessage == string.Empty) { string tempSafeCode = Guid.NewGuid().ToString(); UserBLL.ChangeUserSafeCode(user.Id, tempSafeCode, RequestHelper.DateNow); string url = "http://" + Request.ServerVariables["HTTP_HOST"] + "/mobile/User/ResetPassword.html?CheckCode=" + StringHelper.Encode(user.Id + "|" + user.Email + "|" + userName + "|" + mobile + "|" + tempSafeCode, ShopConfig.ReadConfigInfo().SecureKey); Response.Clear(); Response.Write("ok|" + url); Response.End(); //ResponseHelper.Redirect("/User/FindPassword.aspx?Result=" + Server.UrlEncode(result)); } else { Response.Clear(); Response.Write("error|" + errorMessage); Response.End(); //ResponseHelper.Redirect("/User/FindPassword.aspx?ErrorMessage=" + Server.UrlEncode(errorMessage)); } break; } }
protected void SubmitButton_Click(object sender, EventArgs e) { //如果账号不存在 if (!string.Equals(NewPassword.Text, NewPassword2.Text, StringComparison.OrdinalIgnoreCase)) { ScriptHelper.AlertFront("两次密码不一致"); } else { #region 滑块验证码 GeetestLib geetest = new GeetestLib("b46d1900d0a894591916ea94ea91bd2c", "36fc3fe98530eea08dfc6ce76e3d24c4"); Byte gt_server_status_code = (Byte)Session[GeetestLib.gtServerStatusSessionKey]; String userID = (String)Session["userID"]; int result = 0; String challenge = Request.Form.Get(GeetestLib.fnGeetestChallenge); String validate = Request.Form.Get(GeetestLib.fnGeetestValidate); String seccode = Request.Form.Get(GeetestLib.fnGeetestSeccode); try { if (gt_server_status_code != null && gt_server_status_code == 1) { result = geetest.enhencedValidateRequest(challenge, validate, seccode, userID); } else { result = geetest.failbackValidateRequest(challenge, validate, seccode); } } catch (Exception ex) { result = -1;//极验验证码出错,不进行验证 } if (result == 1 || result == -1) {// 验证通过,重置密码 string checkCode = RequestHelper.GetForm <string>("CheckCode"); string decode = StringHelper.Decode(checkCode, ShopConfig.ReadConfigInfo().SecureKey); int adminID = Convert.ToInt32(decode.Split('|')[0]); string newPassword = StringHelper.Password(NewPassword.Text, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); // 重置密码 AdminBLL.ChangePassword(adminID, newPassword); Task.Run(() => { //安全码 ShopConfigInfo config = ShopConfig.ReadConfigInfo(); config.SecureKey = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); ShopConfig.UpdateConfigInfo(config); }); //清空safecode,finddate恢复 AdminBLL.ChangeAdminSafeCode(adminID, string.Empty, RequestHelper.DateNow); //错误次数清零,解锁 AdminBLL.UpdateStatus(adminID); string msg = "恭喜您,密码修改成功!" + " 点击<a href=\"/admin/Login.aspx\" style=\"color: #1dd42b;font-size: larger;\">\"使用新密码登录\"</a>"; //清除原有的user Cookies CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().AdminCookies); CookiesHelper.DeleteCookie("AdminSign"); ResponseHelper.Redirect("/admin/ResetPassword.aspx?Result=" + Server.UrlEncode(msg)); } else { //验证失败 ScriptHelper.AlertFront("图片验证失败,请拖动图片滑块重新验证。"); } #endregion } }
protected void Page_Load(object sender, EventArgs e) { AdminLogBLL.Add(ShopLanguage.ReadLanguage("LogoutSystem")); CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().AdminCookies); ResponseHelper.Redirect("/Admin/Login.aspx"); }
/// <summary> /// 添加订单产品 /// </summary> /// <param name="orderID"></param> protected void AddOrderProduct(int orderID) { List <CartInfo> cartList = CartBLL.ReadList(base.UserId); //读取产品 checkCart = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart")); int[] cartIds = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k)); cartList = CartBLL.ReadList(base.UserId); cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList(); string strProductID = string.Empty; foreach (CartInfo cart in cartList) { if (strProductID == string.Empty) { strProductID = cart.ProductId.ToString(); } else { strProductID += "," + cart.ProductId.ToString(); } } List <ProductInfo> productList = new List <ProductInfo>(); if (strProductID != string.Empty) { ProductSearchInfo productSearch = new ProductSearchInfo(); productSearch.InProductId = strProductID; productList = ProductBLL.SearchList(productSearch); } //会员价格 //List<MemberPriceInfo> memberPriceList = MemberPriceBLL.ReadMemberPriceByProductGrade(strProductID, base.GradeID); //添加订单产品 Dictionary <string, bool> cartDic = new Dictionary <string, bool>(); Dictionary <int, int> cartOrderDetailDic = new Dictionary <int, int>(); foreach (CartInfo cart in cartList) { ProductInfo product = ProductBLL.ReadProductByProductList(productList, cart.ProductId); OrderDetailInfo orderDetail = new OrderDetailInfo(); orderDetail.OrderId = orderID; orderDetail.ProductId = cart.ProductId; orderDetail.ProductName = cart.ProductName; orderDetail.StandardValueList = cart.StandardValueList; orderDetail.ProductWeight = product.Weight; orderDetail.SendPoint = product.SendPoint; if (!string.IsNullOrEmpty(cart.StandardValueList)) { var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList); orderDetail.ProductPrice = ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID); } else { orderDetail.ProductPrice = ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID); } orderDetail.BuyCount = cart.BuyCount; orderDetail.RandNumber = cart.RandNumber; int orderDetailID = OrderDetailBLL.Add(orderDetail); cartOrderDetailDic.Add(cart.Id, orderDetailID); } /*-----------删除购物车中已下单的商品-----------------------------------*/ CartBLL.Delete(cartIds, base.UserId); CookiesHelper.DeleteCookie("CheckCart"); /*----------------------------------------------------------------------*/ }
private void Submit() { /*-----------重新验证选择的商品------------------------------------------*/ checkCart = StringHelper.AddSafe(RequestHelper.GetForm <string>("CheckCart")); int[] cartIds = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k)); string checkCartCookies = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart")); if (checkCart != checkCartCookies) { ResponseHelper.Write("error|购买商品发生了变化,请重新提交|/cart.html"); ResponseHelper.End(); } if (string.IsNullOrEmpty(checkCart) || cartIds.Length < 1) { ResponseHelper.Write("error|请选择需要购买的商品|/cart.html"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------读取购物车清单---------------------------------------------*/ List <CartInfo> cartList = CartBLL.ReadList(base.UserId); cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList(); if (cartList.Count <= 0) { ResponseHelper.Write("error|请选择需要购买的商品|/cart.html"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------必要性检查:收货地址,配送方式,支付方式-------------------*/ var address = new UserAddressInfo { Id = RequestHelper.GetForm <int>("address_id") }; var shipping = new ShippingInfo { Id = RequestHelper.GetForm <int>("ShippingId") }; var pay = new PayPluginsInfo { Key = StringHelper.AddSafe(RequestHelper.GetForm <string>("pay")) }; //订单优惠活动 var favor = new FavorableActivityInfo { Id = RequestHelper.GetForm <int>("FavorableActivity") }; //商品优惠 var productfavor = new FavorableActivityInfo { Id = RequestHelper.GetForm <int>("ProductFavorableActivity") }; bool reNecessaryCheck = false; doReNecessaryCheck: if (address.Id < 1) { ResponseHelper.Write("error|请选择收货地址|"); ResponseHelper.End(); } if (shipping.Id < 1) { ResponseHelper.Write("error|请选择配送方式|"); ResponseHelper.End(); } if (string.IsNullOrEmpty(pay.Key)) { ResponseHelper.Write("error|请选择支付方式|"); ResponseHelper.End(); } //读取数据库中的数据,进行重复验证 if (!reNecessaryCheck) { address = UserAddressBLL.Read(address.Id, base.UserId); shipping = ShippingBLL.Read(shipping.Id); pay = PayPlugins.ReadPayPlugins(pay.Key); reNecessaryCheck = true; goto doReNecessaryCheck; } /*----------------------------------------------------------------------*/ /*-----------商品清单、商品总价、邮费价格、库存检查---------------------*/ var user = UserBLL.ReadUserMore(base.UserId); decimal productMoney = 0, pointMoney = 0; int count = 0; //输入的兑换积分数 var costPoint = RequestHelper.GetForm <int>("costPoint"); int[] ids = cartList.Select(k => k.ProductId).ToArray(); var productList = ProductBLL.SearchList(1, ids.Length, new ProductSearchInfo { InProductId = string.Join(",", ids) }, ref count); foreach (var cart in cartList) { cart.Product = productList.FirstOrDefault(k => k.Id == cart.ProductId) ?? new ProductInfo(); if (!string.IsNullOrEmpty(cart.StandardValueList)) { //使用规格的库存 var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList); cart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount; productMoney += ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID) * (cart.BuyCount); } else { cart.LeftStorageCount = cart.Product.TotalStorageCount - cart.Product.OrderCount; productMoney += ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID) * (cart.BuyCount); } //检查库存 if (cart.BuyCount > cart.LeftStorageCount) { ResponseHelper.Write("error|商品[" + cart.ProductName + "]库存不足,无法购买|"); ResponseHelper.End(); } } ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shipping.Id, address.RegionId); decimal shippingMoney = ShippingRegionBLL.ReadShippingMoney(shipping.Id, shippingRegion.RegionId, cartList); /*----------------------------------------------------------------------*/ #region 优惠券 decimal couponMoney = 0; string userCouponStr = RequestHelper.GetForm <string>("UserCoupon"); UserCouponInfo userCoupon = new UserCouponInfo(); if (userCouponStr != string.Empty) { int couponID = 0; if (int.TryParse(userCouponStr.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0], out couponID)) { userCoupon = UserCouponBLL.Read(couponID, base.UserId); if (userCoupon.UserId == base.UserId && userCoupon.IsUse == 0) { CouponInfo tempCoupon = CouponBLL.Read(userCoupon.CouponId); if (tempCoupon.UseMinAmount <= productMoney) { couponMoney = CouponBLL.Read(userCoupon.CouponId).Money; } else { ResponseHelper.Write("error|结算金额小于该优惠券要求的最低消费的金额|"); ResponseHelper.End(); } } } } #endregion #region 如果开启了:使用积分抵现,计算积分抵现的现金金额 if (ShopConfig.ReadConfigInfo().EnablePointPay == 1) { if (costPoint > user.PointLeft || costPoint < 0) { ResponseHelper.Write("error|输入的兑换积分数[" + costPoint + "]错误,请检查|"); ResponseHelper.End(); } if (costPoint > 0) { var PointToMoneyRate = ShopConfig.ReadConfigInfo().PointToMoney; pointMoney = costPoint * (decimal)PointToMoneyRate / 100; } } #endregion #region 结算商品优惠金额 decimal productfavorableMoney = 0; var theFavor = FavorableActivityBLL.Read(productfavor.Id); if (theFavor.Id > 0) { decimal tmoney = 0; foreach (var tmpcart in cartList) { tmpcart.Product = productList.FirstOrDefault(k => k.Id == tmpcart.ProductId) ?? new ProductInfo(); if (tmpcart.Product.ClassId.IndexOf(theFavor.ClassIds) > -1) { if (!string.IsNullOrEmpty(tmpcart.StandardValueList)) { //使用规格的库存 var standardRecord = ProductTypeStandardRecordBLL.Read(tmpcart.ProductId, tmpcart.StandardValueList); tmpcart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount; tmpcart.Price = ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID); tmoney += tmpcart.Price * tmpcart.BuyCount; } else { tmpcart.Price = ProductBLL.GetCurrentPrice(tmpcart.Product.SalePrice, base.GradeID); tmoney += tmpcart.Price * tmpcart.BuyCount; } } } switch (theFavor.ReduceWay) { case (int)FavorableMoney.Money: productfavorableMoney += theFavor.ReduceMoney; break; case (int)FavorableMoney.Discount: productfavorableMoney += tmoney * (100 - theFavor.ReduceDiscount) / 100; break; default: break; } } #endregion #region 计算订单优惠活动金额 decimal favorableMoney = 0; favor = FavorableActivityBLL.Read(favor.Id); if (favor.Id > 0) { if (("," + favor.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1 && productMoney >= favor.OrderProductMoney) { switch (favor.ReduceWay) { case (int)FavorableMoney.Money: favorableMoney += favor.ReduceMoney; break; case (int)FavorableMoney.Discount: favorableMoney += productMoney * (100 - favor.ReduceDiscount) / 100; break; default: break; } if (favor.ShippingWay == (int)FavorableShipping.Free && ShippingRegionBLL.IsRegionIn(address.RegionId, favor.RegionId)) { favorableMoney += shippingMoney; } } } #endregion /*-----------应付总价---------------------------------------------------*/ decimal payMoney = productMoney + shippingMoney - couponMoney - pointMoney - favorableMoney - productfavorableMoney; /*----------------------------------------------------------------------*/ /*-----------检查金额---------------------------------------------------*/ if (payMoney <= 0) { ResponseHelper.Write("error|金额有错误,请重新检查|"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------组装基础订单模型,循环生成订单-----------------------------*/ OrderInfo order = new OrderInfo(); order.ProductMoney = productMoney; order.OrderNumber = ShopCommon.CreateOrderNumber(); string payKey = RequestHelper.GetForm <string>("Pay"); PayPluginsInfo payPlugins = PayPlugins.ReadPayPlugins(payKey); if (payMoney == 0 || payPlugins.IsCod == (int)BoolType.True) { order.OrderStatus = (int)OrderStatus.WaitCheck; } else { order.OrderStatus = (int)OrderStatus.WaitPay; } order.Consignee = address.Consignee; order.RegionId = address.RegionId; order.Address = address.Address; order.ZipCode = address.ZipCode; order.Tel = address.Tel; order.Mobile = address.Mobile; order.InvoiceTitle = RequestHelper.GetForm <string>("InvoiceTitle"); order.InvoiceContent = RequestHelper.GetForm <string>("InvoiceContent"); order.GiftMessige = RequestHelper.GetForm <string>("GiftMessige"); order.Email = CookiesHelper.ReadCookieValue("UserEmail"); order.ShippingId = shipping.Id; order.ShippingDate = RequestHelper.DateNow; order.ShippingMoney = shippingMoney; order.CouponMoney = couponMoney; order.Point = costPoint; order.PointMoney = pointMoney; order.FavorableMoney = favorableMoney + productfavorableMoney; order.Balance = 0; order.PayKey = pay.Key; order.PayName = pay.Name; order.PayDate = RequestHelper.DateNow; order.IsRefund = (int)BoolType.False; order.AddDate = RequestHelper.DateNow; order.IP = ClientHelper.IP; order.UserId = base.UserId; order.UserName = base.UserName; order.UserMessage = RequestHelper.GetForm <string>("userMessage"); order.GiftId = RequestHelper.GetForm <int>("GiftID"); order.IsNoticed = 0; int orderId = OrderBLL.Add(order); //添加订单产品 foreach (var cart in cartList) { var orderDetail = new OrderDetailInfo(); orderDetail.OrderId = orderId; orderDetail.ProductId = cart.ProductId; orderDetail.ProductName = cart.ProductName; orderDetail.StandardValueList = cart.StandardValueList; orderDetail.ProductWeight = cart.Product.Weight; if (!string.IsNullOrEmpty(cart.StandardValueList)) { var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList); orderDetail.ProductPrice = ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID); } else { orderDetail.ProductPrice = ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID); } orderDetail.BidPrice = cart.Product.BidPrice; orderDetail.BuyCount = cart.BuyCount; OrderDetailBLL.Add(orderDetail); } #region 更新优惠券状态--已使用 //使用优惠券 if (couponMoney > 0 && userCouponStr != "0|0") { userCoupon.IsUse = (int)BoolType.True; userCoupon.OrderId = orderId; UserCouponBLL.Update(userCoupon); } #endregion #region 减少积分 if (ShopConfig.ReadConfigInfo().EnablePointPay == 1 && costPoint > 0) { //减少积分 UserAccountRecordInfo uarInfo = new UserAccountRecordInfo(); uarInfo.RecordType = (int)AccountRecordType.Point; uarInfo.UserId = base.UserId; uarInfo.UserName = base.UserName; uarInfo.Note = "支付订单:" + order.OrderNumber; uarInfo.Point = -costPoint; uarInfo.Money = 0; uarInfo.Date = DateTime.Now; uarInfo.IP = ClientHelper.IP; UserAccountRecordBLL.Add(uarInfo); } #endregion /*-----------更改产品库存订单数量---------------------------------------*/ ProductBLL.ChangeOrderCountByOrder(orderId, ChangeAction.Plus); /*----------------------------------------------------------------------*/ /*-----------删除购物车中已下单的商品-----------------------------------*/ CartBLL.Delete(cartIds, base.UserId); CookiesHelper.DeleteCookie("CheckCart"); /*----------------------------------------------------------------------*/ ResponseHelper.Write("ok||/Finish.html?id=" + orderId); ResponseHelper.End(); }
private void Submit() { redirectUrl = RequestHelper.GetQueryString <string>("RedirectUrl"); string userName = StringHelper.SearchSafe(RequestHelper.GetForm <string>("name")); string userNoEncryptPassword = RequestHelper.GetForm <string>("password"); string userPassword = StringHelper.Password(userNoEncryptPassword, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); string[] urlArr = Request.RawUrl.Split('/'); UserInfo user = UserBLL.Read(userName); if (user.Id > 0) { if (user.UserPassword != userPassword) { ResponseHelper.Write("error|用户名或者密码错误"); ResponseHelper.End(); } switch (user.Status) { case (int)UserStatus.NoCheck: ResponseHelper.Write("error|该用户未激活"); ResponseHelper.End(); break; case (int)UserStatus.Frozen: ResponseHelper.Write("error|该用户已冻结"); ResponseHelper.End(); break; default: break; } } UserBLL.UserLoginInit(user); //记住用户名 if (!string.IsNullOrEmpty(Request.Form["autologin"])) { CookiesHelper.AddCookie("auto", user.UserName.ToString(), 7, TimeType.Day); } else { CookiesHelper.DeleteCookie("auto"); } if (string.IsNullOrEmpty(redirectUrl)) { if (urlArr[urlArr.Length - 2].ToLower() == "mobile") { redirectUrl = "/Mobile/Index.aspx"; } else { redirectUrl = "/user/index.html"; } } ResponseHelper.Write("ok|登录成功|" + redirectUrl); ResponseHelper.End(); }
/// <summary> /// 提交数据 /// </summary> protected override void PostBack() { string userName = StringHelper.SearchSafe(StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName"))); string email = StringHelper.SearchSafe(StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"))); string userPassword1 = RequestHelper.GetForm <string>("UserPassword1"); string userPassword2 = RequestHelper.GetForm <string>("UserPassword2"); string safeCode = RequestHelper.GetForm <string>("SafeCode"); string Phone = StringHelper.SearchSafe(StringHelper.AddSafe(RequestHelper.GetForm <string>("Phone"))); string phoneCode = RequestHelper.GetForm <string>("PhoneCode"); //检查用户名 if (userName == string.Empty) { errorMessage = "用户名不能为空"; } if (errorMessage == string.Empty) { string forbiddinName = ShopConfig.ReadConfigInfo().ForbiddenName; if (forbiddinName != string.Empty) { foreach (string TempName in forbiddinName.Split('|')) { if (userName.IndexOf(TempName.Trim()) != -1) { errorMessage = "用户名含有非法字符"; break; } } } } if (errorMessage == string.Empty) { if (!UserBLL.UniqueUser(userName)) { errorMessage = "用户名已经被占用"; } } if (errorMessage == string.Empty) { Regex rg = new Regex("^([a-zA-Z0-9_\u4E00-\u9FA5])+$"); if (!rg.IsMatch(userName)) { errorMessage = "用户名只能包含字母、数字、下划线、中文"; } } //检查密码 if (errorMessage == string.Empty) { if (userPassword1 == string.Empty || userPassword2 == string.Empty) { errorMessage = "密码不能为空"; } } if (errorMessage == string.Empty) { if (userPassword1 != userPassword2) { errorMessage = "两次密码不一致"; } } //检查手机 邮箱 验证码 if (ShopConfig.ReadConfigInfo().RegisterCheck == 1) {//短信验证 if (errorMessage == string.Empty) { if (!ShopCommon.CheckMobile(Phone)) { errorMessage = "手机号码错误"; } } if (errorMessage == string.Empty) { if (!UserBLL.CheckMobile(Phone, 0)) { errorMessage = "手机号码已经被注册"; } } if (errorMessage == string.Empty) { if (CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(Phone)) == null) { errorMessage = "验证码失效,请重新获取验证码"; } else { string mobileCode = CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(Phone)).Value.ToString(); if (phoneCode.ToLower() != mobileCode.ToLower()) { errorMessage = "验证码错误"; } else { CookiesHelper.DeleteCookie("MobileCode" + StringHelper.AddSafe(Phone)); } } } } else {//邮件验证 if (errorMessage == string.Empty) { if (errorMessage == string.Empty) { if (!UserBLL.CheckEmail(email)) { errorMessage = "Email已被注册"; } } if (safeCode.ToLower() != Cookies.Common.CheckCode.ToLower()) { errorMessage = "验证码错误"; } } } //注册用户 if (errorMessage == string.Empty) { UserInfo user = new UserInfo(); user.UserName = userName; user.UserPassword = StringHelper.Password(userPassword1, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); user.Mobile = Phone; user.Email = email; user.RegisterIP = ClientHelper.IP; user.RegisterDate = RequestHelper.DateNow; user.LastLoginIP = ClientHelper.IP; user.LastLoginDate = RequestHelper.DateNow; user.FindDate = RequestHelper.DateNow; user.Sex = (int)SexType.Secret; if (ShopConfig.ReadConfigInfo().RegisterCheck == 1) {//短信验证,用户状态为已验证,可直接登录 user.Status = (int)UserStatus.Normal; } else {//邮件验证,用户状态为未验证,需登录邮件手动激活后再登录 user.Status = (int)UserStatus.NoCheck; } int userID = UserBLL.Add(user); if (ShopConfig.ReadConfigInfo().RegisterCheck == 1) { //短信验证,直接登录 HttpCookie cookie = new HttpCookie(ShopConfig.ReadConfigInfo().UserCookies); cookie["User"] = StringHelper.Encode(userName, ShopConfig.ReadConfigInfo().SecureKey); cookie["Password"] = StringHelper.Encode(userPassword1, ShopConfig.ReadConfigInfo().SecureKey); cookie["Key"] = StringHelper.Encode(ClientHelper.Agent, ShopConfig.ReadConfigInfo().SecureKey); HttpContext.Current.Response.Cookies.Add(cookie); user = UserBLL.Read(userID); UserBLL.UserLoginInit(user); ResponseHelper.Redirect("/Mobile/User/Index.html"); } else if (ShopConfig.ReadConfigInfo().RegisterCheck == 2) { try { //邮件验证 string url = "http://" + Request.ServerVariables["HTTP_HOST"] + "/Mobile/User/ActiveUser.html?CheckCode=" + StringHelper.Encode(userID + "|" + email + "|" + userName, ShopConfig.ReadConfigInfo().SecureKey); EmailContentInfo emailContent = EmailContentHelper.ReadSystemEmailContent("Register"); EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo(); emailSendRecord.Title = emailContent.EmailTitle; emailSendRecord.Content = emailContent.EmailContent.Replace("$UserName$", user.UserName).Replace("$Url$", url); emailSendRecord.IsSystem = (int)BoolType.True; emailSendRecord.EmailList = email; emailSendRecord.IsStatisticsOpendEmail = (int)BoolType.False; emailSendRecord.SendStatus = (int)SendStatus.No; emailSendRecord.AddDate = RequestHelper.DateNow; emailSendRecord.SendDate = RequestHelper.DateNow; emailSendRecord.ID = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord); EmailSendRecordBLL.SendEmail(emailSendRecord); result = "恭喜您,注册成功,请登录邮箱激活!<a href=\"http://mail." + email.Substring(email.IndexOf("@") + 1) + "\" target=\"_blank\">马上激活</a>"; } catch (Exception ex) { ScriptHelper.AlertFront("激活邮件发送失败,请联系网站客服"); } } else { //人工审核 result = "恭喜您,注册成功,请等待我们的审核!"; } ResponseHelper.Redirect("/Mobile/User/Register.html?Result=" + Server.UrlEncode(result)); } else { ScriptHelper.AlertFront(errorMessage); //ResponseHelper.Redirect("/Mobile/User/Register.html?ErrorMessage=" + Server.UrlEncode(errorMessage)); } }